# Xcode compiler debugging command (all)

# Xcode compiler debugging command (all)
BK

Before using compiler debugging, each time you only used a few regular debugging commands. However, in accordance with the principle of “tossing and turning”, today all the debugging commands and functions are listed.

Song blog

In the final table at a glance:

Below are examples of common, more important commands:

There is a more detailed demonstration below

If you want to learn more about the compiler debugging commands: the portal

Next, look at the usual debugging command usage:

1.apropos

Lists debugger commands that are relevant to a word or topic.
, e.g,
(lldb), apropos, Po,

# Xcode compiler debugging command (all)
appropos

2.breakpoint

See screenshot documentation:
(lldb) breakpoint

# Xcode compiler debugging command (all)
breakPoint

Can be abbreviated as “br
“, the function is very powerful, there is a detailed description below

3.breakpoint

important

4.print

(lldb) print sums can be abbreviated as (lldb) P sums
: print is written as p

The code says: "VaR, sums = [0]," 0 "," 0 "," 0 "]

Debug window:
results:

(lldb) print, sums ([String]), $R14 = 4, values, {[0] = 0, [1] = 0, [2] = 0, [3] = ` 0 '}

If you want to print the hexadecimal number on the command line:

input parameter Represents the decimal number (e.g)
P/x 66 (x stands for 16 hexadecimal) (Int) $R17 = 0x0000000000000042
P/t 6 (t stands for 2 hexadecimal) (Int) $R20 = 0b0000000000000000000000000000000000000000000000000000000000000110
P/c “s”” (C stands for characters) (String) $R24 = ‘s'”

5.expression

Change its value directly, click continue, and the result is the result of this assignment

(lldb) expression, sums = [10, 0, 0, 0]

Example:

# Xcode compiler debugging command (all)
expression

More usage:
prints in object mode:
, expression, -o – sums can be abbreviated as this: e -o – sums

Among them:
, e, -o – sums can be written as po, and the effect is equivalent.

Process

The commands that interact with the process, of course, are matched with the parameters behind them to achieve the corresponding goal execution (lldb) process help as follows:

# Xcode compiler debugging command (all)
process

Take a common Chestnut:
continue – Continue execution of all threads in the current process.

Is to continue with the program. When a breakpoint is encountered, execution in LLDB is the continuation of the program

Thread

The command that interacts with the process, of course, is to match the parameters behind it to achieve the corresponding goal execution (lldb) thread help as follows:

# Xcode compiler debugging command (all)
thread

The collocation of the parameters command execution is described quite clearly later.
, here’s a couple of highlights:

**` * (lldb) thread return`** early returns from the stack, immediately return command, exit the current stack. You can disguise some return information and so on. From writing some function to behavior, etc..

Frame

The same is done with its parameters to debug

# Xcode compiler debugging command (all)
frame

is a commonly used commands:
lldb) frame info
: print out the current engineering name – the class name – the name of the function – where the line number
other reference of the following explanation

After reading the commands above, take a look at several common buttons for compiler debugging

# Xcode compiler debugging command (all)
lldb

As you can see from the diagram, 4 buttons for debugging

  1. The first continue as shown in figure, click after the program is running, if there are other breakpoints, will jump to the next breakpoint. Ps: click on it and debug in LLDB box input
    (lldb) process continue is the same. The effect of
    C is the same
  2. Second step over when a breakpoint after a pause, click the button the program will be a row of execution, even in the face of the function call can not enter the function to go inside, but skip the execution of the function, as shown below: # Xcode compiler debugging command (all)
    stepOve
    hit a breakpoint in the 115 row, and then click the the button, he will perform in 116 rows, and then click after the execution of 117 lines, and not to the implementation of the 116 call to a function of the inside of the line. The
    ps: LLDB command parameters in the program with the same button is the same as the order is:
    (lldb) n
    (lldb) next
    (lldb) thread step-over
    effect is the same
  3. Third step into., it is the real line, line of executive command, even if the implementation of the function, but also jump into the function inside, to line by line of execution of code. That is to say you want to enter the LLDB command parameters inside the function with it
    ps: in the program with the same button is the same as the order is:
    (lldb) thread step-in
    (lldb) step
    (lldb) s
  4. Fourth step out. If you enter a function and run one or two rows, you want to skip that function, using this button. In fact, its operation is the end of a stack.

Quick view of all breakpoints in Xcode

As shown, this is done by clicking on all breakpoints in the project file

# Xcode compiler debugging command (all)
everyBreak

Then, through the LLDB command to see all breakpoints:
(lldb), Br, list, or (lldb) Br Li can achieve the same purpose

Quickly create breakpoints through the LLDB in the debugger

Use the following command to complete set line breakpoints of
115 (lldb) breakpoint set -f ViewController.swift -l 115
this time we perform the Continue button will find the jump to the 115 line breakpoint.

We look at B through a large list of
Set, a, breakpoint, using, one, of, formats., several, shorthand, and so on

The breakpoint setting command is
(lldb) B ViewController.swift:127, and breakpoints are set at 127

Conditional execution breakpoints on the Xcode UI screen

As shown:

# Xcode compiler debugging command (all)
UIdebug

Can see from:

The first step: we hit a breakpoint at line 24.

The second step: we see the frame of Mark 2, where i==2 means that the breakpoint is executed when I equals 2

The third step: we see the frame of Mark 3, which means that when you execute this breakpoint, LLDB will execute the command Po I

The fourth step: we see the frame of Mark 4, which performs the print operation of the breakpoint when I is 2

Where ignore indicates how many times the breakpoint will actually execute, such as setting ignore to 2, then the breakpoint will be triggered at the third call.

So here’s the point: the breakpoint program compares the number of times the function executes to the breakpoint. Then compare the conditions and execute the LLDB command statement when the condition is satisfied

The + number can support multiple LLDB commands.

Other breakpoint conditions and executed commands, in turn, by analogy.

More function behind Action!

As shown in Figure:

# Xcode compiler debugging command (all)
action

1.AppleScript

A scripting language for apple can start running here

2.Capture GPU Frame

Unity game debugging. There is no research on

3.Debugger Command

Equivalent to using commands directly on LLDB

4.Log Message

# Xcode compiler debugging command (all)
log

When this breakpoint is executed, the Hello message is printed directly in the LLDB column

5.Shell Command

As shown in Figure:

# Xcode compiler debugging command (all)
say

when the breakpoint is executed, the computer reads Hello world

6.Sound

Select the corresponding sound, the breakpoint will be issued corresponding sound, it is also very interesting.

Some LLDB and console plug-ins, along with plug-ins and scripting development, will greatly improve development efficiency.

Chisel
Rainbow

Just break a breakpoint:
command line input: (lldb) help

Quick query, so command list

command Command action description
Apropos — List debugger, commands, related, to, a, word, or, subject.. Lists the debugger commands associated with a word or topic. )
Breakpoint – Commands, for, operating, on, breakpoints (see,’help, B’, for, shorthand.) (breakpoint related operations, see below)
Bugreport — Commands, for, creating, domain-specific, bug, reports. (bug command for creating a feature scope)
Command — Commands, for, managing, custom, LLDB, commands.
Disassemble — Disassemble, specified, instructions, in, the, current, Defaults, to, the, target., current, function, for, the,, current, thread, frame., and, stack
Expression — Evaluate an, expression, on, the, current, thread., Displays, any, returned, value, with, LLDB’s,, default, formatting. (change its value directly, click Continue)
Frame — Commands for, selecting, and, examing, the, current, thread’s, stack, frames. (through the command to check the current stack of relevant information). Combine command parameters in the back
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,, 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, help, on, the, current, platform. (with the commands included, continue, process, you can see)
Quit – Quit, the, LLDB, debugger.
Register — Commands, to, access, registers, for, the, current,, thread, and, stack, frame.
Script — Invoke, the, script, interpreter, with, provided, and, display, any, results., Start, code, the, interactive, interpreter,, if, no, supplied., code, is
Settings – Commands, for, managing, LLDB, settings.
Source – Commands, for, examining, source, code, described, by, debug, information,, for, the, current, process., target
Target — Commands, for, operating, on, debugger, targets.
Thread — Commands for operating on one or more threads in the current process. (the command to operate one or more threads in the current process, combined with the following arguments. Here’s a detailed description of the collocation parameters.)
Type — Commands, for, operating, on, the, type, system.
Version – Show, the, LLDB, debugger, version. (see version of development language)
Watchpoint – Commands, for, operating, on, watchpoints.
Add-dsym — Add, a, debug, symbol, to, one, of, target’s, current, modules, by, specifying, path, to, a, debug, symbols, file, or, using, the, options, a, to, specify,, a, module, the, to, file, download, for., symbols
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, Any, numeric, argument, displays, at, most, that, stack., many, frames., The,, argument,’all’, threads., displays, all
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, formatting., default
Continue – Continue, execution, of, all, threads, in,, the, current, process.
Detach — Detach, from, the, current, target, process.
Di — Disassemble, specified, instructions, in, the, current, Defaults, to, the, target., current, function, for, the,, current, thread, frame., and, stack
Dis — Disassemble, specified, instructions, in, the, current, Defaults, to, the, target., current, function, for, the,, current, thread, frame., and, stack
Display — Evaluate, an, expression, at, every, stop, (see,’help, target, stop-hook’.)
Down — Select, a, newer, stack, frame., to, moving, one, frame, a, numeric, argument, Defaults, 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, specified., unless
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, specified., unless, (as a function of a line or line)
Next — Source, level, single, step, stepping, over, calls., Defaults, to, current, N, thread, unless, specified. (almost the same as the function of)
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. (you can print the values of the relevant parameters in your program, its attribute status)
PArray — Evaluate, an, expression, on, the, current, thread., Displays, any, returned, value, P, with, LLDB’s, default, formatting. (the same as)
Po — the Evaluate an expression on the current thread. Displays any returned p value with formatting controlled the by type’s author. (and the difference from that is the print value, with a relatively simple parameter)
Poarray — Evaluate, an, expression, on, the, current, thread., Displays, any, returned, value, P, with, LLDB’s, default, formatting. (the same as)
Print — Evaluate, an, expression, on, the, current, thread., Displays, any, returned, value, P, with, LLDB’s, default, formatting. (the same as)
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, formatting., default
Reveal_load_dev — Evaluate, an, expression, on, the, current, thread., Displays, any, returned,, value, with, LLDB’s, formatting., default
Reveal_load_sim — Evaluate, an, expression, on, the, current, thread., Displays, any, returned,, value, with, LLDB’s, formatting., default
Reveal_start — Evaluate, an, expression, on, the, current, thread., Displays, any, returned,, value, with, LLDB’s, formatting., default
Reveal_stop — Evaluate, an, expression, on, the, current, thread., Displays, any, returned,, value, with, LLDB’s, formatting., default
Run — Launch, the, executable, in, the, debugger.
S — Source, level, single, step, stepping, into, calls., Defaults, to, current,, thread, unless, specified., step by step, even if the function is encountered, the code is executed 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, TargetFunctionName., matches, the
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., to, moving, one, frame, a, numeric, argument, Defaults, can, specify,, an, arbitrary, number.
X – Read, from, the, memory, of, the,, current, target, process.