简体   繁体   中英

addr2line with archive files

I am trying to use addr2line with a archive file libdpdk.a

I have a backtrace:

backtrace returned: 7
0: 0x46fd05 ./build/ip_pipeline(bt+0x25) [0x46fd05]
1: 0x42a163 ./build/ip_pipeline() [0x42a163]
2: 0x46ff21 ./build/ip_pipeline(rte_eal_init+0x171) [0x46ff21]
3: 0x439629 ./build/ip_pipeline(app_init+0x709) [0x439629]
4: 0x42b3ff ./build/ip_pipeline(main+0x5f) [0x42b3ff]
5: 0x7f101166b830 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f101166b830]
6: 0x42d009 ./build/ip_pipeline(_start+0x29) [0x42d009]

I tried the following command:

addr2line  0x46fd05 -f -e ../../build/lib/librte_eal.a

addr2line: ../../build/lib/librte_eal.a: cannot get addresses from archive

The expected output should be a name of the function in the backtrace at address 0x46fd05 or 0x46fd05 depending on which address I pass. Currently there is no symbol name associated with this address.

Any suggesstions.

I have compiled the code using -rdynamic

Putting a side the reason for choosing.a/.so, The 'addr2line' should be used with the binary that was executed. The reason is that the backtrace addresses are specific to a binary.

The same static (.a) library will usually be loaded into different addresses in different binaries. This is true with '.so' (especially, position-independent code) - but in many cases, Linux will attempt to reuse already mapped '.so' files, so that the actual addresses are the same.

Bottom line - from the man page - use the executable name.

--exe=filename
           Specify the name of the executable for which addresses should be translated. 
           The default file is a.out.

Some practical note - when using '.so' - you want to execute the addr2line on a system that has the same executable, shared objects, and LD_LIBRARY_PATH. If there are different '.so' on your development and on production, the addresses may not match.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM