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

New Feature & Tips in LLDB

New Feature & Tips in LLDB

WWDC2015 情報共有会

0a86666ca90016b2a28289dda921b0d7?s=128

Toshihiro Morimoto

July 07, 2015
Tweet

More Decks by Toshihiro Morimoto

Other Decks in Technology

Transcript

  1. New Feature & Tips in LLDB 2015/07/07 WWDC2015 ৘ใڞ༗ձ @dealforest

    Toshihiro Morimoto
  2. ࣗݾ঺հ

  3. Crying DFTDebugScreenshot cocoapods-browser Tuna

  4. ͓ئ͍

  5. LLDB ͷ࿩Λ͢Δͱ λΠϜϥΠϯ͕͓ͱͳ͘͠ͳΓ ޙͰ΁͜Ή͜ͱʹͳΔͷͰ ͳΜͰ΋͍͍ͷͰͭͿ΍͍͍ͯͩ͘͞

  6. 402 Whats's new in LLDB Έ·͔ͨ͠ʁʁ

  7. ຖ೥ LLVM ͷ࠷దԽͷ࿩͕ ͸͍͍ͬͯͨɻɻɻ (ڈ೥ͩͱ PGO)

  8. ͱ͜Ζ͕ɺࠓ೥͸ ηογϣϯͱ͓ͯ͠ LLDB ͷ࿩

  9. ૉ੖Β͍͠ʂʂʂ

  10. ·ͣ཈͓͑ͯ͘ϙΠϯτʂ p, po ͸ alias Έ͍ͨͳ΋ͷ

  11. breakpoint breakpoint set -E swift -N allThrows • ݴޠαϙʔτ •

    lldbinit ͰॳظઃఆͰ͖ΔΑ͏ʹͳͬͨ
  12. breakpoint ~/.lldbinit breakpoint set -n malloc -N memory breakpoint set

    -n free -N memory breakpoint disable memory (lldb) breakpoint enable memory
  13. formatter i = 10 (lldb) p/x i (lldb) expression -format

    hex -- i (lldb) frame variable --format hex i (Int) $R2 = 0x000000000000000a
  14. formatting models

  15. formatting models • `frame variable` ͸ pure LLDB ͷ৘ใΛग़ྗ •

    `p` ͸ eval ͨ݁͠ՌΛ LLDB format Ͱग़ྗ • `po` ͸ eval ͨ݁͠ՌΛݴޠຖʹΑͬͯ ࠷దͳ΋ͷΛग़ྗ (objc Ͱ͍͏ description)
  16. runtime (lldb) po for i in 1...3 { print(i) }

    1 2 3
  17. It’s All Automatic!!

  18. It’s All Automatic!! in Swift…

  19. ҆৺͍ͯͩ͘͠͞

  20. None
  21. Xcode 6.x :PVS$PEF OBNFT .Z'VOD .Z7JFX ✔ 4%,'VODUJPOT /4-PH /4.BLF3FDU

    ✘ 4%,$MBTTFT /47JFX /4"QQMJDBUJPO ✔ 4%,$POTUBOUT /4"4$**4USJOH&ODPEJOH ✔ .BDSPT */5@."9 ."9 ✘
  22. Xcode 7.x :PVS$PEF OBNFT .Z'VOD .Z7JFX ✔ 4%,'VODUJPOT /4-PH /4.BLF3FDU

    ✔ 4%,$MBTTFT /47JFX /4"QQMJDBUJPO ✔ 4%,$POTUBOUT /4"4$**4USJOH&ODPEJOH ✔ .BDSPT */5@."9 ."9 ✔
  23. only Swift

  24. type lookup protocol HogeProtocol { func hoge() -> String }

    struct Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } }
  25. type lookup protocol HogeProtocol { func hoge() -> String }

    struct Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } } (lldb) type lookup Hoge struct Hoge : HogeProtocol { let a: Swift.String let b: Swift.String let c: Swift.String func aa() func ab() func ac() func hoge() -> Swift.String init(a: Swift.String, b: Swift.String, c: Swift.String) } (lldb) type lookup HogeProtocol protocol HogeProtocol { func hoge() -> Swift.String } protocol extension ΋͋Ε͹Ͱ·͢
  26. protocol 4XJGU 4XJGU 1SJOUBCMF $VTUPN4USJOH$POWFSUJCMF %FCVH1SJOUBCMF $VTUPN%FCVH4USJOH$POWFSUJCMF  $VTUPN3FqFDUBCMF

  27. protocol 4XJGU 4XJGU 1SJOUBCMF $VTUPN4USJOH$POWFSUJCMF QSJOU %FCVH1SJOUBCMF $VTUPN%FCVH4USJOH$POWFSUJCMF EFCVH1SJOU 

    $VTUPN3FqFDUBCMF --%# QP
  28. protocol 4XJGU 4XJGU 1SJOUBCMF $VTUPN4USJOH$POWFSUJCMF QSJOU %FCVH1SJOUBCMF $VTUPN%FCVH4USJOH$POWFSUJCMF EFCVH1SJOU 

    $VTUPN3FqFDUBCMF --%# QP
  29. ͦΕͧΕݟ͍͖ͯ·͠ΐ͏

  30. print protocol HogeProtocol { func hoge() -> String } struct

    Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } }
  31. print protocol HogeProtocol { func hoge() -> String } struct

    Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } } let hoge = Hoge( a: “aaaaa", b: “bbbbb", c: “ccccccccc" ) print(hoge) —————————————————————————————— > Sample.Hoge(a: "aaaaa", b: "bbbbb", c: “ccccccccc")
  32. debugPrint protocol HogeProtocol { func hoge() -> String } struct

    Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } }
  33. debugPrint protocol HogeProtocol { func hoge() -> String } struct

    Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } } let hoge = Hoge( a: “aaaaa", b: “bbbbb", c: “ccccccccc" ) debugPrint(hoge) —————————————————————————————— > Sample.Hoge(a: "aaaaa", b: "bbbbb", c: “ccccccccc") ΧελϚΠζ͠ͳ͍ݶΓجຊಉ͡
  34. (lldb) po protocol HogeProtocol { func hoge() -> String }

    struct Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } }
  35. (lldb) po protocol HogeProtocol { func hoge() -> String }

    struct Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } } let hoge = Hoge( a: “aaaaa", b: “bbbbb", c: “ccccccccc" ) —————————————————————————————— (lldb) po hoge ▿ Sample.Hoge - a : "aaaaa" - b : "bbbbb" - c : "ccccccccc"
  36. (lldb) po protocol HogeProtocol { func hoge() -> String }

    struct Hoge: HogeProtocol { let a: String internal let b: String private let c: String func aa() { } internal func ab() { } private func ac() { } func hoge() -> String { return "hoge" } } let hoge = Hoge( a: “aaaaa", b: “bbbbb", c: “ccccccccc" ) —————————————————————————————— (lldb) po hoge ▿ Sample.Hoge - a : "aaaaa" - b : "bbbbb" - c : "ccccccccc" human readable!!!!
  37. ͱ͸͍͑ LLDB ্Ͱ͔͠࢖͑ͳ͍

  38. ͱ͍͏͜ͱ͸…

  39. break ͠ͳ͍ͱ࢖͑ͳ͍ͱ͔…(ry

  40. https://github.com/dealforest/Tuna

  41. break ͠ͳ͍ breakpoint Λ ؆୯ʹઃఆͰ͖·͢

  42. None
  43. Swift 2 Λར༻͢Δࡍ͸ɹɹɹɹɹɹ ͔ͳΓ޾ͤʹͳΕΔΑ

  44. Objective-C Ͱ΋޾ͤʹͳΕ·͢

  45. Tips • ηογϣϯຖͷ hisotry ͩͬͨͷ͕ stop / start ͯ͠΋࢒ΔΑ͏ʹͳͬͨ •

    ~/.lldbinit-Xcode ΛΈͳ͘ͳͬͨ • all exception breakpoint Debugger command `po $arg1`Λ͠ͱ͚͹ fatal error message ͕ΈΕΔΑ http://natashatherobot.com/xcode-debugging-trick/
  46. ·ͱΊ LLDB ΋৭ʑਐԽͯ͠ΔͷͰ ৮ͬͯΈΔͱͨͷ͍͠Α

  47. ·ͱΊ Tuna Λ࢖ͬͯ human readable ͳ ग़ྗͰσόοάΛ͠·ͤΜ͔ʁ

  48. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