tags:

views:

89

answers:

2

Is it possible to save/dump core file using gdb? Sometimes I want to save file to analyze it later.

+1  A: 

Take a look at the dump command:

(gdb) dump
"dump" must be followed by a subcommand.

List of dump subcommands:

dump binary -- Write target code/data to a raw binary file
dump ihex -- Write target code/data to an intel hex file
dump memory -- Write contents of memory to a raw binary file
dump srec -- Write target code/data to an srec file
dump tekhex -- Write target code/data to a tekhex file
dump value -- Write the value of an expression to a raw binary file
Cristian
+2  A: 

Issue the 'generate-core-file' command in gdb.

(gdb) help generate-core-file
Save a core file with the current state of the debugged process.
Argument is optional filename.  Default filename is 'core.<process_id>'.
(gdb) break main
Breakpoint 1 at 0x400e0b: file utils/udec.c, line 36.
(gdb) r
Starting program: /home/nos/build/utils/udec

Breakpoint 1, main (argc=1, argv=0x7fffffffe9a8) at utils/udec.c:36
36              int fileargc = 1;
(gdb) generate-core-file
Saved corefile core.7336
nos