Addr2line, which can print the corresponding code line based on an address

Source: Internet
Author: User
Addr2line: enter an address and specify an executable with-G compilation. ProgramTo print out the corresponding CodeLine.

In fact, GDB also has this function, but the advantage of addr2line is that, in many cases, bugs are hard to reproduce, and we only have one crash log. In this way, you can use addr2line to find the corresponding code line, which is very convenient. Prerequisites:
1. the executable program is compiled with-g, with debugging information (the so-called debugging information is a correspondence between the Code and the address ).
2. If the crash is in a so object, addr2line cannot directly provide the code line. As we all know, the address in so can be reallocate when the executable file is loaded. I also mentioned the DLL loading logic in Windows core programming. Therefore, if there is only one so address and the corresponding code line needs to be identified, a base address and offset should be given to addr2line, or based on the SMAP information of the executable program, convert the address to an offset address relative to the so base address.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.