libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libunwind] Re: unwinding stacks of user level threads


From: David Mosberger
Subject: [libunwind] Re: unwinding stacks of user level threads
Date: Fri, 22 Aug 2003 22:09:09 -0700

>>>>> On Fri, 22 Aug 2003 19:04:03 +0200, "Karl Ostner" <address@hidden> said:

  Karl> From a utility, which attaches to shared memory, I've access to
  Karl> the stacks of the various threads. Now I want the utility to
  Karl> dump the stack of a thread (which might not be running
  Karl> currently), using the context of the thread saved on top of
  Karl> its stack. OTOH, the utility should also be capable of dumping
  Karl> the stack of a currently running thread (process).

  Karl> Can this be achieved using libunwind ?

Yes (if I understand you correctly).

  Karl> If yes, how?

The basis of doing this is unw_init_remote(3):

 http://www.hpl.hp.com/research/linux/libunwind/man/unw_init_remote(3).php

You'll need to use this if you want to take advantage of the shared memory
mappings.  If performance is a secondar concern, you could probably just
use the existing ptrace support:

 http://www.hpl.hp.com/research/linux/libunwind/man/libunwind-ptrace(3).php

See tests/test-ptrace.c for an example of how to use this.  Depending on
the details of how your user-level thread library works, you may need
to define your own versions of the _UPT_access_reg()/_UPT_access_fpreg()
callbacks, but that should be about the extent of it.

  Karl> Is there a different, simple way following the stack frames,
  Karl> and getting the IP from each frame ?

Nope (at least "no reliable way").  The days of compiler's maintaining
frame-chains are long gone (even on x86).

        --david


reply via email to

[Prev in Thread] Current Thread [Next in Thread]