In common C/C ++ code, you can respond to the segmentation fault error caused by improper memory operations, that is, the signal SIGSEGV (11. You only need to set the handler of SIGSEGV in the program, call the backtrace of libc, and output the corresponding stack information. The problem will soon be found. However, in Android, bionic does not provide similar functions, and the log information is a logger that can be seen through logcat. However, Android also outputs log information, as shown below:
View plaincopy to clipboardprint?
- 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
The binary code is placed in the mobile phone, and the size is taken into consideration, removing the matching information. However, we can use the binary file generated during compilation to obtain its symbolic information and obtain the call Stack:
View plaincopy to clipboardprint?
- Yang @ Ubuntu $ src/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-addr2line-f-e src/out/target/product/pnx6715_refd/symbols/system/lib/libfmradio_jni.so limit 960c 000129ec 0000 cdce listen b2a4 00009496 00008258 10954f6
- 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/.../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.
Android call stack trace, Android call stack parsing, Android print call stack, Android native C call stack
Original article: native code SIGSEGV debugging in Android-call stack Parsing
From: bytes