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

时间:2021-07-09 20:44:35

Possible Duplicate:
Can I set a breakpoint on 'memory access' in 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?

我在内存中有一个特定的位置被破坏了,我希望能够确切地看到事情写入该位置的时间。有什么方法可以让gdb在对该特定地址的内存访问中断?

1 个解决方案

#1


43  

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

是。使用观察点:观察 - 仅在写入时中断(并且仅在值改变时)rwatch - 读取时断开,并且唤醒 - 读取/写入中断。

A more detailed brief from some internet sources:

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

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 watch是gdb设置数据断点的方法,如果内存在指定位置发生变化,将暂停程序的执行。

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) breakpoints break the execution of code when the program tries to read from a variable or memory location.

当程序试图从变量或内存位置读取时,rwatch rwatch(读取监视)断点会中断代码的执行。

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

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 awatch或access watch会中断程序的执行。总之,手表和手表都是一体的。这是创建一个断点而不是两个独立断点的便捷方式。

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

#1


43  

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

是。使用观察点:观察 - 仅在写入时中断(并且仅在值改变时)rwatch - 读取时断开,并且唤醒 - 读取/写入中断。

A more detailed brief from some internet sources:

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

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 watch是gdb设置数据断点的方法,如果内存在指定位置发生变化,将暂停程序的执行。

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) breakpoints break the execution of code when the program tries to read from a variable or memory location.

当程序试图从变量或内存位置读取时,rwatch rwatch(读取监视)断点会中断代码的执行。

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

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 awatch或access watch会中断程序的执行。总之,手表和手表都是一体的。这是创建一个断点而不是两个独立断点的便捷方式。

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