This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: backtrace C-API

On Monday, April 21, 2003, at 02:04 PM, Andrew Cagney wrote:

On Fri, Apr 18, 2003 at 02:33:27PM +0200, Gerrit Bruchhäuser wrote:
is there any C-API function in libgdb.a (or some other library) which
returns a call stack (something 'bt' like)?
No; but you might find backtrace() useful if you're on a
glibc-supported platform.

But there probably should. How hard is it to create a `target-self' that uses local memory, and a jump-buf for registers? The tricky bit, I see, is the symbol table assuming a single global structure.

This falls into the category of Nasty Hack, but I helped someone on our compiler group with a similar problem a long time ago. I had them add a call at the site of interest which (a) got the current process' pid, (b) wrote a little gdb command script into a /tmp file which would attach to the process, bt, and detach, (c) ran system ("gdb --command=/tmp...") in the function, and (d) removed the file from /tmp.

I'm sure there are better ways to handle all this, but it took about five minutes to do all this correctly -- for a one-off problem, it wasn't a bad solution. They captured stdout, massaged the output a bit, and had the info they needed.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]