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

Rex Fenley via lldb-dev lldb-dev at lists.llvm.org
Wed Oct 5 10:14:34 PDT 2016


Maybe I have that incorrectly, this does seem to work when using lldb from
Xcode's console. This doesn't work when typing `lldb` into the terminal and
using it from there. I assumed the two were the same.

On a separate note, --top-level doesn't seem to work for swift (from Xcode
console lldb). We need it to work with swift for the scripts we'll be
writing.

*(lldb) expr -l swift --top-level -- let i = 10*

*expr -l swift --top-level -- let a = i*

error: <EXPR>:3:9: error: use of unresolved identifier 'i'

let a = i

On Wed, Oct 5, 2016 at 10:06 AM, Rex Fenley <rex at remind101.com> wrote:

> Jim,
>
> That doesn't seem to work for us. We're using lldb packaged with Xcode 8
> fyi.
>
> (lldb) expr --top-level -- NSString *string = [NSString
> stringWithUTF8String: "This is a string"];
>
>
> ; Function Attrs: nounwind
>
> define internal void @_GLOBAL__sub_I__null_() #0 section
> "__TEXT,__StaticInit,regular,pure_instructions" {
>
>   call void @__cxx_global_var_init()
>
>   ret void
>
> }
>
> On Tue, Oct 4, 2016 at 4:09 PM, Jim Ingham <jingham at apple.com> wrote:
>
>> 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.
>>
>> Jim
>>
>>
>> > 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
>>
>>
>
>
> --
>
> Rex Fenley  |  IOS DEVELOPER
>
> Remind.com <https://www.remind.com/> |  BLOG <http://blog.remind.com/>  |
>  FOLLOW US <https://twitter.com/remindhq>  |  LIKE US
> <https://www.facebook.com/remindhq>
>



-- 

Rex Fenley  |  IOS DEVELOPER

Remind.com <https://www.remind.com/> |  BLOG <http://blog.remind.com/>
 |  FOLLOW
US <https://twitter.com/remindhq>  |  LIKE US
<https://www.facebook.com/remindhq>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20161005/6125cbd9/attachment-0001.html>


More information about the lldb-dev mailing list