blob: 67e5021478b82c1110d8b6584a529c51350c3f58 [file] [log] [blame]
Greg Clayton854bb532010-06-10 02:48:57 +00001<!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">
3<head>
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>
7</head>
8
9<body>
10 <div class="www_title">
11 The <strong>LLDB</strong> Debugger
12 </div>
Eric Christopherb7eb7092010-06-10 05:35:26 +000013
Greg Clayton854bb532010-06-10 02:48:57 +000014<div id="container">
15 <div id="content">
Chris Lattner3cc7b7f2010-06-11 23:07:14 +000016
17 <!--#include virtual="sidebar.incl"-->
18
Greg Clayton854bb532010-06-10 02:48:57 +000019 <div id="middle">
20 <div class="post">
21 <h1 class ="postheader">Architecture</h1>
22 <div class="postcontent">
23
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>
26 </div>
27 <div class="postfooter"></div>
28 </div>
29 <div class="post">
30 <h1 class ="postheader">Code Layout</h1>
31 <div class="postcontent">
32
33 <p>LLDB has many code groupings that makeup the source base:</p>
34 <ul>
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="#expression">Expression</a></li>
40 <li><a href="#host">Host</a></li>
41 <li><a href="#interpreter">Interpreter</a></li>
42 <li><a href="#symbol">Symbol</a></li>
43 <li><a href="#targ">Target</a></li>
44 <li><a href="#utility">Utility</a></li>
45 </ul>
46 </div>
47 <div class="postfooter"></div>
48 </div>
49 <a name="api"></a>
50 <div class="post">
51 <h1 class ="postheader">API</h1>
52 <div class="postcontent">
53
54 <p>The API folder contains the public interface to LLDB.</p>
55 <p>We are currently vending a C++ API. In order to be able to add
56 methods to this API and allow people to link to our classes,
57 we have certain rules that we must follow:</p>
58 <ul>
59 <li>Classes can't inherit from any other classes.</li>
60 <li>Classes can't contain virtual methods.</li>
61 <li>Classes should be compatible with script bridging utilities like <a href="http://www.swig.org/">swig</a>.</li>
Caroline Ticef2f64f22011-01-07 17:16:03 +000062 <li>Classes should be lightweight and be backed by a single object pointer, shared pointer or global variable in the lldb_private.</li>
Greg Clayton854bb532010-06-10 02:48:57 +000063 <li>The interface should be as minimal as possible in order to give a complete API.</li>
64 </ul>
65 <p>By adhering to these rules we should be able to continue to
66 vend a C++ API, and make changes to the API as any additional
67 methods added to these classes will just be a dynamic loader
68 lookup and they won't affect the class layout (since they
69 aren't virtual methods, and no members can be added to the
Benjamin Kramer46a8cf32010-06-10 08:12:17 +000070 class).</p>
Greg Clayton854bb532010-06-10 02:48:57 +000071 </div>
72 <div class="postfooter"></div>
73 </div>
74 <a name="breakpoint"></a>
75 <div class="post">
76 <h1 class ="postheader">Breakpoint</h1>
77 <div class="postcontent">
78
79 <p>A collection of classes that implement our breakpoint classes.
80 Breakpoints are resolved symbolically and always continue to
Jason Molenda602ce7e2010-06-10 08:23:00 +000081 resolve themselves as your program runs. Whether settings breakpoints
Greg Clayton854bb532010-06-10 02:48:57 +000082 by file and line, by symbol name, by symbol regular expression,
83 or by address, breakpoints will keep trying to resolve new locations
84 each time shared libraries are loaded. Breakpoints will of course
85 unresolve themselves when shared libraries are unloaded. Breakpoints
86 can also be scoped to be set only in a specific shared library. By
87 default, breakpoints can be set in any shared library and will continue
88 to attempt to be resolved with each shared library load.</p>
89 <p>Breakpoint options can be set on the breakpoint,
90 or on the individual locations. This allows flexibility when dealing
Benjamin Kramer46a8cf32010-06-10 08:12:17 +000091 with breakpoints and allows us to do what the user wants.</p>
Greg Clayton854bb532010-06-10 02:48:57 +000092 </div>
93 <div class="postfooter"></div>
94 </div>
95 <a name="commands"></a>
96 <div class="post">
97 <h1 class ="postheader">Commands</h1>
98 <div class="postcontent">
99
100 <p>The command source files represent objects that implement
101 the functionality for all textual commands available
102 in our command line interface.</p>
103 <p>Every command is backed by a <b>lldb_private::CommandObject</b>
104 or <b>lldb_private::CommandObjectMultiword</b> object.</p>
105 <p><b>lldb_private::CommandObjectMultiword</b> are commands that
106 have subcommands and allow command line commands to be
Caroline Ticef2f64f22011-01-07 17:16:03 +0000107 logically grouped into a hierarchy.</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000108 <p><b>lldb_private::CommandObject</b> command line commands
109 are the objects that implement the functionality of the
110 command. They can optionally define
111 options for themselves, as well as group those options into
112 logical groups that can go together. The help system is
113 tied into these objects and can extract the syntax and
114 option groupings to display appropriate help for each
115 command.</p>
116 </div>
117 <div class="postfooter"></div>
118 </div>
119 <a name="core"></a>
120 <div class="post">
121 <h1 class ="postheader">Core</h1>
122 <div class="postcontent">
123
124 <p>The Core source files contain basic functionality that
125 is required in the debugger. A wide variety of classes
Benjamin Kramer46a8cf32010-06-10 08:12:17 +0000126 are implemented:</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000127
128 <ul>
129 <li>Address (section offset addressing)</li>
130 <li>AddressRange</li>
131 <li>Architecture specification</li>
132 <li>Broadcaster / Event / Listener </li>
133 <li>Communication classes that use Connection objects</li>
134 <li>Uniqued C strings</li>
135 <li>Data extraction</li>
136 <li>File specifications</li>
137 <li>Mangled names</li>
138 <li>Regular expressions</li>
139 <li>Source manager</li>
140 <li>Streams</li>
141 <li>Value objects</li>
142 </ul>
143 </div>
144 <div class="postfooter"></div>
145 </div>
146 <a name="expression"></a>
147 <div class="post">
148 <h1 class ="postheader">Expression</h1>
149 <div class="postcontent">
150
151 <p>Expression parsing files cover everything from evaluating
152 DWARF expressions, to evaluating expressions using
153 Clang.</p>
154 <p>The DWARF expression parser has been heavily modified to
155 support type promotion, new opcodes needed for evaluating
156 expressions with symbolic variable references (expression local variables,
157 program variables), and other operators required by
158 typical expressions such as assign, address of, float/double/long
159 double floating point values, casting, and more. The
160 DWARF expression parser uses a stack of lldb_private::Value
161 objects. These objects know how to do the standard C type
162 promotion, and allow for symbolic references to variables
163 in the program and in the LLDB process (expression local
164 and expression global variables).</p>
165 <p>The expression parser uses a full instance of the Clang
166 compiler in order to accurately evaluate expressions.
167 Hooks have been put into Clang so that the compiler knows
Chris Lattnerba6d3bb2010-06-11 22:52:46 +0000168 to ask about identifiers it doesn't know about. Once
Greg Clayton854bb532010-06-10 02:48:57 +0000169 expressions have be compiled into an AST, we can then
170 traverse this AST and either generate a DWARF expression
171 that contains simple opcodes that can be quickly re-evaluated
172 each time an expression needs to be evaluated, or JIT'ed
Benjamin Kramer46a8cf32010-06-10 08:12:17 +0000173 up into code that can be run on the process being debugged.</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000174 </div>
175 <div class="postfooter"></div>
176 </div>
177 <a name="host"></a>
178 <div class="post">
179 <h1 class ="postheader">Host</h1>
180 <div class="postcontent">
181
182 <p>LLDB tries to abstract itself from the host upon which
183 it is currently running by providing a host abstraction
Chris Lattnerba6d3bb2010-06-11 22:52:46 +0000184 layer. This layer involves everything from spawning, detaching,
185 joining and killing native in-process threads, to getting
Greg Clayton854bb532010-06-10 02:48:57 +0000186 current information about the current host.</p>
Benjamin Kramer46a8cf32010-06-10 08:12:17 +0000187 <p>Host functionality includes abstraction layers for:</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000188 <ul>
189 <li>Mutexes</li>
190 <li>Conditions</li>
191 <li>Timing functions</li>
192 <li>Thread functions</li>
193 <li>Host target triple</li>
194 <li>Host child process notifications</li>
195 <li>Host specific types</li>
196 </ul>
197 </div>
198 <div class="postfooter"></div>
199 </div>
200 <a name="interpreter"></a>
201 <div class="post">
202 <h1 class ="postheader">Interpreter</h1>
203 <div class="postcontent">
204
205 <p>The interpreter classes are the classes responsible for
206 being the base classes needed for each command object,
207 and is responsible for tracking and running command line
Benjamin Kramer46a8cf32010-06-10 08:12:17 +0000208 commands.</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000209 </div>
210 <div class="postfooter"></div>
211 </div>
212 <a name="symbol"></a>
213 <div class="post">
214 <h1 class ="postheader">Symbol</h1>
215 <div class="postcontent">
216 <p>Symbol classes involve everything needed in order to parse
217 object files and debug symbols. All the needed classes
218 for compilation units (code and debug info for a source file),
219 functions, lexical blocks within functions, inlined
220 functions, types, declaration locations, and variables
221 are in this section.</p>
222 </div>
223 <div class="postfooter"></div>
224 </div>
225 <a name="targ"></a>
226 <div class="post">
227 <h1 class ="postheader">Target</h1>
228 <div class="postcontent">
229
230 <p>Classes that are related to a debug target include:</p>
231 <ul>
232 <li>Target</li>
233 <li>Process</li>
234 <li>Thread</li>
235 <li>Stack frames</li>
236 <li>Stack frame registers</li>
237 <li>ABI for function calling in process being debugged</li>
238 <li>Execution context batons</li>
239 </ul>
240 </div>
241 <div class="postfooter"></div>
242 </div>
243 <a name="utility"></a>
244 <div class="post">
245 <h1 class ="postheader">Utility</h1>
246 <div class="postcontent">
247
Christopher Friesen236d8422010-06-12 03:34:21 +0000248 <p>Utility files should be as stand alone as possible and
249 available for LLDB, plug-ins or related
Eric Christopherb7eb7092010-06-10 05:35:26 +0000250 applications to use.</p>
Greg Clayton854bb532010-06-10 02:48:57 +0000251 <p>Files found in the Utility section include:</p>
252 <ul>
253 <li>Pseudo-terminal support</li>
254 <li>Register numbering for specific architectures.</li>
255 <li>String data extractors</li>
256 </ul>
257 </div>
258 <div class="postfooter"></div>
259 </div>
260 </div>
261 </div>
262</div>
263</body>
Eric Christopherb7eb7092010-06-10 05:35:26 +0000264</html>