\lldb with Swift across modules

I’m trying to use lldb to debug a project from a test target. I started lldb pointing to the .xctest target

lldb .build/debug/JPEGPackageTests.xctest

and I got this error when i tried to inspect variables inside the code i’m trying to debug

(lldb) p s
warning: Swift error in module JPEGPackageTests.xctest.
Debug info from this module will be unavailable in the debugger.

error: in auto-import:
failed to get module 'JPEG' from AST context
2 Likes

I’m very new to swift, but this reminds me a lot of SR-7388. Are you running Swift 4.1 on Linux?

yes, and SR-7388 is a different bug

Apologies for hijacking this thread, but I've been trying to figure out how to launch the unit tests with lldb, and I'm not getting anywhere.

If you start lldb pointing at an .xctest bundle, is a simple run supposed to be sufficient to kick it off? I just get:

Test > lldb .build/debug/TestPackageTests.xctest
(lldb) target create ".build/debug/TestPackageTests.xctest"
Current executable set to '.build/debug/TestPackageTests.xctest' (x86_64).
(lldb) run
error: failed to launch or debug process
(lldb) 

for me i was always able to just run the unit tests by running the .xctest thing in the terminal. i just don't think it ever worked with lldb

I also had the same issue and found such way:

  1. For simplicity create new package
    mkdir SwiftModuleHelloWorld
    cd SwiftModuleHelloWorld
    swift package init
  2. Run tests to determine how xctest run your test (and get right path)
    $ swift test -v
  3. Run lldb using path from output above (change to your path):
    $ lldb /Applications/Xcode.app/Contents/Developer/usr/bin/xctest /Users/anton/Desktop/sources/SwiftModuleHelloWorld/.build/x86_64-apple-macosx/debug/SwiftModuleHelloWorldPackageTests.xctest
  4. Try run all test from lldb
    (lldb) process launch
  5. Set breakpoint on single test
    (lldb) breakpoint set -f SwiftModuleHelloWorldTests.swift -l 9
  6. Run it again
    (lldb) process launch
  7. Breakpoint was hit, now you can use inspecting commands
Terms of Service

Privacy Policy

Cookie Policy