LLDB (debugger)
Developer(s) | LLVM Developer Group |
---|---|
Repository | |
Written in | C++ |
Operating system | macOS i386 and x86-64, Linux, FreeBSD, Windows |
Type | Debugger |
License | UIUC (BSD-style) Apache License 2.0 with LLVM Exceptions (v9.0.0 or later)[1] |
Website | lldb |
This article may rely excessively on sources too closely associated with the subject, potentially preventing the article from being verifiable and neutral. (February 2015) |
The LLDB Debugger (LLDB) is the debugger component of the LLVM project. It is built as a set of reusable components which extensively use existing libraries from LLVM, such as the Clang expression parser and LLVM disassembler. LLDB is free and open-source software under the University of Illinois/NCSA Open Source License,[2] a BSD-style permissive software license. Since v9.0.0, it was relicensed to the Apache License 2.0 with LLVM Exceptions.[1]
Current state
LLDB supports debugging of programs written in C, Objective-C, and C++. The Swift community maintains a version which adds support for the language. It is known to work on macOS, Linux, FreeBSD, and Windows,[3] and supports i386, x86-64, and ARM instruction sets[4]. LLDB is the default debugger for Xcode 5 and later. It can be used from other IDEs, including Visual Studio Code[5], Eclipse,[6] and CLion.[7]
Feature | FreeBSD | Linux | macOS | Windows |
---|---|---|---|---|
Backtracing | ![]() |
![]() |
![]() |
![]() |
Breakpoints | ![]() |
![]() |
![]() |
![]() |
C++11: | ![]() |
![]() |
![]() |
? |
Command-line lldb tool | ![]() |
![]() |
![]() |
![]() |
Core file debugging | ![]() |
![]() |
![]() |
![]() |
Debugserver (remote debugging) | Not ported | Not ported | ![]() |
Not ported |
Disassembly | ![]() |
![]() |
![]() |
![]() |
Expression evaluation | ? | Works with some bugs | ![]() |
Works with some bugs |
JIT debugging | ? | Symbolic debugging only | Untested | ![]() |
Objective-C 2.0: | ? | — | ![]() |
— |
An example session
Consider the following source-code written in C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
size_t foo_len( const char *s )
{
return strlen( s );
}
int main( int argc, char *argv[] )
{
const char *a = NULL;
printf( "size of a = %lu\n", foo_len(a) );
exit( 0 );
}
Using the Clang compiler on Linux, the code above must be compiled using the -g
flag in order to include appropriate debug information on the binary generated, thus making it possible to inspect it using LLDB. Assuming that the file containing the code above is named example.c
, the command for the compilation could be:
$ clang example.c -Og -g -o example
And the binary can now be run:
$ ./example
Segmentation fault
Since the example code, when executed, generates a segmentation fault, LLDB can be used to inspect the problem.
$ lldb ./example
GNU gdb (GDB) Fedora (7.3.50.20110722-13.fc16)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /path/example...done.
(gdb) run
Starting program: /path/example
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400527 in foo_len (s=0x0) at example.c:8
8 return strlen (s);
(gdb) print s
$1 = 0x0
See also
References
- ^ a b LICENSE.TXT, llvm.org, retrieved 2019-09-24
- ^ "LLVM Release License"
- ^ "LLVM Project Blog".
- ^ a b "LLDB Status". Retrieved November 28, 2019.
- ^ "Add a new tool named "lldb-vscode" that implements the Visual Studio Code Debug Adaptor Protocol".
- ^ "CDT/Useer/FAQ".
- ^ "LLDB CLion Blog".