69

Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process.

If this is possible, what commands would you use? (I'm trying to do this on a Linux box)

ks1322
  • 31,484
  • 13
  • 100
  • 154
readonly
  • 326,166
  • 107
  • 202
  • 204

3 Answers3

77
$ gdb --pid=26426
(gdb) gcore
Saved corefile core.26426
(gdb) detach
Assaf Lavie
  • 68,254
  • 33
  • 142
  • 199
DustinB
  • 10,751
  • 5
  • 44
  • 54
  • 11
    You don't need to set ulimit -c unlimited as gdb doesn't respect it (gdb should always give you the entire core file). You can also do this using the command `gcore pid` from the cli without running gdb. – psanford Jun 13 '12 at 21:21
76

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.

iblue
  • 27,950
  • 18
  • 84
  • 126
Alex Zeffertt
  • 1,322
  • 10
  • 12
1

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

dev
  • 473
  • 5
  • 8