Appendix A: LLDB for GDB Users – Command Summary
LLDB is the supported engine underlying all debugging operations for use with Xcode and all officially distributed Apple development products. Some users who are new to Xcode might be more familiar with GDB commands. By default, LLDB contains a library of aliases modeled on GDB commands in order to ease getting started.
The tables in this appendix list commonly used GDB commands, presenting equivalent LLDB commands and alternative forms. Also listed are the built-in GDB compatibility aliases in LLDB.
Execution Commands
GDB | LLDB |
---|---|
Launch a process with no arguments | |
|
|
Launch a process with arguments | |
|
|
Launch process | |
|
|
Launch a process with arguments in a new terminal window (OS X only) | |
— |
|
Launch a process with arguments in an existing Terminal window, | |
— |
|
Set environment variables for process before launching | |
|
|
Set environment variables for process and launch process in one command | |
|
|
Attach to the process with process ID 123 | |
|
|
Attach to a process named | |
|
|
Wait for a process named | |
|
|
Attach to a remote GDB protocol server running on the system | |
|
|
Attach to a remote GDB protocol server running on the local system, port 8000 | |
|
|
Attach to a Darwin kernel in kdp mode on the system | |
|
|
Do a source-level single step in the currently selected thread | |
|
|
Do a source-level single step over in the currently selected thread | |
|
|
Do an instruction-level single step in the currently selected thread | |
|
|
Do an instruction-level single step over in the currently selected thread | |
|
|
Step out of the currently selected frame | |
|
|
Backtrace and disassemble every time you stop | |
— |
|
Breakpoint Commands
GDB | LLDB |
---|---|
Set a breakpoint at all functions named | |
|
|
Set a breakpoint in file | |
|
|
Set a breakpoint at all C++ methods whose basename is | |
(Note: This will break on any C functions named |
|
Set a breakpoint at an Objective-C function: | |
|
|
Set a breakpoint at all Objective-C methods whose selector is | |
(Note: This will break on any C or C++ functions named |
|
Set a breakpoint by a regular expression on a function name | |
|
|
Set a breakpoint by a regular expression on a source file’s contents | |
|
|
List all breakpoints | |
|
|
Delete a breakpoint | |
|
|
Watchpoint Commands
GDB | LLDB |
---|---|
Set a watchpoint on a variable when it is written to | |
|
|
Set a watchpoint on a memory location when it is written to | |
|
Note: The size of the region to watch for defaults to the pointer size if no |
Set a condition on a watchpoint | |
— |
|
List all watchpoints | |
|
|
Delete a watchpoint | |
|
|
Examining Variables
GDB | LLDB |
---|---|
Show the arguments and local variables for the current frame | |
and
|
|
Show the local variables for the current frame | |
|
|
Show the contents of the local variable | |
|
|
Show the contents of the local variable | |
|
|
Show the contents of the global variable | |
|
|
Show the global/static variables defined in the current source file | |
— |
|
Display the variables | |
|
|
Display the variables | |
—
|
|
Display the variable | |
—
|
|
Evaluating Expressions
GDB | LLDB |
---|---|
Evaluate a generalized expression in the current frame | |
Or if you don’t want to see void returns:
|
Or use the
|
Create and assign a value to a convenience variable | |
Or use the
Or use the
To specify the type of the variable:
| LLDB evaluates a variable declaration expression as you would write it in C:
|
Print the Objective-C | |
|
Or use the
|
Print the dynamic type of the result of an expression | |
Note: Only for C++ objects. |
Or set dynamic type printing as default:
|
Call a function to stop at a breakpoint in the function | |
|
|
Examining Thread State
GDB | LLDB |
---|---|
Show the stack backtrace for the current thread | |
|
|
Show the stack backtraces for all threads | |
|
|
Backtrace the first five frames of the current thread | |
|
|
Select a different stack frame by index for the current thread | |
|
|
List information about the currently selected frame in the current thread | |
— |
|
Select the stack frame that called the current stack frame | |
|
|
Select the stack frame that is called by the current stack frame | |
|
|
Select a different stack frame using a relative offset | |
|
|
Show the general-purpose registers for the current thread | |
|
|
Write a new decimal value | |
|
|
Skip 8 bytes ahead of the current program counter (instruction pointer) | |
|
The LLDB command uses backticks to evaluate an expression and insert the scalar result. |
Show the general-purpose registers for the current thread formatted as signed decimal | |
— |
LLDB now supports the GDB shorthand format syntax, but no space is permitted after the command:
Note: LLDB tries to use the same format characters as |
Show all registers in all register sets for the current thread | |
|
|
Show the values for the registers named | |
|
|
Show the values for the register named | |
|
LLDB now supports the GDB shorthand format syntax, but no space is permitted after the command:
|
Read memory from address | |
|
LLDB now supports the GDB shorthand format syntax, but no space is permitted after the command:
|
Read memory starting at the expression | |
|
Note that any command can inline a scalar expression result (as long as the target is stopped) using back ticks (
|
Read 512 bytes of memory from address | |
|
|
Save binary memory data to a file starting at | |
|
|
Disassemble the current function for the current frame | |
|
|
Disassemble any functions named | |
|
|
Disassemble an address range | |
|
|
Disassemble 20 instructions from a given address | |
|
|
Show mixed source and disassembly for the current function for the current frame | |
— |
|
Disassemble the current function for the current frame and show the opcode bytes | |
— |
|
Disassemble the current source line for the current frame | |
— |
|
Executable and Shared Library Query Commands
GDB | LLDB |
---|---|
List the main executable and all dependent shared libraries | |
|
|
Look up information for a raw address in the executable or any shared libraries | |
|
|
Look up functions matching a regular expression in a binary | |
| This one finds debug symbols:
This one finds non-debug symbols:
Provide a list of binaries as arguments to limit the search. |
Look up information for an address in | |
— |
|
Look up information for a type | |
|
|
Dump all sections from the main executable and any shared libraries | |
|
|
Dump all sections in the | |
— |
|
Dump all symbols from the main executable and any shared libraries | |
— |
|
Dump all symbols in | |
— |
|
Miscellaneous
GDB | LLDB |
---|---|
Echo text to the screen | |
|
|
Remap source file pathnames for the debug session | |
|
Note: 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 the local file path instead of the build system file path. |
Supply a catchall directory to search for source files in | |
| (No equivalent command.) |
Copyright © 2016 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2016-09-13