使用Xcode和LLDB進行高級調(diào)試

1、WWDC2018

1.1 Advanced Debugging with Xcode and LLDB link

Discover advanced techniques, and tips and tricks for enhancing your Xcode debugging workflows. Learn how to take advantage of LLDB and custom breakpoints for more powerful debugging. Get the most out of Xcode's view debugging tools to solve UI issues in your app more efficiently.

1.2 視頻介紹的內(nèi)容

  • 每次啟動app再到響應的測試業(yè)務需要經(jīng)過很多個步驟,使用LLDB調(diào)試可以減少這個時間花費
  • 這個步驟是可以直接拖動跳過的
thread jump
#跳過響應的執(zhí)行行數(shù)
thread jump --by 2
#跳過之后可以執(zhí)行預期需要執(zhí)行的代碼
expression [self.view setBackgroudColor:[UIColor redColor]]
  • 介紹了LLDB的常用指令
    (lldb) p & po
    (lldb) expression & e
    (lldb) frame variable <name>
    
  • 介紹了LLDB 執(zhí)行 Python,快捷LLDB腳本集合Chisel
  • 介紹了Xcode來調(diào)試UI界面,直接頁面操作copy響應視圖或者約束
Debug View Hierarchy


2、Chisel功能使用

2.1 chisel集成

#1.安裝
brew update
brew install chisel
#這里如果出現(xiàn)錯誤按照提示解決
#Cannot brew update or upgrade: Error: homebrew-cask is a shallow clone
#https://github.com/Homebrew/brew/issues/9420

#2.根目錄創(chuàng)建llbdinit文件
touch .lldbinit 
open .lldbinit 

#3.集成Chisel python腳本集合
command script import /usr/local/opt/chisel/libexec/fbchisellldb.py

#4.重啟xcode,在Xcode輸入pviews查看視圖結構 | help查看指令

2.2 腳本常用指令

There are many commands; here's a few: (Compatibility with iOS/Mac indicated at right)

Command Description iOS OS X
pviews Print the recursive view description for the key window. Yes Yes
pvc Print the recursive view controller description for the key window. Yes No
visualize Open a UIImage, CGImageRef, UIView, CALayer, NSData (of an image), UIColor, CIColor, or CGColorRef in Preview.app on your Mac. Yes No
fv Find a view in the hierarchy whose class name matches the provided regex. Yes No
fvc Find a view controller in the hierarchy whose class name matches the provided regex. Yes No
show/hide Show or hide the given view or layer. You don't even have to continue the process to see the changes! Yes Yes
mask/unmask Overlay a view or layer with a transparent rectangle to visualize where it is. Yes No
border/unborder Add a border to a view or layer to visualize where it is. Yes Yes
caflush Flush the render server (equivalent to a "repaint" if no animations are in-flight). Yes Yes
bmessage Set a symbolic breakpoint on the method of a class or the method of an instance without worrying which class in the hierarchy actually implements the method. Yes Yes
wivar Set a watchpoint on an instance variable of an object. Yes Yes
presponder Print the responder chain starting from the given object. Yes Yes

更多指令介紹:Wiki

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容