我可以从地址读取/写入 gdb 中断吗?

Can I have gdb break on read/write from an address?(我可以从地址读取/写入 gdb 中断吗?)
本文介绍了我可以从地址读取/写入 gdb 中断吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
我可以在 GDB 中的内存访问"上设置断点吗?

我在内存中有一个特定位置正在损坏,我希望能够准确地看到写入该位置的时间.有什么方法可以让 gdb 中断对该特定地址的内存访问?

I have a specific location in memory that is getting corrupted, and I'd like to be able to see exactly when things write to that location. Is there any way that I can make gdb break on memory access to that particular address?

推荐答案

是的.
使用观察点:
watch - 仅在写入时中断(并且仅在值更改时)
rwatch - 读取时中断,并且
awatch - 读/写中断.

Yes.
Using Watchpoints:
watch - only breaks on write (and only if the value changes)
rwatch - breaks on read, and
awatch - breaks on read/write.

来自一些互联网资源的更详细的简介:

A more detailed brief from some internet sources:

观看
watch 是 gdb 设置数据断点的方式,如果指定位置的内存发生变化,它将停止程序的执行.

watch
watch is gdb’s way of setting data breakpoints which will halt the execution of a program if memory changes at the specified location.

可以在变量名或任何地址位置设置观察断点.

watch breakpoints can either be set on the variable name or any address location.

watch my_variable
watch *0x12345678
where 0x12345678 is a valid address.

rwatch
rwatch (read-watch) 断点会在程序尝试从变量或内存位置读取时中断代码的执行.

rwatch
rwatch (read-watch) breakpoints break the execution of code when the program tries to read from a variable or memory location.

rwatch iWasAccessed
rwatch *0x12345678
where 0x12345678 is a valid address.

手表
如果变量或内存位置被写入或读取,awatch 或访问手表会中断程序的执行.总而言之,awatches 是 watch 和 rwatches 合二为一.创建一个断点比创建两个单独的断点更方便.

awatch
awatch or access watches break execution of the program if a variable or memory location is written to or read from. In summary, awatches are watches and rwatches all in one. It is a handy way of creating one breakpoint than two separate ones.

awatch *0x12345678
where 0x12345678 is a valid address.

这篇关于我可以从地址读取/写入 gdb 中断吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)