Error recovery (long)

John Woods, Software john at frog.UUCP
Thu Jun 5 06:28:49 AEST 1986


>>While on the subject of compilers, I would like to share two other features
>>of this compiler that I find useful.
>>
>>The first feature is the ability to generate a stack trace ("traceback")
>>in the event of a serious error.  There are two compiler switches that
>>control the amount of information in a traceback.  The "-Clineid" switch
>>causes the offending line number to be included while the "-Cprocid" switch 
>>causes the procedure name to be included.
> 
I have occaisionally used a trick for programs which only seem to crash when
I am not around to poke through entrails, that of writing a C function that
catches signals and prints an admittedly-crude stack backtrace.  While it
is probably nicer to have compiler assist in doing this (I can remember the
reams of output that a student-oriented ALGOL-60 interpreter once gave), I
still find that if I need much more than the hint that this little backtrace
routine of mine gives, I need all of a debugger, anyway.

By the way, my backtracer is written entirely in C, with the exception of
a call on an assembly routine getfp(), which returns the current frame-pointer
value.  Which, by the way, is another function with a problematical type: it
returns a pointer to a --\
	  ^		 |
	  \______________/ ...  (I could have cheated on the getfp() by
using the address of a parameter, but as long as I had the RIGHT tool...)

--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA

"Imagine if every Thursday your shoes exploded if you tied them the usual way.
This happens to us all the time with computers, and nobody thinks of
complaining."
			Jeff Raskin, interviewed in Doctor Dobb's Journal



More information about the Comp.lang.c mailing list