在用編譯器調(diào)試之前,一次只使用幾個常規(guī)的調(diào)試命令。但是基于折騰的原理,今天列出了所有的調(diào)試命令和功能。
語言歌曲
快速列表在最后:下面是一些常見且重要的命令:
下面有更詳細(xì)的演示
如果您想了解關(guān)于編譯器調(diào)試命令的更多信息:
接下來,讓我們看看常見調(diào)試命令的用法:
一個
關(guān)于
列出與單詞或主題相關(guān)的調(diào)試器命令。
例如
(lldb)關(guān)于采購訂單
2
斷點
請看截圖文檔:
(lldb)斷點
它可以縮寫為br
功能很強(qiáng)大,下面詳細(xì)描述
三
斷點
重要的
四
印
(lldb)打印總和可以縮寫為(lldb) p總和
即印刷體寫成p。
在代碼中:varsums = ["0.00 "、" 0.00 "、" 0.00 "、" 0.00"]
調(diào)試窗口如下所示:
結(jié)果:
(lldb)打印總和([String]) $R14 = 4個值{[0]= " 0.00 "[1]= " 0.00 "[2]= " 0.00 "[3]= " 0.00 " }
如果要在命令行上打印十進(jìn)制數(shù):
輸入?yún)?shù)表示進(jìn)制 (e.g)p/x66(x表示16進(jìn)制)(Int) $R17 = 0x0000000000000042p/t6(t表示2進(jìn)制)(Int) $R20 = 0b0000000000000000000000000000000000000000000000000000000000000110p/c"s"(c表示字符)(String) $R24 = "s"五
表達(dá)
直接更改其值,點擊繼續(xù)運行,運行的結(jié)果就是本次賦值后的結(jié)果
(lldb)表達(dá)式總和= ["10.00 "、" 0.00 "、" 0.00 "、" 0.00"]
示例:
更多用法:
作為對象打印:
表達(dá)式-o-sum可以縮寫如下:e-o-sum
其中:
e-o-sum可以寫成po,作用等價。
步驟
與進(jìn)程交互的命令當(dāng)然與它們背后的參數(shù)相匹配,以達(dá)到相應(yīng)的目的(lldb)進(jìn)程幫助如下:
舉個常見的栗子:
繼續(xù)-繼續(xù)執(zhí)行當(dāng)前進(jìn)程中的所有線程。
是繼續(xù)執(zhí)行程序,當(dāng)遇到斷點時,在LLDB中執(zhí)行就是繼續(xù)執(zhí)行程序
線
當(dāng)然,與進(jìn)程交互的命令與它們背后的參數(shù)相匹配,以達(dá)到相應(yīng)的目的(lldb)。線程幫助如下:
匹配參數(shù)命令執(zhí)行的功能將在后面描述。
這里我們應(yīng)該著重談幾個:
* **`(lldb)線程return`**過早地從堆棧返回,立即執(zhí)行return命令并退出當(dāng)前堆棧。可以偽裝一些退貨信息等等。從寫一些函數(shù)的行為等等?;究蚣?/p>
調(diào)試也使用其參數(shù)完成
一個常用的命令:
lldb)幀信息
打印出當(dāng)前行數(shù):項目名-類名-函數(shù)名
其他功能參考參數(shù)后面的解釋
看完上面的命令,我們來看看編譯器調(diào)試常用的幾個按鈕
從圖中可以看出,調(diào)試有四個按鈕
如果遇到如圖所示的第一個繼續(xù),點擊它,程序?qū)⒄_\行。如果有其他斷點,您將跳轉(zhuǎn)到下一個斷點。
Ps:點擊它,在LLDB調(diào)試框中輸入
(lldb) process continue具有相同的功能。
C的效果是一樣的
當(dāng)?shù)诙皆跀帱c處暫停時,單擊此按鈕,程序?qū)⒅鹦袌?zhí)行。即使調(diào)用了函數(shù),也不會進(jìn)入函數(shù),而是直接跳過這個函數(shù)的執(zhí)行,如下圖所示:
在第115行命中一個斷點,然后點擊這個按鈕,他就會執(zhí)行第116行,然后點擊它執(zhí)行第117行,而不是執(zhí)行第116行調(diào)用的函數(shù)中的那一行。
Ps:在程序中,與此按鈕功能相同的LLDB命令的參數(shù)是相同的命令:
(lldb) n
(lldb)下一個
(lldb)線程跨越
效果是一樣的
第三步進(jìn)入。它是真正的逐行執(zhí)行命令。即使執(zhí)行了函數(shù),也會一行一行地跳轉(zhuǎn)到函數(shù)中執(zhí)行代碼。也就是說,想進(jìn)入功能的時候用。
Ps:在程序中,與此按鈕功能相同的LLDB命令的參數(shù)是相同的命令:
(lldb)線程介入
(lldb)步長
(lldb) s
第四步如果你輸入一個函數(shù),運行一兩行后如果你想跳過這個函數(shù),使用這個按鈕。其實它的操作就是一個棧的結(jié)束。
快速查看 Xcode 的所有斷點如圖所示,這是通過單擊查看項目文件中的所有斷點
然后使用LLDB命令查看所有斷點:
(lldb) br list或(lldb) br李燦也達(dá)到同樣的目的
通過調(diào)試器中的LLDB快速創(chuàng)建斷點
使用以下命令完成115個斷點的設(shè)置
(lldb)斷點集-f ViewController.swift -l 115
這時,當(dāng)我們執(zhí)行繼續(xù)按鈕時,我們會發(fā)現(xiàn)我們已經(jīng)跳到了第115行的斷點。
我們通過大名單來看B,它的介紹是:
使用幾種速記格式之一設(shè)置斷點。
設(shè)置斷點的命令是:
swift:127在127設(shè)置斷點
Xcode UI屏幕上的條件執(zhí)行斷點
如圖:
從圖中可以看出:
第一步:我們在第24行遇到了一個斷點。
步驟2:我們看到標(biāo)記為2的框,其中i==2表示當(dāng)I等于2時將執(zhí)行該斷點
步驟3:我們看到標(biāo)記為3的框,這意味著LLDB將在執(zhí)行這個斷點時執(zhí)行po i的命令
第四步:我們看到標(biāo)有4的盒子。當(dāng)I為2時,執(zhí)行斷點的打印操作
其中ignore表示斷點只在第一次執(zhí)行,例如,如果ignore設(shè)置為2,斷點將在第三次調(diào)用時觸發(fā)。
所以重點來了:斷點程序會比較函數(shù)被執(zhí)行的次數(shù)和斷點。然后比較條件,滿足條件后執(zhí)行LLDB命令語句
+號可以支持多個LLDB命令。
其他斷點條件和執(zhí)行的命令等等。
動作背后更多功能!
如圖:
1.阿普爾
蘋果的腳本語言,可以從這里開始運行
2.捕捉圖形處理器幀
Unity游戲調(diào)試。目前沒有研究
3.調(diào)試器命令
相當(dāng)于直接在LLDB上使用命令
4.日志消息
執(zhí)行斷點時,hello信息將直接打印在LLDB列中
5.外殼命令
如圖:
當(dāng)斷點被執(zhí)行時,計算機(jī)將讀取Hello world
6.聲音
選擇對應(yīng)的聲音,遇到斷點就發(fā)出對應(yīng)的聲音,也很有意思。
一些LLDB和控制臺插件,加上插件和腳本開發(fā),會大大提高開發(fā)效率。
只需設(shè)置一個斷點:
命令行輸入:(lldb)幫助
快速查詢所有命令列表
命令命令作用描述apropos-- List debugger commands related to a word or subject.(列出與某個單詞或主題相關(guān)的調(diào)試器命令。)breakpoint-- Commands for operating on breakpoints (see 'help b' for shorthand.)(斷點的相關(guān)操作,詳細(xì)看下面)bugreport-- Commands for creating domain-specific bug reports.(創(chuàng)建某個特點作用域的bug 命令)command-- Commands for managing custom LLDB commands.disassemble-- Disassemble specified instructions in the current target. Defaults to the current function for the current thread and stack frame.expression-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.(直接改變其值,點擊繼續(xù)運行)frame-- Commands for selecting and examing the current thread's stack frames.(通過命令來檢查當(dāng)前堆棧的相關(guān)信息。結(jié)合后面的命令參數(shù))gdb-remote-- Connect to a process via remote GDB server. If no host is specifed, localhost is assumed.gui-- Switch into the curses based GUI mode.help-- Show a list of all debugger commands, or give details about a specific command.kdp-remote-- Connect to a process via remote KDP server. If no UDP port is specified, port 41139 is assumed.language-- Commands specific to a source language.log-- Commands controlling LLDB internal logging.memory-- Commands for operating on memory in the current target process.platform-- Commands to manage and create platforms.plugin-- Commands for managing LLDB plugins.process-- Commands for interacting with processes on the current platform.(配合其包含的命令繼續(xù)執(zhí)行 執(zhí)行 process help即可看到)quit-- Quit the LLDB debugger.register-- Commands to access registers for the current thread and stack frame.-- Invoke the interpreter with provided code and display any results. Start the interactive interpreter if no code is supplied.settings-- Commands for managing LLDB settings.source-- Commands for examining source code described by debug information for the current target process.target-- Commands for operating on debugger targets.thread-- Commands for operating on one or more threads in the current process.(在當(dāng)前進(jìn)程中操作一個或多個線程的命令,結(jié)合其下面的參數(shù)進(jìn)行。下面有其搭配參數(shù)詳細(xì)說明)type-- Commands for operating on the type system.version-- Show the LLDB debugger version.(查看開發(fā)語言的版本)watchpoint-- Commands for operating on watchpoints.add-dsym-- Add a debug symbol file to one of the target's current modules by specifying a path to a debug symbols file, or using the options to specify a module to download symbols for.attach-- Attach to process by ID or name.b-- Set a breakpoint using one of several shorthand formats.bt-- Show the current thread's call stack. Any numeric argument displays at most that many frames. The argument 'all' displays all threads.c-- Continue execution of all threads in the current process.call-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.continue-- Continue execution of all threads in the current process.detach-- Detach from the current target process.di-- Disassemble specified instructions in the current target. Defaults to the current function for the current thread and stack frame.dis-- Disassemble specified instructions in the current target. Defaults to the current function for the current thread and stack frame.display-- Evaluate an expression at every stop (see 'help target stop-hook'.)down-- Select a newer stack frame. Defaults to moving one frame, a numeric argument can specify an arbitrary number.env-- Shorthand for viewing and setting environment variables.exit-- Quit the LLDB debugger.f-- Select the current stack frame by index from within the current thread (see 'thread backtrace'.)file-- Create a target using the argument as the main executable.finish-- Finish executing the current stack frame and stop after returning. Defaults to current thread unless specified.image-- Commands for accessing information for one or more target modules.j-- Set the program counter to a new address.jump-- Set the program counter to a new address.kill-- Terminate the current target process.l-- List relevant source code using one of several shorthand formats.list-- List relevant source code using one of several shorthand formats.n-- Source level single step, stepping over calls. Defaults to current thread unless specified.(相當(dāng)于一行一行的執(zhí)行函數(shù))next-- Source level single step, stepping over calls. Defaults to current thread unless specified.(與 n的作用幾乎一致)nexti-- Instruction level single step, stepping over calls. Defaults to current thread unless specified.ni-- Instruction level single step, stepping over calls. Defaults to current thread unless specified.p-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.(可以打印程序中相關(guān)參數(shù)的值,其屬性狀態(tài))parray-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.(與 p相同)po-- Evaluate an expression on the current thread. Displays any returned value with formatting controlled by the type's author.(與 p的區(qū)別是打印的值所帶的參數(shù)相對簡潔一點)poarray-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.(與 p相同)print-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.(與 p相同)q-- Quit the LLDB debugger.r-- Launch the executable in the debugger.rbreak-- Sets a breakpoint or set of breakpoints in the executable.repl-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.reveal_load_dev-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.reveal_load_sim-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.reveal_start-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.reveal_stop-- Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.run-- Launch the executable in the debugger.s-- Source level single step, stepping into calls. Defaults to current thread unless specified.(一步一步執(zhí)行,即使遇到函數(shù)也會進(jìn)入該函數(shù)一步一步執(zhí)行代碼)si-- Instruction level single step, stepping into calls. Defaults to current thread unless specified.sif-- Step through the current block, stopping if you step directly into a function whose name matches the TargetFunctionName.step-- Source level single step, stepping into calls. Defaults to current thread unless specified.stepi-- Instruction level single step, stepping into calls. Defaults to current thread unless specified.t-- Change the currently selected thread.tbreak-- Set a one-shot breakpoint using one of several shorthand formats.undisplay-- Stop displaying expression at every stop (specified by stop-hook index.)up-- Select an older stack frame. Defaults to moving one frame, a numeric argument can specify an arbitrary number.x-- Read from the memory of the current target process.1.《debug命令 # Xcode 編譯器調(diào)試命令(所有)》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識,僅代表作者本人觀點,與本網(wǎng)站無關(guān),侵刪請聯(lián)系頁腳下方聯(lián)系方式。
2.《debug命令 # Xcode 編譯器調(diào)試命令(所有)》僅供讀者參考,本網(wǎng)站未對該內(nèi)容進(jìn)行證實,對其原創(chuàng)性、真實性、完整性、及時性不作任何保證。
3.文章轉(zhuǎn)載時請保留本站內(nèi)容來源地址,http://f99ss.com/guonei/1221353.html