在Xcode中观察变量 [英] Watching variables in Xcode

查看:213
本文介绍了在Xcode中观察变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Xcode监视变量.我正在按照变量视图">"...",但启用数据格式化程序"除外,其余所有选项均为灰色.有什么想法吗?

I'm trying to watch a variable with Xcode. I'm following the instructions in here by pausing at a breakpoint, selecting Run > Variables View > .... but with the exception of "Enable Data Formatters" the rest of the options are all greyed out. Any ideas?

我正在使用Xcode版本3.1.3.

I'm using Xcode version 3.1.3.

推荐答案

不幸的是,我也没有从运行"菜单中创建观察点来为我工作.要注意的一件事是,当变量超出范围时,监视点可能变得无效.

I haven't gotten watchpoints created from the Run menu to work for me either, unfortunately. One thing to be aware of is that when a variable goes out of scope, the watchpoint may become invalid.

如果您不介意进一步深入,可以使用一些低级的gdb命令来设置内存本身地址的监视点.例如,在链接到的指南中,它们显示了如何监视变量path,该变量是具有值0xbfffeb70的指针.要手动为该地址设置监视点,请在(gdb)"提示后单击调试器控制台(在其中打印调试输出),然后键入以下内容:

If you don't mind getting a little more in-depth, you can use some low-level gdb commands to set a watchpoint for the address of the memory itself. For example, in the guide you linked to, they show how to watch the variable path which is a pointer with the value 0xbfffeb70. To manually set a watchpoint for that address, click in the debugger console (where the debugging output is printed) after the "(gdb)" prompt and type something like this:

watch *((int*)0xbfffeb70)

隐式语法是必需的,因为gdb希望将输入作为C表达式.有关更多详细信息,请访问此链接并跳至标题为"使用硬件观察点" . (我正在Intel机器上进行测试,不确定PowerPC如何处理它.)以这种方式设置观察点时,Xcode会在到达观察点时通过下拉菜单提醒您,并告诉您该值如何更改,以及gdb将在控制台中打印相同的信息.

The cryptic syntax is necessary because gdb expects inputs as C expressions. For a little more detail, visit this link and jump to the section titled "Using hardware watchpoints". (I'm testing on an Intel machine, not sure how PowerPC handles it.) When you set watchpoints this way, Xcode will alert you with a drop-down sheet when a watchpoint is reached and tell you how the value was changed, and gdb will print the same info in the console.

这篇关于在Xcode中观察变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