2022 Developer ToolsSwift
WWDC22 · 20 min · Developer Tools / Swift
Debug Swift debugging with LLDB
Learn how you can set up complex Swift projects for debugging. We’ll take you on a deep dive into the internals of LLDB and debug info. We’ll also share best practices for complex scenarios such as debugging code built on build servers or code from custom build systems.
Watch at developer.apple.com ↗Code shown on screen · 21 snippets
Show info about all loaded dylibs
image list Show debug info for a code address
image lookup -va $pc Show help for target.source-map
settings list target.source-map Remap source paths in LLDB
settings set target.source-map /Volumes/BUILD_SERVER/projects /Users/demo/Desktop/Adventure/3rdparty Source path remapping
settings set target.source-map prefix new Debug prefix map
-debug-prefix-map $PWD=/BUILDROOT Print object description of "words"
po words
expr -O -- words Evaluate the expression "words"
p words
expr words Display the variable "words"
v words
frame variable words Raw memory of a Swift variable
mem read UnsafePointer<Items>(self.inventory) See diagnostics from LLDB's embedded Swift compiler
swift-healthcheck Register Swift modules with the Linker
ld … -add_ast_path /path/to/My.swiftmodule Verify Swift modules were registered in binary
dsymutil -s MyApp | grep .swiftmodule Wrapping Swift modules in object files on Linux
swiftc -modulewrap My.swiftmodule -o My.swiftmodule.o Evaluate the expression "self"
p self Print object description of "words"
po words
expr -O -- words Step into function call
s
thread step-in Step over instruction
n
thread step-over Avoiding serialized search paths in Swift modules (command line)
-no-serialize-debugging-options Avoiding serialized search paths in Swift modules (Xcode)
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO Reintroducing search paths in LLDB
settings set target.swift-extra-clang-flags …
settings set target.swift-framework-search-paths …
settings set target.swift-module-search-paths … Related sessions
-
13 min -
37 min -
21 min -
54 min