How to read Android crash log and stack trace

來源:互聯網
上載者:User

  不錯的文章,感謝作者,原文地址      

http://bootloader.wikidot.com/linux:android:crashlog

    An Android crash in C/C++ code often generates some crash log which looks like the following. They can be seen either with "adb logcat" or found in one of the tombstones under /data/tombstones. This article briefly explains the structure of the log,
how to read it, and how to translate the addresses into symbols with the
stack tool.

The basic items in the log is explained below. The first is the build information in the system property "ro.build.fingerprint"

I/DEBUG   (  730): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***I/DEBUG   (  730): Build fingerprint: 'generic/generic/generic/:1.5/...'

Then, it shows the process ID number (pid) and the thread id (tid). Knowing the PID, one can find its information with /proc/<pid> (of course, before the crash happens). In this example, the PID and TID are the same. However, if the crash happens in a child
thread, the thread ID tid will be different from pid. The child thread itself is also a process in Linux (having its task_struct). The difference from a child process created by fork is that it shares address space and other data with the parent process.

I/DEBUG   (  730): pid: 876, tid: 876  >>> /system/bin/mediaserver <<<

The following shows the signal which caused the process to abort, in this case, it's a segmentation fault. This is followed by the register values.

I/DEBUG   (  730): signal 11 (SIGSEGV), fault addr 00000010I/DEBUG   (  730):  r0 00000000  r1 00016618  r2 80248f78  r3 00000000I/DEBUG   (  730):  r4 80248f78  r5 0000d330  r6 80248f78  r7 beaf9974I/DEBUG   (  730):  r8 00000000  r9 00000000  10 00000000  fp 00000000I/DEBUG   (  730):  ip afd020c8  sp beaf98d8  lr 8021edcd  pc 8021c630  cpsr a0000030

This is the call stack trace. #00 is the depth of the stack pointer. The "pc <addr>" is the PC address in the stack. Sometimes, the "lr" link register containing the return address is shown instead of PC. It is followed by the file containing the code. Of
course, the address doesn't make much sense without resolving it to a symbol. This can be done with the "stack" tool. Download

stack here.

I/DEBUG   (  730):          #00  pc 0001c630  /system/lib/libhelixplayer.soI/DEBUG   (  730):          #01  pc 0001edca  /system/lib/libhelixplayer.soI/DEBUG   (  730):          #02  pc 0001ff0a  /system/lib/libhelixplayer.soI/DEBUG   (  730):          #03  pc 000214e0  /system/lib/libutils.soI/DEBUG   (  730):          #04  pc 0000e322  /system/lib/libmediaplayerservice.so...I/DEBUG   (  730):          #15  pc b0001516  /system/bin/linker

The following is actually the current stack with the stack pointer address and code dump. Each line contains 4 bytes (one machine word), and the address is in ascending order. The words in the stack are mapped onto the memory region it belongs to.

I/DEBUG   (  730): stack:I/DEBUG   (  730):     beaf9898  00016618  [heap]I/DEBUG   (  730):     beaf989c  beaf98d0  [stack]I/DEBUG   (  730):     beaf98a0  0000db28  [heap]I/DEBUG   (  730):     beaf98a4  beaf98f8  [stack]I/DEBUG   (  730):     beaf98b8  8021cf4d  /system/lib/libhelixplayer.soI/DEBUG   (  730):     beaf98bc  80248f78I/DEBUG   (  730): #00 beaf98d8  0000d330  [heap]I/DEBUG   (  730):     beaf98dc  00000000I/DEBUG   (  730):     beaf98e0  0000d330  [heap]I/DEBUG   (  730):     beaf98e4  8021edcd  /system/lib/libhelixplayer.soI/DEBUG   (  730): #01 beaf98e8  80248f78I/DEBUG   (  730):     beaf98ec  80248f78
References

Debugging Native Code:

http://source.android.com/porting/debugging_native.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.