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 #include <stdio.h>
- 2 int main ()
- 3 {
- 4 char* str = "Hello";
- 5 Str[0] = ' H ';
- 6 return 0;
- 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