内存地址上的监视点 [英] Watch points on memory address
问题描述
随着从gdb到lldb的新变化,我找不到一种在某些内存地址上设置监视点的方法.
With the new change from gdb to lldb , I can't find a way how to set watch points on some memory addresses .
在gdb中,我使用了
watch -location *0x123456
在lldb中做同样的事情
Doing the same in lldb
w s e *0x123456
不是为我工作. 那我可以用什么来在lldb中运行相同的命令?
Isn't working for me . So what can I use to run the same command in lldb ?
推荐答案
在lldb中设置监视点时,请省略取消引用运算符" *
,只需传递地址即可:
Omit the "dereferencing operator" *
when setting the watch point in lldb, just pass the address:
watchpoint set expression -- 0x123456
# short form:
w s e -- 0x123456
在存储位置0x123456
上设置观察点. (可选)您可以设置要使用--size
观看的字节数.简短示例:
sets a watchpoint at the memory location 0x123456
. Optionally you can set the number of bytes to watch with --size
. Example in short form:
w s e -s 2 -- 0x123456
您还可以在变量上设置观察点:
You can also set a watchpoint on a variable:
watchpoint set variable <variable>
# short form:
w s v <variable>
示例:在第二行中设置了以下代码和断点:
Example: With the following code and a breakpoint set at the second line:
int x = 2;
x = 5;
我是在Xcode调试器控制台中完成的:
I did this in the Xcode debugger console:
(lldb) p &x
(int *) $0 = 0xbfffcbd8
(lldb) w s e -- 0xbfffcbd8
Watchpoint created: Watchpoint 1: addr = 0xbfffcbd8 size = 4 state = enabled type = w
new value: 2
(lldb) n
Watchpoint 1 hit:
old value: 2
new value: 5
(lldb)
更简单地说,我可以通过以下方式设置观察点
More simply, I could have set the watchpoint with
(lldb) w s v x
Watchpoint created: Watchpoint 1: addr = 0x7fff5fbff7dc size = 4 state = enabled type = w
declare @ '/Users/martin/Documents/tmpprojects/watcher/watcher/main.c:16'
watchpoint spec = 'x'
这篇关于内存地址上的监视点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!