Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in breakpoint condition

I've set a breakpoint with the condition...

[event.name isEqualToString:@"Some Name"]

This works fine.

However, when I try to add another breakpoint with the condition...

[part.name isEqualToString:@"Some Value With A Pound Sign £"]

I get the error...

Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array
Stopped due to an error evaluating condition of breakpoint

Do I need to escape the pound sign or something?

like image 266
Fogmeister Avatar asked Jun 19 '13 13:06

Fogmeister


2 Answers

There's a bug with the expression parser and an NSString literal containing non-ASCII characters.

(lldb) po @"u"
$9 = 0x00007fff7debe5e0 u
(lldb) po @"ü"
Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array
error: warning: expression result unused
error: The expression could not be prepared to run in the target

There is already a bug reported filed with http://bugreport.apple.com/ about this issue.

Non-ASCII C string literals are handled correctly so it is possible to work around this, e.g.

(lldb) po [NSString stringWithUTF8String:"ü"]
$11 = 0x000000010010b040 ü
like image 61
Jason Molenda Avatar answered Oct 12 '22 15:10

Jason Molenda


I don't know why the breakpoints have still such a limited compiler support, but anyway, to fix your problem, it should be sufficient to cast the return type of each method you call like this:

(BOOL)[(NSString *)[part name] isEqualToString:@"some string"]

With this your code should pause if the string doesn't contain the '£' symbol or any other non-ASCII character. As it appears that the LLDB compiler has problems non-ASCII characters you may want to convert the strings first using that encoding. In the mean while I'm looking for a way to avoid this if possible…

like image 2
Gianluca Tranchedone Avatar answered Oct 12 '22 13:10

Gianluca Tranchedone