openEuler 使用coredumpctl调试进程core
openEuler core文件 调试
·
测试代码
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int *a = NULL;
printf("a = %d\n", *a); // 访问野指针,触发core
return 0;
}
编译:gcc -g -o test test.c
运行:./test
查看进程core信息 :coredumpctl list
详细信息:coredumpctl info 2224 #2224 为出core进程的pid
调试core文件:
要直接用gdb调试core文件也是可以的,不过openEuler上保存的core文件是通过lz4算法压缩过的,调试前,需要先解压。
coredump机制配置:/etc/systemd/coredump.conf
系统配置:/proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h
core文件信息会被重定向到systemd-coredump进一步处理压缩成lz4文件。
coredumpctl手册链接:coredumpctl(1) - Linux manual page
[root@localhost /]# coredumpctl --help
coredumpctl [OPTIONS...] COMMAND ...
List or retrieve coredumps from the journal.
Commands:
list [MATCHES...] List available coredumps (default)
info [MATCHES...] Show detailed information about one or more coredumps
dump [MATCHES...] Print first matching coredump to stdout
debug [MATCHES...] Start a debugger for the first matching coredump
Options:
-h --help Show this help
--version Print version string
--no-pager Do not pipe output into a pager
--no-legend Do not print the column headers
--json=pretty|short|off
Generate JSON output
--debugger=DEBUGGER Use the given debugger
-A --debugger-arguments=ARGS Pass the given arguments to the debugger
-n INT Show maximum number of rows
-1 Show information about most recent entry only
-S --since=DATE Only print coredumps since the date
-U --until=DATE Only print coredumps until the date
-r --reverse Show the newest entries first
-F --field=FIELD List all values a certain field takes
-o --output=FILE Write output to FILE
--file=PATH Use journal file
-D --directory=DIR Use journal files from directory
-q --quiet Do not show info messages and privilege warning
See the coredumpctl(1) man page for details.
更多推荐
已为社区贡献20条内容
所有评论(0)