Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Fancy debug tips with LLDB
Search
Pofat
January 20, 2018
Programming
0
250
Fancy debug tips with LLDB
An introduction about how to use LLDB like a boss.
Pofat
January 20, 2018
Tweet
Share
More Decks by Pofat
See All by Pofat
從 UIKit 到 SwiftUI 的思維轉移
pofat
1
170
Sequence, Collection and Array in Swift
pofat
0
3.1k
掀起 SWIFT 的面紗
pofat
0
64
Other Decks in Programming
See All in Programming
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
200
コーンフレークから始める モデリング会話入門
ogurotakayuki
0
360
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
920
TYPO3 v13 – The road to LTS: What's new and new APIs
luisasofie_xoxo
0
200
try! Swift Tokyo 初参加報告LT
hinakko2
0
220
SIMD Parallel Programming with the Vector API
josepaumard
0
150
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
26
8.2k
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.1k
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
230
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
260
Goのmultiple errorsについて (2024年4月版)
syumai
3
640
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Into the Great Unknown - MozCon
thekraken
10
990
XXLCSS - How to scale CSS and keep your sanity
sugarenia
241
1.2M
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
322
20k
Optimizing for Happiness
mojombo
370
69k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
How GitHub (no longer) Works
holman
304
140k
Typedesign – Prime Four
hannesfritz
36
2.1k
A Modern Web Designer's Workflow
chriscoyier
689
190k
Transcript
DEBUG 蕕䌷瞲ܖ ᮎ犚፡蚏㬵ṛ羷ጱLLDBಋ玊 Pofat
LLDB膏౯ҁጱ獮獋ଙ҂
None
None
None
Compiling was like…
矦کSwift 盅…
Print Commands • p , print, call : expression —
• po: expression -O —
Not Only ‘Print Commands’
婘䌃کࠔӞ蟴䌘ܨݢ • 犥ӥ獋ᘏ缛㰷
ݢਯޞ虋碍 $樄毣ԏ虋碍ݢਂࣁෝ lldb ጱ绚樌
ݢਯޞ虋碍
襑ᥝ瞲ਧࣳ獨
襑ᥝ瞲ਧࣳ獨 ObjC Swift
窕纷矒ګ
窕纷矒ګ
thread backtrace
瑽ᛔ http://condor.depaul.edu/slytinen/406s16/ch3.html
瑽ᛔ http://condor.depaul.edu/slytinen/406s16/ch3.html
Frame
Breakpoints • -n : func or symbol name
• li : list all breakpoints
help & apropos
Who did this?
Print? Think again!
Print? Think again! 暱࿆硲Ԫ֦碁מ牫 กॠᥝӤ娄牧merge盅ጱcode 犋Ꭳ螇ெ讕ԧ 薟䌃ԧ礓㮆 customs view ጱ
_layer
None
Print? Think again! Watchpoint
Better way to log
Better way to log maybe • Breakpoints will minimize the
affect to flow • Need a way to import/export breakpoints
UI 砺֢ - present VC
UI 砺֢ - view hierarchy
Viva la Python
.lldbinit ~/command.py ~/.lldbinit
Chisel
Chisel • border
Chisel • visualize
Chisel • bmessage
Chisel in Swift context • error: error: use of undeclared
identifier ‘CGFloat' • CGFloat is defined by macro in objc. In Swift, it’s not.
Target ~/.lldbinit
瑽 by David Lin
Image lookup
None
None
Image lookup • ݢತᐺ磪 API • 犖ݢࣁ lldb 愊狶 method
swizzling
Image lookup • ݢತᐺ磪 API • 犖ݢࣁ lldb 愊狶 method
swizzling
Registers • $rip : Current instruct pointer • $rdi: First
argument • $rsi, $rdx, $rcx, $R8, $R9: Second, third, forth, fifth and sixth arguments • Others will be on stack
Registers • $rip : Current instruct pointer • $rdi: First
argument • $rsi, $rdx, $rcx, $R8, $R9: Second, third, forth, fifth and sixth arguments • Others will be on stack
Registers • $rsp : head of current frame ( head
is smaller than bottom) • $rbp: bottom of current frame • $rax: Return register
Registers 瑽ᛔ http://condor.depaul.edu/slytinen/406s16/ch3.html
瑽ᛔ http://condor.depaul.edu/slytinen/406s16/ch3.html
Witness “Witness Table”
Witness “Witness Table” legs: 8 heads: 2 Metadata Witness Table
Witness “Witness Table” legs: 8 heads: 2 Metadata Witness Table
walk()
Output all current state
薹硯֦ጱᨗᚣ毣
獊ᶎcommand line ࠩ
None
None
Which one is better?
Reference • Dancing in the Debugger - A waltz with
LLDB • ဤ䋊ҁ盄羊䋿ጱӾ㾴硽䋊翕ᒊ҂ • WWDC 2014 Session 410 : Advanced Debugging in LLDB
眤蘛ݱ֖