Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 6 | <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 | |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 13 | <table class="layout" style="width:100%"> |
| 14 | <tr class="layout"> |
| 15 | <td class="left"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 16 | <ul> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 17 | <li><a href="#introduction">Introduction</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 18 | <ol> |
| 19 | <li><a href="#phil">Philosophy behind LLVM debugging information</a></li> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 20 | <li><a href="#consumers">Debug information consumers</a></li> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 21 | <li><a href="#debugopt">Debugging optimized code</a></li> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 22 | </ol></li> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 23 | <li><a href="#format">Debugging information format</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 24 | <ol> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 25 | <li><a href="#debug_info_descriptors">Debug information descriptors</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 26 | <ul> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 27 | <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> |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 30 | <li><a href="#format_blocks">Block descriptors</a></li> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 36 | <li><a href="#format_variables">Local variables</a></li> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 37 | </ul></li> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 48 | </ol></li> |
| 49 | <li><a href="#ccxx_frontend">C/C++ front-end specific debug information</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 50 | <ol> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 58 | </ol></li> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 59 | </ul> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 60 | </td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 61 | <td class="right"> |
Misha Brukman | e849a1a | 2004-05-12 21:26:16 +0000 | [diff] [blame] | 62 | <img src="img/venusflytrap.jpg" alt="A leafy and green bug eater" width="247" |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 63 | height="369"> |
| 64 | </td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 65 | </tr></table> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 66 | |
Chris Lattner | 7911ce2 | 2004-05-23 21:07:27 +0000 | [diff] [blame] | 67 | <div class="doc_author"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 68 | <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> |
Jim Laskey | c760a92 | 2007-03-14 19:32:21 +0000 | [diff] [blame] | 69 | and <a href="mailto:jlaskey@mac.com">Jim Laskey</a></p> |
Chris Lattner | 7911ce2 | 2004-05-23 21:07:27 +0000 | [diff] [blame] | 70 | </div> |
| 71 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 72 | |
| 73 | <!-- *********************************************************************** --> |
Misha Brukman | 94218a7 | 2004-12-09 20:27:37 +0000 | [diff] [blame] | 74 | <div class="doc_section"><a name="introduction">Introduction</a></div> |
| 75 | <!-- *********************************************************************** --> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 76 | |
| 77 | <div class="doc_text"> |
| 78 | |
| 79 | <p>This document is the central repository for all information pertaining to |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 80 | 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 Lattner | 8ad2f98 | 2009-07-18 21:47:15 +0000 | [diff] [blame] | 83 | Further, this document provides specific examples of what debug information |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 84 | for C/C++.</p> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 85 | |
| 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 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 95 | <p>The idea of the LLVM debugging information is to capture how the important |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 96 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 99 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 100 | <ul> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 101 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 104 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 105 | <li>LLVM optimizations should interact in <a href="#debugopt">well-defined and |
| 106 | easily described ways</a> with the debugging information.</li> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 107 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 108 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 111 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 112 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 115 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 116 | <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> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 120 | </ul> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 121 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 122 | <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 |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 125 | description of the source-level program is maintained in LLVM global |
| 126 | variables in an <a href="#ccxx_frontend">implementation-defined format</a> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 130 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 131 | <p>When a program is being debugged, a debugger interacts with the user and |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 132 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 135 | |
| 136 | </div> |
| 137 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 138 | <!-- ======================================================================= --> |
| 139 | <div class="doc_subsection"> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 140 | <a name="consumers">Debug information consumers</a> |
| 141 | </div> |
| 142 | |
| 143 | <div class="doc_text"> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 144 | |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 145 | <p>The role of debug information is to provide meta information normally |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 146 | 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> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 149 | |
| 150 | <p>Currently, debug information is consumed by the DwarfWriter to produce dwarf |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 151 | information used by the gdb debugger. Other targets could use the same |
| 152 | information to produce stabs or other debug forms.</p> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 153 | |
| 154 | <p>It would also be reasonable to use debug information to feed profiling tools |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 155 | for analysis of generated code, or, tools for reconstructing the original |
| 156 | source from generated code.</p> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 157 | |
| 158 | <p>TODO - expound a bit more.</p> |
| 159 | |
| 160 | </div> |
| 161 | |
| 162 | <!-- ======================================================================= --> |
| 163 | <div class="doc_subsection"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 164 | <a name="debugopt">Debugging optimized code</a> |
| 165 | </div> |
| 166 | |
| 167 | <div class="doc_text"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 168 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 169 | <p>An extremely high priority of LLVM debugging information is to make it |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 170 | interact well with optimizations and analysis. In particular, the LLVM debug |
| 171 | information provides the following guarantees:</p> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 172 | |
| 173 | <ul> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 174 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 181 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 182 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 187 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 188 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 193 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 194 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 198 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 199 | <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> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 203 | </ul> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 204 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 205 | <p>Basically, the debug information allows you to compile a program with |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 206 | "<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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 213 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 214 | <p><a href="TestingGuide.html#quicktestsuite">LLVM test suite</a> provides a |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 215 | framework to test optimizer's handling of debugging information. It can be |
| 216 | run like this:</p> |
Devang Patel | a5c05aa | 2008-11-21 19:35:57 +0000 | [diff] [blame] | 217 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 225 | <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 Patel | a5c05aa | 2008-11-21 19:35:57 +0000 | [diff] [blame] | 229 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 230 | </div> |
| 231 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 232 | <!-- *********************************************************************** --> |
| 233 | <div class="doc_section"> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 234 | <a name="format">Debugging information format</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 235 | </div> |
| 236 | <!-- *********************************************************************** --> |
| 237 | |
| 238 | <div class="doc_text"> |
| 239 | |
| 240 | <p>LLVM debugging information has been carefully designed to make it possible |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 241 | for the optimizer to optimize the program and debugging information without |
| 242 | necessarily having to know anything about debugging information. In |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 248 | |
| 249 | <p>To do this, most of the debugging information (descriptors for types, |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 250 | variables, functions, source files, etc) is inserted by the language |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 257 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 258 | <p>Debug information is designed to be agnostic about the target debugger and |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 259 | debugging information representation (e.g. DWARF/Stabs/etc). It uses a |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 268 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 269 | <p>To provide basic functionality, the LLVM debugger does have to make some |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 270 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 276 | |
| 277 | <p>This section of the documentation first describes the representation aspects |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 278 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 280 | |
| 281 | </div> |
| 282 | |
| 283 | <!-- ======================================================================= --> |
| 284 | <div class="doc_subsection"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 285 | <a name="debug_info_descriptors">Debug information descriptors</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 286 | </div> |
| 287 | |
| 288 | <div class="doc_text"> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 289 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 290 | <p>In consideration of the complexity and volume of debug information, LLVM |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 291 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 294 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 295 | <p>Consumers of LLVM debug information expect the descriptors for program |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 296 | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 305 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 306 | <p>The fields of debug descriptors used internally by LLVM (MachineModuleInfo) |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 307 | are restricted to only the simple data types <tt>int</tt>, <tt>uint</tt>, |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 308 | <tt>bool</tt>, <tt>float</tt>, <tt>double</tt>, <tt>i8*</tt> and |
| 309 | <tt>{ }*</tt>. References to arbitrary values are handled using a |
| 310 | <tt>{ }*</tt> and a cast to <tt>{ }*</tt> expression; typically |
| 311 | references to other field descriptors, arrays of descriptors or global |
| 312 | variables.</p> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 313 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 314 | <div class="doc_code"> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 315 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 316 | %llvm.dbg.object.type = type { |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 317 | uint, ;; A tag |
| 318 | ... |
| 319 | } |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 320 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 321 | </div> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 322 | |
Jim Laskey | 7089f45 | 2006-06-16 13:14:03 +0000 | [diff] [blame] | 323 | <p><a name="LLVMDebugVersion">The first field of a descriptor is always an |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 324 | <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 |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 329 | with the current debug version (LLVMDebugVersion = 4 << 16 or 0x40000 or |
| 330 | 262144.)</a></p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 331 | |
Jim Laskey | 7089f45 | 2006-06-16 13:14:03 +0000 | [diff] [blame] | 332 | <p>The details of the various descriptors follow.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 333 | |
| 334 | </div> |
| 335 | |
| 336 | <!-- ======================================================================= --> |
| 337 | <div class="doc_subsubsection"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 338 | <a name="format_compile_units">Compile unit descriptors</a> |
| 339 | </div> |
| 340 | |
| 341 | <div class="doc_text"> |
| 342 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 343 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 344 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 345 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 356 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 357 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 358 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 359 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 360 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 365 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 366 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 370 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 371 | <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 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 380 | </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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 389 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 390 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 391 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 404 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 405 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 406 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 407 | |
| 408 | <p>These descriptors provide debug information about globals variables. The |
| 409 | provide 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 420 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 421 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 422 | %<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) |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 434 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 435 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 436 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 437 | |
| 438 | <p>These descriptors provide debug information about functions, methods and |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 439 | subprograms. They provide details such as name, return types and the source |
| 440 | location where the subprogram is defined.</p> |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 441 | |
| 442 | </div> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 443 | |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 444 | <!-- ======================================================================= --> |
| 445 | <div class="doc_subsubsection"> |
| 446 | <a name="format_blocks">Block descriptors</a> |
| 447 | </div> |
| 448 | |
| 449 | <div class="doc_text"> |
| 450 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 451 | <div class="doc_code"> |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 452 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 453 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 456 | } |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 457 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 458 | </div> |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 459 | |
| 460 | <p>These descriptors provide debug information about nested blocks within a |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 461 | subprogram. The array of member descriptors is used to define local |
| 462 | variables and deeper nested blocks.</p> |
Jim Laskey | 3d11bee | 2006-03-15 19:10:52 +0000 | [diff] [blame] | 463 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 473 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 474 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 475 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 486 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 487 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 488 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 489 | |
| 490 | <p>These descriptors define primitive types used in the code. Example int, bool |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 491 | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 499 | |
| 500 | <p>The type encoding provides the details of the type. The values are typically |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 501 | one of the following:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 502 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 503 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 504 | <pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 505 | DW_ATE_address = 1 |
| 506 | DW_ATE_boolean = 2 |
| 507 | DW_ATE_float = 4 |
| 508 | DW_ATE_signed = 5 |
| 509 | DW_ATE_signed_char = 6 |
| 510 | DW_ATE_unsigned = 7 |
| 511 | DW_ATE_unsigned_char = 8 |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 512 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 513 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 514 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 524 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 525 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 526 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 536 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 537 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 538 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 539 | |
| 540 | <p>These descriptors are used to define types derived from other types. The |
| 541 | value of the tag varies depending on the meaning. The following are possible |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 542 | tag values:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 543 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 544 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 545 | <pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 546 | DW_TAG_formal_parameter = 5 |
| 547 | DW_TAG_member = 13 |
| 548 | DW_TAG_pointer_type = 15 |
| 549 | DW_TAG_reference_type = 16 |
| 550 | DW_TAG_typedef = 22 |
| 551 | DW_TAG_const_type = 38 |
| 552 | DW_TAG_volatile_type = 53 |
| 553 | DW_TAG_restrict_type = 55 |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 554 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 555 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 556 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 557 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 563 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 564 | <p><tt>DW_TAG_typedef</tt> is used to provide a name for the derived type.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 565 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 566 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 570 | |
| 571 | <p><a href="#format_derived_type">Derived type</a> location can be determined |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 572 | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 578 | |
| 579 | <p>Note that the <tt>void *</tt> type is expressed as a |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 580 | <tt>llvm.dbg.derivedtype.type</tt> with tag of <tt>DW_TAG_pointer_type</tt> |
| 581 | and <tt>NULL</tt> derived type.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 582 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 592 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 593 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 594 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 607 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 608 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 609 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 610 | |
| 611 | <p>These descriptors are used to define types that are composed of 0 or more |
| 612 | elements. The value of the tag varies depending on the meaning. The following |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 613 | are possible tag values:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 614 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 615 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 616 | <pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 617 | DW_TAG_array_type = 1 |
| 618 | DW_TAG_enumeration_type = 4 |
| 619 | DW_TAG_structure_type = 19 |
| 620 | DW_TAG_union_type = 23 |
| 621 | DW_TAG_vector_type = 259 |
Bruno Cardoso Lopes | d80ddc0 | 2009-05-29 17:08:57 +0000 | [diff] [blame] | 622 | DW_TAG_subroutine_type = 21 |
| 623 | DW_TAG_inheritance = 28 |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 624 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 625 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 626 | |
Jim Laskey | f8a01a9 | 2006-06-15 20:51:43 +0000 | [diff] [blame] | 627 | <p>The vector flag indicates that an array type is a native packed vector.</p> |
| 628 | |
Jim Laskey | 7089f45 | 2006-06-16 13:14:03 +0000 | [diff] [blame] | 629 | <p>The members of array types (tag = <tt>DW_TAG_array_type</tt>) or vector types |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 630 | (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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 633 | |
| 634 | <p>The members of enumeration types (tag = <tt>DW_TAG_enumeration_type</tt>) are |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 635 | <a href="#format_enumeration">enumerator descriptors</a>, each representing |
| 636 | the definition of enumeration value for the set.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 637 | |
| 638 | <p>The members of structure (tag = <tt>DW_TAG_structure_type</tt>) or union (tag |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 639 | = <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 644 | |
Jim Laskey | 4a9df24 | 2006-08-21 21:21:06 +0000 | [diff] [blame] | 645 | <p>For C++ classes (tag = <tt>DW_TAG_structure_type</tt>), member descriptors |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 646 | 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> |
Jim Laskey | 4a9df24 | 2006-08-21 21:21:06 +0000 | [diff] [blame] | 656 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 657 | <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> |
Jim Laskey | 094ee72 | 2006-06-20 21:13:20 +0000 | [diff] [blame] | 660 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 661 | <p><a href="#format_composite_type">Composite type</a> location can be |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 662 | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 668 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 678 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 679 | <pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 680 | %<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 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 685 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 686 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 687 | |
| 688 | <p>These descriptors are used to define ranges of array subscripts for an array |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 689 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 693 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 703 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 704 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 705 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 709 | } |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 710 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 711 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 712 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 713 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 716 | |
| 717 | </div> |
| 718 | |
| 719 | <!-- ======================================================================= --> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 720 | <div class="doc_subsubsection"> |
| 721 | <a name="format_variables">Local variables</a> |
| 722 | </div> |
| 723 | |
| 724 | <div class="doc_text"> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 725 | |
| 726 | <div class="doc_code"> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 727 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 728 | %<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 |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 735 | } |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 736 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 737 | </div> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 738 | |
| 739 | <p>These descriptors are used to define variables local to a sub program. The |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 740 | value of the tag depends on the usage of the variable:</p> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 741 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 742 | <div class="doc_code"> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 743 | <pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 744 | DW_TAG_auto_variable = 256 |
| 745 | DW_TAG_arg_variable = 257 |
| 746 | DW_TAG_return_variable = 258 |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 747 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 748 | </div> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 749 | |
| 750 | <p>An auto variable is any variable declared in the body of the function. An |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 751 | 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> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 754 | |
Jim Laskey | 2d395d9 | 2006-03-24 09:20:27 +0000 | [diff] [blame] | 755 | <p>The context is either the subprogram or block where the variable is defined. |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 756 | 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> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 759 | |
| 760 | </div> |
| 761 | |
| 762 | <!-- ======================================================================= --> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 763 | <div class="doc_subsection"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 770 | provide debug information at various points in generated code.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 771 | |
| 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> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 781 | void %<a href="#format_common_stoppoint">llvm.dbg.stoppoint</a>( uint, uint, { }* ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 782 | </pre> |
| 783 | |
| 784 | <p>This intrinsic is used to provide correspondence between the source file and |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 785 | 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 |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 787 | source <tt>%<a href="#format_compile_units">llvm.dbg.compile_unit</a>*</tt> |
| 788 | cast to a <tt>{ }*</tt>. Code following a call to this intrinsic will |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 792 | |
| 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> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 802 | void %<a href="#format_common_func_start">llvm.dbg.func.start</a>( { }* ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 803 | </pre> |
| 804 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 805 | <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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 816 | |
| 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> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 826 | void %<a href="#format_common_region_start">llvm.dbg.region.start</a>( { }* ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 827 | </pre> |
| 828 | |
| 829 | <p>This intrinsic is used to define the beginning of a declarative scope (ex. |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 830 | 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> |
Jim Laskey | 383e009 | 2006-03-23 17:54:33 +0000 | [diff] [blame] | 835 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 846 | void %<a href="#format_common_region_end">llvm.dbg.region.end</a>( { }* ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 847 | </pre> |
| 848 | |
| 849 | <p>This intrinsic is used to define the end of a declarative scope (ex. block) |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 850 | 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> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 857 | |
| 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> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 867 | void %<a href="#format_common_declare">llvm.dbg.declare</a>( { } *, { }* ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 868 | </pre> |
| 869 | |
Jim Laskey | 2d395d9 | 2006-03-24 09:20:27 +0000 | [diff] [blame] | 870 | <p>This intrinsic provides information about a local element (ex. variable.) The |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 871 | 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 |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 874 | the description of the variable, also cast to a <tt>{ }*</tt>.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 875 | |
| 876 | </div> |
| 877 | |
| 878 | <!-- ======================================================================= --> |
| 879 | <div class="doc_subsection"> |
| 880 | <a name="format_common_stoppoints"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 888 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 898 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 899 | <p>Using calls to this intrinsic function to demark legal points for the |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 900 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 909 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 910 | </div> |
| 911 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 912 | <!-- ======================================================================= --> |
| 913 | <div class="doc_subsection"> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 914 | <a name="format_common_lifetime">Object lifetimes and scoping</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 915 | </div> |
| 916 | |
| 917 | <div class="doc_text"> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 918 | <p>In many languages, the local variables in functions can have their lifetime |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 919 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 926 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 927 | <p>In order to handle this, the LLVM debug format uses the notion of "regions" |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 928 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 931 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 932 | <div class="doc_code"> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 933 | <pre> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 934 | 1. void foo() { |
| 935 | 2. int X = ...; |
| 936 | 3. int Y = ...; |
| 937 | 4. { |
| 938 | 5. int Z = ...; |
| 939 | 6. ... |
| 940 | 7. } |
| 941 | 8. ... |
| 942 | 9. } |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 943 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 944 | </div> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 945 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 946 | <p>Compiled to LLVM, this function would be represented like this:</p> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 947 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 948 | <div class="doc_code"> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 949 | <pre> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 950 | void %foo() { |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 951 | entry: |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 952 | %X = alloca int |
| 953 | %Y = alloca int |
| 954 | %Z = alloca int |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 955 | |
| 956 | ... |
| 957 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 958 | 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 ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 959 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 960 | 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 ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 961 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 962 | 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, ...) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 964 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 965 | <i>;; Evaluate expression on line 2, assigning to X.</i> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 966 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 967 | 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 ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 968 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 969 | <i>;; Evaluate expression on line 3, assigning to Y.</i> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 970 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 971 | call void @<a href="#format_common_stoppoint">llvm.region.start</a>() |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 ) |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 973 | call void @<a href="#format_common_declare">llvm.dbg.declare</a>({}* %X, ...) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 974 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 975 | <i>;; Evaluate expression on line 5, assigning to Z.</i> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 976 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 977 | 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 ) |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 978 | call void @<a href="#format_common_region_end">llvm.region.end</a>() |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 979 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 980 | 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 ) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 981 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 982 | call void @<a href="#format_common_region_end">llvm.region.end</a>() |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 983 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 984 | ret void |
| 985 | } |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 986 | </pre> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 987 | </div> |
| 988 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 989 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 993 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 994 | <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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1044 | |
| 1045 | <!-- *********************************************************************** --> |
| 1046 | <div class="doc_section"> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1047 | <a name="ccxx_frontend">C/C++ front-end specific debug information</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1048 | </div> |
Misha Brukman | 94218a7 | 2004-12-09 20:27:37 +0000 | [diff] [blame] | 1049 | <!-- *********************************************************************** --> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1050 | |
| 1051 | <div class="doc_text"> |
| 1052 | |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1053 | <p>The C and C++ front-ends represent information about the program in a format |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1054 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1060 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1061 | <p>This section describes the forms used to represent C and C++ programs. Other |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1062 | 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> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1068 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1069 | <p>The following sections provide examples of various C/C++ constructs and the |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1070 | debug information that would best describe those constructs.</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1071 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1072 | </div> |
| 1073 | |
| 1074 | <!-- ======================================================================= --> |
| 1075 | <div class="doc_subsection"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1076 | <a name="ccxx_compile_units">C/C++ source file information</a> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1077 | </div> |
| 1078 | |
| 1079 | <div class="doc_text"> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1080 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1081 | <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> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1083 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1084 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1085 | <pre> |
| 1086 | #include "MyHeader.h" |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1087 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1088 | int main(int argc, char *argv[]) { |
| 1089 | return 0; |
| 1090 | } |
| 1091 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1092 | </div> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1093 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1094 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1095 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1096 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1097 | <pre> |
| 1098 | ... |
| 1099 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 } |
| 1104 | %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = type { uint, { }*, uint, uint, i8*, i8*, i8* } |
| 1105 | ... |
| 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 | ;; |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1114 | ;; Define the compile unit for the source file "/Users/mine/sources/MySource.cpp". |
| 1115 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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, |
| 1121 | 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" |
| 1124 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1125 | ;; |
| 1126 | ;; Define the compile unit for the header file "/Users/mine/sources/MyHeader.h". |
| 1127 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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, |
| 1133 | 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" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1136 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 1137 | ;; |
| 1138 | ;; Define each of the strings used in the compile units. |
| 1139 | ;; |
| 1140 | %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"; |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1144 | ... |
| 1145 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1146 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1147 | |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1148 | </div> |
| 1149 | |
| 1150 | <!-- ======================================================================= --> |
| 1151 | <div class="doc_subsection"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1152 | <a name="ccxx_global_variable">C/C++ global variable information</a> |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1153 | </div> |
| 1154 | |
| 1155 | <div class="doc_text"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1156 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1157 | <p>Given an integer global variable declared as follows:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1158 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1159 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1160 | <pre> |
| 1161 | int MyGlobal = 100; |
| 1162 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1163 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1164 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1165 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1166 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1167 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1168 | <pre> |
| 1169 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 } |
| 1175 | %<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 } |
| 1177 | %<a href="#format_compile_units">llvm.dbg.compile_unit.type</a> = ... |
| 1178 | ... |
| 1179 | ;; |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1180 | ;; Define the global itself. |
| 1181 | ;; |
| 1182 | %MyGlobal = global int 100 |
| 1183 | ... |
| 1184 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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.) |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1188 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1190 | |
| 1191 | ;; |
| 1192 | ;; Define the global variable descriptor. Note the reference to the global |
| 1193 | ;; variable anchor and the global variable itself. |
| 1194 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1199 | i8* getelementptr ([9 x i8]* %str1, int 0, int 0), |
| 1200 | i8* getelementptr ([1 x i8]* %str2, int 0, int 0), |
| 1201 | { }* 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 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1215 | i8* getelementptr ([4 x i8]* %str3, int 0, int 0), |
| 1216 | { }* null, |
| 1217 | int 0, |
| 1218 | uint 32, |
| 1219 | uint 32, |
| 1220 | uint 0, |
| 1221 | uint 5 }, section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1222 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 1223 | ;; |
| 1224 | ;; Define the names of the global variable and basic type. |
| 1225 | ;; |
| 1226 | %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" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1229 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1230 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1231 | |
Chris Lattner | 8ff7590 | 2004-01-06 05:31:32 +0000 | [diff] [blame] | 1232 | </div> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1233 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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 Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1241 | <p>Given a function declared as follows:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1242 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1243 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1244 | <pre> |
| 1245 | int main(int argc, char *argv[]) { |
| 1246 | return 0; |
| 1247 | } |
| 1248 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1249 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1250 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1251 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1252 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1253 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1254 | <pre> |
| 1255 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 | ;; |
| 1260 | %<a href="#format_subprograms">llvm.dbg.subprogram.type</a> = type { uint, { }*, { }*, i8*, { }*, bool, bool } |
| 1261 | %<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 | ;; |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 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 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1278 | i8* getelementptr ([5 x i8]* %str1, int 0, int 0), |
| 1279 | i8* getelementptr ([1 x i8]* %str2, int 0, int 0), |
| 1280 | { }* 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 | ;; |
| 1289 | %str1 = internal constant [5 x i8] c"main\00", section "llvm.metadata" |
| 1290 | %str2 = internal constant [1 x i8] c"\00", section "llvm.metadata" |
| 1291 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1292 | ;; |
| 1293 | ;; Define the subprogram itself. |
| 1294 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 1295 | int %main(int %argc, i8** %argv) { |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1296 | ... |
| 1297 | } |
| 1298 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1299 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1300 | |
| 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 Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1310 | <p>The following are the basic type descriptors for C/C++ core types:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1311 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1321 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1322 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1326 | i8* getelementptr ([5 x i8]* %str1, int 0, int 0), |
| 1327 | { }* null, |
| 1328 | int 0, |
| 1329 | uint 32, |
| 1330 | uint 32, |
| 1331 | uint 0, |
| 1332 | uint 2 }, section "llvm.metadata" |
| 1333 | %str1 = internal constant [5 x i8] c"bool\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1334 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1335 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1336 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1346 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1347 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1351 | i8* getelementptr ([5 x i8]* %str1, int 0, int 0), |
| 1352 | { }* null, |
| 1353 | int 0, |
| 1354 | uint 8, |
| 1355 | uint 8, |
| 1356 | uint 0, |
| 1357 | uint 6 }, section "llvm.metadata" |
| 1358 | %str1 = internal constant [5 x i8] c"char\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1359 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1360 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1361 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1371 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1372 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1376 | i8* getelementptr ([14 x i8]* %str1, int 0, int 0), |
| 1377 | { }* null, |
| 1378 | int 0, |
| 1379 | uint 8, |
| 1380 | uint 8, |
| 1381 | uint 0, |
| 1382 | uint 8 }, section "llvm.metadata" |
| 1383 | %str1 = internal constant [14 x i8] c"unsigned char\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1384 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1385 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1386 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1396 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1397 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1401 | i8* getelementptr ([10 x i8]* %str1, int 0, int 0), |
| 1402 | { }* null, |
| 1403 | int 0, |
| 1404 | uint 16, |
| 1405 | uint 16, |
| 1406 | uint 0, |
| 1407 | uint 5 }, section "llvm.metadata" |
| 1408 | %str1 = internal constant [10 x i8] c"short int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1409 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1410 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1411 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1421 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1422 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1426 | i8* getelementptr ([19 x i8]* %str1, int 0, int 0), |
| 1427 | { }* null, |
| 1428 | int 0, |
| 1429 | uint 16, |
| 1430 | uint 16, |
| 1431 | uint 0, |
| 1432 | uint 7 }, section "llvm.metadata" |
| 1433 | %str1 = internal constant [19 x i8] c"short unsigned int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1434 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1435 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1436 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1446 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1447 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1451 | i8* getelementptr ([4 x i8]* %str1, int 0, int 0), |
| 1452 | { }* null, |
| 1453 | int 0, |
| 1454 | uint 32, |
| 1455 | uint 32, |
| 1456 | uint 0, |
| 1457 | uint 5 }, section "llvm.metadata" |
| 1458 | %str1 = internal constant [4 x i8] c"int\00", section "llvm.metadata" |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1459 | </pre></div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1460 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1470 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1471 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1475 | i8* getelementptr ([13 x i8]* %str1, int 0, int 0), |
| 1476 | { }* null, |
| 1477 | int 0, |
| 1478 | uint 32, |
| 1479 | uint 32, |
| 1480 | uint 0, |
| 1481 | uint 7 }, section "llvm.metadata" |
| 1482 | %str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1483 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1484 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1485 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1495 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1496 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1500 | i8* getelementptr ([14 x i8]* %str1, int 0, int 0), |
| 1501 | { }* null, |
| 1502 | int 0, |
| 1503 | uint 64, |
| 1504 | uint 64, |
| 1505 | uint 0, |
| 1506 | uint 5 }, section "llvm.metadata" |
| 1507 | %str1 = internal constant [14 x i8] c"long long int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1508 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1509 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1510 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1520 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1521 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1525 | i8* getelementptr ([23 x i8]* %str1, int 0, int 0), |
| 1526 | { }* null, |
| 1527 | int 0, |
| 1528 | uint 64, |
| 1529 | uint 64, |
| 1530 | uint 0, |
| 1531 | uint 7 }, section "llvm.metadata" |
| 1532 | %str1 = internal constant [23 x 8] c"long long unsigned int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1533 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1534 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1535 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1545 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1546 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1550 | i8* getelementptr ([6 x i8]* %str1, int 0, int 0), |
| 1551 | { }* null, |
| 1552 | int 0, |
| 1553 | uint 32, |
| 1554 | uint 32, |
| 1555 | uint 0, |
| 1556 | uint 4 }, section "llvm.metadata" |
| 1557 | %str1 = internal constant [6 x i8] c"float\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1558 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1559 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1560 | |
| 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 Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1570 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1571 | <pre> |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1575 | 8* getelementptr ([7 x 8]* %str1, int 0, int 0), |
| 1576 | { }* null, |
| 1577 | int 0, |
| 1578 | uint 64, |
| 1579 | uint 64, |
| 1580 | uint 0, |
| 1581 | uint 4 }, section "llvm.metadata" |
| 1582 | %str1 = internal constant [7 x 8] c"double\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1583 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1584 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1585 | |
| 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 Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1595 | <p>Given the following as an example of C/C++ derived type:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1596 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1597 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1598 | <pre> |
| 1599 | typedef const int *IntPtr; |
| 1600 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1601 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1602 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1603 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1604 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1605 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1606 | <pre> |
| 1607 | ;; |
| 1608 | ;; Define the typedef "IntPtr". |
| 1609 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1613 | i8* getelementptr ([7 x 8]* %str1, int 0, int 0), |
| 1614 | { }* 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" |
| 1620 | %str1 = internal constant [7 x 8] c"IntPtr\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1621 | |
| 1622 | ;; |
| 1623 | ;; Define the pointer type. |
| 1624 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1628 | i8* null, |
| 1629 | { }* 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 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1636 | ;; |
| 1637 | ;; Define the const type. |
| 1638 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1642 | i8* null, |
| 1643 | { }* 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 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1650 | ;; |
| 1651 | ;; Define the int type. |
| 1652 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1656 | 8* getelementptr ([4 x 8]* %str2, int 0, int 0), |
| 1657 | { }* null, |
| 1658 | int 0, |
| 1659 | uint 32, |
| 1660 | uint 32, |
| 1661 | uint 0, |
| 1662 | uint 5 }, section "llvm.metadata" |
| 1663 | %str2 = internal constant [4 x 8] c"int\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1664 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1665 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1666 | |
| 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 Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1676 | <p>Given the following as an example of C/C++ struct type:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1677 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1678 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1679 | <pre> |
| 1680 | struct Color { |
| 1681 | unsigned Red; |
| 1682 | unsigned Green; |
| 1683 | unsigned Blue; |
| 1684 | }; |
| 1685 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1686 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1687 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1688 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1689 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1690 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1691 | <pre> |
| 1692 | ;; |
| 1693 | ;; Define basic type for unsigned int. |
| 1694 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1698 | i8* getelementptr ([13 x i8]* %str1, int 0, int 0), |
| 1699 | { }* null, |
| 1700 | int 0, |
| 1701 | uint 32, |
| 1702 | uint 32, |
| 1703 | uint 0, |
| 1704 | uint 7 }, section "llvm.metadata" |
| 1705 | %str1 = internal constant [13 x i8] c"unsigned int\00", section "llvm.metadata" |
| 1706 | |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1707 | ;; |
| 1708 | ;; Define composite type for struct Color. |
| 1709 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1713 | i8* getelementptr ([6 x i8]* %str2, int 0, int 0), |
| 1714 | { }* 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" |
| 1721 | %str2 = internal constant [6 x i8] c"Color\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1722 | |
| 1723 | ;; |
| 1724 | ;; Define the Red field. |
| 1725 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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, |
| 1729 | i8* getelementptr ([4 x i8]* %str3, int 0, int 0), |
| 1730 | { }* 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" |
| 1736 | %str3 = internal constant [4 x i8] c"Red\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1737 | |
| 1738 | ;; |
| 1739 | ;; Define the Green field. |
| 1740 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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, |
| 1744 | i8* getelementptr ([6 x i8]* %str4, int 0, int 0), |
| 1745 | { }* 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" |
| 1751 | %str4 = internal constant [6 x i8] c"Green\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1752 | |
| 1753 | ;; |
| 1754 | ;; Define the Blue field. |
| 1755 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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, |
| 1759 | i8* getelementptr ([5 x i8]* %str5, int 0, int 0), |
| 1760 | { }* 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" |
| 1766 | %str5 = internal constant [5 x 8] c"Blue\00", section "llvm.metadata" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1767 | |
| 1768 | ;; |
| 1769 | ;; Define the array of fields used by the composite type Color. |
| 1770 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1775 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1776 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1777 | |
| 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 Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1787 | <p>Given the following as an example of C/C++ enumeration type:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1788 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1789 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1790 | <pre> |
| 1791 | enum Trees { |
| 1792 | Spruce = 100, |
| 1793 | Oak = 200, |
| 1794 | Maple = 300 |
| 1795 | }; |
| 1796 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1797 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1798 | |
Misha Brukman | 96e0081 | 2008-12-16 02:54:22 +0000 | [diff] [blame] | 1799 | <p>a C/C++ front-end would generate the following descriptors:</p> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1800 | |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1801 | <div class="doc_code"> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1802 | <pre> |
| 1803 | ;; |
| 1804 | ;; Define composite type for enum Trees |
| 1805 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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 { }*), |
| 1809 | i8* getelementptr ([6 x i8]* %str1, int 0, int 0), |
| 1810 | { }* 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" |
| 1817 | %str1 = internal constant [6 x i8] c"Trees\00", section "llvm.metadata" |
Devang Patel | 2a610c7 | 2009-08-25 05:24:07 +0000 | [diff] [blame] | 1818 | |
| 1819 | ;; |
| 1820 | ;; Define Spruce enumerator. |
| 1821 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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), |
| 1824 | i8* getelementptr ([7 x i8]* %str2, int 0, int 0), |
| 1825 | int 100 }, section "llvm.metadata" |
| 1826 | %str2 = internal constant [7 x i8] c"Spruce\00", section "llvm.metadata" |
Devang Patel | 2a610c7 | 2009-08-25 05:24:07 +0000 | [diff] [blame] | 1827 | |
| 1828 | ;; |
| 1829 | ;; Define Oak enumerator. |
| 1830 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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), |
| 1833 | i8* getelementptr ([4 x i8]* %str3, int 0, int 0), |
| 1834 | int 200 }, section "llvm.metadata" |
| 1835 | %str3 = internal constant [4 x i8] c"Oak\00", section "llvm.metadata" |
Devang Patel | 2a610c7 | 2009-08-25 05:24:07 +0000 | [diff] [blame] | 1836 | |
| 1837 | ;; |
| 1838 | ;; Define Maple enumerator. |
| 1839 | ;; |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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), |
| 1842 | i8* getelementptr ([6 x i8]* %str4, int 0, int 0), |
| 1843 | int 300 }, section "llvm.metadata" |
| 1844 | %str4 = internal constant [6 x i8] c"Maple\00", section "llvm.metadata" |
Devang Patel | 2a610c7 | 2009-08-25 05:24:07 +0000 | [diff] [blame] | 1845 | |
Devang Patel | 8245988 | 2009-08-26 05:01:18 +0000 | [diff] [blame^] | 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" |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1853 | </pre> |
Bill Wendling | 48839d9 | 2009-05-17 05:52:39 +0000 | [diff] [blame] | 1854 | </div> |
Jim Laskey | cec12a5 | 2006-03-14 18:08:46 +0000 | [diff] [blame] | 1855 | |
| 1856 | </div> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1857 | |
| 1858 | <!-- *********************************************************************** --> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1859 | |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1860 | <hr> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1861 | <address> |
| 1862 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 1863 | src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1864 | <a href="http://validator.w3.org/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 1865 | src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1866 | |
| 1867 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> |
Reid Spencer | 05fe4b0 | 2006-03-14 05:39:39 +0000 | [diff] [blame] | 1868 | <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1869 | Last modified: $Date$ |
Misha Brukman | 8287373 | 2004-05-12 19:21:57 +0000 | [diff] [blame] | 1870 | </address> |
Chris Lattner | bdfb339 | 2004-01-05 05:06:33 +0000 | [diff] [blame] | 1871 | |
| 1872 | </body> |
| 1873 | </html> |