Programmatic access to stack traces in C or C++ programs

David Carlton david.carlton@sun.com
Fri Oct 20 21:47:00 GMT 2006


On Fri, 20 Oct 2006 12:41:57 -0700, Michael Snyder <Michael.Snyder@palmsource.com> said:
> On Thu, 2006-10-19 at 22:27 -0400, Ashwin Bharambe wrote:

>> I wanted to create a "stacktrace library" which would provide a
>> routine to obtain the stacktrace of the program from any point
>> _programmatically_ (like Java's stacktraces, for example..)

...

> I think that's pretty hopeless.  But why don't you do it the easy way?

> Just launch your program under gdb from the start, then use gdb
> to put breakpoints at all the functions you are interested in.

I've had the same wish as Ashwin.  The reason why I want it is for
unit testing - jUnit prints out a backtrace when an assertion fails,
and I sometimes want that functionality when running C++ unit tests.
And I'm not about to run GDB every single time that I run a unit test.

libunwind sounds like it might be what I'm looking for, though.

David Carlton
david.carlton@sun.com



More information about the Gdb mailing list