Android--coredump parsing

Source: Internet
Author: User

Writing is not easy, reprint need to indicate the source: http://blog.csdn.net/jscese/article/details/46916869 This article from the "Jscese" blog!

Coredump file generation

The previous Android--coredump configuration records the environment configuration on the Android platform, which is generated in a normal way for the process to trigger those kinds of signal

Manual coredump Status:
    1. Connecting the Gdb-gcore PID
    2. Terminal send signal terminate PROCESS:KILL-S signal PID Natural Send can produce coredump signal, the previous document is recorded, but sometimes can not kill the process signal could be neglected.
      Signal can refer to:
[Email protected]:/# kill-l1HUP Hangup -      - Signal  -                2INT Interrupt the      the Signal  the                3Quit quit *      * Signal  *                4ILL Illegal Instruction $      $ Signal  $                5Trap TrapPanax Notoginseng     Panax Notoginseng Signal Panax Notoginseng                6ABRT aborted -      - Signal  -                7    BUS BusError the      the Signal  the                8FPE floating Point exception +      + Signal  +                9KILL killed A      A Signal  A               TenUSR1 UserSignal 1                  the      the Signal  the                OneSEGV Segmentation Fault +      + Signal  +                AUSR2 UserSignal 2                  -      - Signal  -                -Pipe Broken Pipe $      $ Signal  $                -ALRM Alarm Clock $      $ Signal  $                theTerm Terminated -      - Signal  -                -Stkflt Stack Fault -      - Signal  -                -CHLD Child exited the      the Signal  the                -CONT Continue -      - Signal  -                +STOP Stopped (Signal)Wuyi     Wuyi Signal Wuyi                -TSTP Stopped the      the Signal  the                +Ttin Stopped (TTY input) -      - Signal  -                ATtou Stopped (TTY output) Wu      Wu Signal  Wu                atURG Urgent I/O condition -      - Signal  -                -Xcpu CPU TimeLimit exceeded About      About Signal  About                -XfszFileSize limit exceeded $      $ Signal  $                -VTALRM Virtual Timer expired -      - Signal  -                -PROF Profiling Timer expired -      - Signal  -                -WINCH Window size changed -      - Signal  -                inIO I/O possible A      A Signal  A                -PWR Power Failure +      + Signal  +                toSYS Bad system call the      the Signal  the                +      + Signal  +                      -      - Signal  -
GDB Debug Coredump

Copy the core.droid.simplejni.1797 file from the JNI crash in Simplejni apk to the root directory of the compiled source for example

GDB using the Compile tool chain in the source directory

can also cygwin under the terminal or Eclipse environment using the NDK GDB operation, after many debugging found in the dynamic library of the symbol information, the NDK gdb can not be displayed completely!

    1. To open the Android GDB:
./prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-gdb

Set the dynamic library search load path in 2.GDB mode:

set solib-search-path /home/..../out/target/product/../symbols/system/lib/

Set the symbol in the out directory compiled by the source code

3. Load the Startup program:

file out/target/product/../symbols/system//app进程最后XXX就是app_process32,zygote的启动程序,根据情况修改

4. Load the core file:

5. Common commands:
==============command=========
Set logging on/off log Save

BackTrace (BT) n backtracking N call stacks

List n Displays the source code or displays the number of rows
List-show up

Set Listsize n Sets the number of lines to print

FRAME (f) n Toggle Stack Frame
Info FRAME (f) 0 first stack frame information

Info args Displays the current stack frame function parameters

Info locals current frame function local variables

Info threads/thread n Viewing thread information/switching threads

Info (all-) register/info r rname View all registers/view by register name

Info Line Filename:func/line View the address of a row of code in the file at that time in memory:

Disassemble fuc/disassemble $pc disassembly function/Disassembly PC register the instruction to which the function belongs:

x/Fu address view in-memory values
f represents the display mode, the following values are preferable
x Displays the variable in hexadecimal format.
D Displays the variable in decimal format.
u displays unsigned integers in decimal format.
o Displays the variable in octal format.
T displays the variable in binary format.
A displays the variable in hexadecimal format.
I instruction address format
C Displays the variable in character format.
F Displays the variable in floating-point number format.

