Debugging segmentation fault
来源:互联网 发布:哪个软件直播笑傲江湖 编辑:程序博客网 时间:2024/05/01 23:55
Debugging segmentation fault
Type 1 Seg Fault has backtrace of shared objects (most of the times we face this)
The PC holds the offset and it has to be traced in the top most 'so' file present in back trace. This can be done by using addr2line or objdump tool
a. Using addr2line:
Syntax: <path to arm-eabi-addr2line> -f -e <path to so file> <offset which is the PC value>
Example: #00 pc 0000e234 /system/lib/libc.so ./prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin/arm-eabi-addr2line -f -e ./out/target/product/generic/symbols/system/lib/libc.so 0x0000e234
Returns strlen bionic/libc/arch-arm/bionic/strlen.c:62
b. Using objdump:
Syntax: <path to arm-eabi-objdump> -S <path to so file>
Example: prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin/arm-eabi-objdump -S out/target/product/zoom2/symbols/system/lib/libOMX.TI.Video.encoder.so > ObjDumpFile.txt Output is redirected to ObjDumpFile file
Now the ObjDumpFile has the Intermix of source code with disassembly. We can search using the PC offset in it to see the exact line number
Tip: Make sure to use the debug version of 'so' files which are within the symbols dir in out folder otherwise we would not get the source code symbols in obj dump
Type 2 Seg fault print has the thread name along with register values. The backtrace of shared objects is not present
1. The PC holds a virtual address
2. The first '3' digits of PC provide info on the virtual memory mapping where the shared object('so') is loaded and remaining digits provide the offset within the 'so'
3. Use the 'ps' call to get the Process ID of the thread where it fails.
4. Get the memory map of the process using the following:
In device console/adb shell, print values of 'maps' file within the process id <pid>. Syntax: cat proc/<pid>/maps It is recommended that we get the memory map during the normal execution before the failure itself otherwise it is possible for process to be killed and might lead to mismatch.
5. Use the first '3' digits of PC value to identify the shared object which has caused the failure(using memory map)
6. Get the obj dump of the 'so' and search with the offset to get the exact line of failure. (this can be done in the similar way as in Type 1 seg fault debugging mentioned above)
Example:
Seg Fault Message: PV author: unhandled page fault (11) at 0x00000004, code 0x017 pgd = ccfc8000 [00000004] *pgd=8cbe1031, *pte=00000000, *ppte=00000000 Pid: 9691, comm: PV author CPU: 0 Not tainted (2.6.29-omap1 #20) PC is at 0x81b23140 LR is at 0x81b23049 ...
Based on PC, the shared object is in range of 0x81bxxxxx and offset within that is 0x23140
PV author runs in context of Media server process (PID: 944) Using cat /proc/944/maps we can identify the ‘so’ loaded in this region 81b00000-81b2a000 r-xp 00000000 b3:02 34574 /system/lib/libOMX.TI.Video.encoder.so So appears to be in OMX TI Video encoder
Now with the offset we can use the addr2line or objdump to get the line causing this issue
http://omappedia.org/wiki/Android_Debugging
- Debugging segmentation fault
- Example Debugging Session: Segmentation Fault Example
- gdb教程:7.2 Example Debugging Session: Segmentation Fault Example
- Segmentation Fault
- Segmentation Fault
- Segmentation fault
- SEGMENTATION FAULT
- Segmentation fault
- segmentation fault
- segmentation fault
- segmentation fault
- segmentation fault
- segmentation fault
- segmentation fault
- segmentation fault
- Segmentation fault
- segmentation fault
- segmentation fault
- 唐骏:身价10亿不买房 每月12万住宾馆
- C-结构
- OJ3377数据结构实验之查找五:平方之哈希表
- 水平居中总结-不定宽块状元素方法
- SQL Server迁移登录名没有密码的解决方案
- Debugging segmentation fault
- 数论--简述同余关系及其部分性质
- 谈谈Android里的Context的使用!
- OC篇--数据类型
- u-boot-2016.05移植:(5)、支持DM9000网卡
- 使用JDBC对数据库进行CRUD
- wireshark怎么抓包、wireshark抓包详细图文教程
- easyUI批量删除,向后台传数组
- 15. 3Sum