[Debug] parsing coredump files with GDB

Source: Internet
Author: User

1, the system is not generated by default Coredump file, you need to use the following command to make the system Coredump file

View the limitations of the core file, at this point 0, the non-native core file Ulimit-c 0 Open the core file limit, do not limit the size of the core file, so that the program can produce core files Ulimit-c Unlimitedulimit-c Unlimited

2, the following is an example of a memory access error

[CPP]View Plaincopy
    1. 1 #include <stdio.h>
    2. 2 int main ()
    3. 3 {
    4. 4 char* str = "Hello";
    5. 5 Str[0] = ' H ';
    6. 6 return 0;
    7. 7}


3, compile with the following command:

GCC Demosegfault.c-o a.out-g

GDB A.out Core

Bt

Core is generated by './demosegfault '.  Program terminated with signal one, segmentation fault.  #0  0x0804835a in Main () at Demosegfault.c:5  5               str[0] = ' H ';  (GDB) bt  #0  0x0804835a in Main () at Demosegfault.c:5  (GDB)

the concept of 1,coredump
When a program crashes, the OS saves the process's address space and then debugs offline through the tool (GDB,TRACE32)


2,coredump Parameters

/proc/sys/kernel/core_pattern (Sets the name of the Coredump)
Supported parameters
%p: Add PID%u: Add current uid%g: Add current GID
%s: Add signal causing core%t: Unix time to add core file generation
%H: Add host name%e: Add command name
ULIMIT-A (ignores this parameter when there is a pipe in Core_pattern) (sets the size of the Coredump)
Size can be changed with Ulimit-c filesize (KB)
Ulimit-c Unlimited means no limit
If 0, indicates that Coredump is not supported
/proc/$pid/coredump_filter (sets the memory allowed Coredump)
Supported parameters
Bit0: Private anonymous bit1: Shared anonymous bit2: Private mapping with underlying file bit3: with underlying file share mappings
Bit4:elf head bit5: Private Large Size page BIT6: share Large Size page
Default value: 0x23


3..bat File Authoring Example:
ADB remount

adb shell echo "/system/coredump" >/proc/sys/kernel/core_pattern
adb shell echo 0x27 >/proc/self/coredump_filter
ADB Shell Ulimit-c Unlimited

ADB shell/sbin/recovery

echo "Wait 15s to pull Coredump"

@echo off
Ping-n 127.0.0.1>nul
@echo on

ADB pull/system/coredump

[Debug] parsing coredump files with GDB

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.