blob: fab63046a484414672b10315527ce3707ef08d74 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
Bill Wendlingde024832009-05-17 05:52:39 +00005 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006 <title>Source Level Debugging with LLVM</title>
7 <link rel="stylesheet" href="llvm.css" type="text/css">
8</head>
9<body>
10
11<div class="doc_title">Source Level Debugging with LLVM</div>
12
13<table class="layout" style="width:100%">
14 <tr class="layout">
15 <td class="left">
16<ul>
17 <li><a href="#introduction">Introduction</a>
18 <ol>
19 <li><a href="#phil">Philosophy behind LLVM debugging information</a></li>
20 <li><a href="#consumers">Debug information consumers</a></li>
21 <li><a href="#debugopt">Debugging optimized code</a></li>
22 </ol></li>
23 <li><a href="#format">Debugging information format</a>
24 <ol>
25 <li><a href="#debug_info_descriptors">Debug information descriptors</a>
26 <ul>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 <li><a href="#format_compile_units">Compile unit descriptors</a></li>
28 <li><a href="#format_global_variables">Global variable descriptors</a></li>
29 <li><a href="#format_subprograms">Subprogram descriptors</a></li>
30 <li><a href="#format_blocks">Block descriptors</a></li>
31 <li><a href="#format_basic_type">Basic type descriptors</a></li>
32 <li><a href="#format_derived_type">Derived type descriptors</a></li>
33 <li><a href="#format_composite_type">Composite type descriptors</a></li>
34 <li><a href="#format_subrange">Subrange descriptors</a></li>
35 <li><a href="#format_enumeration">Enumerator descriptors</a></li>
36 <li><a href="#format_variables">Local variables</a></li>
37 </ul></li>
38 <li><a href="#format_common_intrinsics">Debugger intrinsic functions</a>
39 <ul>
40 <li><a href="#format_common_stoppoint">llvm.dbg.stoppoint</a></li>
41 <li><a href="#format_common_func_start">llvm.dbg.func.start</a></li>
42 <li><a href="#format_common_region_start">llvm.dbg.region.start</a></li>
43 <li><a href="#format_common_region_end">llvm.dbg.region.end</a></li>
44 <li><a href="#format_common_declare">llvm.dbg.declare</a></li>
45 </ul></li>
46 <li><a href="#format_common_stoppoints">Representing stopping points in the
47 source program</a></li>
48 </ol></li>
49 <li><a href="#ccxx_frontend">C/C++ front-end specific debug information</a>
50 <ol>
51 <li><a href="#ccxx_compile_units">C/C++ source file information</a></li>
52 <li><a href="#ccxx_global_variable">C/C++ global variable information</a></li>
53 <li><a href="#ccxx_subprogram">C/C++ function information</a></li>
54 <li><a href="#ccxx_basic_types">C/C++ basic types</a></li>
55 <li><a href="#ccxx_derived_types">C/C++ derived types</a></li>
56 <li><a href="#ccxx_composite_types">C/C++ struct/union types</a></li>
57 <li><a href="#ccxx_enumeration_types">C/C++ enumeration types</a></li>
58 </ol></li>
59</ul>
60</td>
61<td class="right">
62<img src="img/venusflytrap.jpg" alt="A leafy and green bug eater" width="247"
63height="369">
64</td>
65</tr></table>
66
67<div class="doc_author">
68 <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a>
69 and <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p>
70</div>
71
72
73<!-- *********************************************************************** -->
74<div class="doc_section"><a name="introduction">Introduction</a></div>
75<!-- *********************************************************************** -->
76
77<div class="doc_text">
78
79<p>This document is the central repository for all information pertaining to
Bill Wendlingde024832009-05-17 05:52:39 +000080 debug information in LLVM. It describes the <a href="#format">actual format
81 that the LLVM debug information</a> takes, which is useful for those
82 interested in creating front-ends or dealing directly with the information.
Chris Lattner990e7652009-07-18 21:47:15 +000083 Further, this document provides specific examples of what debug information
Bill Wendlingde024832009-05-17 05:52:39 +000084 for C/C++.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085
86</div>
87
88<!-- ======================================================================= -->
89<div class="doc_subsection">
90 <a name="phil">Philosophy behind LLVM debugging information</a>
91</div>
92
93<div class="doc_text">
94
95<p>The idea of the LLVM debugging information is to capture how the important
Bill Wendlingde024832009-05-17 05:52:39 +000096 pieces of the source-language's Abstract Syntax Tree map onto LLVM code.
97 Several design aspects have shaped the solution that appears here. The
98 important ones are:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000099
100<ul>
Bill Wendlingde024832009-05-17 05:52:39 +0000101 <li>Debugging information should have very little impact on the rest of the
102 compiler. No transformations, analyses, or code generators should need to
103 be modified because of debugging information.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
Bill Wendlingde024832009-05-17 05:52:39 +0000105 <li>LLVM optimizations should interact in <a href="#debugopt">well-defined and
106 easily described ways</a> with the debugging information.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000107
Bill Wendlingde024832009-05-17 05:52:39 +0000108 <li>Because LLVM is designed to support arbitrary programming languages,
109 LLVM-to-LLVM tools should not need to know anything about the semantics of
110 the source-level-language.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111
Bill Wendlingde024832009-05-17 05:52:39 +0000112 <li>Source-level languages are often <b>widely</b> different from one another.
113 LLVM should not put any restrictions of the flavor of the source-language,
114 and the debugging information should work with any language.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115
Bill Wendlingde024832009-05-17 05:52:39 +0000116 <li>With code generator support, it should be possible to use an LLVM compiler
117 to compile a program to native machine code and standard debugging
118 formats. This allows compatibility with traditional machine-code level
119 debuggers, like GDB or DBX.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120</ul>
121
Bill Wendlingde024832009-05-17 05:52:39 +0000122<p>The approach used by the LLVM implementation is to use a small set
123 of <a href="#format_common_intrinsics">intrinsic functions</a> to define a
124 mapping between LLVM program objects and the source-level objects. The
125 description of the source-level program is maintained in LLVM global
126 variables in an <a href="#ccxx_frontend">implementation-defined format</a>
127 (the C/C++ front-end currently uses working draft 7 of
128 the <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3
129 standard</a>).</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130
131<p>When a program is being debugged, a debugger interacts with the user and
Bill Wendlingde024832009-05-17 05:52:39 +0000132 turns the stored debug information into source-language specific information.
133 As such, a debugger must be aware of the source-language, and is thus tied to
134 a specific language or family of languages.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136</div>
137
138<!-- ======================================================================= -->
139<div class="doc_subsection">
140 <a name="consumers">Debug information consumers</a>
141</div>
142
143<div class="doc_text">
Bill Wendlingde024832009-05-17 05:52:39 +0000144
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145<p>The role of debug information is to provide meta information normally
Bill Wendlingde024832009-05-17 05:52:39 +0000146 stripped away during the compilation process. This meta information provides
147 an LLVM user a relationship between generated code and the original program
148 source code.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149
150<p>Currently, debug information is consumed by the DwarfWriter to produce dwarf
Bill Wendlingde024832009-05-17 05:52:39 +0000151 information used by the gdb debugger. Other targets could use the same
152 information to produce stabs or other debug forms.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153
154<p>It would also be reasonable to use debug information to feed profiling tools
Bill Wendlingde024832009-05-17 05:52:39 +0000155 for analysis of generated code, or, tools for reconstructing the original
156 source from generated code.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157
158<p>TODO - expound a bit more.</p>
159
160</div>
161
162<!-- ======================================================================= -->
163<div class="doc_subsection">
164 <a name="debugopt">Debugging optimized code</a>
165</div>
166
167<div class="doc_text">
168
169<p>An extremely high priority of LLVM debugging information is to make it
Bill Wendlingde024832009-05-17 05:52:39 +0000170 interact well with optimizations and analysis. In particular, the LLVM debug
171 information provides the following guarantees:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172
173<ul>
Bill Wendlingde024832009-05-17 05:52:39 +0000174 <li>LLVM debug information <b>always provides information to accurately read
175 the source-level state of the program</b>, regardless of which LLVM
176 optimizations have been run, and without any modification to the
177 optimizations themselves. However, some optimizations may impact the
178 ability to modify the current state of the program with a debugger, such
179 as setting program variables, or calling functions that have been
180 deleted.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181
Bill Wendlingde024832009-05-17 05:52:39 +0000182 <li>LLVM optimizations gracefully interact with debugging information. If
183 they are not aware of debug information, they are automatically disabled
184 as necessary in the cases that would invalidate the debug info. This
185 retains the LLVM features, making it easy to write new
186 transformations.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187
Bill Wendlingde024832009-05-17 05:52:39 +0000188 <li>As desired, LLVM optimizations can be upgraded to be aware of the LLVM
189 debugging information, allowing them to update the debugging information
190 as they perform aggressive optimizations. This means that, with effort,
191 the LLVM optimizers could optimize debug code just as well as non-debug
192 code.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193
Bill Wendlingde024832009-05-17 05:52:39 +0000194 <li>LLVM debug information does not prevent many important optimizations from
195 happening (for example inlining, basic block reordering/merging/cleanup,
196 tail duplication, etc), further reducing the amount of the compiler that
197 eventually is "aware" of debugging information.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198
Bill Wendlingde024832009-05-17 05:52:39 +0000199 <li>LLVM debug information is automatically optimized along with the rest of
200 the program, using existing facilities. For example, duplicate
201 information is automatically merged by the linker, and unused information
202 is automatically removed.</li>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203</ul>
204
205<p>Basically, the debug information allows you to compile a program with
Bill Wendlingde024832009-05-17 05:52:39 +0000206 "<tt>-O0 -g</tt>" and get full debug information, allowing you to arbitrarily
207 modify the program as it executes from a debugger. Compiling a program with
208 "<tt>-O3 -g</tt>" gives you full debug information that is always available
209 and accurate for reading (e.g., you get accurate stack traces despite tail
210 call elimination and inlining), but you might lose the ability to modify the
211 program and call functions where were optimized out of the program, or
212 inlined away completely.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213
Misha Brukmane5b22d42008-12-16 02:54:22 +0000214<p><a href="TestingGuide.html#quicktestsuite">LLVM test suite</a> provides a
Bill Wendlingde024832009-05-17 05:52:39 +0000215 framework to test optimizer's handling of debugging information. It can be
216 run like this:</p>
Devang Patel7717e542008-11-21 19:35:57 +0000217
218<div class="doc_code">
219<pre>
220% cd llvm/projects/test-suite/MultiSource/Benchmarks # or some other level
221% make TEST=dbgopt
222</pre>
223</div>
224
Bill Wendlingde024832009-05-17 05:52:39 +0000225<p>This will test impact of debugging information on optimization passes. If
226 debugging information influences optimization passes then it will be reported
227 as a failure. See <a href="TestingGuide.html">TestingGuide</a> for more
228 information on LLVM test infrastructure and how to run various tests.</p>
Devang Patel7717e542008-11-21 19:35:57 +0000229
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230</div>
231
232<!-- *********************************************************************** -->
233<div class="doc_section">
234 <a name="format">Debugging information format</a>
235</div>
236<!-- *********************************************************************** -->
237
238<div class="doc_text">
239
240<p>LLVM debugging information has been carefully designed to make it possible
Bill Wendlingde024832009-05-17 05:52:39 +0000241 for the optimizer to optimize the program and debugging information without
242 necessarily having to know anything about debugging information. In
243 particular, the global constant merging pass automatically eliminates
244 duplicated debugging information (often caused by header files), the global
245 dead code elimination pass automatically deletes debugging information for a
246 function if it decides to delete the function, and the linker eliminates
247 debug information when it merges <tt>linkonce</tt> functions.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248
249<p>To do this, most of the debugging information (descriptors for types,
Bill Wendlingde024832009-05-17 05:52:39 +0000250 variables, functions, source files, etc) is inserted by the language
251 front-end in the form of LLVM global variables. These LLVM global variables
252 are no different from any other global variables, except that they have a web
253 of LLVM intrinsic functions that point to them. If the last references to a
254 particular piece of debugging information are deleted (for example, by the
255 <tt>-globaldce</tt> pass), the extraneous debug information will
256 automatically become dead and be removed by the optimizer.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257
258<p>Debug information is designed to be agnostic about the target debugger and
Bill Wendlingde024832009-05-17 05:52:39 +0000259 debugging information representation (e.g. DWARF/Stabs/etc). It uses a
260 generic machine debug information pass to decode the information that
261 represents variables, types, functions, namespaces, etc: this allows for
262 arbitrary source-language semantics and type-systems to be used, as long as
263 there is a module written for the target debugger to interpret the
264 information. In addition, debug global variables are declared in
265 the <tt>"llvm.metadata"</tt> section. All values declared in this section
266 are stripped away after target debug information is constructed and before
267 the program object is emitted.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268
269<p>To provide basic functionality, the LLVM debugger does have to make some
Bill Wendlingde024832009-05-17 05:52:39 +0000270 assumptions about the source-level language being debugged, though it keeps
271 these to a minimum. The only common features that the LLVM debugger assumes
272 exist are <a href="#format_compile_units">source files</a>,
273 and <a href="#format_global_variables">program objects</a>. These abstract
274 objects are used by a debugger to form stack traces, show information about
275 local variables, etc.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276
277<p>This section of the documentation first describes the representation aspects
Bill Wendlingde024832009-05-17 05:52:39 +0000278 common to any source-language. The <a href="#ccxx_frontend">next section</a>
279 describes the data layout conventions used by the C and C++ front-ends.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280
281</div>
282
283<!-- ======================================================================= -->
284<div class="doc_subsection">
285 <a name="debug_info_descriptors">Debug information descriptors</a>
286</div>
287
288<div class="doc_text">
Bill Wendlingde024832009-05-17 05:52:39 +0000289
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290<p>In consideration of the complexity and volume of debug information, LLVM
Bill Wendlingde024832009-05-17 05:52:39 +0000291 provides a specification for well formed debug global variables. The
292 constant value of each of these globals is one of a limited set of
293 structures, known as debug descriptors.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294
295<p>Consumers of LLVM debug information expect the descriptors for program
Bill Wendlingde024832009-05-17 05:52:39 +0000296 objects to start in a canonical format, but the descriptors can include
297 additional information appended at the end that is source-language
298 specific. All LLVM debugging information is versioned, allowing backwards
299 compatibility in the case that the core structures need to change in some
300 way. Also, all debugging information objects start with a tag to indicate
301 what type of object it is. The source-language is allowed to define its own
302 objects, by using unreserved tag numbers. We recommend using with tags in
303 the range 0x1000 thru 0x2000 (there is a defined enum DW_TAG_user_base =
304 0x1000.)</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305
306<p>The fields of debug descriptors used internally by LLVM (MachineModuleInfo)
Bill Wendlingde024832009-05-17 05:52:39 +0000307 are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>,
308 <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>i8*</tt> and
309 <tt>{&nbsp;}*</tt>. References to arbitrary values are handled using a
310 <tt>{&nbsp;}*</tt> and a cast to <tt>{&nbsp;}*</tt> expression; typically
311 references to other field descriptors, arrays of descriptors or global
312 variables.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313
Bill Wendlingde024832009-05-17 05:52:39 +0000314<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000316%llvm.dbg.object.type = type {
317 uint, ;; A tag
318 ...
319}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000321</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322
323<p><a name="LLVMDebugVersion">The first field of a descriptor is always an
Bill Wendlingde024832009-05-17 05:52:39 +0000324 <tt>uint</tt> containing a tag value identifying the content of the
325 descriptor. The remaining fields are specific to the descriptor. The values
326 of tags are loosely bound to the tag values of DWARF information entries.
327 However, that does not restrict the use of the information supplied to DWARF
328 targets. To facilitate versioning of debug information, the tag is augmented
329 with the current debug version (LLVMDebugVersion = 4 << 16 or 0x40000 or
330 262144.)</a></p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331
332<p>The details of the various descriptors follow.</p>
333
334</div>
335
336<!-- ======================================================================= -->
337<div class="doc_subsubsection">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 <a name="format_compile_units">Compile unit descriptors</a>
339</div>
340
341<div class="doc_text">
342
Bill Wendlingde024832009-05-17 05:52:39 +0000343<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000345%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type {
346 i32, ;; Tag = 17 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_compile_unit)
347 { }*, ;; Compile unit anchor = cast = (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*)
348 i32, ;; DWARF language identifier (ex. DW_LANG_C89)
349 i8*, ;; Source file name
350 i8*, ;; Source file directory (includes trailing slash)
351 i8* ;; Producer (ex. "4.0.1 LLVM (LLVM research group)")
352 i1, ;; True if this is a main compile unit.
353 i1, ;; True if this is optimized.
354 i8*, ;; Flags
355 i32 ;; Runtime version
356}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000358</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359
Bill Wendlingde024832009-05-17 05:52:39 +0000360<p>These descriptors contain a source language ID for the file (we use the DWARF
361 3.0 ID numbers, such as <tt>DW_LANG_C89</tt>, <tt>DW_LANG_C_plus_plus</tt>,
362 <tt>DW_LANG_Cobol74</tt>, etc), three strings describing the filename,
363 working directory of the compiler, and an identifier string for the compiler
364 that produced it.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365
Bill Wendlingde024832009-05-17 05:52:39 +0000366<p>Compile unit descriptors provide the root context for objects declared in a
367 specific source file. Global variables and top level functions would be
368 defined using this context. Compile unit descriptors also provide context
369 for source line correspondence.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370
Bill Wendlingde024832009-05-17 05:52:39 +0000371<p>Each input file is encoded as a separate compile unit in LLVM debugging
372 information output. However, many target specific tool chains prefer to
373 encode only one compile unit in an object file. In this situation, the LLVM
374 code generator will include debugging information entities in the compile
375 unit that is marked as main compile unit. The code generator accepts maximum
376 one main compile unit per module. If a module does not contain any main
377 compile unit then the code generator will emit multiple compile units in the
378 output object file.</p>
379
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380</div>
381
382<!-- ======================================================================= -->
383<div class="doc_subsubsection">
384 <a name="format_global_variables">Global variable descriptors</a>
385</div>
386
387<div class="doc_text">
388
Bill Wendlingde024832009-05-17 05:52:39 +0000389<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000391%<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type {
392 i32, ;; Tag = 52 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_variable)
393 { }*, ;; Global variable anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to { }*),
394 { }*, ;; Reference to context descriptor
395 i8*, ;; Name
396 i8*, ;; Display name (fully qualified C++ name)
397 i8*, ;; MIPS linkage name (for C++)
398 { }*, ;; Reference to compile unit where defined
399 i32, ;; Line number where defined
400 { }*, ;; Reference to type descriptor
401 i1, ;; True if the global is local to compile unit (static)
402 i1, ;; True if the global is defined in the compile unit (not extern)
403 { }* ;; Reference to the global variable
404}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000406</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
408<p>These descriptors provide debug information about globals variables. The
409provide details such as name, type and where the variable is defined.</p>
410
411</div>
412
413<!-- ======================================================================= -->
414<div class="doc_subsubsection">
415 <a name="format_subprograms">Subprogram descriptors</a>
416</div>
417
418<div class="doc_text">
419
Bill Wendlingde024832009-05-17 05:52:39 +0000420<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000422%<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type {
423 i32, ;; Tag = 46 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_subprogram)
424 { }*, ;; Subprogram anchor = cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to { }*),
425 { }*, ;; Reference to context descriptor
426 i8*, ;; Name
427 i8*, ;; Display name (fully qualified C++ name)
428 i8*, ;; MIPS linkage name (for C++)
429 { }*, ;; Reference to compile unit where defined
430 i32, ;; Line number where defined
431 { }*, ;; Reference to type descriptor
432 i1, ;; True if the global is local to compile unit (static)
433 i1 ;; True if the global is defined in the compile unit (not extern)
434}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000436</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437
438<p>These descriptors provide debug information about functions, methods and
Bill Wendlingde024832009-05-17 05:52:39 +0000439 subprograms. They provide details such as name, return types and the source
440 location where the subprogram is defined.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441
442</div>
Bill Wendlingde024832009-05-17 05:52:39 +0000443
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444<!-- ======================================================================= -->
445<div class="doc_subsubsection">
446 <a name="format_blocks">Block descriptors</a>
447</div>
448
449<div class="doc_text">
450
Bill Wendlingde024832009-05-17 05:52:39 +0000451<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000453%<a href="#format_blocks">llvm.dbg.block</a> = type {
454 i32, ;; Tag = 13 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_lexical_block)
455 { }* ;; Reference to context descriptor
456}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000458</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459
460<p>These descriptors provide debug information about nested blocks within a
Bill Wendlingde024832009-05-17 05:52:39 +0000461 subprogram. The array of member descriptors is used to define local
462 variables and deeper nested blocks.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
464</div>
465
466<!-- ======================================================================= -->
467<div class="doc_subsubsection">
468 <a name="format_basic_type">Basic type descriptors</a>
469</div>
470
471<div class="doc_text">
472
Bill Wendlingde024832009-05-17 05:52:39 +0000473<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000475%<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type {
476 i32, ;; Tag = 36 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_base_type)
477 { }*, ;; Reference to context (typically a compile unit)
478 i8*, ;; Name (may be "" for anonymous types)
479 { }*, ;; Reference to compile unit where defined (may be NULL)
480 i32, ;; Line number where defined (may be 0)
481 i64, ;; Size in bits
482 i64, ;; Alignment in bits
483 i64, ;; Offset in bits
484 i32, ;; Flags
485 i32 ;; DWARF type encoding
486}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000488</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
490<p>These descriptors define primitive types used in the code. Example int, bool
Bill Wendlingde024832009-05-17 05:52:39 +0000491 and float. The context provides the scope of the type, which is usually the
492 top level. Since basic types are not usually user defined the compile unit
493 and line number can be left as NULL and 0. The size, alignment and offset
494 are expressed in bits and can be 64 bit values. The alignment is used to
495 round the offset when embedded in a
496 <a href="#format_composite_type">composite type</a> (example to keep float
497 doubles on 64 bit boundaries.) The offset is the bit offset if embedded in
498 a <a href="#format_composite_type">composite type</a>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499
500<p>The type encoding provides the details of the type. The values are typically
Bill Wendlingde024832009-05-17 05:52:39 +0000501 one of the following:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502
Bill Wendlingde024832009-05-17 05:52:39 +0000503<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000505DW_ATE_address = 1
506DW_ATE_boolean = 2
507DW_ATE_float = 4
508DW_ATE_signed = 5
509DW_ATE_signed_char = 6
510DW_ATE_unsigned = 7
511DW_ATE_unsigned_char = 8
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000513</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514
515</div>
516
517<!-- ======================================================================= -->
518<div class="doc_subsubsection">
519 <a name="format_derived_type">Derived type descriptors</a>
520</div>
521
522<div class="doc_text">
523
Bill Wendlingde024832009-05-17 05:52:39 +0000524<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000526%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> = type {
527 i32, ;; Tag (see below)
528 { }*, ;; Reference to context
529 i8*, ;; Name (may be "" for anonymous types)
530 { }*, ;; Reference to compile unit where defined (may be NULL)
531 i32, ;; Line number where defined (may be 0)
532 i32, ;; Size in bits
533 i32, ;; Alignment in bits
534 i32, ;; Offset in bits
535 { }* ;; Reference to type derived from
536}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000538</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539
540<p>These descriptors are used to define types derived from other types. The
541value of the tag varies depending on the meaning. The following are possible
Misha Brukmane5b22d42008-12-16 02:54:22 +0000542tag values:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
Bill Wendlingde024832009-05-17 05:52:39 +0000544<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000546DW_TAG_formal_parameter = 5
547DW_TAG_member = 13
548DW_TAG_pointer_type = 15
549DW_TAG_reference_type = 16
550DW_TAG_typedef = 22
551DW_TAG_const_type = 38
552DW_TAG_volatile_type = 53
553DW_TAG_restrict_type = 55
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000555</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556
Bill Wendlingde024832009-05-17 05:52:39 +0000557<p><tt>DW_TAG_member</tt> is used to define a member of
558 a <a href="#format_composite_type">composite type</a>
559 or <a href="#format_subprograms">subprogram</a>. The type of the member is
560 the <a href="#format_derived_type">derived
561 type</a>. <tt>DW_TAG_formal_parameter</tt> is used to define a member which
562 is a formal argument of a subprogram.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563
Bill Wendlingde024832009-05-17 05:52:39 +0000564<p><tt>DW_TAG_typedef</tt> is used to provide a name for the derived type.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565
Bill Wendlingde024832009-05-17 05:52:39 +0000566<p><tt>DW_TAG_pointer_type</tt>,<tt>DW_TAG_reference_type</tt>,
567 <tt>DW_TAG_const_type</tt>, <tt>DW_TAG_volatile_type</tt>
568 and <tt>DW_TAG_restrict_type</tt> are used to qualify
569 the <a href="#format_derived_type">derived type</a>. </p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570
571<p><a href="#format_derived_type">Derived type</a> location can be determined
Bill Wendlingde024832009-05-17 05:52:39 +0000572 from the compile unit and line number. The size, alignment and offset are
573 expressed in bits and can be 64 bit values. The alignment is used to round
574 the offset when embedded in a <a href="#format_composite_type">composite
575 type</a> (example to keep float doubles on 64 bit boundaries.) The offset is
576 the bit offset if embedded in a <a href="#format_composite_type">composite
577 type</a>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578
579<p>Note that the <tt>void *</tt> type is expressed as a
Bill Wendlingde024832009-05-17 05:52:39 +0000580 <tt>llvm.dbg.derivedtype.type</tt> with tag of <tt>DW_TAG_pointer_type</tt>
581 and <tt>NULL</tt> derived type.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582
583</div>
584
585<!-- ======================================================================= -->
586<div class="doc_subsubsection">
587 <a name="format_composite_type">Composite type descriptors</a>
588</div>
589
590<div class="doc_text">
591
Bill Wendlingde024832009-05-17 05:52:39 +0000592<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000594%<a href="#format_composite_type">llvm.dbg.compositetype.type</a> = type {
595 i32, ;; Tag (see below)
596 { }*, ;; Reference to context
597 i8*, ;; Name (may be "" for anonymous types)
598 { }*, ;; Reference to compile unit where defined (may be NULL)
599 i32, ;; Line number where defined (may be 0)
600 i64, ;; Size in bits
601 i64, ;; Alignment in bits
602 i64, ;; Offset in bits
603 i32, ;; Flags
604 { }*, ;; Reference to type derived from
605 { }*, ;; Reference to array of member descriptors
606 i32 ;; Runtime languages
607}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000609</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
611<p>These descriptors are used to define types that are composed of 0 or more
612elements. The value of the tag varies depending on the meaning. The following
Misha Brukmane5b22d42008-12-16 02:54:22 +0000613are possible tag values:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
Bill Wendlingde024832009-05-17 05:52:39 +0000615<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000617DW_TAG_array_type = 1
618DW_TAG_enumeration_type = 4
619DW_TAG_structure_type = 19
620DW_TAG_union_type = 23
621DW_TAG_vector_type = 259
Bruno Cardoso Lopes7ad46092009-05-29 17:08:57 +0000622DW_TAG_subroutine_type = 21
623DW_TAG_inheritance = 28
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000625</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626
627<p>The vector flag indicates that an array type is a native packed vector.</p>
628
629<p>The members of array types (tag = <tt>DW_TAG_array_type</tt>) or vector types
Bill Wendlingde024832009-05-17 05:52:39 +0000630 (tag = <tt>DW_TAG_vector_type</tt>) are <a href="#format_subrange">subrange
631 descriptors</a>, each representing the range of subscripts at that level of
632 indexing.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633
634<p>The members of enumeration types (tag = <tt>DW_TAG_enumeration_type</tt>) are
Bill Wendlingde024832009-05-17 05:52:39 +0000635 <a href="#format_enumeration">enumerator descriptors</a>, each representing
636 the definition of enumeration value for the set.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637
638<p>The members of structure (tag = <tt>DW_TAG_structure_type</tt>) or union (tag
Bill Wendlingde024832009-05-17 05:52:39 +0000639 = <tt>DW_TAG_union_type</tt>) types are any one of
640 the <a href="#format_basic_type">basic</a>,
641 <a href="#format_derived_type">derived</a>
642 or <a href="#format_composite_type">composite</a> type descriptors, each
643 representing a field member of the structure or union.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644
645<p>For C++ classes (tag = <tt>DW_TAG_structure_type</tt>), member descriptors
Bill Wendlingde024832009-05-17 05:52:39 +0000646 provide information about base classes, static members and member
647 functions. If a member is a <a href="#format_derived_type">derived type
648 descriptor</a> and has a tag of <tt>DW_TAG_inheritance</tt>, then the type
649 represents a base class. If the member of is
650 a <a href="#format_global_variables">global variable descriptor</a> then it
651 represents a static member. And, if the member is
652 a <a href="#format_subprograms">subprogram descriptor</a> then it represents
653 a member function. For static members and member
654 functions, <tt>getName()</tt> returns the members link or the C++ mangled
655 name. <tt>getDisplayName()</tt> the simplied version of the name.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656
Bill Wendlingde024832009-05-17 05:52:39 +0000657<p>The first member of subroutine (tag = <tt>DW_TAG_subroutine_type</tt>) type
658 elements is the return type for the subroutine. The remaining elements are
659 the formal arguments to the subroutine.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660
661<p><a href="#format_composite_type">Composite type</a> location can be
Bill Wendlingde024832009-05-17 05:52:39 +0000662 determined from the compile unit and line number. The size, alignment and
663 offset are expressed in bits and can be 64 bit values. The alignment is used
664 to round the offset when embedded in
665 a <a href="#format_composite_type">composite type</a> (as an example, to keep
666 float doubles on 64 bit boundaries.) The offset is the bit offset if embedded
667 in a <a href="#format_composite_type">composite type</a>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668
669</div>
670
671<!-- ======================================================================= -->
672<div class="doc_subsubsection">
673 <a name="format_subrange">Subrange descriptors</a>
674</div>
675
676<div class="doc_text">
677
Bill Wendlingde024832009-05-17 05:52:39 +0000678<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000680%<a href="#format_subrange">llvm.dbg.subrange.type</a> = type {
681 i32, ;; Tag = 33 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_subrange_type)
682 i64, ;; Low value
683 i64 ;; High value
684}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000686</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687
688<p>These descriptors are used to define ranges of array subscripts for an array
Bill Wendlingde024832009-05-17 05:52:39 +0000689 <a href="#format_composite_type">composite type</a>. The low value defines
690 the lower bounds typically zero for C/C++. The high value is the upper
691 bounds. Values are 64 bit. High - low + 1 is the size of the array. If low
692 == high the array will be unbounded.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693
694</div>
695
696<!-- ======================================================================= -->
697<div class="doc_subsubsection">
698 <a name="format_enumeration">Enumerator descriptors</a>
699</div>
700
701<div class="doc_text">
702
Bill Wendlingde024832009-05-17 05:52:39 +0000703<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000705%<a href="#format_enumeration">llvm.dbg.enumerator.type</a> = type {
706 i32, ;; Tag = 40 + <a href="#LLVMDebugVersion">LLVMDebugVersion</a> (DW_TAG_enumerator)
707 i8*, ;; Name
708 i64 ;; Value
709}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000711</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712
Bill Wendlingde024832009-05-17 05:52:39 +0000713<p>These descriptors are used to define members of an
714 enumeration <a href="#format_composite_type">composite type</a>, it
715 associates the name to the value.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
717</div>
718
719<!-- ======================================================================= -->
720<div class="doc_subsubsection">
721 <a name="format_variables">Local variables</a>
722</div>
723
724<div class="doc_text">
Bill Wendlingde024832009-05-17 05:52:39 +0000725
726<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000728%<a href="#format_variables">llvm.dbg.variable.type</a> = type {
729 i32, ;; Tag (see below)
730 { }*, ;; Context
731 i8*, ;; Name
732 { }*, ;; Reference to compile unit where defined
733 i32, ;; Line number where defined
734 { }* ;; Type descriptor
735}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000737</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738
739<p>These descriptors are used to define variables local to a sub program. The
Bill Wendlingde024832009-05-17 05:52:39 +0000740 value of the tag depends on the usage of the variable:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741
Bill Wendlingde024832009-05-17 05:52:39 +0000742<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743<pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000744DW_TAG_auto_variable = 256
745DW_TAG_arg_variable = 257
746DW_TAG_return_variable = 258
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000748</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
750<p>An auto variable is any variable declared in the body of the function. An
Bill Wendlingde024832009-05-17 05:52:39 +0000751 argument variable is any variable that appears as a formal argument to the
752 function. A return variable is used to track the result of a function and
753 has no source correspondent.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754
755<p>The context is either the subprogram or block where the variable is defined.
Bill Wendlingde024832009-05-17 05:52:39 +0000756 Name the source variable name. Compile unit and line indicate where the
757 variable was defined. Type descriptor defines the declared type of the
758 variable.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
760</div>
761
762<!-- ======================================================================= -->
763<div class="doc_subsection">
764 <a name="format_common_intrinsics">Debugger intrinsic functions</a>
765</div>
766
767<div class="doc_text">
768
769<p>LLVM uses several intrinsic functions (name prefixed with "llvm.dbg") to
Bill Wendlingde024832009-05-17 05:52:39 +0000770 provide debug information at various points in generated code.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771
772</div>
773
774<!-- ======================================================================= -->
775<div class="doc_subsubsection">
776 <a name="format_common_stoppoint">llvm.dbg.stoppoint</a>
777</div>
778
779<div class="doc_text">
780<pre>
781 void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, { }* )
782</pre>
783
784<p>This intrinsic is used to provide correspondence between the source file and
Bill Wendlingde024832009-05-17 05:52:39 +0000785 the generated code. The first argument is the line number (base 1), second
786 argument is the column number (0 if unknown) and the third argument the
787 source <tt>%<a href="#format_compile_units">llvm.dbg.compile_unit</a>*</tt>
788 cast to a <tt>{&nbsp;}*</tt>. Code following a call to this intrinsic will
789 have been defined in close proximity of the line, column and file. This
790 information holds until the next call
791 to <tt>%<a href="#format_common_stoppoint">lvm.dbg.stoppoint</a></tt>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792
793</div>
794
795<!-- ======================================================================= -->
796<div class="doc_subsubsection">
797 <a name="format_common_func_start">llvm.dbg.func.start</a>
798</div>
799
800<div class="doc_text">
801<pre>
802 void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( { }* )
803</pre>
804
Bill Wendlingde024832009-05-17 05:52:39 +0000805<p>This intrinsic is used to link the debug information
806 in <tt>%<a href="#format_subprograms">llvm.dbg.subprogram</a></tt> to the
807 function. It defines the beginning of the function's declarative region
808 (scope). It also implies a call to
809 %<tt><a href="#format_common_stoppoint">llvm.dbg.stoppoint</a></tt> which
810 defines a source line "stop point". The intrinsic should be called early in
811 the function after the all the alloca instructions. It should be paired off
812 with a closing
813 <tt>%<a href="#format_common_region_end">llvm.dbg.region.end</a></tt>.
814 The function's single argument is
815 the <tt>%<a href="#format_subprograms">llvm.dbg.subprogram.type</a></tt>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
817</div>
818
819<!-- ======================================================================= -->
820<div class="doc_subsubsection">
821 <a name="format_common_region_start">llvm.dbg.region.start</a>
822</div>
823
824<div class="doc_text">
825<pre>
826 void %<a href="#format_common_region_start">llvm.dbg.region.start</a>( { }* )
827</pre>
828
829<p>This intrinsic is used to define the beginning of a declarative scope (ex.
Bill Wendlingde024832009-05-17 05:52:39 +0000830 block) for local language elements. It should be paired off with a closing
831 <tt>%<a href="#format_common_region_end">llvm.dbg.region.end</a></tt>. The
832 function's single argument is
833 the <tt>%<a href="#format_blocks">llvm.dbg.block</a></tt> which is
834 starting.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835
836
837</div>
838
839<!-- ======================================================================= -->
840<div class="doc_subsubsection">
841 <a name="format_common_region_end">llvm.dbg.region.end</a>
842</div>
843
844<div class="doc_text">
845<pre>
846 void %<a href="#format_common_region_end">llvm.dbg.region.end</a>( { }* )
847</pre>
848
849<p>This intrinsic is used to define the end of a declarative scope (ex. block)
Bill Wendlingde024832009-05-17 05:52:39 +0000850 for local language elements. It should be paired off with an
851 opening <tt>%<a href="#format_common_region_start">llvm.dbg.region.start</a></tt>
852 or <tt>%<a href="#format_common_func_start">llvm.dbg.func.start</a></tt>.
853 The function's single argument is either
854 the <tt>%<a href="#format_blocks">llvm.dbg.block</a></tt> or
855 the <tt>%<a href="#format_subprograms">llvm.dbg.subprogram.type</a></tt>
856 which is ending.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857
858</div>
859
860<!-- ======================================================================= -->
861<div class="doc_subsubsection">
862 <a name="format_common_declare">llvm.dbg.declare</a>
863</div>
864
865<div class="doc_text">
866<pre>
867 void %<a href="#format_common_declare">llvm.dbg.declare</a>( { } *, { }* )
868</pre>
869
870<p>This intrinsic provides information about a local element (ex. variable.) The
Bill Wendlingde024832009-05-17 05:52:39 +0000871 first argument is the alloca for the variable, cast to a <tt>{ }*</tt>. The
872 second argument is
873 the <tt>%<a href="#format_variables">llvm.dbg.variable</a></tt> containing
874 the description of the variable, also cast to a <tt>{ }*</tt>.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875
876</div>
877
878<!-- ======================================================================= -->
879<div class="doc_subsection">
880 <a name="format_common_stoppoints">
881 Representing stopping points in the source program
882 </a>
883</div>
884
885<div class="doc_text">
886
887<p>LLVM debugger "stop points" are a key part of the debugging representation
Bill Wendlingde024832009-05-17 05:52:39 +0000888 that allows the LLVM to maintain simple semantics
889 for <a href="#debugopt">debugging optimized code</a>. The basic idea is that
890 the front-end inserts calls to
891 the <a href="#format_common_stoppoint">%<tt>llvm.dbg.stoppoint</tt></a>
892 intrinsic function at every point in the program where a debugger should be
893 able to inspect the program (these correspond to places a debugger stops when
894 you "<tt>step</tt>" through it). The front-end can choose to place these as
895 fine-grained as it would like (for example, before every subexpression
896 evaluated), but it is recommended to only put them after every source
897 statement that includes executable code.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898
899<p>Using calls to this intrinsic function to demark legal points for the
Bill Wendlingde024832009-05-17 05:52:39 +0000900 debugger to inspect the program automatically disables any optimizations that
901 could potentially confuse debugging information. To
902 non-debug-information-aware transformations, these calls simply look like
903 calls to an external function, which they must assume to do anything
904 (including reading or writing to any part of reachable memory). On the other
905 hand, it does not impact many optimizations, such as code motion of
906 non-trapping instructions, nor does it impact optimization of subexpressions,
907 code duplication transformations, or basic-block reordering
908 transformations.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909
910</div>
911
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912<!-- ======================================================================= -->
913<div class="doc_subsection">
914 <a name="format_common_lifetime">Object lifetimes and scoping</a>
915</div>
916
917<div class="doc_text">
918<p>In many languages, the local variables in functions can have their lifetime
Bill Wendlingde024832009-05-17 05:52:39 +0000919 or scope limited to a subset of a function. In the C family of languages,
920 for example, variables are only live (readable and writable) within the
921 source block that they are defined in. In functional languages, values are
922 only readable after they have been defined. Though this is a very obvious
923 concept, it is also non-trivial to model in LLVM, because it has no notion of
924 scoping in this sense, and does not want to be tied to a language's scoping
925 rules.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926
927<p>In order to handle this, the LLVM debug format uses the notion of "regions"
Bill Wendlingde024832009-05-17 05:52:39 +0000928 of a function, delineated by calls to intrinsic functions. These intrinsic
929 functions define new regions of the program and indicate when the region
930 lifetime expires. Consider the following C fragment, for example:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931
Bill Wendlingde024832009-05-17 05:52:39 +0000932<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933<pre>
9341. void foo() {
9352. int X = ...;
9363. int Y = ...;
9374. {
9385. int Z = ...;
9396. ...
9407. }
9418. ...
9429. }
943</pre>
Bill Wendlingde024832009-05-17 05:52:39 +0000944</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945
946<p>Compiled to LLVM, this function would be represented like this:</p>
947
Bill Wendlingde024832009-05-17 05:52:39 +0000948<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949<pre>
950void %foo() {
951entry:
952 %X = alloca int
953 %Y = alloca int
954 %Z = alloca int
955
956 ...
957
Bill Wendlingde024832009-05-17 05:52:39 +0000958 call void @<a href="#format_common_func_start">llvm.dbg.func.start</a>( %<a href="#format_subprograms">llvm.dbg.subprogram.type</a>* @llvm.dbg.subprogram )
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959
Bill Wendlingde024832009-05-17 05:52:39 +0000960 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 2, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961
Bill Wendlingde024832009-05-17 05:52:39 +0000962 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
963 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %Y, ...)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964
965 <i>;; Evaluate expression on line 2, assigning to X.</i>
966
Bill Wendlingde024832009-05-17 05:52:39 +0000967 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 3, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968
969 <i>;; Evaluate expression on line 3, assigning to Y.</i>
970
Bill Wendlingde024832009-05-17 05:52:39 +0000971 call void @<a href="#format_common_stoppoint">llvm.region.start</a>()
972 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 5, uint 4, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
973 call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
975 <i>;; Evaluate expression on line 5, assigning to Z.</i>
976
Bill Wendlingde024832009-05-17 05:52:39 +0000977 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 7, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
978 call void @<a href="#format_common_region_end">llvm.region.end</a>()
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979
Bill Wendlingde024832009-05-17 05:52:39 +0000980 call void @<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint 9, uint 2, %<a href="#format_compile_units">llvm.dbg.compile_unit</a>* @llvm.dbg.compile_unit )
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981
Bill Wendlingde024832009-05-17 05:52:39 +0000982 call void @<a href="#format_common_region_end">llvm.region.end</a>()
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983
984 ret void
985}
986</pre>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987</div>
988
Bill Wendlingde024832009-05-17 05:52:39 +0000989<p>This example illustrates a few important details about the LLVM debugging
990 information. In particular, it shows how the various intrinsics are applied
991 together to allow a debugger to analyze the relationship between statements,
992 variable definitions, and the code used to implement the function.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993
Bill Wendlingde024832009-05-17 05:52:39 +0000994<p>The first
995 intrinsic <tt>%<a href="#format_common_func_start">llvm.dbg.func.start</a></tt>
996 provides a link with the <a href="#format_subprograms">subprogram
997 descriptor</a> containing the details of this function. This call also
998 defines the beginning of the function region, bounded by
999 the <tt>%<a href="#format_common_region_end">llvm.region.end</a></tt> at the
1000 end of the function. This region is used to bracket the lifetime of
1001 variables declared within. For a function, this outer region defines a new
1002 stack frame whose lifetime ends when the region is ended.</p>
1003
1004<p>It is possible to define inner regions for short term variables by using the
1005 %<a href="#format_common_stoppoint"><tt>llvm.region.start</tt></a>
1006 and <a href="#format_common_region_end"><tt>%llvm.region.end</tt></a> to
1007 bound a region. The inner region in this example would be for the block
1008 containing the declaration of Z.</p>
1009
1010<p>Using regions to represent the boundaries of source-level functions allow
1011 LLVM interprocedural optimizations to arbitrarily modify LLVM functions
1012 without having to worry about breaking mapping information between the LLVM
1013 code and the and source-level program. In particular, the inliner requires
1014 no modification to support inlining with debugging information: there is no
1015 explicit correlation drawn between LLVM functions and their source-level
1016 counterparts (note however, that if the inliner inlines all instances of a
1017 non-strong-linkage function into its caller that it will not be possible for
1018 the user to manually invoke the inlined function from a debugger).</p>
1019
1020<p>Once the function has been defined,
1021 the <a href="#format_common_stoppoint"><tt>stopping point</tt></a>
1022 corresponding to line #2 (column #2) of the function is encountered. At this
1023 point in the function, <b>no</b> local variables are live. As lines 2 and 3
1024 of the example are executed, their variable definitions are introduced into
1025 the program using
1026 %<a href="#format_common_declare"><tt>llvm.dbg.declare</tt></a>, without the
1027 need to specify a new region. These variables do not require new regions to
1028 be introduced because they go out of scope at the same point in the program:
1029 line 9.</p>
1030
1031<p>In contrast, the <tt>Z</tt> variable goes out of scope at a different time,
1032 on line 7. For this reason, it is defined within the inner region, which
1033 kills the availability of <tt>Z</tt> before the code for line 8 is executed.
1034 In this way, regions can support arbitrary source-language scoping rules, as
1035 long as they can only be nested (ie, one scope cannot partially overlap with
1036 a part of another scope).</p>
1037
1038<p>It is worth noting that this scoping mechanism is used to control scoping of
1039 all declarations, not just variable declarations. For example, the scope of
1040 a C++ using declaration is controlled with this and could change how name
1041 lookup is performed.</p>
1042
1043</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044
1045<!-- *********************************************************************** -->
1046<div class="doc_section">
1047 <a name="ccxx_frontend">C/C++ front-end specific debug information</a>
1048</div>
1049<!-- *********************************************************************** -->
1050
1051<div class="doc_text">
1052
1053<p>The C and C++ front-ends represent information about the program in a format
Bill Wendlingde024832009-05-17 05:52:39 +00001054 that is effectively identical
1055 to <a href="http://www.eagercon.com/dwarf/dwarf3std.htm">DWARF 3.0</a> in
1056 terms of information content. This allows code generators to trivially
1057 support native debuggers by generating standard dwarf information, and
1058 contains enough information for non-dwarf targets to translate it as
1059 needed.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060
1061<p>This section describes the forms used to represent C and C++ programs. Other
Bill Wendlingde024832009-05-17 05:52:39 +00001062 languages could pattern themselves after this (which itself is tuned to
1063 representing programs in the same way that DWARF 3 does), or they could
1064 choose to provide completely different forms if they don't fit into the DWARF
1065 model. As support for debugging information gets added to the various LLVM
1066 source-language front-ends, the information used should be documented
1067 here.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068
1069<p>The following sections provide examples of various C/C++ constructs and the
Bill Wendlingde024832009-05-17 05:52:39 +00001070 debug information that would best describe those constructs.</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071
1072</div>
1073
1074<!-- ======================================================================= -->
1075<div class="doc_subsection">
1076 <a name="ccxx_compile_units">C/C++ source file information</a>
1077</div>
1078
1079<div class="doc_text">
1080
Bill Wendlingde024832009-05-17 05:52:39 +00001081<p>Given the source files <tt>MySource.cpp</tt> and <tt>MyHeader.h</tt> located
1082 in the directory <tt>/Users/mine/sources</tt>, the following code:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083
Bill Wendlingde024832009-05-17 05:52:39 +00001084<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085<pre>
1086#include "MyHeader.h"
1087
1088int main(int argc, char *argv[]) {
1089 return 0;
1090}
1091</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001092</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093
Misha Brukmane5b22d42008-12-16 02:54:22 +00001094<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095
Bill Wendlingde024832009-05-17 05:52:39 +00001096<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097<pre>
1098...
1099;;
1100;; Define types used. In this case we need one for compile unit anchors and one
1101;; for compile units.
1102;;
1103%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001104%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type { uint, { }*, uint, uint, i8*, i8*, i8* }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105...
1106;;
1107;; Define the anchor for compile units. Note that the second field of the
1108;; anchor is 17, which is the same as the tag for compile units
1109;; (17 = DW_TAG_compile_unit.)
1110;;
1111%<a href="#format_compile_units">llvm.dbg.compile_units</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 17 }, section "llvm.metadata"
1112
1113;;
1114;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp".
1115;;
1116%<a href="#format_compile_units">llvm.dbg.compile_unit1</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
1117 uint add(uint 17, uint 262144),
1118 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*),
1119 uint 1,
1120 uint 1,
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001121 i8* getelementptr ([13 x i8]* %str1, i32 0, i32 0),
1122 i8* getelementptr ([21 x i8]* %str2, i32 0, i32 0),
1123 i8* getelementptr ([33 x i8]* %str3, i32 0, i32 0) }, section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124
1125;;
1126;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h".
1127;;
1128%<a href="#format_compile_units">llvm.dbg.compile_unit2</a> = internal constant %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> {
1129 uint add(uint 17, uint 262144),
1130 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_units</a> to { }*),
1131 uint 1,
1132 uint 1,
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001133 i8* getelementptr ([11 x i8]* %str4, int 0, int 0),
1134 i8* getelementptr ([21 x i8]* %str2, int 0, int 0),
1135 i8* getelementptr ([33 x i8]* %str3, int 0, int 0) }, section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136
1137;;
1138;; Define each of the strings used in the compile units.
1139;;
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001140%str1 = internal constant [13 x i8] c"MySource.cpp\00", section "llvm.metadata";
1141%str2 = internal constant [21 x i8] c"/Users/mine/sources/\00", section "llvm.metadata";
1142%str3 = internal constant [33 x i8] c"4.0.1 LLVM (LLVM research group)\00", section "llvm.metadata";
1143%str4 = internal constant [11 x i8] c"MyHeader.h\00", section "llvm.metadata";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144...
1145</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001146</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147
1148</div>
1149
1150<!-- ======================================================================= -->
1151<div class="doc_subsection">
1152 <a name="ccxx_global_variable">C/C++ global variable information</a>
1153</div>
1154
1155<div class="doc_text">
1156
Misha Brukmane5b22d42008-12-16 02:54:22 +00001157<p>Given an integer global variable declared as follows:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158
Bill Wendlingde024832009-05-17 05:52:39 +00001159<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160<pre>
1161int MyGlobal = 100;
1162</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001163</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164
Misha Brukmane5b22d42008-12-16 02:54:22 +00001165<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166
Bill Wendlingde024832009-05-17 05:52:39 +00001167<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168<pre>
1169;;
1170;; Define types used. One for global variable anchors, one for the global
1171;; variable descriptor, one for the global's basic type and one for the global's
1172;; compile unit.
1173;;
1174%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001175%<a href="#format_global_variables">llvm.dbg.global_variable.type</a> = type { uint, { }*, { }*, i8*, { }*, uint, { }*, bool, bool, { }*, uint }
1176%<a href="#format_basic_type">llvm.dbg.basictype.type</a> = type { uint, { }*, i8*, { }*, int, uint, uint, uint, uint }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
1178...
1179;;
1180;; Define the global itself.
1181;;
1182%MyGlobal = global int 100
1183...
1184;;
1185;; Define the anchor for global variables. Note that the second field of the
1186;; anchor is 52, which is the same as the tag for global variables
1187;; (52 = DW_TAG_variable.)
1188;;
1189%<a href="#format_global_variables">llvm.dbg.global_variables</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 52 }, section "llvm.metadata"
1190
1191;;
1192;; Define the global variable descriptor. Note the reference to the global
1193;; variable anchor and the global variable itself.
1194;;
1195%<a href="#format_global_variables">llvm.dbg.global_variable</a> = internal constant %<a href="#format_global_variables">llvm.dbg.global_variable.type</a> {
1196 uint add(uint 52, uint 262144),
1197 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_global_variables">llvm.dbg.global_variables</a> to { }*),
1198 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001199 i8* getelementptr ([9 x i8]* %str1, int 0, int 0),
1200 i8* getelementptr ([1 x i8]* %str2, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1202 uint 1,
1203 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*),
1204 bool false,
1205 bool true,
1206 { }* cast (int* %MyGlobal to { }*) }, section "llvm.metadata"
1207
1208;;
1209;; Define the basic type of 32 bit signed integer. Note that since int is an
1210;; intrinsic type the source file is NULL and line 0.
1211;;
1212%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1213 uint add(uint 36, uint 262144),
1214 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001215 i8* getelementptr ([4 x i8]* %str3, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 { }* null,
1217 int 0,
1218 uint 32,
1219 uint 32,
1220 uint 0,
1221 uint 5 }, section "llvm.metadata"
1222
1223;;
1224;; Define the names of the global variable and basic type.
1225;;
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001226%str1 = internal constant [9 x i8] c"MyGlobal\00", section "llvm.metadata"
1227%str2 = internal constant [1 x i8] c"\00", section "llvm.metadata"
1228%str3 = internal constant [4 x i8] c"int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001230</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231
1232</div>
1233
1234<!-- ======================================================================= -->
1235<div class="doc_subsection">
1236 <a name="ccxx_subprogram">C/C++ function information</a>
1237</div>
1238
1239<div class="doc_text">
1240
Misha Brukmane5b22d42008-12-16 02:54:22 +00001241<p>Given a function declared as follows:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242
Bill Wendlingde024832009-05-17 05:52:39 +00001243<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244<pre>
1245int main(int argc, char *argv[]) {
1246 return 0;
1247}
1248</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001249</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250
Misha Brukmane5b22d42008-12-16 02:54:22 +00001251<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252
Bill Wendlingde024832009-05-17 05:52:39 +00001253<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254<pre>
1255;;
1256;; Define types used. One for subprogram anchors, one for the subprogram
1257;; descriptor, one for the global's basic type and one for the subprogram's
1258;; compile unit.
1259;;
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001260%<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type { uint, { }*, { }*, i8*, { }*, bool, bool }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261%<a href="#format_anchors">llvm.dbg.anchor.type</a> = type { uint, uint }
1262%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ...
1263
1264;;
1265;; Define the anchor for subprograms. Note that the second field of the
1266;; anchor is 46, which is the same as the tag for subprograms
1267;; (46 = DW_TAG_subprogram.)
1268;;
1269%<a href="#format_subprograms">llvm.dbg.subprograms</a> = linkonce constant %<a href="#format_anchors">llvm.dbg.anchor.type</a> { uint 0, uint 46 }, section "llvm.metadata"
1270
1271;;
1272;; Define the descriptor for the subprogram. TODO - more details.
1273;;
1274%<a href="#format_subprograms">llvm.dbg.subprogram</a> = internal constant %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> {
1275 uint add(uint 46, uint 262144),
1276 { }* cast (%<a href="#format_anchors">llvm.dbg.anchor.type</a>* %<a href="#format_subprograms">llvm.dbg.subprograms</a> to { }*),
1277 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001278 i8* getelementptr ([5 x i8]* %str1, int 0, int 0),
1279 i8* getelementptr ([1 x i8]* %str2, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1281 uint 1,
1282 { }* null,
1283 bool false,
1284 bool true }, section "llvm.metadata"
1285
1286;;
1287;; Define the name of the subprogram.
1288;;
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001289%str1 = internal constant [5 x i8] c"main\00", section "llvm.metadata"
1290%str2 = internal constant [1 x i8] c"\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291
1292;;
1293;; Define the subprogram itself.
1294;;
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001295int %main(int %argc, i8** %argv) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296...
1297}
1298</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001299</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300
1301</div>
1302
1303<!-- ======================================================================= -->
1304<div class="doc_subsection">
1305 <a name="ccxx_basic_types">C/C++ basic types</a>
1306</div>
1307
1308<div class="doc_text">
1309
Misha Brukmane5b22d42008-12-16 02:54:22 +00001310<p>The following are the basic type descriptors for C/C++ core types:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311
1312</div>
1313
1314<!-- ======================================================================= -->
1315<div class="doc_subsubsection">
1316 <a name="ccxx_basic_type_bool">bool</a>
1317</div>
1318
1319<div class="doc_text">
1320
Bill Wendlingde024832009-05-17 05:52:39 +00001321<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322<pre>
1323%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1324 uint add(uint 36, uint 262144),
1325 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001326 i8* getelementptr ([5 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 { }* null,
1328 int 0,
1329 uint 32,
1330 uint 32,
1331 uint 0,
1332 uint 2 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001333%str1 = internal constant [5 x i8] c"bool\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001335</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336
1337</div>
1338
1339<!-- ======================================================================= -->
1340<div class="doc_subsubsection">
1341 <a name="ccxx_basic_char">char</a>
1342</div>
1343
1344<div class="doc_text">
1345
Bill Wendlingde024832009-05-17 05:52:39 +00001346<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347<pre>
1348%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1349 uint add(uint 36, uint 262144),
1350 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001351 i8* getelementptr ([5 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 { }* null,
1353 int 0,
1354 uint 8,
1355 uint 8,
1356 uint 0,
1357 uint 6 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001358%str1 = internal constant [5 x i8] c"char\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001360</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361
1362</div>
1363
1364<!-- ======================================================================= -->
1365<div class="doc_subsubsection">
1366 <a name="ccxx_basic_unsigned_char">unsigned char</a>
1367</div>
1368
1369<div class="doc_text">
1370
Bill Wendlingde024832009-05-17 05:52:39 +00001371<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372<pre>
1373%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1374 uint add(uint 36, uint 262144),
1375 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001376 i8* getelementptr ([14 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 { }* null,
1378 int 0,
1379 uint 8,
1380 uint 8,
1381 uint 0,
1382 uint 8 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001383%str1 = internal constant [14 x i8] c"unsigned char\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001385</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386
1387</div>
1388
1389<!-- ======================================================================= -->
1390<div class="doc_subsubsection">
1391 <a name="ccxx_basic_short">short</a>
1392</div>
1393
1394<div class="doc_text">
1395
Bill Wendlingde024832009-05-17 05:52:39 +00001396<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397<pre>
1398%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1399 uint add(uint 36, uint 262144),
1400 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001401 i8* getelementptr ([10 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 { }* null,
1403 int 0,
1404 uint 16,
1405 uint 16,
1406 uint 0,
1407 uint 5 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001408%str1 = internal constant [10 x i8] c"short int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001410</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411
1412</div>
1413
1414<!-- ======================================================================= -->
1415<div class="doc_subsubsection">
1416 <a name="ccxx_basic_unsigned_short">unsigned short</a>
1417</div>
1418
1419<div class="doc_text">
1420
Bill Wendlingde024832009-05-17 05:52:39 +00001421<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422<pre>
1423%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1424 uint add(uint 36, uint 262144),
1425 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001426 i8* getelementptr ([19 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 { }* null,
1428 int 0,
1429 uint 16,
1430 uint 16,
1431 uint 0,
1432 uint 7 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001433%str1 = internal constant [19 x i8] c"short unsigned int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001435</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436
1437</div>
1438
1439<!-- ======================================================================= -->
1440<div class="doc_subsubsection">
1441 <a name="ccxx_basic_int">int</a>
1442</div>
1443
1444<div class="doc_text">
1445
Bill Wendlingde024832009-05-17 05:52:39 +00001446<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447<pre>
1448%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1449 uint add(uint 36, uint 262144),
1450 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001451 i8* getelementptr ([4 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452 { }* null,
1453 int 0,
1454 uint 32,
1455 uint 32,
1456 uint 0,
1457 uint 5 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001458%str1 = internal constant [4 x i8] c"int\00", section "llvm.metadata"
Bill Wendlingde024832009-05-17 05:52:39 +00001459</pre></div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460
1461</div>
1462
1463<!-- ======================================================================= -->
1464<div class="doc_subsubsection">
1465 <a name="ccxx_basic_unsigned_int">unsigned int</a>
1466</div>
1467
1468<div class="doc_text">
1469
Bill Wendlingde024832009-05-17 05:52:39 +00001470<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471<pre>
1472%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1473 uint add(uint 36, uint 262144),
1474 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001475 i8* getelementptr ([13 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 { }* null,
1477 int 0,
1478 uint 32,
1479 uint 32,
1480 uint 0,
1481 uint 7 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001482%str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001484</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485
1486</div>
1487
1488<!-- ======================================================================= -->
1489<div class="doc_subsubsection">
1490 <a name="ccxx_basic_long_long">long long</a>
1491</div>
1492
1493<div class="doc_text">
1494
Bill Wendlingde024832009-05-17 05:52:39 +00001495<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496<pre>
1497%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1498 uint add(uint 36, uint 262144),
1499 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001500 i8* getelementptr ([14 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 { }* null,
1502 int 0,
1503 uint 64,
1504 uint 64,
1505 uint 0,
1506 uint 5 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001507%str1 = internal constant [14 x i8] c"long long int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001509</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510
1511</div>
1512
1513<!-- ======================================================================= -->
1514<div class="doc_subsubsection">
1515 <a name="ccxx_basic_unsigned_long_long">unsigned long long</a>
1516</div>
1517
1518<div class="doc_text">
1519
Bill Wendlingde024832009-05-17 05:52:39 +00001520<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521<pre>
1522%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1523 uint add(uint 36, uint 262144),
1524 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001525 i8* getelementptr ([23 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 { }* null,
1527 int 0,
1528 uint 64,
1529 uint 64,
1530 uint 0,
1531 uint 7 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001532%str1 = internal constant [23 x 8] c"long long unsigned int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001534</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535
1536</div>
1537
1538<!-- ======================================================================= -->
1539<div class="doc_subsubsection">
1540 <a name="ccxx_basic_float">float</a>
1541</div>
1542
1543<div class="doc_text">
1544
Bill Wendlingde024832009-05-17 05:52:39 +00001545<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546<pre>
1547%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1548 uint add(uint 36, uint 262144),
1549 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001550 i8* getelementptr ([6 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 { }* null,
1552 int 0,
1553 uint 32,
1554 uint 32,
1555 uint 0,
1556 uint 4 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001557%str1 = internal constant [6 x i8] c"float\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001559</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560
1561</div>
1562
1563<!-- ======================================================================= -->
1564<div class="doc_subsubsection">
1565 <a name="ccxx_basic_double">double</a>
1566</div>
1567
1568<div class="doc_text">
1569
Bill Wendlingde024832009-05-17 05:52:39 +00001570<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571<pre>
1572%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1573 uint add(uint 36, uint 262144),
1574 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001575 8* getelementptr ([7 x 8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 { }* null,
1577 int 0,
1578 uint 64,
1579 uint 64,
1580 uint 0,
1581 uint 4 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001582%str1 = internal constant [7 x 8] c"double\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001584</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585
1586</div>
1587
1588<!-- ======================================================================= -->
1589<div class="doc_subsection">
1590 <a name="ccxx_derived_types">C/C++ derived types</a>
1591</div>
1592
1593<div class="doc_text">
1594
Misha Brukmane5b22d42008-12-16 02:54:22 +00001595<p>Given the following as an example of C/C++ derived type:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596
Bill Wendlingde024832009-05-17 05:52:39 +00001597<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598<pre>
1599typedef const int *IntPtr;
1600</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001601</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602
Misha Brukmane5b22d42008-12-16 02:54:22 +00001603<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604
Bill Wendlingde024832009-05-17 05:52:39 +00001605<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606<pre>
1607;;
1608;; Define the typedef "IntPtr".
1609;;
1610%<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1611 uint add(uint 22, uint 262144),
1612 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001613 i8* getelementptr ([7 x 8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1615 int 1,
1616 uint 0,
1617 uint 0,
1618 uint 0,
1619 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001620%str1 = internal constant [7 x 8] c"IntPtr\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621
1622;;
1623;; Define the pointer type.
1624;;
1625%<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1626 uint add(uint 15, uint 262144),
1627 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001628 i8* null,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 { }* null,
1630 int 0,
1631 uint 32,
1632 uint 32,
1633 uint 0,
1634 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to { }*) }, section "llvm.metadata"
1635
1636;;
1637;; Define the const type.
1638;;
1639%<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1640 uint add(uint 38, uint 262144),
1641 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001642 i8* null,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643 { }* null,
1644 int 0,
1645 uint 0,
1646 uint 0,
1647 uint 0,
1648 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype1</a> to { }*) }, section "llvm.metadata"
1649
1650;;
1651;; Define the int type.
1652;;
1653%<a href="#format_basic_type">llvm.dbg.basictype1</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1654 uint add(uint 36, uint 262144),
1655 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001656 8* getelementptr ([4 x 8]* %str2, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 { }* null,
1658 int 0,
1659 uint 32,
1660 uint 32,
1661 uint 0,
1662 uint 5 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001663%str2 = internal constant [4 x 8] c"int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001665</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666
1667</div>
1668
1669<!-- ======================================================================= -->
1670<div class="doc_subsection">
1671 <a name="ccxx_composite_types">C/C++ struct/union types</a>
1672</div>
1673
1674<div class="doc_text">
1675
Misha Brukmane5b22d42008-12-16 02:54:22 +00001676<p>Given the following as an example of C/C++ struct type:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677
Bill Wendlingde024832009-05-17 05:52:39 +00001678<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679<pre>
1680struct Color {
1681 unsigned Red;
1682 unsigned Green;
1683 unsigned Blue;
1684};
1685</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001686</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687
Misha Brukmane5b22d42008-12-16 02:54:22 +00001688<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689
Bill Wendlingde024832009-05-17 05:52:39 +00001690<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691<pre>
1692;;
1693;; Define basic type for unsigned int.
1694;;
1695%<a href="#format_basic_type">llvm.dbg.basictype</a> = internal constant %<a href="#format_basic_type">llvm.dbg.basictype.type</a> {
1696 uint add(uint 36, uint 262144),
1697 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001698 i8* getelementptr ([13 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 { }* null,
1700 int 0,
1701 uint 32,
1702 uint 32,
1703 uint 0,
1704 uint 7 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001705%str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706
1707;;
1708;; Define composite type for struct Color.
1709;;
1710%<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
1711 uint add(uint 19, uint 262144),
1712 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001713 i8* getelementptr ([6 x i8]* %str2, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1715 int 1,
1716 uint 96,
1717 uint 32,
1718 uint 0,
1719 { }* null,
1720 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001721%str2 = internal constant [6 x i8] c"Color\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722
1723;;
1724;; Define the Red field.
1725;;
1726%<a href="#format_derived_type">llvm.dbg.derivedtype1</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1727 uint add(uint 13, uint 262144),
1728 { }* null,
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001729 i8* getelementptr ([4 x i8]* %str3, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1731 int 2,
1732 uint 32,
1733 uint 32,
1734 uint 0,
1735 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001736%str3 = internal constant [4 x i8] c"Red\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737
1738;;
1739;; Define the Green field.
1740;;
1741%<a href="#format_derived_type">llvm.dbg.derivedtype2</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1742 uint add(uint 13, uint 262144),
1743 { }* null,
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001744 i8* getelementptr ([6 x i8]* %str4, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1746 int 3,
1747 uint 32,
1748 uint 32,
1749 uint 32,
1750 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001751%str4 = internal constant [6 x i8] c"Green\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752
1753;;
1754;; Define the Blue field.
1755;;
1756%<a href="#format_derived_type">llvm.dbg.derivedtype3</a> = internal constant %<a href="#format_derived_type">llvm.dbg.derivedtype.type</a> {
1757 uint add(uint 13, uint 262144),
1758 { }* null,
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001759 i8* getelementptr ([5 x i8]* %str5, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1761 int 4,
1762 uint 32,
1763 uint 32,
1764 uint 64,
1765 { }* cast (%<a href="#format_basic_type">llvm.dbg.basictype.type</a>* %<a href="#format_basic_type">llvm.dbg.basictype</a> to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001766%str5 = internal constant [5 x 8] c"Blue\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767
1768;;
1769;; Define the array of fields used by the composite type Color.
1770;;
1771%llvm.dbg.array = internal constant [3 x { }*] [
1772 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype1</a> to { }*),
1773 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype2</a> to { }*),
1774 { }* cast (%<a href="#format_derived_type">llvm.dbg.derivedtype.type</a>* %<a href="#format_derived_type">llvm.dbg.derivedtype3</a> to { }*) ], section "llvm.metadata"
1775</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001776</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777
1778</div>
1779
1780<!-- ======================================================================= -->
1781<div class="doc_subsection">
1782 <a name="ccxx_enumeration_types">C/C++ enumeration types</a>
1783</div>
1784
1785<div class="doc_text">
1786
Misha Brukmane5b22d42008-12-16 02:54:22 +00001787<p>Given the following as an example of C/C++ enumeration type:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788
Bill Wendlingde024832009-05-17 05:52:39 +00001789<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790<pre>
1791enum Trees {
1792 Spruce = 100,
1793 Oak = 200,
1794 Maple = 300
1795};
1796</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001797</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798
Misha Brukmane5b22d42008-12-16 02:54:22 +00001799<p>a C/C++ front-end would generate the following descriptors:</p>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800
Bill Wendlingde024832009-05-17 05:52:39 +00001801<div class="doc_code">
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802<pre>
1803;;
1804;; Define composite type for enum Trees
1805;;
1806%<a href="#format_composite_type">llvm.dbg.compositetype</a> = internal constant %<a href="#format_composite_type">llvm.dbg.compositetype.type</a> {
1807 uint add(uint 4, uint 262144),
1808 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001809 i8* getelementptr ([6 x i8]* %str1, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 { }* cast (%<a href="#format_compile_units">llvm.dbg.compile_unit.type</a>* %<a href="#format_compile_units">llvm.dbg.compile_unit</a> to { }*),
1811 int 1,
1812 uint 32,
1813 uint 32,
1814 uint 0,
1815 { }* null,
1816 { }* cast ([3 x { }*]* %llvm.dbg.array to { }*) }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001817%str1 = internal constant [6 x i8] c"Trees\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818
1819;;
1820;; Define Spruce enumerator.
1821;;
1822%<a href="#format_enumeration">llvm.dbg.enumerator1</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1823 uint add(uint 40, uint 262144),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001824 i8* getelementptr ([7 x i8]* %str2, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 int 100 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001826%str2 = internal constant [7 x i8] c"Spruce\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827
1828;;
1829;; Define Oak enumerator.
1830;;
1831%<a href="#format_enumeration">llvm.dbg.enumerator2</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1832 uint add(uint 40, uint 262144),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001833 i8* getelementptr ([4 x i8]* %str3, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 int 200 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001835%str3 = internal constant [4 x i8] c"Oak\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836
1837;;
1838;; Define Maple enumerator.
1839;;
1840%<a href="#format_enumeration">llvm.dbg.enumerator3</a> = internal constant %<a href="#format_enumeration">llvm.dbg.enumerator.type</a> {
1841 uint add(uint 40, uint 262144),
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001842 i8* getelementptr ([6 x i8]* %str4, int 0, int 0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 int 300 }, section "llvm.metadata"
Chris Lattnerabbbe6a2009-04-03 00:29:19 +00001844%str4 = internal constant [6 x i8] c"Maple\00", section "llvm.metadata"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845
1846;;
1847;; Define the array of enumerators used by composite type Trees.
1848;;
1849%llvm.dbg.array = internal constant [3 x { }*] [
1850 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator1</a> to { }*),
1851 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator2</a> to { }*),
1852 { }* cast (%<a href="#format_enumeration">llvm.dbg.enumerator.type</a>* %<a href="#format_enumeration">llvm.dbg.enumerator3</a> to { }*) ], section "llvm.metadata"
1853</pre>
Bill Wendlingde024832009-05-17 05:52:39 +00001854</div>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855
1856</div>
1857
1858<!-- *********************************************************************** -->
1859
1860<hr>
1861<address>
1862 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman947321d2008-12-11 17:34:48 +00001863 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman947321d2008-12-11 17:34:48 +00001865 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866
1867 <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
1868 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
1869 Last modified: $Date$
1870</address>
1871
1872</body>
1873</html>