gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Mea Culp » Sun, 02 Feb 2003 12:57:38



I just did something really dumb.

I was getting to the end of a marathon debugging session, like seriously 8
or 9 hours. I kept editing, recompiling, running; editing recompiling
running... I must have been getting tired, because I typed this:

gcc hugeprogram.c -o hugeprogram.c

Jeez - shouldn't a compiler warn you if you try to write over your source
code?!

Anyway, just to make sure, there's no magic trick for recovering source
code from gcc-compiled code, is there?

I was doing all my work in a unix window, and found scraps of the program
in the scroll-back buffer, but can't think of anything else to try.

I never use emoticons, but right now I am really bummed :-(

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Martien Verbrugge » Sun, 02 Feb 2003 14:26:55


On 1 Feb 2003 03:57:38 GMT,

Quote:> I just did something really dumb.

Please, don't multipost this to several groups, especially not using
different fake names. If you feel it belongs in multiple groups,
cross-post.

However, this does not belong in comp.lang.c or comp.unix.shell, the two
places I've seen it now.

Quote:> I was getting to the end of a marathon debugging session, like seriously 8
> or 9 hours. I kept editing, recompiling, running; editing recompiling
> running... I must have been getting tired, because I typed this:

> gcc hugeprogram.c -o hugeprogram.c

> Jeez - shouldn't a compiler warn you if you try to write over your source
> code?!

Why?

Quote:> Anyway, just to make sure, there's no magic trick for recovering source
> code from gcc-compiled code, is there?

Nope, although you could ask this question in a gcc specific group, or
one that talks about your platform.

Quote:> I was doing all my work in a unix window, and found scraps of the program
> in the scroll-back buffer, but can't think of anything else to try.

Next time, make sure you have backups, or use a decent versioning
scheme and version control system.

Quote:> I never use emoticons, but right now I am really bummed :-(

Learn your lesson.

Martien
--
                        |
Martien Verbruggen      | We are born *, wet and hungry. Then
                        | things get worse.
                        |

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Sun, 02 Feb 2003 16:37:42



> I just did something really dumb.

> I was getting to the end of a marathon debugging session, like seriously 8
> or 9 hours. I kept editing, recompiling, running; editing recompiling
> running... I must have been getting tired, because I typed this:

> gcc hugeprogram.c -o hugeprogram.c

> Jeez - shouldn't a compiler warn you if you try to write over your source
> code?!

Not using make ... or perhaps even a lowly shell script
to do the compile indicates that you are incompetent
at UNIX development and that you, unfortunately, were
not protected from such an accident.

Don't you AT LEAST have a DECENT shell.  Or is it that
you just don't know how to use its command history to
avoid the ridiculous re-typing of long/reiterative commands?

Doesn't your management care that you obviously lack the
training to perform your job?

I think I have a clue why you're doing 8-9 debug sessions.

I've seen people fired for this kind of nonsense, but it
is probably the management that is at fault for not providing
you with what need (ie training) to perform your tasks ...
or assigning you taks that they should have known you were incompetent
to perform, perhaps out of a misguided cost-cutting measure ...
indicating that they, themselves, are also incompetent.

Quote:

> Anyway, just to make sure, there's no magic trick for recovering source
> code from gcc-compiled code, is there?

It would be a 'decompiler'.  Never had the displeasure of having
to use one.  You had better determine your backup situation
... that is if the SA staff is more competent at their job than
you are at yours.  Of course, unless your are fabulously lucky,
you'll lose some work.  I recommend that, in the future, you
have a .save directory in the CWD and 'save early, save often'.
Also do a 'man make' and/or dig up some makefiles.

For UNIX sakes, at LEAST write a shell script to do tasks to save
manual labor AND accidents and/or work in a decent shell
command line interpreter and LEARN its command history
AND USE IT!  People like you shouldn't make UNIX look bad,
but you do.  You could go back to the padded cell of MS-land
where you probably came from.

Quote:

> I was doing all my work in a unix window, and found scraps of the program
> in the scroll-back buffer, but can't think of anything else to try.

Program scraps ... program scraps.  You're making me hungry!

Quote:

> I never use emoticons, but right now I am really bummed :-(

Then I suppose this didn't help much.  Sorry.  There's
a wide range of mood-altering * on the market.  But, you
know what?  I've never seen a person's competence improved
by them.  But, at least, maybe they feel better about their
shortcomings.   :-)

HTH

Tim

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Sun, 02 Feb 2003 17:38:10



> I just did something really dumb.

It was an accident.  But at least you walked away from
it ... maybe.

Quote:

> Anyway, just to make sure, there's no magic trick for recovering source
> code from gcc-compiled code, is there?

I'm feeling a little of my own Mea Culpa regarding my initial
response to you on this.  BTW, anything I said about your management
and SA staff applies to YOU if you don't have any management
(are working independently).  You would be your own management
and you have to provide yourself the tools to enable you to
accomplish the tasks correctly.

Quote:

> I never use emoticons, but right now I am really bummed :-(

Don't get bummed.  Get mad.  Like any serious accident:

   1) Determine the cause(s)
   2) Correct these to make sure it doesn't happen again

Your work habits were an accident waiting to happen IMHO.

I've lost source code only twice, due to my poor work habits,
in a many-year career.  Losing source is the one thing I hate
the most because it is a big waste of time and life and it's
very boring going through (especially manual) recovery.
Although it could be an opportunity to do a ground zero rewrite!

The first time, I had a 'cleanup' shell I was developing go
wild and wipe itself out as well as three hours of work.
I had paper backups of most of the modules because I had
just printed them.  Having a bug in a module that is operating
in your development area is a risk that comes with the
software development turf.

What did I do about this for the future?  I changed my work
habits by creating .save directories and taking snapshots, often,
of the source.  This can be also used like a mini version control
if the snapshots are not overwritten.  They can be compared
with each other, reverted-to, etc.

The second time I accidentally executed a 'shell archive' in
my CWD.  Before I could stop it, it had reverted/overwritten
several source modules.

What did I do for the future?  I made sure that my shell archives
where not directly executable as this one was.  I had simply
typed the wrong command.  Nowadays, I would have to 'dot'
execute one to have such an accident.  This is much less likely.
Also, I don't keep 'shars' lying around in the CWD or zip them
up if I do.

A valuable policy:  KEEP YOUR OWN BACKUPS IF IT IS POSSIBLE
                    DO SO ... AND CHECK THEM.  BE PARANOID!
                    THE CLOSER YOU GET TO COMPLETION OF
                    SOMETHING THE MORE PARANOID YOU SHOULD BE ...

CONSTANTLY ASK YOURSELF THE QUESTION DURING DEVELOPMENT:

   WHAT WOULD BE THE IMPACT IF I LOST THE SOURCE RIGHT NOW?

Do not rely on other people to backup your work because:

  1)  They may not be doing it or there may be a fault
      in the backup procedure.  I HAVE SEEN THIS MANY TIMES
      and it is tragic.  Once saw an entire development group
      lose a week of work by having a faulty backup procedure.

  2)  Their backup regime may not meet your backup needs.

  3)  It is a PIA to go to them for recovery, if not just
      plain embarrassing.

