1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5 <link href="../style.css" rel="stylesheet" type="text/css" />
6 <title>LLDB Architecture</title>
10 <div class="www_title">
11 <strong>LLDB</strong>'s Architecture
17 <!--#include virtual="../sidebar.incl"-->
21 <h1 class ="postheader">Architecture</h1>
22 <div class="postcontent">
24 <p>LLDB is a large and complex codebase. This section will help you become more familiar with
25 the pieces that make up LLDB and give a general overview of the general architecture.</p>
27 <div class="postfooter"></div>
30 <h1 class ="postheader">Code Layout</h1>
31 <div class="postcontent">
33 <p>LLDB has many code groupings that makeup the source base:</p>
35 <li><a href="#api">API</a></li>
36 <li><a href="#breakpoint">Breakpoint</a></li>
37 <li><a href="#commands">Commands</a></li>
38 <li><a href="#core">Core</a></li>
39 <li><a href="#dataformatters">DataFormatters</a></li>
40 <li><a href="#expression">Expression</a></li>
41 <li><a href="#host">Host</a></li>
42 <li><a href="#interpreter">Interpreter</a></li>
43 <li><a href="#symbol">Symbol</a></li>
44 <li><a href="#targ">Target</a></li>
45 <li><a href="#utility">Utility</a></li>
48 <div class="postfooter"></div>
52 <h1 class ="postheader">API</h1>
53 <div class="postcontent">
55 <p>The API folder contains the public interface to LLDB.</p>
56 <p>We are currently vending a C++ API. In order to be able to add
57 methods to this API and allow people to link to our classes,
58 we have certain rules that we must follow:</p>
60 <li>Classes can't inherit from any other classes.</li>
61 <li>Classes can't contain virtual methods.</li>
62 <li>Classes should be compatible with script bridging utilities like <a href="http://www.swig.org/">swig</a>.</li>
63 <li>Classes should be lightweight and be backed by a single member. Pointers (or shared pointers) are the preferred choice since they allow changing the contents of the backend without affecting the public object layout.</li>
64 <li>The interface should be as minimal as possible in order to give a complete API.</li>
66 <p>By adhering to these rules we should be able to continue to
67 vend a C++ API, and make changes to the API as any additional
68 methods added to these classes will just be a dynamic loader
69 lookup and they won't affect the class layout (since they
70 aren't virtual methods, and no members can be added to the
73 <div class="postfooter"></div>
75 <a name="breakpoint"></a>
77 <h1 class ="postheader">Breakpoint</h1>
78 <div class="postcontent">
80 <p>A collection of classes that implement our breakpoint classes.
81 Breakpoints are resolved symbolically and always continue to
82 resolve themselves as your program runs. Whether settings breakpoints
83 by file and line, by symbol name, by symbol regular expression,
84 or by address, breakpoints will keep trying to resolve new locations
85 each time shared libraries are loaded. Breakpoints will of course
86 unresolve themselves when shared libraries are unloaded. Breakpoints
87 can also be scoped to be set only in a specific shared library. By
88 default, breakpoints can be set in any shared library and will continue
89 to attempt to be resolved with each shared library load.</p>
90 <p>Breakpoint options can be set on the breakpoint,
91 or on the individual locations. This allows flexibility when dealing
92 with breakpoints and allows us to do what the user wants.</p>
94 <div class="postfooter"></div>
96 <a name="commands"></a>
98 <h1 class ="postheader">Commands</h1>
99 <div class="postcontent">
101 <p>The command source files represent objects that implement
102 the functionality for all textual commands available
103 in our command line interface.</p>
104 <p>Every command is backed by a <b>lldb_private::CommandObject</b>
105 or <b>lldb_private::CommandObjectMultiword</b> object.</p>
106 <p><b>lldb_private::CommandObjectMultiword</b> are commands that
107 have subcommands and allow command line commands to be
108 logically grouped into a hierarchy.</p>
109 <p><b>lldb_private::CommandObject</b> command line commands
110 are the objects that implement the functionality of the
111 command. They can optionally define
112 options for themselves, as well as group those options into
113 logical groups that can go together. The help system is
114 tied into these objects and can extract the syntax and
115 option groupings to display appropriate help for each
118 <div class="postfooter"></div>
122 <h1 class ="postheader">Core</h1>
123 <div class="postcontent">
125 <p>The Core source files contain basic functionality that
126 is required in the debugger. A wide variety of classes
130 <li>Address (section offset addressing)</li>
131 <li>AddressRange</li>
132 <li>Architecture specification</li>
133 <li>Broadcaster / Event / Listener </li>
134 <li>Communication classes that use Connection objects</li>
135 <li>Uniqued C strings</li>
136 <li>Data extraction</li>
137 <li>File specifications</li>
138 <li>Mangled names</li>
139 <li>Regular expressions</li>
140 <li>Source manager</li>
142 <li>Value objects</li>
145 <div class="postfooter"></div>
147 <a name="dataformatters"></a>
149 <h1 class ="postheader">DataFormatters</h1>
150 <div class="postcontent">
152 <p>A collection of classes that implement the data formatters subsystem.</p>
153 <p>Data formatters provide a set of user-tweakable hooks in the ValueObjects world that allow
154 to customize presentation aspects of variables. While users interact with formatters mostly through the
155 <code>type</code> command, inside LLDB there are a few layers to the implementation: DataVisualization at the highest
156 end of the spectrum, backed by classes implementing individual formatters, matching rules, ...</p>
158 <p>For a general user-level introduction to data formatters, you can look <a href="../varformats.html">here</a>.
159 <p>More details on the architecture are to be found <a href="../architecture/varformats.html">here</a>.
161 <div class="postfooter"></div>
163 <a name="expression"></a>
165 <h1 class ="postheader">Expression</h1>
166 <div class="postcontent">
168 <p>Expression parsing files cover everything from evaluating
169 DWARF expressions, to evaluating expressions using
171 <p>The DWARF expression parser has been heavily modified to
172 support type promotion, new opcodes needed for evaluating
173 expressions with symbolic variable references (expression local variables,
174 program variables), and other operators required by
175 typical expressions such as assign, address of, float/double/long
176 double floating point values, casting, and more. The
177 DWARF expression parser uses a stack of lldb_private::Value
178 objects. These objects know how to do the standard C type
179 promotion, and allow for symbolic references to variables
180 in the program and in the LLDB process (expression local
181 and expression global variables).</p>
182 <p>The expression parser uses a full instance of the Clang
183 compiler in order to accurately evaluate expressions.
184 Hooks have been put into Clang so that the compiler knows
185 to ask about identifiers it doesn't know about. Once
186 expressions have be compiled into an AST, we can then
187 traverse this AST and either generate a DWARF expression
188 that contains simple opcodes that can be quickly re-evaluated
189 each time an expression needs to be evaluated, or JIT'ed
190 up into code that can be run on the process being debugged.</p>
192 <div class="postfooter"></div>
196 <h1 class ="postheader">Host</h1>
197 <div class="postcontent">
199 <p>LLDB tries to abstract itself from the host upon which
200 it is currently running by providing a host abstraction
201 layer. This layer involves everything from spawning, detaching,
202 joining and killing native in-process threads, to getting
203 current information about the current host.</p>
204 <p>Host functionality includes abstraction layers for:</p>
208 <li>Timing functions</li>
209 <li>Thread functions</li>
210 <li>Host target triple</li>
211 <li>Host child process notifications</li>
212 <li>Host specific types</li>
215 <div class="postfooter"></div>
217 <a name="interpreter"></a>
219 <h1 class ="postheader">Interpreter</h1>
220 <div class="postcontent">
222 <p>The interpreter classes are the classes responsible for
223 being the base classes needed for each command object,
224 and is responsible for tracking and running command line
227 <div class="postfooter"></div>
229 <a name="symbol"></a>
231 <h1 class ="postheader">Symbol</h1>
232 <div class="postcontent">
233 <p>Symbol classes involve everything needed in order to parse
234 object files and debug symbols. All the needed classes
235 for compilation units (code and debug info for a source file),
236 functions, lexical blocks within functions, inlined
237 functions, types, declaration locations, and variables
238 are in this section.</p>
240 <div class="postfooter"></div>
244 <h1 class ="postheader">Target</h1>
245 <div class="postcontent">
247 <p>Classes that are related to a debug target include:</p>
252 <li>Stack frames</li>
253 <li>Stack frame registers</li>
254 <li>ABI for function calling in process being debugged</li>
255 <li>Execution context batons</li>
258 <div class="postfooter"></div>
260 <a name="utility"></a>
262 <h1 class ="postheader">Utility</h1>
263 <div class="postcontent">
265 <p>Utility files should be as stand alone as possible and
266 available for LLDB, plug-ins or related
267 applications to use.</p>
268 <p>Files found in the Utility section include:</p>
270 <li>Pseudo-terminal support</li>
271 <li>Register numbering for specific architectures.</li>
272 <li>String data extractors</li>
275 <div class="postfooter"></div>