How can gdb be used to watch for any changes in an entire region of memory?

六眼飞鱼酱① 提交于 2019-12-07 23:27:42

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6764544/how-can-gdb-be-used-to-watch-for-any-changes-in-an-entire-region-of-memory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!