objective-cnsstringruntime-errorlldbparsing-error

Why can't I use the LLDB to print out a string literal with a ¢ character?


While in a breakpoint during a XCTest (and later during a normal run), I encountered something... odd. I think the screenshot below explains my problem:

Two calls of the LLDB, one reading <code>po @"12"</code>, with the successful print below reading <code>12</code>. The next is <code>po @"\u0031\u0032"</code> and also prints <code>12</code>. The next reads <code>po @"12¢"</code>, with an error below saying "An Objective-C constant string's string initializer is not an array". The third reads <code>po @"\u0031\u0032\u00A2"</code>, the fourth reads <code>po @"¢"</code>, and the fifth <code>po @"\u00A2"</code> and all have the same issue.

Why does it claim An Objective-C constant string's string initializer is not an array? It appears as if its attempt to translate my @"" NSString literal sugar into an NSString initializer-with-C-string was unsuccessful, but why?

Also, I've tested many other strings with the ¢ character or its Unicode escape sequence, and they all have the same result.


Solution

  • That looks like a bug. Please file it with http://bugreporter.apple.com.

    Static string construction involves some compiler magic, and apparently lldb isn't getting that right when the string contains high-bit characters. You can achieve the same effect in the expression parser by using one of the NSString constructors:

    (lldb) expr NSString *$newstr = [NSString stringWithUTF8String: "Something¢"]
    (lldb) expr $newstr
    (__NSCFString *) $newstr = 0x00000001007000a0 @"Something¢"
    

    Then you can use $newstr in future expressions.