gdb.info: Dump/Restore Files

Go forward to Character Sets
Go backward to Memory Region Attributes
Go up to Data
Go to the top op gdb

Copy between memory and a file

You can use the commands `dump', `append', and `restore' to copy data
between target memory and a file.  The `dump' and `append' commands
write data to a file, and the `restore' command reads data from a file
back into the inferior's memory.  Files may be in binary, Motorola
S-record, Intel hex, or Tektronix Hex format; however, GDB can only
append to binary files.
`dump [FORMAT] memory FILENAME START_ADDR END_ADDR'
`dump [FORMAT] value FILENAME EXPR'
     Dump the contents of memory from START_ADDR to END_ADDR, or the
     value of EXPR, to FILENAME in the given format.
     The FORMAT parameter may be any one of:
    `binary'
          Raw binary form.
    `ihex'
          Intel hex format.
    `srec'
          Motorola S-record format.
    `tekhex'
          Tektronix Hex format.
     GDB uses the same definitions of these formats as the GNU binary
     utilities, like `objdump' and `objcopy'.  If FORMAT is omitted,
     GDB dumps the data in raw binary form.
`append [binary] memory FILENAME START_ADDR END_ADDR'
`append [binary] value FILENAME EXPR'
     Append the contents of memory from START_ADDR to END_ADDR, or the
     value of EXPR, to FILENAME, in raw binary form.  (GDB can only
     append data to files in raw binary form.)
`restore FILENAME [binary] BIAS START END'
     Restore the contents of file FILENAME into memory.  The `restore'
     command can automatically recognize any known BFD file format,
     except for raw binary.  To restore a raw binary file you must
     specify the optional keyword `binary' after the filename.
     If BIAS is non-zero, its value will be added to the addresses
     contained in the file.  Binary files always start at address zero,
     so they will be restored at address BIAS.  Other bfd files have a
     built-in location; they will be restored at offset BIAS from that
     location.
     If START and/or END are non-zero, then only data between file
     offset START and file offset END will be restored.  These offsets
     are relative to the addresses in the file, before the BIAS
     argument is applied.