LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-09-2009, 12:24 PM   #1
telia
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
how to convert address in current process to filename:line number


I have an address returned by backtrace(), I need to convert it to filename and line number

thanks in advance
 
Old 01-10-2009, 09:12 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
The easiest way is to make sure you compile/link using debug symbols:
Quote:
gcc -O0 -g ...
 
Old 01-11-2009, 06:41 AM   #3
telia
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
thanks for the tip, my bad explanation,

I'm receiving something like this:

app_name(_ZN15function_nameC2Ev+0x28) [0x8049b10]

there's an info about the place, but it's not filename and line number. is there any way to retrieve them?

thanks again
 
Old 01-11-2009, 02:58 PM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

You definitely need to include symbols in your executable ("gcc -g" will do this). You also need to link with "-rdynamic". This link should help:

http://www.linuxforums.org/forum/lin...o-symbols.html
 
Old 01-12-2009, 02:10 AM   #5
telia
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
command line:

"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC -c -o "bin/gcc-4.3.2/debug/main.o" "main.cpp"
"g++" -o "bin/app_name" -Wl,--start-group "bin/gcc-4.3.2/debug/main.o" -Wl,-Bstatic -Wl,-Bdynamic -Wl,--end-group -g -rdynamic


backtrace output example:

app_name(_ZN15function_nameC2Ev+0x28) [0x8049b10]

e.g. receiving absolute address, function name and shift. can I convert this info to filename and line number?
 
Old 01-12-2009, 04:06 AM   #6
telia
LQ Newbie
 
Registered: Jan 2009
Posts: 4

Original Poster
Rep: Reputation: 0
I need functionality provided by A2N library (http://perfinsp.sourceforge.net/a2n_linux.html), but it's too complicated supporting external processes, many platforms and different symbols formats. And I'm not sure but seems it uses hand-made approach. Is there any standard way?
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert filename extension to lowercase jakev383 Programming 6 12-07-2008 06:24 AM
Convert a number on each line to CSV file OlRoy Programming 9 08-20-2008 11:05 AM
Convert static library (Filename.a) to dynamic shared object (filename.so) afx2029 Linux - Software 4 08-17-2007 06:07 AM
mtrace / addr2line not resolving address to file + line number jph4599 Linux - Software 0 01-12-2007 03:54 PM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 02:43 PM


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

Main Menu
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