'Tracing using addresses obtained from execinfo.h to human readable format
I want to trace some addresses I received from a trace file (execinfo.h / backtrace) (see below) back into humand readable function calls.
From the backtrace I got:
Obtained 10 stack frames.
/app/name() [0x81e4912]
/app/name() [0x81e4332]
[0xffffe40c]
/app/name() [0x81ddb32]
/app/name() [0x81f6a54]
/app/name() [0x81e2576]
/app/name() [0x81e2386]
/app/name() [0x81f795b]
I want to translate the above lines into more readable form like this:
functioncall1() line x
functioncall2() line x
SigFault() line x <- here I called the backtrace and write it to output stream
I got the corresponding .bin .hex files etc. I could go normally through all the addresses and look for the classes but this wont help me for my problem. Is there a sys command for me doing that automatically? I have looked into the execinfo.h dokumentation but I dont find something about my problem.
Thank you in advance
Solution 1:[1]
addr2line has done the job for me
for i in `grep "\[0x.*\]" $Filename |sed -e "s/.*\[\|\].*$//g"`;
do
echo $i
mem_start="$(( $i ))"
mem_end="$(( $i + 1 ))"
**addr2line -e ${BINARY} $i**
objdump ${BINARY} --start=$mem_start --stop=$mem_end -S
done
done
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user11344770 |
