Swift Concurrency / LLDB unable to print object

Hi everyone,

first post - hope this is the correct place. I've converted my codebase from a GCD implementation to the new async / await concurrency features of Swift.
When debugging I highly rely on LLDBs po command to print values to the console. However in many cases LLDB refuses to work for me when im in a Task or concurrently executing context.

The error message I often see is the following:

error: <EXPR>:19:5: error: cannot find '$__lldb_injected_self' in scope
    $__lldb_injected_self.$__lldb_wrapped_expr_1(
    ^~~~~~~~~~~~~~~~~~~~~

I'm on a debug build and optimization is turned off.
Has anybody encountered similar issues and maybe even found a solution / workaround or is this just a general limitation of LLDB in concurrently executing contexts?

Glad for any help or even just a explanation as to why this limitation exists.

Best Regards

8 Likes

We can confirm this. We always receive this error message for all async functions (within Task). Unfortunately I have not yet found a workaround for this behavior. The root cause is that self is unavailable.

Upon further investigation i noticed that I don't seem to get the error when im debugging on a simulator. I just ran a few tests on the Simulator and then on a physical device.
On the simulator i always get fast results from po and the debugger is working properly while on my physical device it always prints the above mentioned error after a few seconds.

I might have been unaware of this and therefore thought that it sometimes occured (i switch between debugging on device and simulator) but it seems that it always fails on a physical device.
This was a very quick test and I'll try to reproduce this on a minimal project tomorrow.

1 Like

Thanks for this detail that I can confirm. I also was not ware of this behaviour. Debugging on simulator works fine in async functions but as soon as I use a physical device po self fails.

In my case only on the physical device the unnamed_symbol for CFNetwork appears in the stack trace but not on the simulator (at the same breakpoint).

Screenshot 2022-05-11 at 20.43.28

@Adrian_Prantl Do you have any idea why this happens on a physical device but not on a simulator and how to fix this?

I run into this a lot in Xcode when debugging my macOS Vapor SPM project. I also have a great deal of difficulty stepping over await calls.