是否可以在 Xcode 中创建数据断点?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4378019/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:58:50  来源:igfitidea点击:

Is it possible to create a data breakpoint in Xcode?

objective-cxcode

提问by Xrieaz

The data breakpoints in Visual Studio is very a very useful debugging tool and I need something like that for my current iPad project (pointers and memory acting strange).

Visual Studio 中的数据断点是一个非常有用的调试工具,我当前的 iPad 项目需要类似的东西(指针和内存表现得很奇怪)。

Is it possible to create data breakpoints in Xcode?

是否可以在 Xcode 中创建数据断点?

回答by mbritto

Here is the documentation for the Watchpoint in Xcode :

这是 Xcode 中 Watchpoint 的文档:

To monitor changes to the value of variables or data items, you can set watchpoints. A watchpoint pauses execution of the program whenever the value of the watched item changes. You can set a watchpoint on a variable only when execution of the program is halted. To set a watchpoint on a variable:

With execution of the program paused at a breakpoint, select the variable in the Variable list in the Debugger window. See “Debugging in the Debugger” to learn more about the Variable list. Choose one of the following: Run > Variables View > Watch Variable Watch Variable from the variable list shortcut menu Xcode displays a magnifying glass next to the variable to indicate that the variable is being watched, as shown in Figure 7-5. Figure 7-5 Watched variable in the Variable list

When the value of the variable changes, Xcode pauses execution of the program and displays a dialog showing the location of the program counter and the new value of the variable. If execution of the program moves beyond the scope of the current variable, Xcode deletes the watchpoint and pauses execution of the program.

Important: Watching local variables, located on the stack, can cause your program to crash if system calls are made in the current function.

要监视变量或数据项的值的变化,您可以设置观察点。每当被观察项的​​值发生变化时,观察点就会暂停程序的执行。仅当程序执行停止时,您才能在变量上设置观察点。在变量上设置观察点:

程序的执行在断点处暂停,在调试器窗口的变量列表中选择变量。请参阅“在调试器中调试”以了解有关变量列表的更多信息。选择以下其中一项: Run > Variables View > Watch Variable 从变量列表快​​捷菜单中观察变量 Xcode 在变量旁边显示一个放大镜,表示该变量正在被观察,如图 7-5 所示。图 7-5 Variable 列表中的 Watched 变量

当变量的值发生变化时,Xcode 会暂停程序的执行并显示一个对话框,显示程序计数器的位置和变量的新值。如果程序的执行超出了当前变量的范围,Xcode 会删除观察点并暂停程序的执行。

重要提示:如果在当前函数中进行系统调用,观察位于堆栈上的局部变量可能会导致程序崩溃。

回答by w-m

I'm not familiar with Visual Studio but I guess you're looking for watchpoints. Search for "watchpoint" in the Xcode Debugging Guide.

我不熟悉 Visual Studio,但我猜您正在寻找观察点。在Xcode Debugging Guide 中搜索“watchpoint” 。