]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - www/architecture/index.html
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / www / architecture / index.html
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">
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       <strong>LLDB</strong>'s Architecture
12     </div>
13
14 <div id="container">
15         <div id="content">
16         
17   <!--#include virtual="../sidebar.incl"-->
18   
19                 <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="#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>
46                                     </ul>
47                                 </div>
48                                 <div class="postfooter"></div>
49                         </div>
50                         <a name="api"></a>
51                         <div class="post">
52                                 <h1 class ="postheader">API</h1>
53                                 <div class="postcontent">
54
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>
59                    <ul>
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>
65                                     </ul>
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
71                                         class).</p>
72                                 </div>
73                                 <div class="postfooter"></div>
74                         </div>
75                         <a name="breakpoint"></a>
76                         <div class="post">
77                                 <h1 class ="postheader">Breakpoint</h1>
78                                 <div class="postcontent">
79
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>
93                                 </div>
94                                 <div class="postfooter"></div>
95                         </div>
96                         <a name="commands"></a>
97                         <div class="post">
98                                 <h1 class ="postheader">Commands</h1>
99                                 <div class="postcontent">
100
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
116                      command.</p>
117                                 </div>
118                                 <div class="postfooter"></div>
119                         </div>
120                         <a name="core"></a>
121                         <div class="post">
122                                 <h1 class ="postheader">Core</h1>
123                                 <div class="postcontent">
124
125                                    <p>The Core source files contain basic functionality that
126                                        is required in the debugger. A wide variety of classes
127                                        are implemented:</p>
128                                        
129                        <ul>
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>
141                                                 <li>Streams</li>
142                                                 <li>Value objects</li>
143                                     </ul>
144                                 </div>
145                                 <div class="postfooter"></div>
146                         </div>
147                         <a name="dataformatters"></a>
148                         <div class="post">
149                                 <h1 class ="postheader">DataFormatters</h1>
150                                 <div class="postcontent">
151
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>
157                                 
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>.
160                                 </div>
161                                 <div class="postfooter"></div>
162                         </div>
163                         <a name="expression"></a>
164                         <div class="post">
165                                 <h1 class ="postheader">Expression</h1>
166                                 <div class="postcontent">
167
168                                    <p>Expression parsing files cover everything from evaluating
169                                        DWARF expressions, to evaluating expressions using
170                                        Clang.</p>
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>
191                                 </div>
192                                 <div class="postfooter"></div>
193                         </div>
194                         <a name="host"></a>
195                         <div class="post">
196                                 <h1 class ="postheader">Host</h1>
197                                 <div class="postcontent">
198
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>
205                            <ul>
206                                                 <li>Mutexes</li>
207                                                 <li>Conditions</li>
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>
213                                             </ul>
214                                 </div>
215                                 <div class="postfooter"></div>
216                         </div>
217                         <a name="interpreter"></a>
218                         <div class="post">
219                                 <h1 class ="postheader">Interpreter</h1>
220                                 <div class="postcontent">
221
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
225                                        commands.</p>
226                                 </div>
227                                 <div class="postfooter"></div>
228                         </div>
229                         <a name="symbol"></a>
230                         <div class="post">
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>
239                                 </div>
240                                 <div class="postfooter"></div>
241                         </div>
242                         <a name="targ"></a>
243                         <div class="post">
244                                 <h1 class ="postheader">Target</h1>
245                                 <div class="postcontent">
246
247                                    <p>Classes that are related to a debug target include:</p>
248                        <ul>
249                                            <li>Target</li>
250                                                 <li>Process</li>
251                                                 <li>Thread</li>
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>
256                                     </ul>
257                                 </div>
258                                 <div class="postfooter"></div>
259                         </div>
260                         <a name="utility"></a>
261                         <div class="post">
262                                 <h1 class ="postheader">Utility</h1>
263                                 <div class="postcontent">
264
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>
269                            <ul>
270                                                    <li>Pseudo-terminal support</li>
271                                                 <li>Register numbering for specific architectures.</li>
272                                                 <li>String data extractors</li>
273                                             </ul>
274                                 </div>
275                                 <div class="postfooter"></div>
276                         </div>
277                 </div>
278         </div>
279 </div>
280 </body>
281 </html>