佳为好友

转:在XCode中设定内存断点(数据断点,变量断点)

10-1-19

转:http://lists.apple.com/archives/xcode-users/2004/Dec/msg00205.html

[自:简而言之,可以先试试:
(gdb) print  &(foo->bar->baz)
如果不行,则试试:
(gdb) print  &(foo->bar->baz)
(gdb) watch *<HEX address returned from the previous command>
注意,表达式没有<>]

There isn't a GUI way to do this yet. But you can do it in the gdb console. Just bring up the Debugger log (under the Debug menu), and use the "watch" command.

One little subtlety, if you do something like:

(gdb) watch foo->bar->baz

gdb will watch all three locations so you will know if the result of the expression changes for any reason. This is sometimes what you want, and sometimes not. If you know you just want to watch a simple memory location, it is sometimes easier to do:

(gdb) print  &(foo->bar->baz)

(gdb) watch *<HEX address returned from the previous command>

The * in this case tells gdb that you are giving it an address, and not an expression... And of course, without the <>'s...

If you want more help on how to use the gdb console, there are docs in /Developer/Documentation/DeveloperTools/gdb/gdb/gdb_toc.html.

Jim

+++++

posted on 2012-12-23 10:15 佳为好友 阅读(3543) 评论(0)  编辑 收藏 引用 所属分类: Debug-GDB


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(1)

随笔分类

搜索

最新评论

评论排行榜