跟踪 Xcode 中的变量或内存变化?

发布于 2024-10-14 07:03:07 字数 132 浏览 6 评论 0原文

有什么方法可以跟踪 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

街角卖回忆 2024-10-21 07:03:07

Xcode 使用 gdb (或 lldb,但那是另一个故事了)来实现其调试功能。 gdb 能够设置硬件观察点,因此 Xcode 也能。

对于内存错误的一般调试非常有用。 Xcode 的调试控制台窗口实际上只是一个 gdb shell,您可以随意输入命令。永远有帮助的 Quinn Taylor 在这篇相关帖子中解释了如何做到这一点。

如果您不想直接与 gdb 交互,可以右键单击 Xcode 调试窗口中的变量并选择“Watch Variable”。只要变量的值发生更改,Xcode 就会提醒您。

Xcode uses gdb (or lldb, 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.

地狱即天堂 2024-10-21 07:03:07

您可以使用硬件观察点

您必须获取要跟踪的变量的地址(在 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 (or w s e (int *)0x12345678)

This assumes your variable is an int. It will create an hardware watchpoint on this address.

Hope this helps.

孤寂小茶 2024-10-21 07:03:07

是的。

在“运行”菜单下有“调试器”,它为 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.

一生独一 2024-10-21 07:03:07

我知道这篇文章已经过时了,但如果您仍然想知道,我在这里发布了详细的答案:在 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文