GDB Dump Mem Example and commands

Source: Internet
Author: User

How to use:

You can use the commands dump , append and to restore copy data between target memory and a file. dump append The and commands write data to a file, and the restore command reads data from a file back into the inferior ' s M Emory. Files May is 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&NB Sp expr , to  filename  in the given format.

the  format  parameter May is 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&nbs P;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 end_addr to, or the value expr of, to the file filename , in raw bin ary form. ( gdb can only append the data to the files in raw binary form.)

restore  filename [ binary] bias start end
Restore the contents of file filenameinto memory. The restorecommand can automatically recognize any known BFD file format, except for raw binary. To restore a raw binary file you must specify the optional keyword after the binary filename.

If bias is Non-zero, its value would be added to the addresses contained in the file. Binary files always start at address zero and so they'll be restored at address bias . Other BFD files has a built-in location; They'll is restored at offset from the bias .

If start and/or end is Non-zero, then only data between file offset and start file offset would be end restored. These offsets was relative to the addresses of the file, before the bias argument is applied.

As an example:

dump binary memory result.bin 0x200000000 0x20000c350

This would give you a plain binary dump int file result.bin . You can also with the following to dump it in hex format:

dump ihex memory result.bin 0x200000000 0x20000c350

Using the dump command is a much clearer than using the GDB logging hack (which even did not work for me somehow)

Reference Document: Https://stackoverflow.com/questions/16095948/gdb-dump-memory-save-formatted-output-into-a-file

GDB Dump Mem Example and commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.