1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5 <link href="style.css" rel="stylesheet" type="text/css" />
6 <title>LLDB to GDB Command Map</title>
10 <div class="www_title">
11 The <strong>LLDB</strong> Debugger
16 <!--#include virtual="sidebar.incl"-->
20 <h1 class ="postheader">GDB to LLDB Command Map</h1>
23 <p>Below is a table of GDB commands with the LLDB counterparts.
24 The built in GDB-compatibility aliases in LLDB are also
25 listed. The full lldb command names are often long, but any
26 unique short form can be used. Instead of "<b>breakpoint set</b>",
27 "<b>br se</b>" is also acceptable.</p>
29 <div class="postfooter"></div>
31 <h1 class ="postheader">Execution Commands</h1>
36 <table class="stats" width="620" cellspacing="0">
38 <td class="hed" width="50%">GDB</td>
39 <td class="hed" width="50%">LLDB</td>
42 <tr><td class="header" colspan="2">Launch a process no arguments.</td></tr>
48 <b>(lldb)</b> process launch<br>
55 <tr><td class="header" colspan="2">Launch a process with arguments <code><args></code>.</td></tr>
57 <b>(gdb)</b> run <args><br>
58 <b>(gdb)</b> r <args>
61 <b>(lldb)</b> process launch -- <args><br>
62 <b>(lldb)</b> r <args>
66 <tr><td class="header" colspan="2">Launch a process for with arguments <b><code>a.out 1 2 3</code></b> without having to supply the args every time.</td></tr>
68 <b>%</b> gdb --args a.out 1 2 3<br>
75 <b>%</b> lldb -- a.out 1 2 3<br>
83 <tr><td class="header" colspan="2">Or:</td></tr>
85 <b>(gdb)</b> set args 1 2 3<br>
92 <b>(lldb)</b> settings set target.run-args 1 2 3<br>
100 <tr><td class="header" colspan="2">Launch a process with arguments in new terminal window (Mac OS X only).</td></tr>
104 <b>(lldb)</b> process launch --tty -- <args><br>
105 <b>(lldb)</b> pro la -t -- <args><br>
109 <tr><td class="header" colspan="2">Launch a process with arguments in existing terminal <cope>/dev/ttys006</code> (Mac OS X only).</td></tr>
113 <b>(lldb)</b> process launch --tty=/dev/ttys006 -- <args><br>
114 <b>(lldb)</b> pro la -t/dev/ttys006 -- <args><br>
118 <tr><td class="header" colspan="2">Set environment variables for process before launching.</td></tr>
120 <b>(gdb)</b> set env DEBUG 1<br>
123 <b>(lldb)</b> settings set target.env-vars DEBUG=1<br>
124 <b>(lldb)</b> set se target.env-vars DEBUG=1<br>
125 <b>(lldb)</b> env DEBUG=1<br>
129 <tr><td class="header" colspan="2">Unset environment variables for process before launching.</td></tr>
131 <b>(gdb)</b> unset env DEBUG<br>
134 <b>(lldb)</b> settings remove target.env-vars DEBUG<br>
135 <b>(lldb)</b> set rem target.env-vars DEBUG<br>
139 <tr><td class="header" colspan="2">Show the arguments that will be or were passed to the program when run.</td></tr>
141 <b>(gdb)</b> show args<br>
142 Argument list to give program being debugged when it is started is "1 2 3".<br>
145 <b>(lldb)</b> settings show target.run-args<br>
146 target.run-args (array of strings) =<br>
147 [0]: "1"<br>
148 [1]: "2"<br>
149 [2]: "3"<br>
154 <tr><td class="header" colspan="2">Set environment variables for process and launch process in one command.</td></tr>
158 <b>(lldb)</b> process launch -v DEBUG=1<br>
162 <tr><td class="header" colspan="2">Attach to a process with process ID 123.</td></tr>
165 <b>(gdb)</b> attach 123
168 <b>(lldb)</b> process attach --pid 123<br>
169 <b>(lldb)</b> attach -p 123
173 <tr><td class="header" colspan="2">Attach to a process named "a.out".</td></tr>
176 <b>(gdb)</b> attach a.out
179 <b>(lldb)</b> process attach --name a.out<br>
180 <b>(lldb)</b> pro at -n a.out
184 <tr><td class="header" colspan="2">Wait for a process named "a.out" to launch and attach.</td></tr>
187 <b>(gdb)</b> attach -waitfor a.out
190 <b>(lldb)</b> process attach --name a.out --waitfor<br>
191 <b>(lldb)</b> pro at -n a.out -w
195 <tr><td class="header" colspan="2">Attach to a remote gdb protocol server running on system "eorgadd", port 8000.</td></tr>
198 <b>(gdb)</b> target remote eorgadd:8000
201 <b>(lldb)</b> gdb-remote eorgadd:8000
205 <tr><td class="header" colspan="2">Attach to a remote gdb protocol server running on the local system, port 8000.</td></tr>
208 <b>(gdb)</b> target remote localhost:8000
211 <b>(lldb)</b> gdb-remote 8000
215 <tr><td class="header" colspan="2">Attach to a Darwin kernel in kdp mode on system "eorgadd".</td></tr>
218 <b>(gdb)</b> kdp-reattach eorgadd
221 <b>(lldb)</b> kdp-remote eorgadd
225 <tr><td class="header" colspan="2">Do a source level single step in the currently selected thread.</td></tr>
228 <b>(gdb)</b> step<br>
232 <b>(lldb)</b> thread step-in<br>
233 <b>(lldb)</b> step<br>
239 <tr><td class="header" colspan="2">Do a source level single step over in the currently selected thread.</td></tr>
242 <b>(gdb)</b> next<br>
246 <b>(lldb)</b> thread step-over<br>
247 <b>(lldb)</b> next<br>
252 <tr><td class="header" colspan="2">Do an instruction level single step in the currently selected thread.</td></tr>
255 <b>(gdb)</b> stepi<br>
259 <b>(lldb)</b> thread step-inst<br>
264 <tr><td class="header" colspan="2">Do an instruction level single step over in the currently selected thread.</td></tr>
267 <b>(gdb)</b> nexti<br>
271 <b>(lldb)</b> thread step-inst-over<br>
276 <tr><td class="header" colspan="2">Step out of the currently selected frame.</td></tr>
279 <b>(gdb)</b> finish<br>
282 <b>(lldb)</b> thread step-out<br>
283 <b>(lldb)</b> finish<br>
287 <tr><td class="header" colspan="2">Return immediately from the currently selected frame, with an optional return value.</td></tr>
290 <b>(gdb)</b> return <RETURN EXPRESSION><br>
293 <b>(lldb)</b> thread return <RETURN EXPRESSION><br>
297 <tr><td class="header" colspan="2">Backtrace and disassemble every time you stop.</td></tr>
302 <b>(lldb)</b> target stop-hook add<br>
303 Enter your stop hook command(s). Type 'DONE' to end.<br>
305 > disassemble --pc<br>
307 Stop hook #1 added.<br>
314 <div class="postfooter"></div>
316 <h1 class ="postheader">Breakpoint Commands</h1>
321 <table class="stats" width="620" cellspacing="0">
323 <td class="hed" width="50%">GDB</td>
324 <td class="hed" width="50%">LLDB</td>
327 <tr><td class="header" colspan="2">Set a breakpoint at all functions named <b>main</b>.</td></tr>
330 <b>(gdb)</b> break main
333 <b>(lldb)</b> breakpoint set --name main<br>
334 <b>(lldb)</b> br s -n main<br>
339 <tr><td class="header" colspan="2">Set a breakpoint in file <b>test.c</b> at line <b>12</b>.</td></tr>
342 <b>(gdb)</b> break test.c:12
345 <b>(lldb)</b> breakpoint set --file test.c --line 12<br>
346 <b>(lldb)</b> br s -f test.c -l 12<br>
347 <b>(lldb)</b> b test.c:12
351 <tr><td class="header" colspan="2">Set a breakpoint at all C++ methods whose basename is <b>main</b>.</td></tr>
354 <b>(gdb)</b> break main<br>
355 <i>(Hope that there are no C functions named <b>main</b>)</i>.
358 <b>(lldb)</b> breakpoint set --method main<br>
359 <b>(lldb)</b> br s -M main<br>
363 <tr><td class="header" colspan="2">Set a breakpoint at and object C function: <b>-[NSString stringWithFormat:]</b>.</td></tr>
366 <b>(gdb)</b> break -[NSString stringWithFormat:]<br>
369 <b>(lldb)</b> breakpoint set --name "-[NSString stringWithFormat:]"<br>
370 <b>(lldb)</b> b -[NSString stringWithFormat:]<br>
374 <tr><td class="header" colspan="2">Set a breakpoint at all Objective C methods whose selector is <b>count</b>.</td></tr>
377 <b>(gdb)</b> break count<br>
378 <i>(Hope that there are no C or C++ functions named <b>count</b>)</i>.
381 <b>(lldb)</b> breakpoint set --selector count<br>
382 <b>(lldb)</b> br s -S count<br>
385 <tr><td class="header" colspan="2">Set a breakpoint by regular expression on function name.</td></tr>
389 <b>(gdb)</b> rbreak regular-expression<br>
392 <b>(lldb)</b> breakpoint set --func-regex regular-expression<br>
393 <b>(lldb)</b> br s -r regular-expression<br>
397 <tr><td class="header" colspan="2">Ensure that breakpoints by file and line work for #included .c/.cpp/.m files.</td></tr>
401 <b>(gdb)</b> b foo.c:12<br>
404 <b>(lldb)</b> settings set target.inline-breakpoint-strategy always<br>
405 <b>(lldb)</b> br s -f foo.c -l 12<br>
409 <tr><td class="header" colspan="2">Set a breakpoint by regular expression on source file contents.</td></tr>
413 <b>(gdb)</b> shell grep -e -n pattern source-file<br>
414 <b>(gdb)</b> break source-file:CopyLineNumbers<br>
417 <b>(lldb)</b> breakpoint set --source-pattern regular-expression --file SourceFile<br>
418 <b>(lldb)</b> br s -p regular-expression -f file<br>
422 <tr><td class="header" colspan="2">Set a conditional breakpoint</td></tr>
426 <b>(gdb)</b> break foo if strcmp(y,"hello") == 0<br>
429 <b>(lldb)</b> breakpoint set --name foo --condition '(int)strcmp(y,"hello") == 0'<br>
430 <b>(lldb)</b> br s -n foo -c '(int)strcmp(y,"hello") == 0'<br>
434 <tr><td class="header" colspan="2">List all breakpoints.</td></tr>
437 <b>(gdb)</b> info break<br>
440 <b>(lldb)</b> breakpoint list<br>
441 <b>(lldb)</b> br l<br>
445 <tr><td class="header" colspan="2">Delete a breakpoint.</td></tr>
448 <b>(gdb)</b> delete 1<br>
451 <b>(lldb)</b> breakpoint delete 1<br>
452 <b>(lldb)</b> br del 1<br>
459 <div class="postfooter"></div>
461 <h1 class ="postheader">Watchpoint Commands</h1>
466 <table class="stats" width="620" cellspacing="0">
468 <td class="hed" width="50%">GDB</td>
469 <td class="hed" width="50%">LLDB</td>
472 <tr><td class="header" colspan="2">Set a watchpoint on a variable when it is written to.</td></tr>
475 <b>(gdb)</b> watch global_var
478 <b>(lldb)</b> watchpoint set variable global_var<br>
479 <b>(lldb)</b> wa s v global_var<br>
483 <tr><td class="header" colspan="2">Set a watchpoint on a memory location when it is written into. The size of the region to watch for defaults to the pointer size if no '-x byte_size' is specified.
484 This command takes raw input, evaluated as an expression returning an unsigned integer pointing to the start of the region, after the '--' option terminator.</td></tr>
487 <b>(gdb)</b> watch -location g_char_ptr
490 <b>(lldb)</b> watchpoint set expression -- my_ptr<br>
491 <b>(lldb)</b> wa s e -- my_ptr<br>
495 <tr><td class="header" colspan="2">Set a condition on a watchpoint</b>.</td></tr>
500 <b>(lldb)</b> watch set var global<br>
501 <b>(lldb)</b> watchpoint modify -c '(global==5)'<br>
505 * thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1<br>
506 frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16<br>
507 frame #1: 0x0000000100000eac a.out`main + 108 at main.cpp:25<br>
508 frame #2: 0x00007fff8ac9c7e1 libdyld.dylib`start + 1<br>
509 <b>(lldb)</b> frame var global<br>
510 (int32_t) global = 5<br>
514 <tr><td class="header" colspan="2">List all watchpoints.</td></tr>
517 <b>(gdb)</b> info break<br>
520 <b>(lldb)</b> watchpoint list<br>
521 <b>(lldb)</b> watch l<br>
525 <tr><td class="header" colspan="2">Delete a watchpoint.</td></tr>
528 <b>(gdb)</b> delete 1<br>
531 <b>(lldb)</b> watchpoint delete 1<br>
532 <b>(lldb)</b> watch del 1<br>
540 <div class="postfooter"></div>
541 <h1 class ="postheader">Examining Variables</h1>
544 <table class="stats" width="620" cellspacing="0">
546 <td class="hed" width="50%">GDB</td>
547 <td class="hed" width="50%">LLDB</td>
550 <tr><td class="header" colspan="2">Show the arguments and local variables for the current frame.</td></tr>
553 <b>(gdb)</b> info args<br>
555 <b>(gdb)</b> info locals<br>
558 <b>(lldb)</b> frame variable<br>
559 <b>(lldb)</b> fr v<br>
563 <tr><td class="header" colspan="2">Show the local variables for the current frame.</td></tr>
566 <b>(gdb)</b> info locals<br>
569 <b>(lldb)</b> frame variable --no-args<br>
570 <b>(lldb)</b> fr v -a<br>
574 <tr><td class="header" colspan="2">Show the contents of local variable "bar".</td></tr>
577 <b>(gdb)</b> p bar<br>
580 <b>(lldb)</b> frame variable bar <br>
581 <b>(lldb)</b> fr v bar <br>
582 <b>(lldb)</b> p bar <br>
586 <tr><td class="header" colspan="2">Show the contents of local variable "bar" formatted as hex.</td></tr>
589 <b>(gdb)</b> p/x bar<br>
592 <b>(lldb)</b> frame variable --format x bar <br>
593 <b>(lldb)</b> fr v -f x bar <br>
597 <tr><td class="header" colspan="2">Show the contents of global variable "baz".</td></tr>
600 <b>(gdb)</b> p baz<br>
603 <b>(lldb)</b> target variable baz <br>
604 <b>(lldb)</b> ta v baz <br>
608 <tr><td class="header" colspan="2">Show the global/static variables defined in the current source file.</td></tr>
614 <b>(lldb)</b> target variable <br>
615 <b>(lldb)</b> ta v <br>
619 <tr><td class="header" colspan="2">Display the variables "argc" and "argv" every time you stop.</td></tr>
622 <b>(gdb)</b> display argc<br>
623 <b>(gdb)</b> display argv<br>
626 <b>(lldb)</b> target stop-hook add --one-liner "frame variable argc argv"<br>
627 <b>(lldb)</b> ta st a -o "fr v argc argv"<br>
628 <b>(lldb)</b> display argc<br>
629 <b>(lldb)</b> display argv<br>
633 <tr><td class="header" colspan="2">Display the variables "argc" and "argv" only when you stop in the function named <b>main</b>.</td></tr>
638 <b>(lldb)</b> target stop-hook add --name main --one-liner "frame variable argc argv"<br>
639 <b>(lldb)</b> ta st a -n main -o "fr v argc argv"<br>
643 <tr><td class="header" colspan="2">Display the variable "*this" only when you stop in c class named <b>MyClass</b>.</td></tr>
648 <b>(lldb)</b> target stop-hook add --classname MyClass --one-liner "frame variable *this"<br>
649 <b>(lldb)</b> ta st a -c MyClass -o "fr v *this"<br>
660 <h1 class ="postheader">Evaluating expressions</h1>
663 <table class="stats" width="620" cellspacing="0">
665 <td class="hed" width="50%">GDB</td>
666 <td class="hed" width="50%">LLDB</td>
669 <tr><td class="header" colspan="2">Evaluating a generalized expression in the current frame.</td></tr>
672 <b>(gdb)</b> print (int) printf ("Print nine: %d.", 4 + 5)<br>
673 or if you don't want to see void returns: <br>
674 <b>(gdb)</b> call (int) printf ("Print nine: %d.", 4 + 5)<br>
677 <b>(lldb)</b> expr (int) printf ("Print nine: %d.", 4 + 5)<br>
678 or using the print alias:<br>
679 <b>(lldb)</b> print (int) printf ("Print nine: %d.", 4 + 5)<br>
683 <tr><td class="header" colspan="2">Creating and assigning a value to a convenience variable.</td></tr>
686 <b>(gdb)</b> set $foo = 5<br>
687 <b>(gdb)</b> set variable $foo = 5<br>
688 or using the print command <br>
689 <b>(gdb)</b> print $foo = 5<br>
690 or using the call command <br>
691 <b>(gdb)</b> call $foo = 5<br>
692 and if you want to specify the type of the variable:
693 <b>(gdb)</b> set $foo = (unsigned int) 5<br>
697 In lldb you evaluate a variable declaration expression as you would write it in C:<br>
698 <b>(lldb)</b> expr unsigned int $foo = 5<br>
702 <tr><td class="header" colspan="2">Printing the ObjC "description" of an object.</td></tr>
705 <b>(gdb)</b> po [SomeClass returnAnObject]<br>
708 <b>(lldb)</b> expr -o -- [SomeClass returnAnObject]<br>
709 or using the po alias:<br>
710 <b>(lldb)</b> po [SomeClass returnAnObject]<br>
714 <tr><td class="header" colspan="2">Print the dynamic type of the result of an expression.</td></tr>
717 <b>(gdb)</b> set print object 1<br>
718 <b>(gdb)</b> p someCPPObjectPtrOrReference<br>
719 only works for C++ objects.<br>
722 <b>(lldb)</b> expr -d 1 -- [SomeClass returnAnObject]<br>
723 <b>(lldb)</b> expr -d 1 -- someCPPObjectPtrOrReference<br>
724 or set dynamic type printing to be the default:
725 <b>(lldb)</b> settings set target.prefer-dynamic run-target<br>
729 <tr><td class="header" colspan="2">Calling a function so you can stop at a breakpoint in the function.</td></tr>
732 <b>(gdb)</b> set unwindonsignal 0<br>
733 <b>(gdb)</b> p function_with_a_breakpoint()<br>
736 <b>(lldb)</b> expr -i 0 -- function_with_a_breakpoint()<br>
740 <tr><td class="header" colspan="2">Calling a function that crashes, and stopping when the function crashes.</td></tr>
743 <b>(gdb)</b> set unwindonsignal 0<br>
744 <b>(gdb)</b> p function_which_crashes()<br>
747 <b>(lldb)</b> expr -u 0 -- function_which_crashes()<br>
756 <h1 class ="postheader">Examining Thread State</h1>
759 <table class="stats" width="620" cellspacing="0">
761 <td class="hed" width="50%">GDB</td>
762 <td class="hed" width="50%">LLDB</td>
766 <tr><td class="header" colspan="2">Show the stack backtrace for the current thread.</td></tr>
772 <b>(lldb)</b> thread backtrace<br>
777 <tr><td class="header" colspan="2">Show the stack backtraces for all threads.</td></tr>
780 <b>(gdb)</b> thread apply all bt
783 <b>(lldb)</b> thread backtrace all<br>
788 <tr><td class="header" colspan="2">Backtrace the first five frames of the current thread.</td></tr>
794 <b>(lldb)</b> thread backtrace -c 5<br>
795 <b>(lldb)</b> bt 5 (<i>lldb-169 and later</i>)<br>
796 <b>(lldb)</b> bt -c 5 (<i>lldb-168 and earlier</i>)
800 <tr><td class="header" colspan="2">Select a different stack frame by index for the current thread.</td></tr>
803 <b>(gdb)</b> frame 12
806 <b>(lldb)</b> frame select 12<br>
807 <b>(lldb)</b> fr s 12<br>
808 <b>(lldb)</b> f 12<br>
812 <tr><td class="header" colspan="2">List information about the currently selected frame in the current thread.</td></tr>
817 <b>(lldb)</b> frame info<br>
821 <tr><td class="header" colspan="2">Select the stack frame that called the current stack frame.</td></tr>
828 <b>(lldb)</b> frame select --relative=1<br>
832 <tr><td class="header" colspan="2">Select the stack frame that is called by the current stack frame.</td></tr>
838 <b>(lldb)</b> down<br>
839 <b>(lldb)</b> frame select --relative=-1<br>
840 <b>(lldb)</b> fr s -r-1<br>
844 <tr><td class="header" colspan="2">Select a different stack frame using a relative offset.</td></tr>
847 <b>(gdb)</b> up 2<br>
848 <b>(gdb)</b> down 3<br>
851 <b>(lldb)</b> frame select --relative 2<br>
852 <b>(lldb)</b> fr s -r2<br>
854 <b>(lldb)</b> frame select --relative -3<br>
855 <b>(lldb)</b> fr s -r-3<br>
859 <tr><td class="header" colspan="2">Show the general purpose registers for the current thread.</td></tr>
862 <b>(gdb)</b> info registers<br>
865 <b>(lldb)</b> register read<br>
869 <tr><td class="header" colspan="2">Write a new decimal value '123' to the current thread register 'rax'.</td></tr>
872 <b>(gdb)</b> p $rax = 123<br>
875 <b>(lldb)</b> register write rax 123<br>
879 <tr><td class="header" colspan="2">Skip 8 bytes ahead of the current program counter (instruction pointer). Note that we use backticks to evaluate an expression and insert the scalar result in LLDB.</td></tr>
882 <b>(gdb)</b> jump *$pc+8<br>
885 <b>(lldb)</b> register write pc `$pc+8`<br>
889 <tr><td class="header" colspan="2">Show the general purpose registers for the current thread formatted as <b>signed decimal</b>. LLDB tries to use
890 the same format characters as <b>printf(3)</b> when possible. Type "help format" to see the full list of format specifiers.</td></tr>
895 <b>(lldb)</b> register read --format i<br>
896 <b>(lldb)</b> re r -f i<br>
898 <i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i><br>
899 <b>(lldb)</b> register read/d<br>
903 <tr><td class="header" colspan="2">Show all registers in all register sets for the current thread.</td></tr>
906 <b>(gdb)</b> info all-registers<br>
909 <b>(lldb)</b> register read --all<br>
910 <b>(lldb)</b> re r -a<br>
914 <tr><td class="header" colspan="2">Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.</td></tr>
917 <b>(gdb)</b> info all-registers rax rsp rbp<br>
920 <b>(lldb)</b> register read rax rsp rbp<br>
924 <tr><td class="header" colspan="2">Show the values for the register named "rax" in the current thread formatted as <b>binary</b>.</td></tr>
927 <b>(gdb)</b> p/t $rax<br>
930 <b>(lldb)</b> register read --format binary rax<br>
931 <b>(lldb)</b> re r -f b rax<br>
933 <i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i><br>
934 <b>(lldb)</b> register read/t rax<br>
935 <b>(lldb)</b> p/t $rax<br>
939 <tr><td class="header" colspan="2">Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.</td></tr>
942 <b>(gdb)</b> x/4xw 0xbffff3c0<br>
945 <b>(lldb)</b> memory read --size 4 --format x --count 4 0xbffff3c0<br>
946 <b>(lldb)</b> me r -s4 -fx -c4 0xbffff3c0<br>
947 <b>(lldb)</b> x -s4 -fx -c4 0xbffff3c0<br>
949 <i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i><br>
950 <b>(lldb)</b> memory read/4xw 0xbffff3c0<br>
951 <b>(lldb)</b> x/4xw 0xbffff3c0<br>
952 <b>(lldb)</b> memory read --gdb-format 4xw 0xbffff3c0<br>
956 <tr><td class="header" colspan="2">Read memory starting at the expression "argv[0]".</td></tr>
959 <b>(gdb)</b> x argv[0]<br>
962 <b>(lldb)</b> memory read `argv[0]`<br>
963 <i><b>NOTE:</b> any command can inline a scalar expression result (as long as the target is stopped) using backticks around any expression:</i><br>
964 <b>(lldb)</b> memory read --size `sizeof(int)` `argv[0]`<br>
968 <tr><td class="header" colspan="2">Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as <b>text</b>.</td></tr>
971 <b>(gdb)</b> set logging on<br>
972 <b>(gdb)</b> set logging file /tmp/mem.txt<br>
973 <b>(gdb)</b> x/512bx 0xbffff3c0<br>
974 <b>(gdb)</b> set logging off<br>
977 <b>(lldb)</b> memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0<br>
978 <b>(lldb)</b> me r -o/tmp/mem.txt -c512 0xbffff3c0<br>
979 <b>(lldb)</b> x/512bx -o/tmp/mem.txt 0xbffff3c0<br>
983 <tr><td class="header" colspan="2">Save binary memory data starting at 0x1000 and ending at 0x2000 to a file.</td></tr>
986 <b>(gdb)</b> dump memory /tmp/mem.bin 0x1000 0x2000
989 <b>(lldb)</b> memory read --outfile /tmp/mem.bin --binary 0x1000 0x2000<br>
990 <b>(lldb)</b> me r -o /tmp/mem.bin -b 0x1000 0x2000<br>
993 <tr><td class="header" colspan="2">Get information about a specific heap allocation (available on Mac OS X only).</td></tr>
996 <b>(gdb)</b> info malloc 0x10010d680
999 <b>(lldb)</b> command script import lldb.macosx.heap<br>
1000 <b>(lldb)</b> process launch --environment MallocStackLogging=1 -- [ARGS]<br>
1001 <b>(lldb)</b> malloc_info --stack-history 0x10010d680<br>
1004 <tr><td class="header" colspan="2">Get information about a specific heap allocation and cast the result to any dynamic type that can be deduced (available on Mac OS X only)</td></tr>
1006 <td class="content">
1008 <td class="content">
1009 <b>(lldb)</b> command script import lldb.macosx.heap<br>
1010 <b>(lldb)</b> malloc_info --type 0x10010d680<br>
1013 <tr><td class="header" colspan="2">Find all heap blocks that contain a pointer specified by an expression EXPR (available on Mac OS X only).</td></tr>
1015 <td class="content">
1017 <td class="content">
1018 <b>(lldb)</b> command script import lldb.macosx.heap<br>
1019 <b>(lldb)</b> ptr_refs EXPR <br>
1022 <tr><td class="header" colspan="2">Find all heap blocks that contain a C string anywhere in the block (available on Mac OS X only).</td></tr>
1024 <td class="content">
1026 <td class="content">
1027 <b>(lldb)</b> command script import lldb.macosx.heap<br>
1028 <b>(lldb)</b> cstr_refs CSTRING<br>
1031 <tr><td class="header" colspan="2">Disassemble the current function for the current frame.</td></tr>
1033 <td class="content">
1034 <b>(gdb)</b> disassemble
1036 <td class="content">
1037 <b>(lldb)</b> disassemble --frame<br>
1042 <tr><td class="header" colspan="2">Disassemble any functions named <b>main</b>.</td></tr>
1044 <td class="content">
1045 <b>(gdb)</b> disassemble main
1047 <td class="content">
1048 <b>(lldb)</b> disassemble --name main<br>
1049 <b>(lldb)</b> di -n main
1053 <tr><td class="header" colspan="2">Disassemble an address range.</td></tr>
1055 <td class="content">
1056 <b>(gdb)</b> disassemble 0x1eb8 0x1ec3
1058 <td class="content">
1059 <b>(lldb)</b> disassemble --start-address 0x1eb8 --end-address 0x1ec3<br>
1060 <b>(lldb)</b> di -s 0x1eb8 -e 0x1ec3<br>
1064 <tr><td class="header" colspan="2">Disassemble 20 instructions from a given address.</td></tr>
1066 <td class="content">
1067 <b>(gdb)</b> x/20i 0x1eb8
1069 <td class="content">
1070 <b>(lldb)</b> disassemble --start-address 0x1eb8 --count 20<br>
1071 <b>(lldb)</b> di -s 0x1eb8 -c 20<br>
1075 <tr><td class="header" colspan="2">Show mixed source and disassembly for the current function for the current frame.</td></tr>
1077 <td class="content">
1080 <td class="content">
1081 <b>(lldb)</b> disassemble --frame --mixed<br>
1082 <b>(lldb)</b> di -f -m
1086 <tr><td class="header" colspan="2">Disassemble the current function for the current frame and show the opcode bytes.</td></tr>
1088 <td class="content">
1091 <td class="content">
1092 <b>(lldb)</b> disassemble --frame --bytes<br>
1093 <b>(lldb)</b> di -f -b
1097 <tr><td class="header" colspan="2">Disassemble the current source line for the current frame.</td></tr>
1099 <td class="content">
1102 <td class="content">
1103 <b>(lldb)</b> disassemble --line<br>
1111 <div class="postfooter"></div>
1113 <h1 class ="postheader">Executable and Shared Library Query Commands</h1>
1118 <table class="stats" width="620" cellspacing="0">
1120 <td class="hed" width="50%">GDB</td>
1121 <td class="hed" width="50%">LLDB</td>
1125 <tr><td class="header" colspan="2">List the main executable and all dependent shared libraries.</td></tr>
1127 <td class="content">
1128 <b>(gdb)</b> info shared<br>
1130 <td class="content">
1131 <b>(lldb)</b> image list<br>
1135 <tr><td class="header" colspan="2">Look up information for a raw address in the executable or any shared libraries.</td></tr>
1137 <td class="content">
1138 <b>(gdb)</b> info symbol 0x1ec4<br>
1140 <td class="content">
1141 <b>(lldb)</b> image lookup --address 0x1ec4<br>
1142 <b>(lldb)</b> im loo -a 0x1ec4<br>
1146 <tr><td class="header" colspan="2">Look up functions matching a regular expression in a binary.</td></tr>
1148 <td class="content">
1149 <b>(gdb)</b> info function <FUNC_REGEX><br>
1151 <td class="content">
1152 This one finds debug symbols:<br>
1153 <b>(lldb)</b> image lookup -r -n <FUNC_REGEX><br><br>
1154 This one finds non-debug symbols:<br>
1155 <b>(lldb)</b> image lookup -r -s <FUNC_REGEX><br><br>
1156 Provide a list of binaries as arguments to limit the search.
1160 <tr><td class="header" colspan="2">Find full source line information.</td></tr>
1162 <td class="content">
1163 <b>(gdb)</b> info line 0x1ec4<br>
1165 <td class="content">
1166 This one is a bit messy at present. Do:<br><br>
1167 <b>(lldb)</b> image lookup -v --address 0x1ec4<br><br>
1168 and look for the LineEntry line, which will have the full source path and
1169 line range information.<br>
1173 <tr><td class="header" colspan="2">Look up information for an address in <b>a.out</b> only.</td></tr>
1175 <td class="content">
1177 <td class="content">
1178 <b>(lldb)</b> image lookup --address 0x1ec4 a.out<br>
1179 <b>(lldb)</b> im loo -a 0x1ec4 a.out<br>
1183 <tr><td class="header" colspan="2">Look up information for for a type <code>Point</code> by name.</td></tr>
1185 <td class="content">
1186 <b>(gdb)</b> ptype Point<br>
1188 <td class="content">
1189 <b>(lldb)</b> image lookup --type Point<br>
1190 <b>(lldb)</b> im loo -t Point<br>
1194 <tr><td class="header" colspan="2">Dump all sections from the main executable and any shared libraries.</td></tr>
1196 <td class="content">
1197 <b>(gdb)</b> maintenance info sections<br>
1199 <td class="content">
1200 <b>(lldb)</b> image dump sections<br>
1204 <tr><td class="header" colspan="2">Dump all sections in the <b>a.out</b> module.</td></tr>
1206 <td class="content">
1208 <td class="content">
1209 <b>(lldb)</b> image dump sections a.out<br>
1213 <tr><td class="header" colspan="2">Dump all symbols from the main executable and any shared libraries.</td></tr>
1215 <td class="content">
1217 <td class="content">
1218 <b>(lldb)</b> image dump symtab<br>
1222 <tr><td class="header" colspan="2">Dump all symbols in <b>a.out</b> and <b>liba.so</b>.</td></tr>
1224 <td class="content">
1226 <td class="content">
1227 <b>(lldb)</b> image dump symtab a.out liba.so<br>
1234 <div class="postfooter"></div>
1235 <h1 class ="postheader">Miscellaneous</h1>
1238 <table class="stats" width="620" cellspacing="0">
1240 <td class="hed" width="50%">GDB</td>
1241 <td class="hed" width="50%">LLDB</td>
1244 <tr><td class="header" colspan="2">Echo text to the screen.</td></tr>
1246 <td class="content">
1247 <b>(gdb)</b> echo Here is some text\n<br>
1249 <td class="content">
1250 <b>(lldb)</b> script print "Here is some text"<br>
1254 <tr><td class="header" colspan="2">Remap source file pathnames for the debug session. If your source files are no longer located in the same location as when the program was built --- maybe the program was built on a different computer --- you need to tell the debugger how to find the sources at their local file path instead of the build system's file path.</td></tr>
1256 <td class="content">
1257 <b>(gdb)</b> set pathname-substitutions /buildbot/path /my/path<br>
1259 <td class="content">
1260 <b>(lldb)</b> settings set target.source-map /buildbot/path /my/path<br>
1264 <tr><td class="header" colspan="2">Supply a catchall directory to search for source files in.</td></tr>
1266 <td class="content">
1267 <b>(gdb)</b> directory /my/path<br>
1269 <td class="content">
1270 (<i>No equivalent command - use the source-map instead.</i>)<br>
1278 <div class="postfooter"></div>