u represents the length of an address unit
b represents a single byte,
H represents double-byte,
W represents four bytes,
g = Eight bytes

The value of the PC is the address at which the next instruction is placed, at which point the PC value points to the following instruction:

The arm instruction for the Assembly, which is represented by the 0x2004681b

The instructions executed at this time are LDR R3, [R3, #0]
Load the value of [R3, #0] address to the R3 register, and you can see the previous sentence:
movs R3, #0 was set to 0.
To view the current value of the R3 Register, p X:

Here is the load from 0 address, access to 0 address memory, null pointer, resulting in a segment error

Recording


Report illegal instructions, disassembly see the instructions that the PC refers to, this point is that gdb disassembled the corresponding dynamic library (libsurfaceflinger.so) under the symbol, and then based on the memory address and the offset in the dynamic library, you can also view the instructions in memory at that time:

Due to the illegal instructions, we can manually disassemble the libsurfaceflinger.so to verify that the actual instructions in memory are consistent:
SOURCE directory:

prebuilts/gcc/linux-x86  /arm/arm-eabi  -  4.8 /bin/arm-eabi  -objdump  -s  -d  out/target/product /  /symbols/system/lib/libsurfaceflinger So >  libsurfaceflinger TXT  
-x<可查到该文件的所有动态库>-t-h-j.text/.data-S-S obj C语言与汇编语言同时显示

View Libsurfaceflinger.txt Assembly files
According to the above info line to get the address and the address here is offset, calculate the libsurfaceflinger.txt should correspond to the instructions

or view the memory map with cat/proc/4702 (PID)/maps before the crash, and calculate the offset address to get the instruction:

//dynamic library is loaded into the memory maproot:/# CAT/proc/4702(PID)/maps | Grepsurfaceb6ec5000-b6ef4000 R-XP00000000 5D:Ten 1567/system/lib/libsurfaceflinger.sob6ef4000-b6ef9000 r--p0002e000 5D:Ten 1567/system/lib/libsurfaceflinger.sob6ef9000-b6efa000 rw-p00033000 5D:Ten 1567/system/lib/libsurfaceflinger.sob6feb000-b6fed000 R-XP00000000 5D:Ten 464/system/bin/surfaceflingerb6fed000-b6fee000 r--p00001000 5D:Ten 464/system/bin/surfaceflinger altogether has6The first column of the column represents the virtual address of the memory segment the second column represents the Execute permission, R,w,x Needless to say, p= private s= sharing it goes without saying that heap and stack segments should not have X, otherwise it would be easier to be XX, But this is about the exact version. The third column represents the offset in the process address the Fourth column mapping file's main device number and secondary device number via CAT/proc/devices learned that FD is253Device-mapper the node number of the fifth column image file, that is, the Inode Sixth column is the path to the image file

Here, it is found that the in-memory instructions are correct, considering that the CPU may have taken the wrong

Assembly
Register Storage
Stmia, such as the current RO point to the memory address is 0x1000,stmia RO!,{R1-R7} is the first to put R1 into 0x1000,
Then r2 into the 0x1004, and then R3 into the 0x1008, if the 32-bit processor is to add 4 bytes each time, and so on, and so on r1-r7 by the increment address deposit ....
This r0! is from the address of the r0 to save the meaning of ...

STMIA.W R11, {R2, R3, R4, R5}//.W means to tell the compiler that this instruction takes 32bit encoding.
Same:
STR.W R2 [R11]//The value of the register R2 is stored in the address of the R11 point, the register itself R11 the value of the same
STR.W R3, [R11, #4]
STR.W R4, [R11, #8]
STR.W R5, [R11, #12]

32bit one time +4 byte

Stmdb is the address from the r0 beginning to reduce, in turn store ...

Temporarily record so much ~ subsequent need to add ~

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android--coredump parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.