HTH

Tim

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by j.. » Sun, 02 Feb 2003 21:47:34



> I just did something really dumb.

> I was getting to the end of a marathon debugging session, like
> seriously 8 or 9 hours. I kept editing, recompiling, running;
> editing recompiling running... I must have been getting tired,
> because I typed this:

> gcc hugeprogram.c -o hugeprogram.c

I don't suppose you were using an editor that makes backups were you?
If you were using emacs, for example, look for hugeprogram.c~

Tim covered pretty much everything else :-)

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Sun, 02 Feb 2003 23:50:24




> > I just did something really dumb.

Here's the address of a 'makefile' that you could apply
in the future:
http://groups.google.com/groups?q=group:comp.unix.programmer+author:t...

You would have to change the details and convert to tabs
for indentation.

Quote:

> HTH

> Tim

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Mon, 03 Feb 2003 07:50:38




> > I just did something really dumb.

> > I was getting to the end of a marathon debugging session, like
> > seriously 8 or 9 hours. I kept editing, recompiling, running;
> > editing recompiling running... I must have been getting tired,
> > because I typed this:

> > gcc hugeprogram.c -o hugeprogram.c

> I don't suppose you were using an editor that makes backups were you?
> If you were using emacs, for example, look for hugeprogram.c~

Good call.  I assumed that he, at least, could find a local copy.
Figured he wore out his keyboard with 'ls'.

But OTOH, you never know.  I've been known to install Trojans
(the shell exec kind!) for 'vi' and 'rm' in high-risk situations.
They made copies of the files prior to invokation.  As it turned out,
they became very useful from another software security aspect.

But that's another story.

Quote:

> Tim covered pretty much everything else :-)

Overcovered, maybe?  ... if that's possible when it comes to software
security.

Regards,

Tim

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by John DuBo » Wed, 05 Feb 2003 01:23:41




