<td class="header" colspan="2">Set a watchpoint on a variable when it is written to.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> watch global_var
</td>
<td class="content">
<b>(lldb)</b> watchpoint set variable global_var
<br>
<b>(lldb)</b> wa s v global_var
<br>
</td>
</tr>
<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. 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>
<tr>
<td class="content">
<b>(gdb)</b> watch -location g_char_ptr
</td>
<td class="content">
<b>(lldb)</b> watchpoint set expression -- my_ptr
<br>
<b>(lldb)</b> wa s e -- my_ptr
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Set a condition on a watchpoint.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> watch set var global
<br>
<b>(lldb)</b> watchpoint modify -c '(global==5)'
<br>
<b>(lldb)</b> c
<br> ...
<br>
<b>(lldb)</b> bt
<br> * thread #1: tid = 0x1c03, 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16, stop reason = watchpoint 1
<br> frame #0: 0x0000000100000ef5 a.out`modify + 21 at main.cpp:16
<br> frame #1: 0x0000000100000eac a.out`main + 108 at main.cpp:25
<td class="header" colspan="2">List the threads in your program.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> info threads
<br>
</td>
<td class="content">
<b>(lldb)</b> thread list
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Select thread 1 as the default thread for subsequent commands.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> thread 1
<br>
</td>
<td class="content">
<b>(lldb)</b> thread select 1
<br>
<b>(lldb)</b> t 1
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Show the stack backtrace for the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> bt
<br>
</td>
<td class="content">
<b>(lldb)</b> thread backtrace
<br>
<b>(lldb)</b> bt
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Show the stack backtraces for all threads.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> thread apply all bt
</td>
<td class="content">
<b>(lldb)</b> thread backtrace all
<br>
<b>(lldb)</b> bt all
</td>
</tr>
<tr>
<td class="header" colspan="2">Backtrace the first five frames of the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> bt 5
</td>
<td class="content">
<b>(lldb)</b> thread backtrace -c 5
<br>
<b>(lldb)</b> bt 5 (<i>lldb-169 and later</i>)
<br>
<b>(lldb)</b> bt -c 5 (<i>lldb-168 and earlier</i>)
</td>
</tr>
<tr>
<td class="header" colspan="2">Select a different stack frame by index for the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> frame 12
</td>
<td class="content">
<b>(lldb)</b> frame select 12
<br>
<b>(lldb)</b> fr s 12
<br>
<b>(lldb)</b> f 12
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">List information about the currently selected frame in the current thread.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> frame info
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Select the stack frame that called the current stack frame.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> up
</td>
<td class="content">
<b>(lldb)</b> up
<br>
<b>(lldb)</b> frame select --relative=1
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Select the stack frame that is called by the current stack frame.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> down
</td>
<td class="content">
<b>(lldb)</b> down
<br>
<b>(lldb)</b> frame select --relative=-1
<br>
<b>(lldb)</b> fr s -r-1
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Select a different stack frame using a relative offset.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> up 2
<br>
<b>(gdb)</b> down 3
<br>
</td>
<td class="content">
<b>(lldb)</b> frame select --relative 2
<br>
<b>(lldb)</b> fr s -r2
<br>
<br>
<b>(lldb)</b> frame select --relative -3
<br>
<b>(lldb)</b> fr s -r-3
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Show the general purpose registers for the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> info registers
<br>
</td>
<td class="content">
<b>(lldb)</b> register read
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Write a new decimal value '123' to the current thread register 'rax'.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> p $rax = 123
<br>
</td>
<td class="content">
<b>(lldb)</b> register write rax 123
<br>
</td>
</tr>
<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>
<tr>
<td class="content">
<b>(gdb)</b> jump *$pc+8
<br>
</td>
<td class="content">
<b>(lldb)</b> register write pc `$pc+8`
<br>
</td>
</tr>
<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 the same format characters as <b>printf(3)</b> when possible. Type "help format" to see the full list of format specifiers.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> register read --format i
<br>
<b>(lldb)</b> re r -f i
<br>
<br>
<i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i>
<br>
<b>(lldb)</b> register read/d
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Show all registers in all register sets for the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> info all-registers
<br>
</td>
<td class="content">
<b>(lldb)</b> register read --all
<br>
<b>(lldb)</b> re r -a
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> info all-registers rax rsp rbp
<br>
</td>
<td class="content">
<b>(lldb)</b> register read rax rsp rbp
<br>
</td>
</tr>
<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>
<tr>
<td class="content">
<b>(gdb)</b> p/t $rax
<br>
</td>
<td class="content">
<b>(lldb)</b> register read --format binary rax
<br>
<b>(lldb)</b> re r -f b rax
<br>
<br>
<i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i>
<br>
<b>(lldb)</b> register read/t rax
<br>
<b>(lldb)</b> p/t $rax
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> x/4xw 0xbffff3c0
<br>
</td>
<td class="content">
<b>(lldb)</b> memory read --size 4 --format x --count 4 0xbffff3c0
<br>
<b>(lldb)</b> me r -s4 -fx -c4 0xbffff3c0
<br>
<b>(lldb)</b> x -s4 -fx -c4 0xbffff3c0
<br>
<br>
<i>LLDB now supports the GDB shorthand format syntax but there can't be space after the command:</i>
<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 macOS only)</td>
<br> Provide a list of binaries as arguments to limit the search.
</td>
</tr>
<tr>
<td class="header" colspan="2">Find full source line information.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> info line 0x1ec4
<br>
</td>
<td class="content">
This one is a bit messy at present. Do:
<br>
<br>
<b>(lldb)</b> image lookup -v --address 0x1ec4
<br>
<br> and look for the LineEntry line, which will have the full source path and line range information.
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Look up information for an address in <b>a.out</b> only.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> image lookup --address 0x1ec4 a.out
<br>
<b>(lldb)</b> im loo -a 0x1ec4 a.out
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Look up information for for a type <code>Point</code> by name.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> ptype Point
<br>
</td>
<td class="content">
<b>(lldb)</b> image lookup --type Point
<br>
<b>(lldb)</b> im loo -t Point
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Dump all sections from the main executable and any shared libraries.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> maintenance info sections
<br>
</td>
<td class="content">
<b>(lldb)</b> image dump sections
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Dump all sections in the <b>a.out</b> module.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> image dump sections a.out
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Dump all symbols from the main executable and any shared libraries.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> image dump symtab
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Dump all symbols in <b>a.out</b> and <b>liba.so</b>.</td>
</tr>
<tr>
<td class="content">
</td>
<td class="content">
<b>(lldb)</b> image dump symtab a.out liba.so
<br>
</td>
</tr>
</tbody>
</table>
Miscellaneous
-------------
..raw:: html
<table class="mapping" cellspacing="0">
<tbody>
<tr>
<td class="hed" width="50%">GDB</td>
<td class="hed" width="50%">LLDB</td>
</tr>
<tr>
<td class="header" colspan="2">Search command help for a keyword.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> apropos keyword
<br>
</td>
<td class="content">
<b>(lldb)</b> apropos keyword
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Echo text to the screen.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> echo Here is some text\n
<br>
</td>
<td class="content">
<b>(lldb)</b> script print "Here is some text"
<br>
</td>
</tr>
<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>
<tr>
<td class="content">
<b>(gdb)</b> set pathname-substitutions /buildbot/path /my/path
<br>
</td>
<td class="content">
<b>(lldb)</b> settings set target.source-map /buildbot/path /my/path
<br>
</td>
</tr>
<tr>
<td class="header" colspan="2">Supply a catchall directory to search for source files in.</td>
</tr>
<tr>
<td class="content">
<b>(gdb)</b> directory /my/path
<br>
</td>
<td class="content">
(<i>No equivalent command - use the source-map instead.</i>)