@@ -299,3 +299,90 @@ function in the current frame::
299
299
Summary: CollectionType3`ext.CollectionType3.CollectionType3.MutableCollectionType2<A where A: CollectionType3.MutableCollectionType2>.(subscript.materializeForSet : (Swift.Range<A.Index>) -> Swift.MutableSlice<A>).(closure #1)
300
300
Module: file = "/Volumes/Files/work/solon/build/build-swift/validation-test-macosx-x86_64/stdlib/Output/CollectionType.swift.gyb.tmp/CollectionType3", arch = "x86_64"
301
301
Symbol: id = {0x0000008c}, range = [0x0000000100004db0-0x00000001000056f0), name="ext.CollectionType3.CollectionType3.MutableCollectionType2<A where A: CollectionType3.MutableCollectionType2>.(subscript.materializeForSet : (Swift.Range<A.Index>) -> Swift.MutableSlice<A>).(closure #1)", mangled="_TFFeRq_15CollectionType322MutableCollectionType2_S_S0_m9subscriptFGVs5Rangeqq_s16MutableIndexable5Index_GVs12MutableSliceq__U_FTBpRBBRQPS0_MS4__T_"
302
+
303
+ Debugging failures in LLDB
304
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
305
+
306
+ Sometimes one needs to be able to while debugging actually debug LLDB and its
307
+ interaction with Swift itself. Some examples of problems where this can come up
308
+ are:
309
+
310
+ 1. Compiler bugs when LLDB attempts to evaluate an expression. (expression
311
+ debugging)
312
+ 2. Swift variables being shown with no types. (type debugging)
313
+
314
+ To gain further insight into these sorts of failures, we use LLDB log
315
+ categories. LLDB log categories provide introspection by causing LLDB to dump
316
+ verbose information relevant to the category into the log as it works. The two
317
+ log channels that are useful for debugging Swift issues are the "types" and
318
+ "expression" log channels.
319
+
320
+ For more details about any of the information below, please run::
321
+
322
+ (lldb) help log enable
323
+
324
+ "Types" Log
325
+ ```````````
326
+
327
+ The "types" log reports on LLDB's process of constructing SwiftASTContexts and
328
+ errors that may occur. The two main tasks here are::
329
+
330
+ 1. Constructing the SwiftASTContext for a specific single Swift module. This is
331
+ used to implement frame local variable dumping via the lldb ``frame
332
+ variable `` command, as well as the Xcode locals view. On failure, local
333
+ variables will not have types.
334
+
335
+ 2. Building a SwiftASTContext in which to run Swift expressions using the
336
+ "expression" command. Upon failure, one will see an error like: "Shared Swift
337
+ state for has developed fatal errors and is being discarded."
338
+
339
+ These errors can be debugged by turning on the types log::
340
+
341
+ (lldb) log enable -f /tmp/lldb-types-log.txt lldb types
342
+
343
+ That will write the types log to the file passed to the -f option.
344
+
345
+ **NOTE ** Module loading can happen as a side-effect of other operations in lldb
346
+ (e.g. the "file" command). To be sure that one has enabled logging before /any/
347
+ module loading has occured, place the command into either::
348
+
349
+ ~/.lldbinit
350
+ $PWD/.lldbinit
351
+
352
+ This will ensure that the type import command is run before /any/ modules are
353
+ imported.
354
+
355
+ "Expression" Log
356
+ ````````````````
357
+
358
+ The "expression" log reports on the process of wrapping, parsing, SILGen'ing,
359
+ JITing, and inserting an expression into the current Swift module. Since this can
360
+ only be triggered by the user manually evaluating expression, this can be turned
361
+ on at any point before evaluating an expression. To enable expression logging,
362
+ first run::
363
+
364
+ (lldb) log enable -f /tmp/lldb-expr-log.txt lldb expression
365
+
366
+ and then evaluate the expression. The expression log dumps, in order, the
367
+ following non-exhaustive list of state:
368
+
369
+ 1. The unparsed, textual expression passed to the compiler.
370
+ 2. The parsed expression.
371
+ 3. The initial SILGen.
372
+ 4. SILGen after SILLinking has occured.
373
+ 5. SILGen after SILLinking and Guaranteed Optimizations have occured.
374
+ 6. The resulting LLVM IR.
375
+ 7. The assembly code that will be used by the JIT.
376
+
377
+ **NOTE ** LLDB runs a handful of preparatory expressions that it uses to set up
378
+ for running Swift expressions. These can make the expression logs hard to read
379
+ especially if one evaluates multiple expressions with the logging enabled. In
380
+ such a situation, run all expressions before the bad expression, turn on the
381
+ logging, and only then run the bad expression.
382
+
383
+ Multiple Logs at a Time
384
+ ```````````````````````
385
+
386
+ Note, you can also turn on more than one log at a time as well, e.x.::
387
+
388
+ (lldb) log enable -f /tmp/lldb-types-log.txt lldb types expression
0 commit comments