- 浏览: 1499803 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (419)
- XMPP (19)
- Android (180)
- Java (59)
- Network (4)
- HTML5 (13)
- Eclipse (9)
- SCM (23)
- C/C++ (4)
- UML (4)
- Libjingle (15)
- Tools&Softwares (29)
- Linphone (5)
- Linux&UNIX (6)
- Windows (18)
- Google (10)
- MISC (3)
- SIP (6)
- SQLite (5)
- Security (4)
- Opensource (29)
- Online (2)
- 文章 (3)
- MemoryLeak (10)
- Decompile (5)
- Ruby (1)
- Image (1)
- Bat (4)
- TTS&ASR (28)
- Multimedia (1)
- iOS (20)
- Asciiflow - ASCII Flow Diagram Tool.htm (1)
- Networking (1)
- DLNA&UPnP (2)
- Chrome (2)
- CI (1)
- SmartHome (0)
- CloudComputing (1)
- NodeJS (3)
- MachineLearning (2)
最新评论
-
bzhao:
点赞123!
Windows的adb shell中使用vi不乱码方法及AdbPutty -
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
HTML5 WebSocket 技术介绍 -
obehavior:
view.setOnTouchListenerview是什么
[转]android 一直在最前面的浮动窗口效果 -
wutenghua:
[转]android 一直在最前面的浮动窗口效果 -
zee3.lin:
Sorry~~
When I build "call ...
Step by Step about How to Build libjingle 0.4
http://www.codexperiments.com/android/2010/08/tips-tricks-debugging-android-ndk-stack-traces/
http://crazydaks.com/debugging-in-android-with-tombstones.html
http://blog.csdn.net/coder_jack/archive/2010/06/28/5700348.aspx
-
Debugging in Android with Tombstones
Everytime a process crashes under Android, a so called Tombstone is written for the process. A tombstone is a file containing important information about the process when it crashed. A slimmed core dump of sorts.
It is printed out in the log (can be seen in the printout using adb shell logcat), but the tombstones are also saved and stored on target under /data/tombstones/ and are called tombstone_XX where XX is a number increased by one with each crash.
To get a stacktrace for the crashed process containing file and line information we need to cross reference
the tombstone with the debugging symbols located on the host. generally
the debug symbols are stripped when the libraries are loaded in the
rootfs to save space. Hence you may need to dig the appropriate
/out/product/xxx/symbols/system/libxx to get the unstripped libraries.
Once that you can extract the line number and function name etc from a
uitility called addr2line. this is generally found in the prebuilt
directory of android source distribution.
$(android-root)prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin is the normal location.
hence once you have located the unstripped libraries and location of addr2line tool on your host its as simple as using the addr2line command.
$(android-root)prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/addr2line -f -e /out/product/xxx/symbols/system/libc.so 0xbe8c1630 if 0xbe8c1630 is one of the symbols in the strack trace from library libc.so. is a typical dump for a system that underwent 6 crashes on my target.
# ls -l /data/tombstones
-rw——- system system 24216 2000-01-01 00:04 tombstone_02
-rw——- system system 22684 2000-01-01 00:03 tombstone_01
-rw——- system system 21913 2000-01-01 00:02 tombstone_06
-rw——- system system 24216 2000-01-01 00:04 tombstone_03
-rw——- system system 24322 2000-01-01 00:10 tombstone_05
-rw——- system system 22612 2000-01-01 00:02 tombstone_04
-rw——- system system 24665 2000-01-01 00:02 tombstone_00
# cat tombstone_01
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: ‘generic/myboard_xxx/xxx/myplatform:2.1/ERD79/eng.arunks.20100726.14330
8:eng/test-keys’
pid: 1138, tid: 1138 >>> /system/bin/bluetoothd <<<
signal 11 (SIGSEGV), fault addr deadbaad
r0 00000000 r1 afe13369 r2 00000027 r3 00000054
r4 afe3ae08 r5 00000000 r6 00000000 r7 0000a000
r8 00000000 r9 00000000 10 00000000 fp 00000000
ip 00002ed8 sp bec782d8 lr deadbaad pc afe10a20 cpsr 60000030
#00 pc 00010a20 /system/lib/libc.so
#01 pc 0000b332 /system/lib/libc.so
#02 pc 0000ca62 /system/lib/bluez-plugin/audio.so
#03 pc 0000d1ce /system/lib/bluez-plugin/audio.so
#04 pc 0000e0ba /system/lib/bluez-plugin/audio.so
#05 pc 0002f9a2 /system/lib/libbluetoothd.so
#06 pc 00026806 /system/lib/libbluetoothd.so
#07 pc 00026986 /system/lib/libbluetoothd.so
#08 pc 0002800c /system/lib/libbluetoothd.so
#09 pc 00028b72 /system/lib/libbluetoothd.so
#10 pc 0001891a /system/lib/libbluetoothd.so
#11 pc 0000c228 /system/lib/libc.so
code around pc:
afe10a10 f8442001 4798000c e054f8df 26002227
afe10a20 2000f88e ef2cf7fb f7fd2106 f04fe80a
afe10a30 91035180 460aa901 96012006 f7fc9602
code around lr:
deadba9c ffffffff ffffffff ffffffff ffffffff
deadbaac ffffffff ffffffff ffffffff ffffffff
deadbabc ffffffff ffffffff ffffffff ffffffff
stack:
bec78298 bec78334 [stack]
bec7829c bec7838b [stack]
bec782a0 afe3b02c /system/lib/libc.so
is a typical tombstone dump from my system….
-
Tips & Tricks: Debugging with Android NDK stack traces
Stuck in the hell of crashing applications? Don’t know how to find the tiny allocation or deallocation mistake hidden in a code stack of thousands of lines? Here is your way to heaven.
08-22 23:27:40.730: INFO/DEBUG(65): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 08-22 23:27:40.730: INFO/DEBUG(65): Build fingerprint: 'htc_wwe/htc_bravo/bravo/bravo:2.2/FRF91/218634:user/release-keys' 08-22 23:27:40.730: INFO/DEBUG(65): pid: 2474, tid: 2485 >>> com.test <<< 08-22 23:27:40.730: INFO/DEBUG(65): signal 11 (SIGSEGV), fault addr 00000001 08-22 23:27:40.730: INFO/DEBUG(65): r0 00000001 r1 00000000 r2 afd438e4 r3 00000001 08-22 23:27:40.730: INFO/DEBUG(65): r4 4825395c r5 00001000 r6 00001000 r7 00000001 08-22 23:27:40.730: INFO/DEBUG(65): r8 48253ad8 r9 432faf40 10 802a3448 fp 432faf40 ... 08-22 23:27:40.730: INFO/DEBUG(65): d30 0000000000000000 d31 0000000000000000 08-22 23:27:40.730: INFO/DEBUG(65): scr 80000012 08-22 23:27:40.790: INFO/DEBUG(65): #00 pc 00018656 /data/data/com.test/lib/libmylib.so 08-22 23:27:40.790: INFO/DEBUG(65): #01 pc 000186d2 /data/data/com.test/lib/libmylib.so 08-22 23:27:40.790: INFO/DEBUG(65): #02 pc 00018708 /data/data/com.test/lib/libmylib.so ...
Well if you understand that, then it means that either you’re an overly talented developer or you’d rather look for an ophthalmologist . But you’re just a normal coder, than at best you know that this is a stack trace. An Android native stack trace to be more precise, generated after an application crash.
Hopefully, some tools are available to “decrypt” that mysterious data: arm-eabi-addr2line. This tools is in the “${ANDROID_NDK}/build/prebuilt/linux-x86/arm-eabi-[version]/bin/ ” directory which contains some utility tools for ARM processors. And combine with the original library that generated it, you can find the incriminated methods and file lines. And that’s priceless when you can’t debug your code!
First ensure your native code is compiled in Debug mode to access code information (“APP_OPTIM := debug ” in your application.mk). Then call the executable with your .so compiled library, for example:
${Android-NDK}/build/prebuilt/linux-x86/arm-eabi-[version]/bin/arm-eabi-addr2line -C -f -e libmylib.so
Then just type the address, the one you can find after the “pc ” directive, for example:
00018656
taken from line “#00 pc 00018656 /system/lib/libstlport.so “.
That’s all!
- android 调试中 addr2line 命令的使用
问题引出:i850的wifi定位开启后,在使用goole maps时出现rootfs重启现象,打印的log信息如下:
//////////////////////////
I/DEBUG ( 3411): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 3411): Build fingerprint: 'PROWAVE/i850/i850/:Eclair/ECLAIR/eng.zhangjiejing.20100430.113200:eng/test-keys'
I/DEBUG ( 3411): pid: 3436, tid: 3475 >>> system_server <<<
I/DEBUG ( 3411): signal 11 (SIGSEGV), fault addr 00000000
I/DEBUG ( 3411): r0 26ba7eec r1 403f3c49 r2 e98cf6f4 r3 405e58ae
I/DEBUG ( 3411): r4 00000000 r5 00000000 r6 4229b6cc r7 48fecec8
I/DEBUG ( 3411): r8 490ecd84 r9 48feceb4 10 48fece9c fp 00314d30
I/DEBUG ( 3411): ip ad3527cd sp 490ecd68 lr ad3527eb pc 00000000 cpsr 00000010
I//system/bin/dhcpcd( 3673): wlan0: looping
I//system/bin/dhcpcd( 3673): wlan0: signal_fd: 4,fd:5
I/ActivityManager( 3436): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/.Launcher }
D/LocationManager( 3777): removeUpdates: listener = P.a@43da64b8
I/DEBUG ( 3411): #00 pc 00000000
I/DEBUG ( 3411): #01 pc 000527e8 /system/lib/libandroid_runtime.so
I/DEBUG ( 3411): #02 pc 0000f1f4 /system/lib/libdvm.so
I/DEBUG ( 3411):
I/DEBUG ( 3411): code around lr:
I/DEBUG ( 3411): ad3527d8 69e19806 694c9000 1c191c10 9b059a04
I/DEBUG ( 3411): ad3527e8 b00247a0 46c0bd10 00017868 00006728
I/DEBUG ( 3411): ad3527f8 4c0fb570 447c4d0f 6b2e1965 d1112e00
I/DEBUG ( 3411):
I/DEBUG ( 3411): stack:
I/DEBUG ( 3411): 490ecd28 00000013
I/DEBUG ( 3411): 490ecd2c ad05f661 /system/lib/libdvm.so
I/DEBUG ( 3411): 490ecd30 410c2aec /dalvik-LinearAlloc (deleted)
I/DEBUG ( 3411): 490ecd34 ad0560f7 /system/lib/libdvm.so
I/DEBUG ( 3411): 490ecd38 400292d8 /mspace/dalvik-heap/zygote/0 (deleted)
I/DEBUG ( 3411): 490ecd3c 410c2aec /dalvik-LinearAlloc (deleted)
I/DEBUG ( 3411): 490ecd40 000003dc
I/DEBUG ( 3411): 490ecd44 ad0591f5 /system/lib/libdvm.so
I/DEBUG ( 3411): 490ecd48 42200d44 /data/dalvik-cache/system@@classes.dex
I/DEBUG ( 3411): 490ecd4c 42200d44 /data/dalvik-cache/system@@classes.dex
I/DEBUG ( 3411): 490ecd50 4232b87d /data/dalvik-cache/system@@classes.dex
I/DEBUG ( 3411): 490ecd54 00000000
I/DEBUG ( 3411): 490ecd58 4264aa04 /data/dalvik-cache/system@@classes.dex
I/DEBUG ( 3411): 490ecd5c 410c1cbc /dalvik-LinearAlloc (deleted)
I/DEBUG ( 3411): 490ecd60 df002777
I/DEBUG ( 3411): 490ecd64 e3a070ad
I/DEBUG ( 3411): #01 490ecd68 43160000
I/DEBUG ( 3411): 490ecd6c ad05f661 /system/lib/libdvm.so
I/DEBUG ( 3411): 490ecd70 490ecda8
I/DEBUG ( 3411): 490ecd74 ad00f1f8 /system/lib/libdvm.so
W/ActivityManager( 3436): Activity pause timeout for HistoryRecord{43d6cd48 com.google.android.apps.maps/com.google.android.maps.MapsActivity}
wait for fb sleep Enter
D/WifiService( 3436): releaseWifiLockLocked: WifiLock{NetworkLocationProvider type=2 binder=android.os.Binder@43bfb998}
binder: release 3436:3560 transaction 22233 in, still active
binder: send failed reply for transaction 22233 to 3777:3777
I/DEBUG ( 3411): debuggerd committing suicide to free the zombie!
I/DEBUG ( 3855): debuggerd: Apr 14 2010 14:24:22
I/ServiceManager( 2066): service 'usagestats' died
I/ServiceManager( 2066): service 'account' died
//////////////////////////
注意到红色部分,这就是程序执 行时的栈!显然第一个pc指针的值为0,也就是pc指针为空,这就是问题之所在,接 下来就是要定位这个问题,上边说了,这里是程序执行时的栈,那么#01 pc 000527e8 /system/lib/libandroid_runtime.so 这个地址就是我们要找的问题的范围,因为显然是后者先入栈的,所以显然前者包含于后者,那么通过如下命令用地址定位一下源码的位置:
cpp@cpp:~/r7_0422$ ../gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-addr2line -e out/target/product/i850/symbols /system/lib/libandroid_runtime.so 000527e8
frameworks/base/core/jni/android_location_GpsLocationProvider.cpp:397
cpp@cpp:~/r7_0422$
看到源码的397行是一个函数,那么000527e8就是这个函数的入 口地址了。继而,pc 000000 对应的调用就应该在该函数内部,看到该函数内部只是做了对另一个函数指针的调用而已,所以我们可以断定这个函数指针的值为空,显然调用一个空的指针函数是 错误的。所以需要给这个函数指针在早些时候赋值一下问题就可以解决了!
关于addr2line的一点补充: 如果可执行文件中没有包括调试符号,您将获得??:0 作为响应。 还有在linux中的readelf命令可以读取可执行文件的相关信息,比如有一个可执行文件 aa.elf 则可以这么使用: readelf -h aa.elf 参数-h读取可执行文件的head信息。
参考连接:http://www.xxlinux.com /linux/article/accidence/technique/20070125/7209.html
发表评论
-
[Android] 为Android安装BusyBox —— 完整的bash shell
2013-12-27 10:19 1475http://www.cnblogs.com/xiaowen ... -
Windows的adb shell中使用vi不乱码方法及AdbPutty
2013-12-27 10:17 7534http://www.veryhuo.com/down/ht ... -
AppMobi推出新XDK,可创建测试PhoneGap项目
2012-09-03 13:39 2618AppMobi今天发布了一个新的工具PhoneGap Mobi ... -
Sencha
2012-09-03 12:59 1179http://www.sencha.com/ Se ... -
jQuery Mobile学习
2012-09-01 12:33 1673使用Jquery Mobile设计Android通讯录 ... -
BackBone
2012-09-01 12:34 1252Backbone.js 是一种重量级javascript M ... -
jQTouch
2012-08-30 15:57 976A Zepto/jQuery plugin for mobil ... -
SwiFTP
2012-08-30 15:43 1294SwiFTP is a FTP server that run ... -
kWS
2012-08-30 15:41 1192kWS is a lightweight and fast W ... -
jQuery Mobile
2012-08-30 15:07 1013http://jquerymobile.com/ -
PhoneGap
2012-08-30 15:07 1035http://phonegap.com/ -
Android Button background image pressed/highlighted and disabled states without
2012-08-06 12:49 1669http://shikii.net/blog/android- ... -
[AndriodTips]Image, saved to sdcard, doesn't appear in Android's Gallery app
2012-08-04 16:15 1149http://stackoverflow.com/questi ... -
Voice detection for Android
2012-07-23 11:39 2333Here it is, my fist JAVA applic ... -
[AndroidTip]local reference table overflow (max=512)的错误解决
2012-07-22 22:56 6024JNI层coding经常会遇到ReferenceTable o ... -
[AndroidTip]EditText如何初始状态不获得焦点?
2012-07-22 15:35 1220最简单的办法是在EditText前面放置一个看不到的Linea ... -
[AndroidTip]android textview滚动条
2012-07-21 14:29 1290本来是想做一个显示文字信息的,当文字很多时View的高度不能超 ... -
Google公布Android 4.1完整功能
2012-07-16 09:48 3170http://www.android.com/about/je ... -
Android开发:使用AudioTrack播放PCM音频数据【附源码】
2012-07-13 15:20 20825http://www.linuxidc.com/Linux/2 ... -
Android上的行车记录仪
2012-07-11 22:31 2001MyCar Recorder DailyRoads
相关推荐
在实际使用中,`addr2line`的工作原理是这样的:它通过读取目标库文件的调试信息(通常在`.debug`节区),找到内存地址所对应的函数和源代码行。这个过程依赖于编译时开启的`-g`选项,以保留完整的调试信息。如果`....
《addr2line在x86平台上的应用与内存泄露检测》 在软件开发过程中,内存泄漏是一个常见的问题,它可能导致程序性能下降甚至崩溃。addr2line是GNU Binutils工具链中的一部分,它能够帮助开发者从内存地址反解析出...
addr2line 跨平台库,用于从具有DWARF调试信息的文件中检索每个地址的调试信息。 addr2line使用解析调试信息,并公开一个接口,用于查找源文件,行号以及目标程序中指令地址的包装函数。 这些查找可以通过Context:...
tensa-esp32-elf-addr2line
现在的软件源代码动则千万行,初学者常常感到迷惘,如果能自动生成关键函数的调用关系图,则思路可以清晰许多。如下面这幅图展示了WebKit网页渲染的部分函数执行过程,比单纯地看代码直观多了。...
addr2line.exe
免费 免费 感谢 https://github.com/armink/CmBacktrace/blob/master/tools/addr2line/win64/addr2line.exe
【保姆级IDF】ESP32调试利器:xtensa-esp32-elf-addr2line介绍、安装、使用
Qualcomm865_3/android-ndk-r21e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-addr2line -f -C -e workplace/Qualcomm865_3/native-agent/Agent/bin/AC_card_agent ...
在IT行业中,`addr2line`是一个非常重要的工具,它属于GNU Binutils的一部分,用于将程序内存地址转换为源代码中的行号和函数名。这个工具对于调试和分析二进制程序的行为尤其有用,因为它可以帮助开发者理解代码...
总结来说,LeakTracker是Android开发中一个强大的内存泄漏检测工具,其解析相对地址的能力和优化的addr2line脚本,为开发者提供了更高效、准确的内存泄漏定位方法。通过深入理解和运用LeakTracker,开发者可以更好地...
要定位NDK引发的崩溃问题,Android NDK提供了一些调试工具,包括addr2line、objdump和ndk-stack。这些工具可以帮助将崩溃的堆栈信息映射回具体的C/C++源代码位置。 addr2line工具可以将程序中的地址转换成对应的...
2. **NDK集成**:此工具链可能与Android Native Development Kit (NDK)相关联,NDK是一套用于在Android平台上开发原生应用和库的工具。 3. **目标API级别**:根据目标设备的Android版本,选择合适的API级别进行编译...
这里 `<executable>` 是产生内存泄漏的程序,`<relative_address>` 是LeakTracker报告中的相对地址,而`<ADDR2LINE_PATH>` 则指向addr2line的可执行文件。 优化脚本还可能包括并行处理多个内存泄漏地址,以提高分析...
3. **运行addr2line**:将PC寄存器的值作为参数传递给addr2line,命令格式大致为`addr2line -e 文件> <内存地址>`,其中文件>是你的目标程序的ELF文件,这是包含程序映射信息的文件。 4. **解析结果**:addr2line会...
3. **运行addr2line**:将PC寄存器的值作为参数传递给addr2line,命令格式大致为`addr2line -e 文件> <内存地址>`,其中文件>是你的目标程序的ELF文件,这是包含程序映射信息的文件。 4. **解析结果**:addr2line会...
3. **运行addr2line**:将PC寄存器的值作为参数传递给addr2line,命令格式大致为`addr2line -e 文件> <内存地址>`,其中文件>是你的目标程序的ELF文件,这是包含程序映射信息的文件。 4. **解析结果**:addr2line会...
总的来说,调试Android的bin和so文件需要结合logcat的日志、addr2line和objdump工具,以及可能的第三方调试辅助工具,来定位问题的源头。理解这些工具的用法和崩溃日志的含义,对于任何Android开发者来说都是至关...
在Android源码树中添加userspace I2C读写工具(i2c-util) 本文使用的开发板是:杭州若格科技有限公司的全志R8。CPU:CPUARM Cortex-A8 更多芯片资料请参见全志官网: http://www.allwinnertech.com/clq/r/R8.html...
Addr2LineUI.exe