使用方法:
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_addrdump
[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_addrappend
[binary
]value
filename expr- Append the contents of memory from start_addr to end_addr, or the value of expr, to the file 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 keywordbinary
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.
举个例子:
dump binary memory result.bin 0x200000000 0x20000c350
This will give you a plain binary dump int file result.bin
. You can also use the following to dump it in hex format:
dump ihex memory result.bin 0x200000000 0x20000c350
Using the dump command is much clearer than using the gdb logging hack (which even did not work for me somehow)
参考文档: https://stackoverflow.com/questions/16095948/gdb-dump-memory-save-formatted-output-into-a-file
作者:虚生 出处:https://www.cnblogs.com/dylancao/ 以音频和传感器算法为核心的智能可穿戴产品解决方案提供商 ,提供可穿戴智能软硬件解决方案的设计,开发和咨询服务。 勾搭热线:邮箱:1173496664@qq.com weixin:18019245820 市场技术对接群:347609188 |
![]() |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战