Error in breakpoint condition

人盡茶涼 提交于 2019-12-04 04:04:53

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 ü

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…

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