LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 05: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, 06: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, 10: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



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 07:40 PM
Alsa backtrace? hosler Slackware 9 02-07-2006 12:23 AM
how to make a good backtrace in C/C++? Thinking Programming 1 12-06-2005 07:16 AM
Backtrace / stack dump for all Linux platforms GreyBeard Programming 7 07-21-2005 12:04 PM
How to interpret backtrace (gdb) jnusa Programming 1 12-06-2004 09:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:47 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
Open Source Consulting | Domain Registration