190 lines · plain
1Overview2========3 4LLDB is a large and complex codebase. This section will help you become more5familiar with the pieces that make up LLDB and give a general overview of the6general architecture.7 8LLDB has many code groupings that makeup the source base:9 10API11---12 13The API folder contains the public interface to LLDB.14 15We are currently vending a C++ API. In order to be able to add methods to this16API and allow people to link to our classes, we have certain rules that we must17follow:18 19- Classes can't inherit from any other classes.20- Classes can't contain virtual methods.21- Classes should be compatible with script bridging utilities like swig.22- Classes should be lightweight and be backed by a single member. Pointers (or23 shared pointers) are the preferred choice since they allow changing the24 contents of the backend without affecting the public object layout.25- The interface should be as minimal as possible in order to give a complete26 API.27 28By adhering to these rules we should be able to continue to vend a C++ API, and29make changes to the API as any additional methods added to these classes will30just be a dynamic loader lookup and they won't affect the class layout (since31they aren't virtual methods, and no members can be added to the class).32 33Breakpoint34----------35 36A collection of classes that implement our breakpoint classes. Breakpoints are37resolved symbolically and always continue to resolve themselves as your program38runs. Whether settings breakpoints by file and line, by symbol name, by symbol39regular expression, or by address, breakpoints will keep trying to resolve new40locations each time shared libraries are loaded. Breakpoints will of course41unresolve themselves when shared libraries are unloaded. Breakpoints can also42be scoped to be set only in a specific shared library. By default, breakpoints43can be set in any shared library and will continue to attempt to be resolved44with each shared library load.45 46Breakpoint options can be set on the breakpoint, or on the individual47locations. This allows flexibility when dealing with breakpoints and allows us48to do what the user wants.49 50Commands51--------52 53The command source files represent objects that implement the functionality for54all textual commands available in our command line interface.55 56Every command is backed by a ``lldb_private::CommandObject`` or57``lldb_private::CommandObjectMultiword`` object.58 59``lldb_private::CommandObjectMultiword`` are commands that have subcommands and60allow command line commands to be logically grouped into a hierarchy.61 62``lldb_private::CommandObject`` command line commands are the objects that63implement the functionality of the command. They can optionally define options64for themselves, as well as group those options into logical groups that can go65together. The help system is tied into these objects and can extract the syntax66and option groupings to display appropriate help for each command.67 68Core69----70 71The Core source files contain basic functionality that is required in the72debugger as well as the class representing the debugger itself (Debugger). A73wide variety of classes are implemented:74 75- Address (section offset addressing)76- AddressRange77- Broadcaster / Event / Listener78- Communication classes that use Connection objects79- Mangled names80- Source manager81- Value objects82 83Data Formatters84---------------85 86A collection of classes that implement the data formatters subsystem.87 88Data formatters provide a set of user-tweakable hooks in the ValueObjects world89that allow to customize presentation aspects of variables. While users interact90with formatters mostly through the type command, inside LLDB there are a few91layers to the implementation: DataVisualization at the highest end of the92spectrum, backed by classes implementing individual formatters, matching rules,93etc.94 95For a general user-level introduction to data formatters, see :doc:`/use/variable`.96 97More details on their architecture can be found in :doc:`/resources/dataformatters`.98 99Expression100----------101 102Expression parsing files cover everything from evaluating DWARF expressions, to103evaluating expressions using Clang.104 105The DWARF expression parser has been heavily modified to support type106promotion, new opcodes needed for evaluating expressions with symbolic variable107references (expression local variables, program variables), and other operators108required by typical expressions such as assign, address of, float/double/long109double floating point values, casting, and more. The DWARF expression parser110uses a stack of lldb_private::Value objects. These objects know how to do the111standard C type promotion, and allow for symbolic references to variables in112the program and in the LLDB process (expression local and expression global113variables).114 115The expression parser uses a full instance of the Clang compiler in order to116accurately evaluate expressions. Hooks have been put into Clang so that the117compiler knows to ask about identifiers it doesn't know about. Once expressions118have be compiled into an AST, we can then traverse this AST and either generate119a DWARF expression that contains simple opcodes that can be quickly120re-evaluated each time an expression needs to be evaluated, or JIT'ed up into121code that can be run on the process being debugged.122 123Host124----125 126LLDB tries to abstract itself from the host upon which it is currently running127by providing a host abstraction layer. This layer includes functionality, whose128implementation varies wildly from host to host.129 130Host functionality includes abstraction layers for:131 132- Information about the host system (triple, list of running processes, etc.)133- Launching processes134- Various OS primitives like pipes and sockets135 136It also includes the base classes of the NativeProcess/Thread hierarchy, which137is used by lldb-server.138 139Interpreter140-----------141 142The interpreter classes are the classes responsible for being the base classes143needed for each command object, and is responsible for tracking and running144command line commands.145 146Symbol147------148 149Symbol classes involve everything needed in order to parse object files and150debug symbols. All the needed classes for compilation units (code and debug151info for a source file), functions, lexical blocks within functions, inlined152functions, types, declaration locations, and variables are in this section.153 154Target155------156 157Classes that are related to a debug target include:158 159- Target160- Process161- Thread162- Stack frames163- Stack frame registers164- ABI for function calling in process being debugged165- Execution context batons166 167Utility168-------169 170This module contains the lowest layers of LLDB. A lot of these classes don't171really have anything to do with debugging -- they are just there because the172higher layers of the debugger use these classes to implement their173functionality. Others are data structures used in many other parts of the174debugger. Most of the functionality in this module could be useful in an175application that is not a debugger; however, providing a general purpose C++176library is an explicit non-goal of this module..177 178This module provides following functionality:179 180- Abstract path manipulation (FileSpec)181- Architecture specification182- Data buffers (DataBuffer, DataEncoder, DataExtractor)183- Logging184- Structured data manipulation (JSON)185- Streams186- Timers187 188For historic reasons, some of this functionality overlaps that which is189provided by the LLVM support library.190