xcode 内存地址观察点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21063995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Watch points on memory address
提问by user3001909
With the new change from gdb to lldb , I can't find a way how to set watch points on some memory addresses .
随着从 gdb 到 lldb 的新变化,我找不到如何在某些内存地址上设置观察点的方法。
In gdb I used this
在gdb中我使用了这个
watch -location *0x123456
Doing the same in lldb
在 lldb 中做同样的事情
w s e *0x123456
Isn't working for me . So what can I use to run the same command in lldb ?
不适合我。那么我可以用什么来在 lldb 中运行相同的命令呢?
回答by Martin R
Omit the "dereferencing operator" *
when setting the watch point in lldb, just pass the address:
*
在lldb中设置观察点时省略“解引用操作符” ,直接传地址即可:
watchpoint set expression -- 0x123456
# short form:
w s e -- 0x123456
sets a watchpoint at the memory location 0x123456
. Optionally you can set the number of bytes to watch with --size
. Example in short form:
在内存位置设置一个观察点0x123456
。(可选)您可以设置要监视的字节数--size
。简写示例:
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;
I did this in the Xcode debugger console:
我在 Xcode 调试器控制台中这样做了:
(lldb) p &x (int *)(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'= 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
更简单地说,我可以设置观察点
##代码##