Is it possible to get a core dump of a running process and its symbol table?

大兔子大兔子 提交于 2019-11-28 03:03:44
DustinB
$ gdb --pid=26426
(gdb) gcore
Saved corefile core.26426
(gdb) detach
Alex Zeffertt

Or run gcore $(pidof processname).

This has the benefit (over running gdb and issuing commands to the CLI) that you attach and detach in the shortest possible time.

You can used generate-core-file command in gdb to generate core dump of running process.

Note: The following method will terminate the running process & requires the symbols too.

You can send one of the following signals (with action=core) to the running process:
From: http://man7.org/linux/man-pages/man7/signal.7.html

       Signal     Value     Action   Comment
       ──────────────────────────────────────────────────────────────────────
       SIGHUP        1       Term    Hangup detected on controlling terminal
                                     or death of controlling process
       SIGINT        2       Term    Interrupt from keyboard
       SIGQUIT       3       Core    Quit from keyboard
       SIGILL        4       Core    Illegal Instruction
       SIGABRT       6       Core    Abort signal from abort(3)
       SIGFPE        8       Core    Floating point exception
       SIGKILL       9       Term    Kill signal
       SIGSEGV      11       Core    Invalid memory reference
       SIGPIPE      13       Term    Broken pipe: write to pipe with no
                                     readers
       SIGALRM      14       Term    Timer signal from alarm(2)
       SIGTERM      15       Term    Termination signal
       SIGUSR1   30,10,16    Term    User-defined signal 1
       SIGUSR2   31,12,17    Term    User-defined signal 2
       SIGCHLD   20,17,18    Ign     Child stopped or terminated
       SIGCONT   19,18,25    Cont    Continue if stopped
       SIGSTOP   17,19,23    Stop    Stop process
       SIGTSTP   18,20,24    Stop    Stop typed at terminal
       SIGTTIN   21,21,26    Stop    Terminal input for background process
       SIGTTOU   22,22,27    Stop    Terminal output for background process

Like so:
kill <signal> <pid>

And once you have the core, you can open in gdb along with the symbol file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!