跟踪 Xcode 中的变量或内存变化?
有什么方法可以跟踪 Xcode 中的变量更改或内存更改吗?我正在寻找像 Visual Studio 的数据断点这样的功能。
我想知道我的对象的视图框架在哪里被更改。我想在成员变量处设置断点并运行它。然后我就可以确定它在哪里发生了变化。
Is there any way to track variable changes or memory changes in Xcode? I'm looking for functionality like Visual Studio's data breakpoint.
I want to know where my object's view frame is being changed. I want to set a breakpoint at a member variable and run it. Then I could determine where it's changed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Xcode 使用
gdb
(或lldb
,但那是另一个故事了)来实现其调试功能。gdb
能够设置硬件观察点,因此 Xcode 也能。此对于内存错误的一般调试非常有用。 Xcode 的调试控制台窗口实际上只是一个 gdb shell,您可以随意输入命令。永远有帮助的 Quinn Taylor 在这篇相关帖子中解释了如何做到这一点。
如果您不想直接与
gdb
交互,可以右键单击 Xcode 调试窗口中的变量并选择“Watch Variable”。只要变量的值发生更改,Xcode 就会提醒您。Xcode uses
gdb
(orlldb
, but that's another story) to implement its debugging functionality.gdb
has the ability to set hardware watchpoints and hence so does Xcode.This is a useful page for generic debugging of memory errors. Xcode's debugging console window is really just a
gdb
shell, you can type in commands as you please. The ever-helpful Quinn Taylor explains how to do so in this related post.If you'd rather avoid interacting with
gdb
directly, you can right-click a variable in Xcode's debugging window and select "Watch Variable". Xcode will then alert you whenever your variable's value has been changed.您可以使用硬件观察点。
您必须获取要跟踪的变量的地址(在 gdb 提示符中键入
p &my_var
)。它会打印类似
0x12345678
的内容。使用 gdb:输入
watch *(int *)0x12345678
。使用 lldb:
监视集表达式 (int *)0x12345678
(或wse (int *)0x12345678
)这假设您的变量是
int
。它将在此地址上创建一个硬件观察点。希望这有帮助。
You can use hardware watchpoints.
You have to get the address of the variable you want to track (type
p &my_var
in gdb prompt).It will print somehting like
0x12345678
.With gdb: type
watch *(int *)0x12345678
.With lldb:
watch set expression (int *)0x12345678
(orw s e (int *)0x12345678
)This assumes your variable is an
int
. It will create an hardware watchpoint on this address.Hope this helps.
是的。
在“运行”菜单下有“调试器”,它为 gdb 提供了可视化前端。
此外,“构建并运行”按钮旁边还有一个断点按钮。您可以单击它并在“运行”>“管理”下管理您的断点。管理断点。
Yes.
Under the Run menu there is "Debugger" which provides a visual frontend to gdb.
Also, there is a breakpoint button next to the Build and Run button. You can click that and manage your breakpoints under Run > Manage Breakpoints.
我知道这篇文章已经过时了,但如果您仍然想知道,我在这里发布了详细的答案:在 XCode 6 中如何在不停止执行的情况下设置观察点?
I know this post is old but in case you are still wondering I posted a detailed answer here: In XCode 6 how can you set a watchpoint without stopping execution?