Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intrducing debug in WWDC2016

Intrducing debug in WWDC2016

WWDC.next

Toshihiro Morimoto

July 01, 2016
Tweet

More Decks by Toshihiro Morimoto

Other Decks in Technology

Transcript

  1. WWDC2016 Debug Session 1. #410 - Visual Debugging with Xcode

    2. #412 - Thread Sanitizer and Static Analysis 3. #417 - Debugging Tips and Tricks
  2. WWDC2016 Debug Session 1. #410 - Visual Debugging with Xcode

    (100P) 2. #412 - Thread Sanitizer and Static Analysis (64P) 3. #417 - Debugging Tips and Tricks (494P)
  3. WWDC2016 Debug Session 1. #410 - Visual Debugging with Xcode

    (100P) 2. #412 - Thread Sanitizer and Static Analysis (64P) 3. #417 - Debugging Tips and Tricks (494P)
  4. your app LLDB Swift Compiler inject p: ΞϓϦଆͰ LLDB ͷ৘ใΛग़ྗ

    po: ΞϓϦଆͰఆٛͨ͠৘ใ(description)Λग़ྗ
  5. ม਺Λग़ྗ͢Δ • p <expression> • po <expression> • frame variable

    <local-name> • parray <count> <expression> • poarray <count> <expression>
  6. ม਺Λग़ྗ͢Δ • p <expression> • po <expression> • frame variable

    <local-name> • parray <count> <expression> • poarray <count> <expression> parray, poarray ͸ C ϙΠϯλ ͷ഑ྻΛදࣔ
  7. ม਺Λग़ྗ͢Δ int count = 5; int data[5] = { 1000,

    2, 3, 17, 50 }; int *dataset = data; (lldb) p dataset (int *) $1 = 0x00007fff5a5bedb0 (lldb) po dataset 0x00007fff5a5bedb0 (lldb) parray 5 dataset (int *) $3 = 0x00007fff5a5bedb0 { (int) [0] = 1000 (int) [1] = 2 (int) [2] = 3 (int) [3] = 17 (int) [4] = 50 }
  8. ม਺Λग़ྗ͢Δ int count = 5; int data[5] = { 1000,

    2, 3, 17, 50 }; int *dataset = data;
  9. ม਺Λग़ྗ͢Δ int count = 5; int data[5] = { 1000,

    2, 3, 17, 50 }; int *dataset = data; (lldb) poarray `count` dataset { 1000 2 3 17 50 }
  10. Objective-C ͷΠϯελϯεΛग़ྗ Objective-C Ͱ࡞ΒΕͨΠϯελϯε (lldb) po 0x1003183e0 Enrico, 700 Swift

    Street, Mountain View, CA Swift ͷίʔυ (lldb) po 0x1003183e0 4298212320
  11. Objective-C ͷΠϯελϯεΛग़ྗ Objective-C Ͱ࡞ΒΕͨΠϯελϯε (lldb) po 0x1003183e0 Enrico, 700 Swift

    Street, Mountain View, CA Swift ͷίʔυ (lldb) po 0x1003183e0 4298212320 (lldb) expr -O --language objc -- 0x1003183e0 Enrico, 700 Swift Street, Mountain View, CA po ͱ expr -O ͸ಉٛͰ͢
  12. import module (lldb) p [NSApplication sharedApplication].undoManager error: property ‘undoManager’ not

    found on object of type ‘id’ (lldb) p @import AppKit (lldb) p [NSApplication sharedApplication].undoManager (NSUndoManager * __nullable) $1 = 0x00007fb399629cd0
  13. auto import module (lldb) p [NSApplication sharedApplication].undoManager (NSUndoManager * __nullable)

    $1 = 0x00007fb399629cd0 ͜ͷػೳΛແޮʹ͢Δ͜ͱ΋Ͱ͖·͢ (lldb) settings show target.auto-import-clang-modules false
  14. REPL $ swift Welcome to Apple Swift version 3.0. Type

    :help for assistance. 1> po "Welcome to WWDC.next!!" error: repl.swift:2:3: error: consecutive statements on a line must be separated by ';' po "Welcome to WWDC.next!!" ^ ; 1> :po "Welcome to WWDC.next!!" "Welcome to WWDC.next!!"
  15. REPL $ swift Welcome to Apple Swift version 3.0. Type

    :help for assistance. 1> :type lookup Comparable protocol Comparable : Equatable { @warn_unused_result func <(lhs: Self, rhs: Self) -> Swift.Bool @warn_unused_result func <=(lhs: Self, rhs: Self) -> Swift.Bool @warn_unused_result func >=(lhs: Self, rhs: Self) -> Swift.Bool @warn_unused_result func >(lhs: Self, rhs: Self) -> Swift.Bool }
  16. REPL let value: Int? = 10 value + 10 ⚠Value

    of optional type 'Optional<Int>' not unwrapped; did you mean to use '!' or '?'?
  17. REPL let value: Int? = 10 value + 10 ⚠Value

    of optional type 'Optional<Int>' not unwrapped; did you mean to use '!' or '?'? (lldb) p Optional(10) + 10 (Int) $R0 = 20 Fixit applied, fixed expression was: Optional(10)! + 10
  18. Breakpoint • Symbolic Breakpoints • ಛఆͷ method, property ʹ step-in

    ͢Δ sif <TargetFunctionName> • ͲͷόΠφϦ͕ϩʔυ͞Ε͍ͯΔͷ͔ image list • --queue-name (or -q) Ͱಛఆͷ queue ͕ dequeue ͞ΕΔλ ΠϛϯάͰ attach Ͱ͖Δ
  19. Low-Level Debugging • Optimized code • Third-party code with no

    debug info ୭͠΋Ұ౓͸ܦݧ͋Δ͔ͱ͸ࢥ͍·͢