lldb
Debug programs interactively
TLDR
Debug an executable
Attach lldb to a running process with a given PID
Wait for a new process to launch with a given name, and attach to it
SYNOPSIS
lldb [options] [<executable> [<executable_arguments>...]]
PARAMETERS
-b, --batch
Run commands specified in -s, -o, -O, -l, -L and then exit.
-c, --core <core_file>
Debug a core dump file.
-f, --file <executable>
Specify the executable to debug.
-o, --one-line <command>
Run a single LLDB command upon startup.
-s, --source <file>
Read and execute LLDB commands from the specified file.
-p, --attach-pid <pid>
Attach to a running process by its process ID.
-n, --attach-name <name>
Attach to a running process by its name.
--
Separator indicating that all subsequent arguments are for the inferior process, not for lldb itself.
-v, --version
Print the lldb version and exit.
-h, --help
Show lldb command-line help.
DESCRIPTION
lldb is a powerful, next-generation debugger built as part of the LLVM project. It is designed to be highly extensible, reusable, and efficient, leveraging the modular components provided by LLVM and Clang. Unlike older debuggers, lldb is built on top of a modern architecture, utilizing the LLVM disassembler, JIT compilation, and the Clang expression parser for advanced debugging capabilities.
It supports debugging of C, C++, Objective-C, and Swift programs across various architectures and operating systems, including macOS, Linux, and Windows. lldb provides a rich command-line interface that can be extended with Python scripting, allowing users to automate complex debugging tasks, create custom commands, and format data types. Its modular design makes it easy to integrate into IDEs and other development tools, making it the default debugger for Xcode on macOS.
CAVEATS
Users accustomed to GDB might find lldb's command syntax and structure different, requiring a learning curve. While highly capable, certain niche features or very specific debugging scenarios might have varying levels of maturity or support compared to more established debuggers on some platforms. Its performance and features are closely tied to the LLVM ecosystem, meaning full functionality often benefits from a recent LLVM/Clang installation.
KEY FEATURES
lldb boasts a modular architecture, allowing for flexible integration and customization. It supports powerful Python scripting for automation and extension, a Clang expression parser for evaluating C/C++/Objective-C expressions directly, and robust support for JIT compilation for on-the-fly code generation. It also provides advanced data formatters to present complex data structures in an understandable way.
INTERACTIVE USAGE
When launched without specific commands, lldb enters an interactive mode, providing a command-line prompt. Users can set breakpoints, step through code, inspect variables, evaluate expressions, and manage threads. Its tab-completion and command aliasing features enhance the interactive debugging experience. Commands are typically intuitive, such as breakpoint set, frame variable, next, and continue.
HISTORY
lldb originated as an open-source project within the broader LLVM initiative, conceived to address the limitations and architectural challenges of older debuggers like GDB. Development began with a strong emphasis on modularity, performance, and extensibility. It gained significant traction when Apple adopted it as the default debugger for Xcode, replacing GDB and leveraging its deep integration with the Clang compiler and LLVM toolchain. Over time, it has evolved into a cross-platform debugger, supporting Linux, Windows, and other Unix-like systems, widely used in modern C++, Objective-C, and Swift development.