[lldb-dev] --top-level doesn't work in lldb for Objective-C or Swift :(

Jim Ingham via lldb-dev lldb-dev at lists.llvm.org
Tue Oct 4 16:09:53 PDT 2016

This isn't an issue with ObjC support in general, but rather shows that ObjC string constants are odd beasts.  You can work around this pretty easily by making dynamic strings:

(lldb) expr --top-level -- NSString *string = [NSString stringWithUTF8String: "This is a string"];
(lldb) expr string
(__NSCFString *) $0 = 0x00000001002001b0 @"This is a string"

Please file a bug about the problem with ObjC constant strings.


> On Oct 4, 2016, at 3:57 PM, Rex Fenley via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> Hey lldb team!
> I'm trying to use `expr --top-level` from lldb in Xcode but it throws errors like the following:
> (lldb) expression --top-level -- NSString *str = @"This is a string";
> Error [IRForTarget]: Couldn't replace an Objective-C constant string with a dynamic string
> error: cannot import unsupported AST node ObjCStringLiteral
> error: The expression could not be prepared to run in the target
> It seems like top-level only supports raw C code and not Objective-C. Is there an option we can set to support this? Is there somewhere in lldb's source code that could help point us to fixing this?
> Thank you, you guys rule!
> -- 
> Rex Fenley  |  IOS DEVELOPER
> Remind.com |  BLOG  |  FOLLOW US  |  LIKE US
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

More information about the lldb-dev mailing list