>I don't suppose you were using an editor that makes backups were you?
>If you were using emacs, for example, look for hugeprogram.c~

>Tim covered pretty much everything else :-)

Well, for the future there's also: if the filesystem you're using has the
option of file versioning (an "undelete" feature), enable it!  It can be a
lifesaver.  

        John
--

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by mea culp » Wed, 05 Feb 2003 02:39:50



> Doesn't your management care that you obviously lack the
> training to perform your job?

Hi Tim - I can understand it'd be frustrating to imagine someone getting
paid to program who'd*something up so badly as I did, especially
with so many fine programmers out of work (I know plenty). Your comments
were well-received, and just to reassure you, I'm a hobbyist who's never
been paid in his life to program.

And yes I was OT for this group and in comp.lang.c, sorry to have vented
on the newsgroups. I will look into the project management tools you
mentioned, they're surely useful even for an amateur working on a project
for fun.

Best regards.

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Wolfgang Riede » Wed, 05 Feb 2003 03:42:01



> I just did something really dumb.

> I was getting to the end of a marathon debugging session, like seriously 8
> or 9 hours. I kept editing, recompiling, running; editing recompiling
> running... I must have been getting tired, because I typed this:

> gcc hugeprogram.c -o hugeprogram.c

> Jeez - shouldn't a compiler warn you if you try to write over your source
> code?!

> Anyway, just to make sure, there's no magic trick for recovering source
> code from gcc-compiled code, is there?

> I was doing all my work in a unix window, and found scraps of the program
> in the scroll-back buffer, but can't think of anything else to try.

> I never use emoticons, but right now I am really bummed :-(

Hi Mea,

You have received some advice, even though being OT in the 2 ng's I saw it.
One additional comment would be:

        (as I don't know which editor you use) look up your editors docu
        seek whether it has some sort of aurosave option
        (mine has 'autocount 50' changes, 'idletime 2' secs; since I
         discovered those options, I never lost more than 5 LOC's)
        btw.: those autosaved files might not be, where you expect them,
        $TMP/* might be a place to look - and might not be named as you
        expect them, so look up 'grep' et al..

And: Look up your editors docu!

Maybe you discover something helping you in this case, surely it will help you
in the future and maybe you're inclined to find (and learn!) another editor.

WS,
Wolfgang

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Kevin Rodger » Wed, 05 Feb 2003 04:35:47



> Here's the address of a 'makefile' that you could apply
> in the future:
> http://groups.google.com/groups?q=group:comp.unix.programmer+author:t...

I appreciate the idea of providing a Makefile template for people who
aren't familiar with make.

Buf for something as simple as compiling a C source file into an object
or executable, make's implicit rules provide everything a novice needs.
Usually, the most one needs to do is tweak some internal macros, e.g.

LDFLAGS = -L/usr/local/unusual -lweird

--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Wed, 05 Feb 2003 08:36:17




> > Doesn't your management care that you obviously lack the
> > training to perform your job?

> Hi Tim - I can understand it'd be frustrating to imagine someone getting
> paid to program who'd*something up so badly as I did, especially
> with so many fine programmers out of work (I know plenty). Your comments
> were well-received, and just to reassure you, I'm a hobbyist who's never
> been paid in his life to program.

Good to hear from you.  Glad that we're still on posting terms ...
especially after my rants!

Quote:

> And yes I was OT for this group and in comp.lang.c, sorry to have vented
> on the newsgroups. I will look into the project management tools you
> mentioned, they're surely useful even for an amateur working on a project
> for fun.

I always say:  makefiles - don't go programming without them*

* = paid or unpaid

Quote:

> Best regards.

Ditto,

Tim

 
 
 

gcc hugeprogram.c -o hugeprogram.c :-( :-( :-(

Post by Tim Cargi » Wed, 05 Feb 2003 08:49:54




> > Here's the address of a 'makefile' that you could apply
> > in the future:
> > http://groups.google.com/groups?q=group:comp.unix.programmer+author:t...

> I appreciate the idea of providing a Makefile template for people who
> aren't familiar with make.

> Buf for something as simple as compiling a C source file into an object
> or executable, make's implicit rules provide everything a novice needs.
> Usually, the most one needs to do is tweak some internal macros, e.g.

> LDFLAGS = -L/usr/local/unusual -lweird

Good point.  And for with one 'humungous' C module that'll work.
So will a single line shell script.  However, when there
are multi-module compiles and dependencies like header files
it gets untenable.  At least it's a start with 'make'.

Thanks,

Tim