1
1
Tutorial
2
2
========
3
3
4
- This document describes how to use lldb if you are already familiar with
5
- gdb 's command set. We will start with some details on lldb command structure and
4
+ This document describes how to use LLDB if you are already familiar with
5
+ GDB 's command set. We will start with some details on LLDB command structure and
6
6
syntax.
7
7
8
8
Command Structure
9
9
-----------------
10
10
11
- Unlike gdb 's quite free-form commands, lldb 's are more structured. All commands
11
+ Unlike GDB 's quite free-form commands, LLDB 's are more structured. All commands
12
12
are of the form:
13
13
14
14
::
@@ -24,11 +24,11 @@ all commands. The command syntax for basic commands is very simple.
24
24
* Escape backslashes and double quotes within arguments should be escaped
25
25
with a backslash ``\ ``.
26
26
27
- This makes lldb 's commands more regular, but it also means you may have to quote
28
- some arguments in lldb that you would not in gdb .
27
+ This makes LLDB 's commands more regular, but it also means you may have to quote
28
+ some arguments in LLDB that you would not in GDB .
29
29
30
- There is one other special quote character in lldb - the backtick ``` ``.
31
- If you put backticks around an argument or option value, lldb will run the text
30
+ There is one other special quote character in LLDB - the backtick ``` ``.
31
+ If you put backticks around an argument or option value, LLDB will run the text
32
32
of the value through the expression parser, and the result of the expression
33
33
will be passed to the command. So for instance, if ``len `` is a local
34
34
``int `` variable with the value ``5 ``, then the command:
@@ -40,7 +40,7 @@ will be passed to the command. So for instance, if ``len`` is a local
40
40
Will receive the value ``5 `` for the count option, rather than the string ``len ``.
41
41
42
42
Options can be placed anywhere on the command line, but if the arguments begin
43
- with a ``- `` then you have to tell lldb that you are done with options for the
43
+ with a ``- `` then you have to tell LLDB that you are done with options for the
44
44
current command by adding an option termination: ``-- ``.
45
45
46
46
So for instance, if you want to launch a process and give the ``process launch ``
@@ -53,7 +53,7 @@ to launch to be launched with the arguments ``-program_arg value``, you would ty
53
53
54
54
We also tried to reduce the number of special purpose argument parsers, which
55
55
sometimes forces the user to be explicit about their intentions. The first
56
- instance you willl see of this is the breakpoint command. In gdb , to set a
56
+ instance you willl see of this is the breakpoint command. In GDB , to set a
57
57
breakpoint, you might enter:
58
58
59
59
::
@@ -71,17 +71,17 @@ from ``foo`` from ``foo.c::foo`` (which means the function ``foo`` in the file `
71
71
got more and more complex. Especially in C++ there are times where there is
72
72
really no way to specify the function you want to break on.
73
73
74
- The lldb commands are more verbose but also more precise and allow for
74
+ The LLDB commands are more verbose but also more precise and allow for
75
75
intelligent auto completion.
76
76
77
- To set the same file and line breakpoint in lldb you can enter either of:
77
+ To set the same file and line breakpoint in LLDB you can enter either of:
78
78
79
79
::
80
80
81
81
(lldb) breakpoint set --file foo.c --line 12
82
82
(lldb) breakpoint set -f foo.c -l 12
83
83
84
- To set a breakpoint on a function named ``foo `` in lldb you can enter either of:
84
+ To set a breakpoint on a function named ``foo `` in LLDB you can enter either of:
85
85
86
86
::
87
87
@@ -96,7 +96,7 @@ conditions or commands without having to specify them multiple times:
96
96
97
97
(lldb) breakpoint set --name foo --name bar
98
98
99
- Setting breakpoints by name is even more specialized in lldb as you can specify
99
+ Setting breakpoints by name is even more specialized in LLDB as you can specify
100
100
that you want to set a breakpoint at a function by method name. To set a
101
101
breakpoint on all C++ methods named ``foo `` you can enter either of:
102
102
@@ -125,7 +125,7 @@ The ``--shlib`` option can also be repeated to specify several shared libraries.
125
125
126
126
Suggestions on more interesting primitives of this sort are also very welcome.
127
127
128
- Just like gdb , the lldb command interpreter does a shortest unique string match
128
+ Just like GDB , the LLDB command interpreter does a shortest unique string match
129
129
on command names, so the following two commands will both execute the same
130
130
command:
131
131
@@ -134,12 +134,12 @@ command:
134
134
(lldb) breakpoint set -n "-[SKTGraphicView alignLeftEdges:]"
135
135
(lldb) br s -n "-[SKTGraphicView alignLeftEdges:]"
136
136
137
- lldb also supports command completion for source file names, symbol names, file
137
+ LLDB also supports command completion for source file names, symbol names, file
138
138
names, etc. Completion is initiated by hitting TAB. Individual options in a
139
139
command can have different completers, so for instance, the ``--file <path> ``
140
140
option in ``breakpoint `` completes to source files, the ``--shlib <path> `` option
141
141
to currently loaded shared libraries, etc. You can even do things like if you
142
- specify ``--shlib <path> ``, and are completing on ``--file <path> ``, lldb will only
142
+ specify ``--shlib <path> ``, and are completing on ``--file <path> ``, LLDB will only
143
143
list source files in the shared library specified by ``--shlib <path> ``.
144
144
145
145
The individual commands are pretty extensively documented. You can use the ``help ``
@@ -162,23 +162,23 @@ You can do:
162
162
(lldb) command alias bfl breakpoint set -f %1 -l %2
163
163
(lldb) bfl foo.c 12
164
164
165
- lldb has a few aliases for commonly used commands (e.g. ``step ``, ``next `` and
165
+ LLDB has a few aliases for commonly used commands (e.g. ``step ``, ``next `` and
166
166
``continue ``) but it does not try to be exhaustive because in our experience it
167
167
is more convenient to make the basic commands unique down to a letter or two,
168
168
and then learn these sequences than to fill the namespace with lots of aliases,
169
169
and then have to type them all the way out.
170
170
171
- However, users are free to customize lldb 's command set however they like, and
172
- since lldb reads the file ``~/.lldbinit `` at startup, you can store all your
171
+ However, users are free to customize LLDB 's command set however they like, and
172
+ since LLDB reads the file ``~/.lldbinit `` at startup, you can store all your
173
173
aliases there and they will be generally available to you. Your aliases are
174
174
also documented in the ``help `` command so you can remind yourself of what you have
175
175
set up.
176
176
177
- One alias of note that lldb does include by popular demand is a weak emulator of
178
- gdb 's ``break `` command. It does not try to do everything that gdb 's break command
177
+ One alias of note that LLDB does include by popular demand is a weak emulator of
178
+ GDB 's ``break `` command. It does not try to do everything that GDB 's break command
179
179
does (for instance, it does not handle ``foo.c::bar ``). But it mostly works, and
180
180
makes the transition easier. Also, by popular demand, it is aliased to ``b ``. If you
181
- actually want to learn the lldb command set natively, that means it will get in
181
+ actually want to learn the LLDB command set natively, that means it will get in
182
182
the way of the rest of the breakpoint commands. Fortunately, if you do not like
183
183
one of our aliases, you can easily get rid of it by running, for example:
184
184
@@ -192,9 +192,9 @@ You can also do:
192
192
193
193
(lldb) command alias b breakpoint
194
194
195
- So you can run the native lldb breakpoint command with just ``b ``.
195
+ So you can run the native LLDB breakpoint command with just ``b ``.
196
196
197
- The lldb command parser also supports "raw" commands, where, after command
197
+ The LLDB command parser also supports "raw" commands, where, after command
198
198
options are stripped off, the rest of the command string is passed
199
199
uninterpreted to the command. This is convenient for commands whose arguments
200
200
might be some complex expression that would be painful to backslash protect.
@@ -205,17 +205,17 @@ commands still can have options, if your command string has dashes in it,
205
205
you will have to indicate these are not option markers by putting ``-- `` after the
206
206
command name, but before your command string.
207
207
208
- lldb also has a built-in Python interpreter, which is accessible by the
208
+ LLDB also has a built-in Python interpreter, which is accessible by the
209
209
``"script `` command. All the functionality of the debugger is available as classes
210
- in the Python interpreter, so the more complex commands that in gdb you would
210
+ in the Python interpreter, so the more complex commands that in GDB you would
211
211
introduce with the ``define `` command can be done by writing Python functions
212
- using the lldb- Python library, then loading the scripts into your running
212
+ using the LLDB Python library, then loading the scripts into your running
213
213
session and accessing them with the ``script `` command.
214
214
215
- Loading a Program Into lldb
215
+ Loading a Program Into LLDB
216
216
---------------------------
217
217
218
- First you need to set the program to debug. As with gdb , you can start lldb and
218
+ First you need to set the program to debug. As with GDB , you can start LLDB and
219
219
specify the file you wish to debug on the command line:
220
220
221
221
::
@@ -273,16 +273,16 @@ address it corresponds to gets loaded into the program you are debugging. For
273
273
instance if you set a breakpoint in a shared library that then gets unloaded,
274
274
that breakpoint location will remain, but it will no longer be resolved.
275
275
276
- One other thing to note for gdb users is that lldb acts like gdb with:
276
+ One other thing to note for GDB users is that LLDB acts like GDB with:
277
277
278
278
::
279
279
280
280
(gdb) set breakpoint pending on
281
281
282
- Which means that lldb will always make a breakpoint from your specification, even if it
282
+ Which means that LLDB will always make a breakpoint from your specification, even if it
283
283
could not find any locations that match the specification. You can tell whether
284
284
the expression was resolved or not by checking the locations field in
285
- ``breakpoint list ``, and lldb reports the breakpoint as ``pending `` when you set it so
285
+ ``breakpoint list ``, and LLDB reports the breakpoint as ``pending `` when you set it so
286
286
you can tell you have made a typo more easily, if that was indeed the reason no
287
287
locations were found:
288
288
@@ -304,12 +304,12 @@ command to print a backtrace when you hit this breakpoint you could do:
304
304
> bt
305
305
> DONE
306
306
307
- By default, the breakpoint command add command takes lldb command line
307
+ By default, the breakpoint command add command takes LLDB command line
308
308
commands. You can also specify this explicitly by passing the ``--command ``
309
309
option. Use ``--script `` if you want to implement your breakpoint command using
310
310
the Python script instead.
311
311
312
- This is a convenient point to bring up another feature of the lldb command
312
+ This is a convenient point to bring up another feature of the LLDB command
313
313
``help ``. Do:
314
314
315
315
::
@@ -447,7 +447,7 @@ a variable called ``global`` for write operation, but only stop if the condition
447
447
Starting or Attaching to Your Program
448
448
-------------------------------------
449
449
450
- To launch a program in lldb you will use the ``process launch `` command or one of
450
+ To launch a program in LLDB you will use the ``process launch `` command or one of
451
451
its built in aliases:
452
452
453
453
::
@@ -457,7 +457,7 @@ its built in aliases:
457
457
(lldb) r
458
458
459
459
You can also attach to a process by process ID or process name. When attaching
460
- to a process by name, lldb also supports the ``--waitfor `` option which waits for
460
+ to a process by name, LLDB also supports the ``--waitfor `` option which waits for
461
461
the next process that has that name to show up, and attaches to it
462
462
463
463
::
@@ -497,49 +497,49 @@ for process control all exist under the "thread" command:
497
497
498
498
At present you can only operate on one thread at a time, but the design will
499
499
ultimately support saying "step over the function in Thread 1, and step into the
500
- function in Thread 2, and continue Thread 3" etc. When lldb eventually supports
500
+ function in Thread 2, and continue Thread 3" etc. When LLDB eventually supports
501
501
keeping some threads running while others are stopped this will be particularly
502
502
important. For convenience, however, all the stepping commands have easy aliases.
503
503
So ``thread continue `` is just ``c ``, etc.
504
504
505
- The other program stepping commands are pretty much the same as in gdb . You have got:
505
+ The other program stepping commands are pretty much the same as in GDB . You have got:
506
506
507
507
::
508
508
509
- (lldb) thread step-in // The same as gdb 's "step" or "s"
510
- (lldb) thread step-over // The same as gdb 's "next" or "n"
511
- (lldb) thread step-out // The same as gdb 's "finish" or "f"
509
+ (lldb) thread step-in // The same as GDB 's "step" or "s"
510
+ (lldb) thread step-over // The same as GDB 's "next" or "n"
511
+ (lldb) thread step-out // The same as GDB 's "finish" or "f"
512
512
513
- By default, lldb does defined aliases to all common gdb process control commands
514
- (``s ``, ``step ``, ``n ``, ``next ``, ``finish ``). If lldb is missing any, please add
513
+ By default, LLDB does defined aliases to all common GDB process control commands
514
+ (``s ``, ``step ``, ``n ``, ``next ``, ``finish ``). If LLDB is missing any, please add
515
515
them to your ``~/.lldbinit `` file using the ``command alias `` command.
516
516
517
- lldb also supports the step by instruction versions:
517
+ LLDB also supports the step by instruction versions:
518
518
519
519
::
520
520
521
521
522
- (lldb) thread step-inst // The same as gdb 's "stepi" / "si"
523
- (lldb) thread step-over-inst // The same as gdb 's "nexti" / "ni"
522
+ (lldb) thread step-inst // The same as GDB 's "stepi" / "si"
523
+ (lldb) thread step-over-inst // The same as GDB 's "nexti" / "ni"
524
524
525
- Finally, lldb has a run until line or frame exit stepping mode:
525
+ Finally, LLDB has a run until line or frame exit stepping mode:
526
526
527
527
::
528
528
529
529
(lldb) thread until 100
530
530
531
531
This command will run the thread in the current frame until it reaches line 100
532
532
in this frame or stops if it leaves the current frame. This is a pretty close
533
- equivalent to gdb 's ``until `` command.
533
+ equivalent to GDB 's ``until `` command.
534
534
535
- A process, by default, will share the lldb terminal with the inferior process.
536
- When in this mode, much like when debugging with gdb , when the process is
535
+ A process, by default, will share the LLDB terminal with the inferior process.
536
+ When in this mode, much like when debugging with GDB , when the process is
537
537
running anything you type will go to the ``STDIN `` of the inferior process. To
538
538
interrupt your inferior program, type ``CTRL+C ``.
539
539
540
540
If you attach to a process, or launch a process with the ``--no-stdin `` option,
541
541
the command interpreter is always available to enter commands. It might be a
542
- little disconcerting to gdb users to always have an ``(lldb) `` prompt. This allows
542
+ little disconcerting to GDB users to always have an ``(lldb) `` prompt. This allows
543
543
you to set a breakpoint, or use any other command without having to explicitly
544
544
interrupt the program you are debugging:
545
545
@@ -563,16 +563,16 @@ and memory reading and writing (``memory [read|write] ...``).
563
563
The question of disabling stdio when running brings up a good opportunity to
564
564
show how to set debugger properties. If you always want to run in
565
565
the ``--no-stdin `` mode, you can set this as a generic process property using the
566
- lldb ``settings `` command, which is equivalent to gdb 's ``set `` command.
566
+ LLDB ``settings `` command, which is equivalent to GDB 's ``set `` command.
567
567
In this case you would say:
568
568
569
569
::
570
570
571
571
(lldb) settings set target.process.disable-stdio true
572
572
573
- Over time, gdb 's ``set `` command became a wilderness of disordered options, so
574
- that there were useful options that even experienced gdb users did not know
575
- about because they were too hard to find. lldb instead organizes the settings
573
+ Over time, GDB 's ``set `` command became a wilderness of disordered options, so
574
+ that there were useful options that even experienced GDB users did not know
575
+ about because they were too hard to find. LLDB instead organizes the settings
576
576
hierarchically using the structure of the basic entities in the debugger. For
577
577
the most part anywhere you can specify a setting on a generic entity (threads,
578
578
for example) you can also apply the option to a particular instance. You can
@@ -582,7 +582,7 @@ on the settings command explaining how it works more generally.
582
582
Examining Thread State
583
583
----------------------
584
584
585
- Once you have stopped, lldb will choose a current thread, usually the one that
585
+ Once you have stopped, LLDB will choose a current thread, usually the one that
586
586
stopped "for a reason", and a current frame in that thread (on stop this is
587
587
always the bottom-most frame). Many the commands for inspecting state work on
588
588
this current thread/frame.
@@ -685,7 +685,7 @@ pointers as arrays:
685
685
(char const *) argv[0] = 0x00007fff5fbffaf8 "/Projects/Sketch/build/Debug/Sketch.app/Contents/MacOS/Sketch"
686
686
687
687
The frame variable command will also perform "object printing" operations on
688
- variables (currently lldb only supports ObjC printing, using the object's
688
+ variables (currently LLDB only supports ObjC printing, using the object's
689
689
``description `` method. Turn this on by passing the ``-o `` flag to frame variable:
690
690
691
691
::
@@ -697,4 +697,4 @@ variables (currently lldb only supports ObjC printing, using the object's
697
697
frame #9: 0x0000000100015ae3, where = Sketch`function1 + 33 at /Projects/Sketch/SKTFunctions.m:11
698
698
699
699
You can also move up and down the stack by passing the ``--relative `` (``-r ``) option.
700
- We also have built-in aliases ``u `` and ``d `` which behave like their gdb equivalents.
700
+ We also have built-in aliases ``u `` and ``d `` which behave like their GDB equivalents.
0 commit comments