Slide 1

Slide 1 text

How to play with LLDB in iOS runtime? @stinge

Slide 2

Slide 2 text

• slide url
 https://ppt.cc/fhdtqx • QR Code

Slide 3

Slide 3 text

Background stinge • Mercari iOS Engineer • twitter: @StingeSu • hobby: traveling & cooking

Slide 4

Slide 4 text

Outline • Why LLDB(Low Level Debugger)? • How LLDB works? • LLDB OSS • Custom LLDB command

Slide 5

Slide 5 text

Why LLDB? • high-performance debugger • Clang expression parser & LLVM disassembler • Default debugger in Xcode • Run Swift REPL & python supported • Save your time

Slide 6

Slide 6 text

Clang v.s GCC(GNU Compiler Collection) Clang • Apple official compiler • Frontend for LLVM • High performance • BSD license • …… GCC • Linux based • Support more languages • GPL license

Slide 7

Slide 7 text

Clang (Xcode 10.2.1) GCC (Darwin Kernel on Raspberry Pi)

Slide 8

Slide 8 text

• How Apple deprecated GCC Front-end Back-end Xcode 3 GCC GCC Xcode 4 GCC LLVM Xcode 5 Clang LLVM

Slide 9

Slide 9 text

• gcc hello.c

Slide 10

Slide 10 text

Is it good for iOS?

Slide 11

Slide 11 text

Is it good for iOS? NO 

Slide 12

Slide 12 text

build process

Slide 13

Slide 13 text

Clang-Swift • The compiler process of swift cmd+B

Slide 14

Slide 14 text

Clang-Swift • The compiler process of swift Clang AST Reference https://ppt.cc/fnA4Qx

Slide 15

Slide 15 text

Clang-Swift • The compiler process of swift

Slide 16

Slide 16 text

How LLDB works?

Slide 17

Slide 17 text

How LLDB works? command action option argument

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

• p(print) → expr -- expr -- foo • po(print object) → expr -O -- expr -O -- foo

Slide 20

Slide 20 text

p v.s po

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

• Changes the value of variables • Creates temporary variables • Validates the values

Slide 23

Slide 23 text

• DEMO • Tasks 1. Changes UIButton title into red 2. Moves UIView up

Slide 24

Slide 24 text

• Can we use a efficient way to finish these commands?
 - YES

Slide 25

Slide 25 text

LLDB Python API https://lldb.llvm.org/python_reference/index.html

Slide 26

Slide 26 text

LLDB OSS • Facebook/chisel • DEMO

Slide 27

Slide 27 text

Customized command • nudge(swift) • DEMO https://gist.github.com/sTinGe/059dc4c15347b7fef4ee537efdcc6e53