Error in breakpoint condition

前提是你 提交于 2019-12-09 17:28:17

问题


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?


回答1:


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 ü



回答2:


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…



来源:https://stackoverflow.com/questions/17192505/error-in-breakpoint-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!