SlideShare a Scribd company logo
1 of 62
Download to read offline
DEBUG 裝屌指南
那些看起來來⾼高級的LLDB⼿手勢
Pofat
Pofat Tseng
iOS, Product,
UX, Triathlon & Coffee
LLDB與我(的前兩兩年年)
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
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
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 啦
Which one is better?
Reference
• Dancing in the Debugger - A waltz with LLDB

• 泊學(很精實的中國教學網站)

• WWDC 2014 Session 410 : Advanced Debugging in LLDB
感謝各位

More Related Content

What's hot

Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
kiki utagawa
 

What's hot (20)

最新C++事情 C++14-C++20 (2018年10月)
最新C++事情 C++14-C++20 (2018年10月)最新C++事情 C++14-C++20 (2018年10月)
最新C++事情 C++14-C++20 (2018年10月)
 
用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》用十分鐘搞懂《離散數學》
用十分鐘搞懂《離散數學》
 
"Simple Made Easy" Made Easy
"Simple Made Easy" Made Easy"Simple Made Easy" Made Easy
"Simple Made Easy" Made Easy
 
T4 Template 入門
T4 Template 入門T4 Template 入門
T4 Template 入門
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
Pythonによる黒魔術入門
Pythonによる黒魔術入門Pythonによる黒魔術入門
Pythonによる黒魔術入門
 
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
Cocos2d-x(JS) ハンズオン #12「Cocos2d-xとSpine」
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 
Row-based Effect Systems for Algebraic Effect Handlers
Row-based Effect Systems for Algebraic Effect HandlersRow-based Effect Systems for Algebraic Effect Handlers
Row-based Effect Systems for Algebraic Effect Handlers
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
用十分鐘 學會《資料結構、演算法和計算理論》
用十分鐘  學會《資料結構、演算法和計算理論》用十分鐘  學會《資料結構、演算法和計算理論》
用十分鐘 學會《資料結構、演算法和計算理論》
 
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
Pythonの処理系はどのように実装され,どのように動いているのか? 我々はその実態を調査すべくアマゾンへと飛んだ.
 
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
C#×LLVM=アセンブラ!? 〜詳説・Burstコンパイラー〜
 
創作共用電子書:語言處理技術
創作共用電子書:語言處理技術創作共用電子書:語言處理技術
創作共用電子書:語言處理技術
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
from Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Worksfrom Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Works
 
クロージャデザインパターン
クロージャデザインパターンクロージャデザインパターン
クロージャデザインパターン
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Map
MapMap
Map
 
コードゴルフのススメ(C言語)
コードゴルフのススメ(C言語)コードゴルフのススメ(C言語)
コードゴルフのススメ(C言語)
 

Similar to DEBUG 裝屌指南 - 那些看起來高級的 LLDB 手勢

Mysql(2)
Mysql(2)Mysql(2)
Mysql(2)
tomcoh
 
Dimitry Solovyov - The imminent threat of functional programming
Dimitry Solovyov - The imminent threat of functional programmingDimitry Solovyov - The imminent threat of functional programming
Dimitry Solovyov - The imminent threat of functional programming
Dmitry Buzdin
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
d0nn9n
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
Sang Don Kim
 

Similar to DEBUG 裝屌指南 - 那些看起來高級的 LLDB 手勢 (20)

Mysql(2)
Mysql(2)Mysql(2)
Mysql(2)
 
Lec15a1-Object-Oriented Development.ppt
Lec15a1-Object-Oriented Development.pptLec15a1-Object-Oriented Development.ppt
Lec15a1-Object-Oriented Development.ppt
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Development
 
LLDB Beyond po
LLDB   Beyond poLLDB   Beyond po
LLDB Beyond po
 
F# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperioF# for BLOBA, by brandon d'imperio
F# for BLOBA, by brandon d'imperio
 
Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash Cracking
 
Dimitry Solovyov - The imminent threat of functional programming
Dimitry Solovyov - The imminent threat of functional programmingDimitry Solovyov - The imminent threat of functional programming
Dimitry Solovyov - The imminent threat of functional programming
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
 
Debugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to LinuxDebugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to Linux
 
Inspecting Block Closures To Generate Shaders for GPU Execution
Inspecting Block Closures To Generate Shaders for GPU ExecutionInspecting Block Closures To Generate Shaders for GPU Execution
Inspecting Block Closures To Generate Shaders for GPU Execution
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
 
Massive applications in node.js
Massive applications in node.jsMassive applications in node.js
Massive applications in node.js
 
The NRB Group mainframe day 2021 - New Programming Languages on Z - Frank Van...
The NRB Group mainframe day 2021 - New Programming Languages on Z - Frank Van...The NRB Group mainframe day 2021 - New Programming Languages on Z - Frank Van...
The NRB Group mainframe day 2021 - New Programming Languages on Z - Frank Van...
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
SOA Latam 2015
SOA Latam 2015SOA Latam 2015
SOA Latam 2015
 
Object oriented programming in 2014:Standard or Legacy?
Object oriented programming in 2014:Standard or Legacy?Object oriented programming in 2014:Standard or Legacy?
Object oriented programming in 2014:Standard or Legacy?
 
VS Debugging Tricks
VS Debugging TricksVS Debugging Tricks
VS Debugging Tricks
 
UML for Aspect Oriented Design
UML for Aspect Oriented DesignUML for Aspect Oriented Design
UML for Aspect Oriented Design
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 

DEBUG 裝屌指南 - 那些看起來高級的 LLDB 手勢