[lug] Stack trace question

D. Stimits stimits at idcomm.com
Wed Aug 16 17:46:46 MDT 2000


Dan Wilson wrote:
> 
> Hi All,
> 
> In my program I want to trace the stack and see every function within
> the stack and what module it is coming from.  If main() calls foo() from
> foo.so and foo called bar() from bar.so and bar() called myfunction() from
> mylibrary.so,  In myfunction() I want to see bar() coming from bar.so
> and foo() coming from foo.so and so on.  No clue how to do this any
> help is greatly appreciated.
> 
> Thank you
> Dan
> 
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug

gdb is the beast you need. Compile with -g, and don't use -O2 (or
-OsomethingOptimized).

What you are looking for is "bt". Inside the debugger, type "help bt".
It should give you info sufficient to see not only the calls, but the
arguments passed. If you are using threads, it gets more complicated,
and generally you'd need a patch for threads under stock gdb.




More information about the LUG mailing list