Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

ࣗݾ঺հ

Slide 3

Slide 3 text

Crying DFTDebugScreenshot cocoapods-browser Tuna

Slide 4

Slide 4 text

͓ئ͍

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

ૉ੖Β͍͠ʂʂʂ

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

breakpoint breakpoint set -E swift -N allThrows • ݴޠαϙʔτ • lldbinit ͰॳظઃఆͰ͖ΔΑ͏ʹͳͬͨ

Slide 12

Slide 12 text

breakpoint ~/.lldbinit breakpoint set -n malloc -N memory breakpoint set -n free -N memory breakpoint disable memory (lldb) breakpoint enable memory

Slide 13

Slide 13 text

formatter i = 10 (lldb) p/x i (lldb) expression -format hex -- i (lldb) frame variable --format hex i (Int) $R2 = 0x000000000000000a

Slide 14

Slide 14 text

formatting models

Slide 15

Slide 15 text

formatting models • `frame variable` ͸ pure LLDB ͷ৘ใΛग़ྗ • `p` ͸ eval ͨ݁͠ՌΛ LLDB format Ͱग़ྗ • `po` ͸ eval ͨ݁͠ՌΛݴޠຖʹΑͬͯ ࠷దͳ΋ͷΛग़ྗ (objc Ͱ͍͏ description)

Slide 16

Slide 16 text

runtime (lldb) po for i in 1...3 { print(i) } 1 2 3

Slide 17

Slide 17 text

It’s All Automatic!!

Slide 18

Slide 18 text

It’s All Automatic!! in Swift…

Slide 19

Slide 19 text

҆৺͍ͯͩ͘͠͞

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

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 ✘

Slide 22

Slide 22 text

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 ✔

Slide 23

Slide 23 text

only Swift

Slide 24

Slide 24 text

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" } }

Slide 25

Slide 25 text

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 ΋͋Ε͹Ͱ·͢

Slide 26

Slide 26 text

protocol 4XJGU 4XJGU 1SJOUBCMF $VTUPN4USJOH$POWFSUJCMF %FCVH1SJOUBCMF $VTUPN%FCVH4USJOH$POWFSUJCMF $VTUPN3FqFDUBCMF

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

ͦΕͧΕݟ͍͖ͯ·͠ΐ͏

Slide 30

Slide 30 text

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" } }

Slide 31

Slide 31 text

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")

Slide 32

Slide 32 text

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" } }

Slide 33

Slide 33 text

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") ΧελϚΠζ͠ͳ͍ݶΓجຊಉ͡

Slide 34

Slide 34 text

(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" } }

Slide 35

Slide 35 text

(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"

Slide 36

Slide 36 text

(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!!!!

Slide 37

Slide 37 text

ͱ͸͍͑ LLDB ্Ͱ͔͠࢖͑ͳ͍

Slide 38

Slide 38 text

ͱ͍͏͜ͱ͸…

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

https://github.com/dealforest/Tuna

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

Tips • ηογϣϯຖͷ hisotry ͩͬͨͷ͕ stop / start ͯ͠΋࢒ΔΑ͏ʹͳͬͨ • ~/.lldbinit-Xcode ΛΈͳ͘ͳͬͨ • all exception breakpoint Debugger command `po $arg1`Λ͠ͱ͚͹ fatal error message ͕ΈΕΔΑ http://natashatherobot.com/xcode-debugging-trick/

Slide 46

Slide 46 text

·ͱΊ LLDB ΋৭ʑਐԽͯ͠ΔͷͰ ৮ͬͯΈΔͱͨͷ͍͠Α

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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