Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

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 ↗

Transcript all transcripts

Code shown on screen · 21 snippets

Show info about all loaded dylibs bash · at 5:04 ↗
image list
Show debug info for a code address bash · at 5:24 ↗
image lookup -va $pc
Show help for target.source-map bash · at 5:58 ↗
settings list target.source-map
Remap source paths in LLDB bash · at 6:37 ↗
settings set target.source-map /Volumes/BUILD_SERVER/projects /Users/demo/Desktop/Adventure/3rdparty
Source path remapping bash · at 7:02 ↗
settings set target.source-map prefix new
Debug prefix map bash · at 8:13 ↗
-debug-prefix-map $PWD=/BUILDROOT
Print object description of "words" bash · at 8:32 ↗
po words
expr -O -- words
Evaluate the expression "words" bash · at 8:40 ↗
p words
expr words
Display the variable "words" bash · at 8:58 ↗
v words
frame variable words
Raw memory of a Swift variable bash · at 10:10 ↗
mem read UnsafePointer<Items>(self.inventory)
See diagnostics from LLDB's embedded Swift compiler bash · at 11:59 ↗
swift-healthcheck
Register Swift modules 
with the Linker bash · at 15:47 ↗
ld … -add_ast_path /path/to/My.swiftmodule
Verify Swift modules were registered in binary bash · at 16:05 ↗
dsymutil -s MyApp | grep .swiftmodule
Wrapping Swift modules in object files on Linux bash · at 16:12 ↗
swiftc -modulewrap My.swiftmodule -o My.swiftmodule.o
Evaluate the expression "self" bash · at 16:52 ↗
p self
Print object description of "words" bash · at 16:58 ↗
po words
expr -O -- words
Step into function call bash · at 17:08 ↗
s
thread step-in
Step over instruction bash · at 17:10 ↗
n
thread step-over
Avoiding serialized search paths 
in Swift modules (command line) bash · at 18:23 ↗
-no-serialize-debugging-options
Avoiding serialized search paths 
in Swift modules (Xcode) bash · at 18:24 ↗
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO
Reintroducing search paths in LLDB bash · at 18:32 ↗
settings set target.swift-extra-clang-flags …
settings set target.swift-framework-search-paths …
settings set target.swift-module-search-paths …