Mail Archives: djgpp/1996/09/05/02:05:07
On Thu, 5 Sep 1996, Michael Day wrote:
> When a djgpp program crashes, it prints a nice stack trace which is very handy
> for debugging. Is there anyway to generate this without actually crashing, ie:
> if you want to find out how a particular procedure got called then insert a
> line that generates the stacktrace? Or is this a CWSDPMI thing?
Use the following snippet to produce a traceback *and* cause the program
to exit:
signal (SIGINT, SIG_DFL);
__asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception");
I usually put the above code into a function that gets called from
``impossible'' situation, when something that shouldn't ever happen,
somehow did. Then by examining the traceback I know where the culprit
is.
Why do you need the traceback without exiting? Isn't that what debuggers
are for? E.g., GDB has a command to print the `back-trace' which shows
all the call sequence that got you to the place you are.
- Raw text -