Addr2line dynamic library

Source: Internet
Author: User

In Android development, Java exceptions are intuitive, but dynamic library exceptions print addresses. The following method can be used to lock the faulty function.

Arm-eabi-addr2line-C-F-s-e dynamic library address can parse the address information of the original fault.

For example:

Arm-eabi-addr2line-C-F-s-e libpcmhost. So 0c480

Print:

_ Jnienv: callintmethod (_ jobject *, _ jmethodid *,...)

 

 

 

In backtrace, there are generally only some addresses. However, with the addr2line tool, you can find the correspondingCodeLine. The prerequisite is executable.ProgramOr the-G option is included in the dynamic link library compilation.

Specifically, there are two situations:

1. If the following line of Backtrace is located in an executable file, you can directly add addr2line-E <executable> <address>

2. If the backtrace to be followed is located in a dynamic link library, it is troublesome because the base address of the dynamic link library is not fixed. At this time, we should first find the memory map of the process. InLinuxThe memory map of the process can be obtained in the/proc/<pid>/maps file. Find the base address of the dynamic link library in this file, and then set the address in backtrace to the base address of the dynamic link library to get the offset address, finally, addr2line-E <shared library> <OFFSET address>.

Of course, you can use GDB to find the code line corresponding to the address. However, compared with addr2line, GDB needs to reproduce the bug phenomenon. For bugs that are not easy to reproduce, or bugs that are randomly reproduced, you can use addr2line to directly find the corresponding code line from backtrace, it does not need to be reproduced and is easier to use than GDB.

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.