LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-06-2005, 03:37 AM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
how to make a good backtrace in C/C++?


hiho@ll

my prog creates a backtrace if an exception is thrown during runtime
i use my own Exception class for this purpose

the backtrace is done like this

the problem is, this is a not easy to read
it causes something like this:

1079507548 ./../lib/libmaster.so.0(_ZN9ExceptionC1EiSsPcii+0x1bc) [0x4057fa5c]
1079462361 ./../lib/libmaster.so.0(_Z9tcpServeri+0x251) [0x405749d9]
1079511536 ./../lib/libmaster.so.0(_ZN8Net2FIFOC1EiP10FIFOStream+0x158) [0x405809f0]
1079489564 ./../lib/libmaster.so.0(_ZN6Master5startEv+0x240) [0x4057b41c]
134563775 ./masterdaemon(main+0x1285) [0x80547bf]
1075286624 /lib/tls/libc.so.6(__libc_start_main+0xe0) [0x40179260]
134538641 ./masterdaemon(__gxx_personality_v0+0x349) [0x804e591]

Q1: is it possible to rename "_ZN9ExceptionC1EiSsPcii+0x1bc" to the correct function/class name "Exception()"? if yes how?
Q2: what exactly does the above backtrace means?
i use the function backtrace(); and backtrace_symbols(); to create the addresses of the functions (the numbers on the left) and get the symbol strings (the right part of the lines). but what does this "[0x405809f0]" mean, or (_Z9tcpServeri+0x251) what does +0x251 means? and why has the main function the name "main+0x1285" and the other functions have some cryptic characters in the function name (i think it has something to do with classes/functionname, address space, ...)
Q3: anybody knows a better method to do a backtrace? i thought about using something like a "register/unregister" function at the beginning and end of each function, so i can do better human readable form of Stack trace
Q4: what stuff do you use when trying to debug linux progs which are released and maybe posted by some users? which information can i collect except a backtrace?
[EDIT]
Q5: if its possible to get the function symbols using backtrace_symbols(); is it possible to the variable symbols and it's values, so i can check which variables have which values?
[/EDIT]

thx@ll

Last edited by Thinking; 12-06-2005 at 03:53 AM.
 
Old 12-06-2005, 07:16 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The C/C++ compiler mangles the function names. The reason for this si to support overloaded functions. There may be a library that will convert these functions back to their original but it will be compiler dependent and you will need to compile you code with debugging information.

graeme.
 
  


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
kde crash backtrace help MRDucks Mandriva 1 11-14-2005 01:10 PM
Backtrace / stack dump for all Linux platforms GreyBeard Programming 7 07-21-2005 12:04 PM
Boot Text: How do I make it look good? sulzla SUSE / openSUSE 2 02-01-2005 07:53 AM
Solaris make a good webserver? MikeZila Solaris / OpenSolaris 7 12-24-2004 01:10 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 03:26 AM.

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