LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-24-2006, 06:18 PM   #1
bcreane
LQ Newbie
 
Registered: Apr 2006
Posts: 5

Rep: Reputation: 0
Lightbulb Getting stack backtrace for all instantiated threads


Hi All, I'm hoping someone can point me in the right direction ... I've got the bones of a stack trace based on backtrace, backtrace_symbols, and libcwd::demangle_symbol. This works fine as long as I'm only interested in the currently running thread's stack. But it would be really useful to get a picture (for an assert log) of the entire application. This means doing a stack trace on all created threads.

The path I'm dreading is getting each thread's stack (pthread_attr_getstack), and walking the stack "manually." Does anyone have an alternate direction that might yield a portable solution?

thanks in advance,
bcreane
 
Old 04-24-2006, 07:05 PM   #2
bcreane
LQ Newbie
 
Registered: Apr 2006
Posts: 5

Original Poster
Rep: Reputation: 0
a simplifying influence ...

Some positive info ... if I can get the return addresses on the stack into an array of void*, then backtrace_symbols() will search the loaded dynamic libraries for the symbol that corresponds to that address. So its only half the work I thought.
cheers!
bcreane
 
Old 05-02-2006, 11:58 AM   #3
bcreane
LQ Newbie
 
Registered: Apr 2006
Posts: 5

Original Poster
Rep: Reputation: 0
a good direction

Just thought I'd check in with the direction I'm heading in ... libthread_db is used by gdb and the bozo profiler (among others) to control the threading activity of a remote process. The api is undocumented in linux, but there's a Solaris man page for each of the functions provided by libthread_db. The approach I'm looking at is to iterate through each thread, and save the frame register (%EPX on an x86) and then create a backtrace from that. Libthread_db also appears to support suspending and resuming threads which was another goal. Hope this is helpful to someone else.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference b/t Kernel stack and User stack hazzyb Linux - Software 2 09-29-2008 08:40 PM
Alsa backtrace? hosler Slackware 9 02-07-2006 01:23 AM
how to make a good backtrace in C/C++? Thinking Programming 1 12-06-2005 08:16 AM
Backtrace / stack dump for all Linux platforms GreyBeard Programming 7 07-21-2005 01:04 PM
How to interpret backtrace (gdb) jnusa Programming 1 12-06-2004 10:16 AM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration