In C, how to print stack trace like db

In C, how to print stack trace like db

Post by Bart Smaalde » Fri, 27 Oct 1995 04:00:00



I'm loathe to figure out the stabs format the compiler folks use;
it's pretty groaty.  The gdb folks have grokked this so it is possible;
just not very enticing :-).  






>> >I would like to be able to print a function call stack trace
>> >in C code similar to the way dbx does when you do a 'where'
>> >on a core file.

>> This works on Solaris 2.4 and higher (sparc, x86 and PPC):

>> /*
>>   walks up call stack, printing library:routine+offset for each routine
>>   */

>[snip]

>Thanks very much for that gem - I just tried it out.

>Is it possible to make it pick up the compiler's -g information
>(if present) so than not only public symbols, but static functions
>could also be identified (other than as an offset from the last
>public function)?  I just had a look through some answerbooks,
>but I could find almost no mention of the ELF .debug section format
>(if that's the right thing to be looking for anyway).

>--



---
Bart Smaalders                  OS Performance          SunSoft

http://playground.sun.com/~barts                   2550 Garcia Ave
                                                        Mt View, CA 94043-1100
 
 
 

In C, how to print stack trace like db

Post by Sinan Kara » Fri, 27 Oct 1995 04:00:00


 Actually, I grokked it a while back. The only thing I
have not figured out completely yet how to edit it so
that I can export the same symbol as "C", "FORTRAN" and
"PASCAL" , but am working on it.....

I know how to export Fortran common stuff as "C"
variables  and I can fool the "ld" linker.
However I have not been able to fool the de* yet....

Sinan

PS: see another post I just made. That program was written
by someone else that I helped a while back. Unfortunately
I do not remember his name to give him proper credit.

--
 Redistribution by Microsoft Network is prohibited.

 
 
 

1. Printing a stack trace upon program error

    Hello,

    I'd like to build a widget into a UNIX application to
    hande segmentation violations and other fatal signals,
    and print a stack trace of the program at the point the
    error occurred.

    I suppose one way to do this is to use a shell program
    to run the application, check for error status, and then
    call gdb (or dbx) to print the stack trace.  I'm hoping
    there's a more elegant solution than this.

    I'm running SunOs 4.1.3 with GNU g++ 2.7.0, so the fix would
    have to work with this environment.

    Any thoughts, anyone?

    Thanks,

                                - Jim

2. Wordperfect 8.0 gunzip

3. In C, how to print stack trace like dbx does

4. iBCS for ADSM ???

5. Printing a stack trace from C++

6. Root filesystem is too small. Make it bigger?

7. Problems calling a gdb stack trace from inside the program thats being traced.

8. symlink_prefix

9. Stack trace in C/C++

10. t: Displaying stack trace without using sdb

11. stack trace

12. Stack trace wanted

13. Stack trace - Multi threaded