xref: /freebsd-src/contrib/llvm-project/lldb/docs/man/lldb.rst (revision 480093f4440d54b30b3025afeac24b48f2ba7a2e)
1*480093f4SDimitry Andric:orphan:
2*480093f4SDimitry Andric
3*480093f4SDimitry Andriclldb -- The Debugger
4*480093f4SDimitry Andric====================
5*480093f4SDimitry Andric
6*480093f4SDimitry Andric.. program:: lldb
7*480093f4SDimitry Andric
8*480093f4SDimitry AndricSYNOPSIS
9*480093f4SDimitry Andric--------
10*480093f4SDimitry Andric
11*480093f4SDimitry Andric| :program:`lldb` [*options*] *executable*
12*480093f4SDimitry Andric
13*480093f4SDimitry AndricDESCRIPTION
14*480093f4SDimitry Andric-----------
15*480093f4SDimitry Andric
16*480093f4SDimitry Andric:program:`lldb` is a next generation, high-performance debugger. It is built as
17*480093f4SDimitry Andrica set of reusable components which highly leverage existing libraries in the
18*480093f4SDimitry Andriclarger LLVM Project, such as the Clang expression parser and LLVM disassembler.
19*480093f4SDimitry Andric
20*480093f4SDimitry Andric:program:`lldb` is the default debugger in Xcode on macOS and supports
21*480093f4SDimitry Andricdebugging C, Objective-C and C++ on the desktop and iOS devices and simulator.
22*480093f4SDimitry Andric
23*480093f4SDimitry AndricAll of the code in the LLDB project is available under the Apache 2.0 License
24*480093f4SDimitry Andricwith LLVM exceptions.
25*480093f4SDimitry Andric
26*480093f4SDimitry AndricATTACHING
27*480093f4SDimitry Andric---------
28*480093f4SDimitry Andric
29*480093f4SDimitry Andric.. option:: --attach-name <name>
30*480093f4SDimitry Andric
31*480093f4SDimitry Andric Tells the debugger to attach to a process with the given name.
32*480093f4SDimitry Andric
33*480093f4SDimitry Andric.. option:: --attach-pid <pid>
34*480093f4SDimitry Andric
35*480093f4SDimitry Andric Tells the debugger to attach to a process with the given pid.
36*480093f4SDimitry Andric
37*480093f4SDimitry Andric.. option:: -n <value>
38*480093f4SDimitry Andric
39*480093f4SDimitry Andric Alias for --attach-name
40*480093f4SDimitry Andric
41*480093f4SDimitry Andric.. option:: -p <value>
42*480093f4SDimitry Andric
43*480093f4SDimitry Andric Alias for --attach-pid
44*480093f4SDimitry Andric
45*480093f4SDimitry Andric.. option:: --wait-for
46*480093f4SDimitry Andric
47*480093f4SDimitry Andric Tells the debugger to wait for a process with the given pid or name to launch before attaching.
48*480093f4SDimitry Andric
49*480093f4SDimitry Andric.. option:: -w
50*480093f4SDimitry Andric
51*480093f4SDimitry Andric Alias for --wait-for
52*480093f4SDimitry Andric
53*480093f4SDimitry AndricCOMMANDS
54*480093f4SDimitry Andric--------
55*480093f4SDimitry Andric
56*480093f4SDimitry Andric.. option:: --batch
57*480093f4SDimitry Andric
58*480093f4SDimitry Andric Tells the debugger to run the commands from -s, -S, -o & -O, and then quit.
59*480093f4SDimitry Andric
60*480093f4SDimitry Andric.. option:: -b
61*480093f4SDimitry Andric
62*480093f4SDimitry Andric Alias for --batch
63*480093f4SDimitry Andric
64*480093f4SDimitry Andric.. option:: -K <value>
65*480093f4SDimitry Andric
66*480093f4SDimitry Andric Alias for --source-on-crash
67*480093f4SDimitry Andric
68*480093f4SDimitry Andric.. option:: -k <value>
69*480093f4SDimitry Andric
70*480093f4SDimitry Andric Alias for --one-line-on-crash
71*480093f4SDimitry Andric
72*480093f4SDimitry Andric.. option:: --local-lldbinit
73*480093f4SDimitry Andric
74*480093f4SDimitry Andric Allow the debugger to parse the .lldbinit files in the current working directory, unless --no-lldbinit is passed.
75*480093f4SDimitry Andric
76*480093f4SDimitry Andric.. option:: --no-lldbinit
77*480093f4SDimitry Andric
78*480093f4SDimitry Andric Do not automatically parse any '.lldbinit' files.
79*480093f4SDimitry Andric
80*480093f4SDimitry Andric.. option:: --one-line-before-file <command>
81*480093f4SDimitry Andric
82*480093f4SDimitry Andric Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded.
83*480093f4SDimitry Andric
84*480093f4SDimitry Andric.. option::  --one-line-on-crash <command>
85*480093f4SDimitry Andric
86*480093f4SDimitry Andric When in batch mode, tells the debugger to run this one-line lldb command if the target crashes.
87*480093f4SDimitry Andric
88*480093f4SDimitry Andric.. option:: --one-line <command>
89*480093f4SDimitry Andric
90*480093f4SDimitry Andric Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded.
91*480093f4SDimitry Andric
92*480093f4SDimitry Andric.. option:: -O <value>
93*480093f4SDimitry Andric
94*480093f4SDimitry Andric Alias for --one-line-before-file
95*480093f4SDimitry Andric
96*480093f4SDimitry Andric.. option:: -o <value>
97*480093f4SDimitry Andric
98*480093f4SDimitry Andric Alias for --one-line
99*480093f4SDimitry Andric
100*480093f4SDimitry Andric.. option:: -Q
101*480093f4SDimitry Andric
102*480093f4SDimitry Andric Alias for --source-quietly
103*480093f4SDimitry Andric
104*480093f4SDimitry Andric.. option:: --source-before-file <file>
105*480093f4SDimitry Andric
106*480093f4SDimitry Andric Tells the debugger to read in and execute the lldb commands in the given file, before any file has been loaded.
107*480093f4SDimitry Andric
108*480093f4SDimitry Andric.. option:: --source-on-crash <file>
109*480093f4SDimitry Andric
110*480093f4SDimitry Andric When in batch mode, tells the debugger to source this file of lldb commands if the target crashes.
111*480093f4SDimitry Andric
112*480093f4SDimitry Andric.. option:: --source-quietly
113*480093f4SDimitry Andric
114*480093f4SDimitry Andric Tells the debugger to execute this one-line lldb command before any file has been loaded.
115*480093f4SDimitry Andric
116*480093f4SDimitry Andric.. option:: --source <file>
117*480093f4SDimitry Andric
118*480093f4SDimitry Andric Tells the debugger to read in and execute the lldb commands in the given file, after any file has been loaded.
119*480093f4SDimitry Andric
120*480093f4SDimitry Andric.. option:: -S <value>
121*480093f4SDimitry Andric
122*480093f4SDimitry Andric Alias for --source-before-file
123*480093f4SDimitry Andric
124*480093f4SDimitry Andric.. option:: -s <value>
125*480093f4SDimitry Andric
126*480093f4SDimitry Andric Alias for --source
127*480093f4SDimitry Andric
128*480093f4SDimitry Andric.. option:: -x
129*480093f4SDimitry Andric
130*480093f4SDimitry Andric Alias for --no-lldbinit
131*480093f4SDimitry Andric
132*480093f4SDimitry AndricOPTIONS
133*480093f4SDimitry Andric-------
134*480093f4SDimitry Andric
135*480093f4SDimitry Andric.. option:: --arch <architecture>
136*480093f4SDimitry Andric
137*480093f4SDimitry Andric Tells the debugger to use the specified architecture when starting and running the program.
138*480093f4SDimitry Andric
139*480093f4SDimitry Andric.. option:: -a <value>
140*480093f4SDimitry Andric
141*480093f4SDimitry Andric Alias for --arch
142*480093f4SDimitry Andric
143*480093f4SDimitry Andric.. option:: --capture-path <filename>
144*480093f4SDimitry Andric
145*480093f4SDimitry Andric Tells the debugger to use the given filename for the reproducer.
146*480093f4SDimitry Andric
147*480093f4SDimitry Andric.. option:: --capture
148*480093f4SDimitry Andric
149*480093f4SDimitry Andric Tells the debugger to capture a reproducer.
150*480093f4SDimitry Andric
151*480093f4SDimitry Andric.. option:: --core <filename>
152*480093f4SDimitry Andric
153*480093f4SDimitry Andric Tells the debugger to use the full path to <filename> as the core file.
154*480093f4SDimitry Andric
155*480093f4SDimitry Andric.. option:: -c <value>
156*480093f4SDimitry Andric
157*480093f4SDimitry Andric Alias for --core
158*480093f4SDimitry Andric
159*480093f4SDimitry Andric.. option:: --debug
160*480093f4SDimitry Andric
161*480093f4SDimitry Andric Tells the debugger to print out extra information for debugging itself.
162*480093f4SDimitry Andric
163*480093f4SDimitry Andric.. option:: -d
164*480093f4SDimitry Andric
165*480093f4SDimitry Andric Alias for --debug
166*480093f4SDimitry Andric
167*480093f4SDimitry Andric.. option:: --editor
168*480093f4SDimitry Andric
169*480093f4SDimitry Andric Tells the debugger to open source files using the host's "external editor" mechanism.
170*480093f4SDimitry Andric
171*480093f4SDimitry Andric.. option:: -e
172*480093f4SDimitry Andric
173*480093f4SDimitry Andric Alias for --editor
174*480093f4SDimitry Andric
175*480093f4SDimitry Andric.. option:: --file <filename>
176*480093f4SDimitry Andric
177*480093f4SDimitry Andric Tells the debugger to use the file <filename> as the program to be debugged.
178*480093f4SDimitry Andric
179*480093f4SDimitry Andric.. option:: -f <value>
180*480093f4SDimitry Andric
181*480093f4SDimitry Andric Alias for --file
182*480093f4SDimitry Andric
183*480093f4SDimitry Andric.. option:: --help
184*480093f4SDimitry Andric
185*480093f4SDimitry Andric Prints out the usage information for the LLDB debugger.
186*480093f4SDimitry Andric
187*480093f4SDimitry Andric.. option:: -h
188*480093f4SDimitry Andric
189*480093f4SDimitry Andric Alias for --help
190*480093f4SDimitry Andric
191*480093f4SDimitry Andric.. option:: --no-use-colors
192*480093f4SDimitry Andric
193*480093f4SDimitry Andric Do not use colors.
194*480093f4SDimitry Andric
195*480093f4SDimitry Andric.. option:: --replay <filename>
196*480093f4SDimitry Andric
197*480093f4SDimitry Andric Tells the debugger to replay a reproducer from <filename>.
198*480093f4SDimitry Andric
199*480093f4SDimitry Andric.. option:: --version
200*480093f4SDimitry Andric
201*480093f4SDimitry Andric Prints out the current version number of the LLDB debugger.
202*480093f4SDimitry Andric
203*480093f4SDimitry Andric.. option:: -v
204*480093f4SDimitry Andric
205*480093f4SDimitry Andric Alias for --version
206*480093f4SDimitry Andric
207*480093f4SDimitry Andric.. option:: -X
208*480093f4SDimitry Andric
209*480093f4SDimitry Andric Alias for --no-use-color
210*480093f4SDimitry Andric
211*480093f4SDimitry AndricREPL
212*480093f4SDimitry Andric----
213*480093f4SDimitry Andric
214*480093f4SDimitry Andric.. option:: -r=<flags>
215*480093f4SDimitry Andric
216*480093f4SDimitry Andric Alias for --repl=<flags>
217*480093f4SDimitry Andric
218*480093f4SDimitry Andric.. option:: --repl-language <language>
219*480093f4SDimitry Andric
220*480093f4SDimitry Andric Chooses the language for the REPL.
221*480093f4SDimitry Andric
222*480093f4SDimitry Andric.. option:: --repl=<flags>
223*480093f4SDimitry Andric
224*480093f4SDimitry Andric Runs lldb in REPL mode with a stub process with the given flags.
225*480093f4SDimitry Andric
226*480093f4SDimitry Andric.. option:: -R <value>
227*480093f4SDimitry Andric
228*480093f4SDimitry Andric Alias for --repl-language
229*480093f4SDimitry Andric
230*480093f4SDimitry AndricSCRIPTING
231*480093f4SDimitry Andric---------
232*480093f4SDimitry Andric
233*480093f4SDimitry Andric.. option:: -l <value>
234*480093f4SDimitry Andric
235*480093f4SDimitry Andric Alias for --script-language
236*480093f4SDimitry Andric
237*480093f4SDimitry Andric.. option:: --python-path
238*480093f4SDimitry Andric
239*480093f4SDimitry Andric Prints out the path to the lldb.py file for this version of lldb.
240*480093f4SDimitry Andric
241*480093f4SDimitry Andric.. option:: -P
242*480093f4SDimitry Andric
243*480093f4SDimitry Andric Alias for --python-path
244*480093f4SDimitry Andric
245*480093f4SDimitry Andric.. option:: --script-language <language>
246*480093f4SDimitry Andric
247*480093f4SDimitry Andric Tells the debugger to use the specified scripting language for user-defined scripts.
248*480093f4SDimitry Andric
249*480093f4SDimitry AndricEXAMPLES
250*480093f4SDimitry Andric--------
251*480093f4SDimitry Andric
252*480093f4SDimitry AndricThe debugger can be started in several modes.
253*480093f4SDimitry Andric
254*480093f4SDimitry AndricPassing an executable as a positional argument prepares :program:`lldb` to
255*480093f4SDimitry Andricdebug the given executable. Arguments passed after -- are considered arguments
256*480093f4SDimitry Andricto the debugged executable.
257*480093f4SDimitry Andric
258*480093f4SDimitry Andric  lldb --arch x86_64 /path/to/program -- --arch arvm7
259*480093f4SDimitry Andric
260*480093f4SDimitry AndricPassing one of the attach options causes :program:`lldb` to immediately attach
261*480093f4SDimitry Andricto the given process.
262*480093f4SDimitry Andric
263*480093f4SDimitry Andric  lldb -p <pid>
264*480093f4SDimitry Andric  lldb -n <process-name>
265*480093f4SDimitry Andric
266*480093f4SDimitry AndricPassing --repl starts :program:`lldb` in REPL mode.
267*480093f4SDimitry Andric
268*480093f4SDimitry Andric  lldb -r
269*480093f4SDimitry Andric
270*480093f4SDimitry AndricPassing --core causes :program:`lldb` to debug the core file.
271*480093f4SDimitry Andric
272*480093f4SDimitry Andric  lldb -c /path/to/core
273*480093f4SDimitry Andric
274*480093f4SDimitry AndricCommand options can be combined with these modes and cause :program:`lldb` to
275*480093f4SDimitry Andricrun the specified commands before or after events, like loading the file or
276*480093f4SDimitry Andriccrashing, in the order provided on the command line.
277*480093f4SDimitry Andric
278*480093f4SDimitry Andric  lldb -O 'settings set stop-disassembly-count 20' -o 'run' -o 'bt'
279*480093f4SDimitry Andric  lldb -S /source/before/file -s /source/after/file
280*480093f4SDimitry Andric  lldb -K /source/before/crash -k /source/after/crash
281*480093f4SDimitry Andric
282*480093f4SDimitry AndricNote: In REPL mode no file is loaded, so commands specified to run after
283*480093f4SDimitry Andricloading the file (via -o or -s) will be ignored.
284*480093f4SDimitry Andric
285*480093f4SDimitry AndricUSING LLDB
286*480093f4SDimitry Andric----------
287*480093f4SDimitry Andric
288*480093f4SDimitry AndricIn :program:`lldb` there is a help command which can be used to find
289*480093f4SDimitry Andricdescriptions and examples of all :program:`lldb` commands.  To get help on
290*480093f4SDimitry Andric"breakpoint set" you would type "help breakpoint set".
291*480093f4SDimitry Andric
292*480093f4SDimitry AndricThere is also an apropos command which will search the help text of all
293*480093f4SDimitry Andriccommands for a given term ‐‐ this is useful for locating a command by topic.
294*480093f4SDimitry AndricFor instance, "apropos breakpoint" will list any command that has the word
295*480093f4SDimitry Andric"breakpoint" in its help text.
296*480093f4SDimitry Andric
297*480093f4SDimitry AndricCONFIGURATION FILES
298*480093f4SDimitry Andric-------------------
299*480093f4SDimitry Andric
300*480093f4SDimitry Andric:program:`lldb` reads things like settings, aliases and commands from the
301*480093f4SDimitry Andric.lldbinit file. It will first look for ~/.lldbinit and load that first.
302*480093f4SDimitry AndricSecondly, it will look for an .lldbinit file in the current working directory.
303*480093f4SDimitry AndricFor security reasons, :program:`lldb` will print a warning and not source this
304*480093f4SDimitry Andricfile by default. This behavior can be changed by changing the
305*480093f4SDimitry Andrictarget.load-cwd-lldbinit setting.
306*480093f4SDimitry Andric
307*480093f4SDimitry AndricTo always load the .lldbinit file in the current working directory, add the
308*480093f4SDimitry Andricfollowing command to ~/.lldbinit:
309*480093f4SDimitry Andric
310*480093f4SDimitry Andric  settings set target.load-cwd-lldbinit true
311*480093f4SDimitry Andric
312*480093f4SDimitry AndricTo never load the .lldbinit file in the current working directory and silence
313*480093f4SDimitry Andricthe warning, add the following command to ~/.lldbinit:
314*480093f4SDimitry Andric
315*480093f4SDimitry Andric  settings set target.load-cwd-lldbinit false
316*480093f4SDimitry Andric
317*480093f4SDimitry AndricSEE ALSO
318*480093f4SDimitry Andric--------
319*480093f4SDimitry Andric
320*480093f4SDimitry AndricThe LLDB project page https://lldb.llvm.org has many different resources
321*480093f4SDimitry Andricfor :program:`lldb` users ‐‐ the gdb/lldb command equivalence page
322*480093f4SDimitry Andrichttps://lldb.llvm.org/use/map.html can be especially helpful for users
323*480093f4SDimitry Andriccoming from gdb.
324