LLDB常用命令

apropos

  • 列出與單詞或主題相關的調試器命令
  • eg: apropos br

breakpoint

  • 設置斷點
  • breakpoint set -a 函數地址
  • breakpoint set -n 函數名
    • breakpoint set -n test (所有文件)
    • breakpoint set -n touchesBegan:withEvent: (所有文件)
    • breakpoint set -n "-[ViewController touchesBegan:withEvent:]" (ViewController這個類里邊)
  • breakpoint set -r 正則表達式
  • breakpoint set -s 動態庫 -n 函數名
  • breakpoint list (列出所有的斷點)
  • breakpoint set --file test.c --line 12 (設置一個斷點在文件test.c中的第12行)

watchpoint內存斷點(在內存數據發?改變的時候觸發)

  • watchpoint set variable 變量
    • watchpoint set variable self->age
  • watchpoint set expression 地址
    • watchpoint set expression &(self->_age)
  • watchpoint list

thread

  • thread backtrace
    • 打印線程的堆棧信息
    • 和指令bt的效果?樣
  • thread return []
    • 讓函數直接返回某個值,不會執?斷點后?的代碼

image lookup

  • image lookup -t 類型 :查找某個類型的信息
  • image lookup -a 地址 :根據內存地址查找在模塊中的位置
  • image lookup -n 符號或者函數名 :查找某個符號或者函數的位置

image list

  • 列出所加載的模塊信息
  • image list -o -f
    • 打印出模塊的偏移地址、全路徑

expression

  • expression self.view.backgroundColor = [UIColor redColor]

  • e @import UIKit

  • Debug View Hierarchy的時候

    變量需要加 $, 注意函數返回void
    (lldb) e id $view = (id)0x127817450;
    (lldb) e (void)[$view setBackgroundColor:[UIColor redColor]]
    (lldb) e (void)[CATransaction flush]
    

官方文檔 https://lldb.llvm.org/use/map.html

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。