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

New Feature & Tips in LLDB

New Feature & Tips in LLDB

WWDC2015 情報共有会

Toshihiro Morimoto

July 07, 2015
Tweet

More Decks by Toshihiro Morimoto

Other Decks in Technology

Transcript

  1. breakpoint ~/.lldbinit breakpoint set -n malloc -N memory breakpoint set

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

    hex -- i (lldb) frame variable --format hex i (Int) $R2 = 0x000000000000000a
  3. formatting models • `frame variable` ͸ pure LLDB ͷ৘ใΛग़ྗ •

    `p` ͸ eval ͨ݁͠ՌΛ LLDB format Ͱग़ྗ • `po` ͸ eval ͨ݁͠ՌΛݴޠຖʹΑͬͯ ࠷దͳ΋ͷΛग़ྗ (objc Ͱ͍͏ description)
  4. 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 ✘
  5. 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 ✔
  6. 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" } }
  7. 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 ΋͋Ε͹Ͱ·͢
  8. 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" } }
  9. 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")
  10. 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" } }
  11. 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") ΧελϚΠζ͠ͳ͍ݶΓجຊಉ͡
  12. (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" } }
  13. (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"
  14. (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!!!!
  15. Tips • ηογϣϯຖͷ hisotry ͩͬͨͷ͕ stop / start ͯ͠΋࢒ΔΑ͏ʹͳͬͨ •

    ~/.lldbinit-Xcode ΛΈͳ͘ͳͬͨ • all exception breakpoint Debugger command `po $arg1`Λ͠ͱ͚͹ fatal error message ͕ΈΕΔΑ http://natashatherobot.com/xcode-debugging-trick/