gdb如何用来监视整个内存区域的任何变化? [英] How can gdb be used to watch for any changes in an entire region of memory?

查看:1113
本文介绍了gdb如何用来监视整个内存区域的任何变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我可以在从< startaddress> < endaddress>
如何读取和/或写入?

解决方案

在Linux / x86上,GDB使用处理器调试寄存器硬件观察点。这种观察点速度很快 - 程序全速运行,直到处理器停止并在访问或写入观察点被触发时发出信号。工作在1字大小的数据上。

最近的Valgrind版本(SVN,但没有发布的版本)实现GDB远程协议存根,并允许您设置读或写观察点任何内存通过特殊的监视器命令。



因此,如果您在一个拥有Valgrind的平台上,并且您的应用程序在Valgrind下运行速度可以接受,那么是的:您可以设置观察点在任意内存区域。


For example, can I break on any change to memory in an address range from <startaddress> to <endaddress>? How about reads and/or writes?

解决方案

On Linux/x86, GDB uses the processor debug registers to implement hardware watchpoints. Such watchpoints are fast -- the program runs at full speed, until the processor stops and signals the application when the access or write watchpoint is triggered.

But such watchpoints can only work on 1-word sized data.

Recent Valgrind versions (SVN, but no released versions) implement GDB remote protocol stub, and allow you to set read or write watchpoints over arbitrary memory via special monitor commands.

So if you are on a platform that has Valgrind, and if your application runs acceptably fast under Valgrind, then yes: you can set watchpoints on arbitrary memory regions.

这篇关于gdb如何用来监视整个内存区域的任何变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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