Re: accessing each pthread's context
- From: "bcreane" <bcreane@xxxxxxxxx>
- Date: 21 May 2006 20:41:52 -0700
That's an illusion. ... backtrace ... doesn't work in ... read() ...
I'm just beginning to understand that issue. There's backtrace
code written for OS X PPC that gets around that issue by
creating a fake frame when the thread is doing a system call.
The code walks up the stack looking for a system call instruction
("sc" in ppc), and then builds a fake frame with a link register
pointing to the previous (valid) frame. I imagine something similar
could be done on x86. Here's their code:
http://developer.apple.com/samplecode/MoreIsBetter/listing41.html
Newer glibc's have backtrace_symbols() which will translate PCvalues to symbol names for you.
Yea, I've used it, but its easier to bypass backtrace_symbols when you
use libcwd to demangle the symbol name. Also backtrace_symbols doesn't
do a very good job of figuring out the arguments to a function on the
stack ... by using the frame pointer you can print out the top eight
or so args on the stack when the function is called and later
reconstruct the arguments to the function.
cheers,
brendan
.
- Follow-Ups:
- OT [Re: accessing each pthread's context]
- From: Paul Pluzhnikov
- OT [Re: accessing each pthread's context]
- References:
- accessing each pthread's context
- From: bcreane
- Re: accessing each pthread's context
- From: davids
- Re: accessing each pthread's context
- From: Clifford Heath
- Re: accessing each pthread's context
- From: bcreane
- Re: accessing each pthread's context
- From: Paul Pluzhnikov
- accessing each pthread's context
- Prev by Date: Re: accessing each pthread's context
- Next by Date: Re: accessing each pthread's context
- Previous by thread: Re: accessing each pthread's context
- Next by thread: OT [Re: accessing each pthread's context]
- Index(es):