如何在Xcode中设置条件断点?

时间:2011-04-11 20:47:16

标签: iphone xcode gdb

我的情况在这里

(gdb) info break
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x0000db8f in -[Instrument getFormattedPriceString:] at Instrument.m:195
condition not yet parsed: (bool)[[self name] hasPrefix:@"7_"]
breakpoint already hit 1 time
Current language:  auto; currently objective-c
(gdb) p (bool)[[self name] hasPrefix:@"7_"]
$1 = false
(gdb) po name
2_YEAR

尽管条件评估正确,但我的断点每次都会中断执行。我在这里看到了一些奇特的陈述condition not yet parsed。为什么GDB不会解析我的情况?

BTW我使用的是xcode 3.2.6。 Xcode4甚至不评估像a==1

这样的条件

1 个答案:

答案 0 :(得分:0)

考虑一个临时的assert()或NSAssert()。基于调试器的表达式评估更加可靠。一旦不再需要断点,就删除assert()调用。语法是:

#include <assert.h>

assert( !(expression_on_which_to_break));