观看gdb中的内存范围? [英] Watch a memory range in gdb?

查看:770
本文介绍了观看gdb中的内存范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gdb中调试程序,当访问内存区域0x08049000到0x0804a000时,我想让程序停止。当我尝试手动设置内存断点时,gdb一次似乎不支持两个以上的位置。

I am debugging a program in gdb and I want the program to stop when the memory region 0x08049000 to 0x0804a000 is accessed. When I try to set memory breakpoints manually, gdb does not seem to support more than two locations at a time.

(gdb) awatch *0x08049000
Hardware access (read/write) watchpoint 1: *0x08049000
(gdb) awatch *0x08049001
Hardware access (read/write) watchpoint 2: *0x08049001
(gdb) awatch *0x08049002
Hardware access (read/write) watchpoint 3: *0x08049002
(gdb) run
Starting program: /home/iblue/git/some-code/some-executable
Warning:
Could not insert hardware watchpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.

已经有一个问题出现在哪里,并且答案是可以的,用valgrind做这个。不幸的是,答案不包含任何示例或参考valgrind手册,所以不是很有启发:如何使用gdb来监视整个内存区域的任何更改?

There is already a question where this has been asked and the answer was, that it may be possible to do this with valgrind. Unfortunately the answer does not contain any examples or reference to the valgrind manual, so it was not very enlightning: How can gdb be used to watch for any changes in an entire region of memory?

所以我怎么看整个内存区?

So: How can I watch the whole memory region?

推荐答案

如果你一起使用GDB 7.4与Valgrind 3.7.0,那么你有
无限的模拟硬件观察点。

If you use GDB 7.4 together with Valgrind 3.7.0, then you have unlimited "emulated" hardware watchpoints.

在Valgrind下启动你的程序,给出参数
- vgdb = full --vgdb-error = 0
然后使用GDB连接到它( target remote | vgdb )。
那么你可以$ code>或 awatch rwatch b $ b rwatch(char [100])* 0x5180040

Start your program under Valgrind, giving the arguments --vgdb=full --vgdb-error=0 then use GDB to connect to it (target remote | vgdb). Then you can e.g. watch or awatch or rwatch a memory range by doing rwatch (char[100]) *0x5180040

请参阅关于gdb集成的Valgrind用户手册详细信息

这篇关于观看gdb中的内存范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