参考 http://blog.csdn.net/span76/article/details/44225415, 编写一个必然crash的程序
#include <stdio.h> void f() { char *c=0; *c=0; } int main (void) { printf("hello world"); f(); return 0; }
编译后复制到 system/bin 下面
而后adb shell 登陆到device上运行,系统报告Segmentation fault (core dumped)
adb log 打印下面的信息
03-31 02:27:19.533 15 15 I DEBUG : backtrace:
03-31 02:27:19.533 15 15 I DEBUG : #00 pc
00000514 /system/bin/pnp5
03-31 02:27:19.533 15 15 I DEBUG : #01 pc 00017c94 /system/lib/libc.so (__libc_init+84)
..
执行下面的命令定位到 source
prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/i686-linux-android-addr2line -e out/target/product/Product1/symbols/system/bin/pnp5
0x00000514
结果如下,定位是准确的
/home/payne/zjb/pnp5/jni/main.c:5
时间: 2024-11-29 05:48:28