[Excerpt] Using arm-eabi-addr2line, ndk-stack tool to track Android call stack

Source: Internet
Author: User
Tracing Android call stacks using arm-eabi-addr2line tools
Author: liangshengyang
Transferred from: Http://www.linuxidc.com/Linux/2011-01/31803.htm

In normal C/C ++CodeIn, you can respond to the segmentation fault error caused by improper memory operations, that is, the signal SIGSEGV (11. As longProgramIn handler set in SIGSEGV, call the backtrace of libc to output the corresponding stack information, and you will soon find the problem. However, in Android, bionic does not provide similar functions, and the log information is the Loger, which can be seen through logcat. However, Android also outputs log information, as shown below:

02-08 10:36:32. 076: INFO/debug (1261): PID: 1959, TID: 1959 >>> Android. Radio <
02-08 10:36:32. 076: INFO/debug (1261): Signal 11 (SIGSEGV), fault ADDR 00198080
02-08 10:36:32. 076: INFO/debug (1261): R0 00198080 R1 81116dac R2 ffffffea R3 00000000
02-08 10:36:32. 086: INFO/debug (1261): R4 8111a9f0 R5 0000000a R6 00000888 R7 0000000a
02-08 10:36:32. 086: INFO/debug (1261): R8 735f6d66 R9 525f6474 10 4154bcd8 FP 00000000
02-08 10:36:32. 086: INFO/debug (1261): IP a0000000 SP bec1a300 LR 81112561 PC 81109124 CPSR 80010010
02-08 10:36:32. 306: INFO/debug (1261): #00 PC 00009124/system/lib/libfmradio_jni.so
02-08 10:36:32. 306: INFO/debug (1261): #01 PC 0001255c/system/lib/libfmradio_jni.so
02-08 10:36:32. 306: INFO/debug (1261): #02 PC route c93e/system/lib/libfmradio_jni.so
02-08 10:36:32. 316: INFO/debug (1261): #03 PC restart ae14/system/lib/libfmradio_jni.so
02-08 10:36:32. 316: INFO/debug (1261): #04 PC route 8a72/system/lib/libfmradio_jni.so
02-08 10:36:32. 316: INFO/debug (1261): #05 PC route 6c22/system/lib/libfmradio_jni.so
02-08 10:36:32. 326: INFO/debug (1261): #06 PC route 4d92/system/lib/libfmradio_jni.so
02-08 10:36:32. 326: INFO/debug (1261): #07 PC release e434/system/lib/libdvm. So

Generally, when compiling Android code, the symbolic information is removed for the sake of size. However, we can use the binary files generated during compilation (Note: files containing symbolic information are usually located in. /out/target/product/[project]/symbols/system/lib/directory) to obtain its symbolic information and obtain the call Stack:

$. /Prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-addr2line-f-e. /out/target/product/[project]/symbols/system/lib/libfmradio_jni.so limit 960c 000129ec 0000 cdce limit b2a4 00009496 00008258 limit 54f6
Non_congruent
Bionic/libc/arch-arm/bionic/memcpy. S: 229
_ Sfvwrite
Bionic/libc/stdio/fvwrite. C: 151
_ Sprint
Bionic/libc/stdio/vfprintf. C: 71
Printf
Bionic/libc/stdio/printf. C: 44
Fm_std_power
Frameworks/base/fmradio/JNI/http://www.cnblogs.com/http://www.cnblogs.com/external/.../fmradio/fmapi/fm_std_api.c:144
_ Z11fm_switchonv
Frameworks/base/fmradio/JNI/fm_functions.cpp: 95
Radio_switchon
Frameworks/base/fmradio/JNI/native. cpp: 41
Yang @ Ubuntu $ C ++ filt _ z11fm_switchonv
Fm_switchon ()

In this way, you can obtain the call stack information and find out the problem.

Bytes -------------------------------------------------------------------------------------------------------------------
Method 2
Bytes -------------------------------------------------------------------------------------------------------------------
Cat logcat_3.log | ndk-Stack-sym ~ /[SOURCE-DIR]/out/target/product/[project]/symbols/system/lib/

Bytes -------------------------------------------------------------------------------------------------------------------
Method 3
Bytes -------------------------------------------------------------------------------------------------------------------
From: http://www.cppblog.com/fwxjj/archive/2011/09/30/157242.aspx

Google provides a Python script that can be downloaded from the http://code.google.com/p/android-ndk-stacktrace-analyzer/ and exported to the crash log using
ADB logcat-D> logfile,
Use arm-Eabi-objdump (located under build/prebuilt/linux-x86/arm-eabi-4.2.1/bin) to convert so or EXE into assembly code, such:
arm-Eabi-objdump-s mylib. so> mylib. ASM,
use the script
Python parse_stack.py

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.