Previous debugging with the compiler used just a few normal debugging commands at a time. But as a rule of thumb, today I’m going toAll debugging commands
And the functions are listed.
Language song blog
Summary at the end:
The following are examples of common and important commands:
Here's a more detailed demonstration
If you want to learn more about compiler debugging commands: portals
Let’s look at some common debugging commands:
1.apropos
Lists debugger commands related to a word or topic. e.g (lldb) apropos po
2.breakpoint
See the screenshot documentation: (LLDB) BreakPoint
Br is very powerful, as described below
3.breakpoint
important
4.print
(LLDB) print sums can be abbreviated to (LLDB) p sums
Var sums = ["0.00","0.00","0.00","0.00"]Copy the code
The debugging window looks like this:
(LLDB) print sums ([String]) $R14 = 4 values {[0] = "0.00" [1] = "0.00" [2] = "0.00" [3] = "0.00"}Copy the code
If you want to print base numbers on the command line:
The input parameters | Representation base (LLDB) |
---|---|
p/x 66 | (x indicates hexadecimal)(Int) $R17 = 0x0000000000000042 |
p/t 6 | (t 2 hexadecimal) (Int) $b0000000000000000000000000000000000000000000000000000000000000110 R20 = 0 |
p/c “s” | $R24 = “s” $R24 = “s” |
5.expression
Directly change its value, click continue to run, run the result is the result of this assignment
= (LLDB) expression sums [" 10.00 ", "0.00", "0.00", "0.00"]Copy the code
Example:
More uses: To print the sums in object style: expression -o — sums can be simply written like this: e-o — sums
E-o — sums can be written Po and the sums are equivalent.
process
The commands that interact with the process, of course, are executed with the following parameters to achieve the corresponding purpose (LLDB) process help as follows:
Continue — continue execution of all threads in the current process.
When a breakpoint is hit, executing in the LLDB means continuing to execute the program
thread
The commands that interact with the process, of course, are executed with the following parameters to achieve the corresponding purpose (LLDB) thread help:
The function of its accompanying parameter command execution is described quite clearly later. Here are a few highlights:
** * '(LLDB) thread return' ** Returns from the stack prematurely and executes the return command to exit the current stack. You can disguise some return information and so on. From writing the behavior of some function and so on.Copy the code
frame
Also with its parameters to complete debugging
lldb) frame info
Project name
The class name
The function name
Number of rows
Having looked at the commands above, let’s take a look at some compiler debuggingCommonly used button
You can see the four buttons for debugging
-
The first “continue” is clicked as shown in the figure, and the program runs normally. If there are other breakpoints, it jumps to the next one.
Ps: Clicking on it is the same as typing process Continue in the LLDB debug box. The effect of c is the same
-
Click the button and the program will be executed line by line. Even if the function is called, the program will not enter the function, but directly skip the execution of the function, as shown in the following figure:
在
115
Line hits a breakpoint, then clicks the button and it executes116
Ok, and then it will execute117
Line, not execute116
The function calledThe inside of the line.
ps: has the same effect as this button in the programLLDB
The command parameters are the same.(lldb) n
(lldb) next
(lldb) thread step-over
The effect is the same -
The third step into. It is the execution of commands line by line in the real sense. Even when a function is executed, it will jump into the function to execute the code line by line. Ps: the LLDB command has the same parameters as this button in the program. The command is: (LLDB) thread step-in (LLDB) step (LLDB) s
- The fourth step out is if you get into a function, and after a line or two you want to skip that function you use this button. In fact, its run is the end of a stack.
Take a quick look at all breakpoints in Xcode
This is done by clicking to see all the breakpoints in the project file
The LLDB command is used to view all breakpoints: (LLDB) br list or (LLDB) br li can do the same
Pass in the debuggerLLDB
Create breakpoints quickly
Breakpoint set -f viewController.swift -l 115 breakpoint set -f viewController.swift -l 115
Set a breakpoint using one of several shorthand formats
The command to set the breakpoint is: (LLDB) b viewController.swift :127 The breakpoint is set at 127
Conditional execution on Xcode UI screenThe breakpoint
As shown in figure:
As can be seen from the picture:
Step 1: We hit a break point at line 24.
Step 2: We see the box marked 2, where I ==2 indicates that the breakpoint will be executed when I is equal to 2
Step 3: We see the box marked 3, where the LLDB will execute Po I when the breakpoint is executed
Step 4: We see the box marked 4, which prints the breakpoint when I is 2
Ignore indicates the number of times the breakpoint is actually executed. For example, if ignore is set to 2, the breakpoint is triggered on the third call.
The point here is that the breakpoint program first compares the number of times the function executes to the breakpoint. The LLDB command is executed after the conditions are met
The + sign can support multiple LLDB commands.
Other breakpoint conditions and commands executed, and so on.
Action
More on the back!
As shown in figure:
1.AppleScript
Apple’s scripting language, where you can start running
2.Capture GPU Frame
Debugging Unity games. No research for now 😄
3.Debugger Command
This is equivalent to using commands directly on the LLDB
4.Log Message
The LLDB bar will print the hello message when the breakpoint is reached
5.Shell Command
As shown in figure:
Hello world
6.Sound
It’s also interesting to select the sound that makes the sound when you hit the breakpoint.
Some of theLLDBAnd console plug-in, with plug-in and script development will greatly improve the development efficiency.
chisel
Rainbow
…
Type: (LLDB) help
This section describes how to quickly query all commands
The command | Command Function Description | |||
---|---|---|---|---|
apropos | — List debugger commands related to a word or subject. | |||
breakpoint | — Commands for operating on breakpoints (see ‘help B ‘for breakpoints.) | |||
bugreport | — Commands for Creating domain-specific bug reports. | |||
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 (Directly change their values, click to continue) | |||
frame | Commands for selecting and examing the current thread’s stack frames. Commands for selecting and examing the current thread’s stack frames. Combined with command arguments) | |||
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 processes on the current platformprocess help Can be seen) |
|||
quit | — Quit the LLDB debugger. | |||
register | — Commands to access registers for the current thread and stack frame. | |||
script | — Invoke the script 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, combined with the parameters below. The following is a detailed description of its collocation parameters.) | |||
type | — Commands for operating on the type system. | |||
version | — Show the LLDB debugger version. | |||
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. | |||
next | — Source level single step, stepping over calls. Defaults to current thread unless specifiednAlmost the same effect) | |||
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 (Can print the values of related parameters in the program, their attribute status) | |||
parray | — Evaluate an expression on the current thread. Displays any returned value with LLDB’s default formattingpThe same) | |||
po | — Evaluate an expression on the current thread. Displays any returned value with formatting controlled by the type’s Author. (withpThe difference is that the printed values take relatively concise arguments.) | |||
poarray | — Evaluate an expression on the current thread. Displays any returned value with LLDB’s default formattingpThe same) | |||
— Evaluate an expression on the current thread. Displays any returned value with LLDB’s default formattingpThe same) | ||||
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. Even if it encounters a function, it will enter that function and execute the code step by step.) | |||
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. | |||