whitequark | 789164d | 2017-11-01 22:18:52 +0000 | [diff] [blame] | 1 | //===------------ DebugInfo.h - LLVM C API Debug Info API -----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// This file declares the C API endpoints for generating DWARF Debug Info |
| 11 | /// |
| 12 | /// Note: This interface is experimental. It is *NOT* stable, and may be |
| 13 | /// changed without warning. |
| 14 | /// |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Adrian Prantl | f2593d0 | 2017-11-02 20:58:58 +0000 | [diff] [blame^] | 17 | #ifndef LLVM_C_DEBUGINFO_H |
| 18 | #define LLVM_C_DEBUGINFO_H |
| 19 | |
whitequark | 789164d | 2017-11-01 22:18:52 +0000 | [diff] [blame] | 20 | #include "llvm-c/Core.h" |
| 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | /// Debug info flags. |
| 27 | typedef enum { |
| 28 | LLVMDIFlagZero = 0, |
| 29 | LLVMDIFlagPrivate = 1, |
| 30 | LLVMDIFlagProtected = 2, |
| 31 | LLVMDIFlagPublic = 3, |
| 32 | LLVMDIFlagFwdDecl = 1 << 2, |
| 33 | LLVMDIFlagAppleBlock = 1 << 3, |
| 34 | LLVMDIFlagBlockByrefStruct = 1 << 4, |
| 35 | LLVMDIFlagVirtual = 1 << 5, |
| 36 | LLVMDIFlagArtificial = 1 << 6, |
| 37 | LLVMDIFlagExplicit = 1 << 7, |
| 38 | LLVMDIFlagPrototyped = 1 << 8, |
| 39 | LLVMDIFlagObjcClassComplete = 1 << 9, |
| 40 | LLVMDIFlagObjectPointer = 1 << 10, |
| 41 | LLVMDIFlagVector = 1 << 11, |
| 42 | LLVMDIFlagStaticMember = 1 << 12, |
| 43 | LLVMDIFlagLValueReference = 1 << 13, |
| 44 | LLVMDIFlagRValueReference = 1 << 14, |
| 45 | LLVMDIFlagReserved = 1 << 15, |
| 46 | LLVMDIFlagSingleInheritance = 1 << 16, |
| 47 | LLVMDIFlagMultipleInheritance = 2 << 16, |
| 48 | LLVMDIFlagVirtualInheritance = 3 << 16, |
| 49 | LLVMDIFlagIntroducedVirtual = 1 << 18, |
| 50 | LLVMDIFlagBitField = 1 << 19, |
| 51 | LLVMDIFlagNoReturn = 1 << 20, |
| 52 | LLVMDIFlagMainSubprogram = 1 << 21, |
| 53 | LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5), |
| 54 | LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected | |
| 55 | LLVMDIFlagPublic, |
| 56 | LLVMDIFlagPtrToMemberRep = LLVMDIFlagSingleInheritance | |
| 57 | LLVMDIFlagMultipleInheritance | |
| 58 | LLVMDIFlagVirtualInheritance |
| 59 | } LLVMDIFlags; |
| 60 | |
| 61 | /// Source languages known by DWARF. |
| 62 | typedef enum { |
| 63 | LLVMDWARFSourceLanguageC89, |
| 64 | LLVMDWARFSourceLanguageC, |
| 65 | LLVMDWARFSourceLanguageAda83, |
| 66 | LLVMDWARFSourceLanguageC_plus_plus, |
| 67 | LLVMDWARFSourceLanguageCobol74, |
| 68 | LLVMDWARFSourceLanguageCobol85, |
| 69 | LLVMDWARFSourceLanguageFortran77, |
| 70 | LLVMDWARFSourceLanguageFortran90, |
| 71 | LLVMDWARFSourceLanguagePascal83, |
| 72 | LLVMDWARFSourceLanguageModula2, |
| 73 | // New in DWARF v3: |
| 74 | LLVMDWARFSourceLanguageJava, |
| 75 | LLVMDWARFSourceLanguageC99, |
| 76 | LLVMDWARFSourceLanguageAda95, |
| 77 | LLVMDWARFSourceLanguageFortran95, |
| 78 | LLVMDWARFSourceLanguagePLI, |
| 79 | LLVMDWARFSourceLanguageObjC, |
| 80 | LLVMDWARFSourceLanguageObjC_plus_plus, |
| 81 | LLVMDWARFSourceLanguageUPC, |
| 82 | LLVMDWARFSourceLanguageD, |
| 83 | // New in DWARF v4: |
| 84 | LLVMDWARFSourceLanguagePython, |
| 85 | // New in DWARF v5: |
| 86 | LLVMDWARFSourceLanguageOpenCL, |
| 87 | LLVMDWARFSourceLanguageGo, |
| 88 | LLVMDWARFSourceLanguageModula3, |
| 89 | LLVMDWARFSourceLanguageHaskell, |
| 90 | LLVMDWARFSourceLanguageC_plus_plus_03, |
| 91 | LLVMDWARFSourceLanguageC_plus_plus_11, |
| 92 | LLVMDWARFSourceLanguageOCaml, |
| 93 | LLVMDWARFSourceLanguageRust, |
| 94 | LLVMDWARFSourceLanguageC11, |
| 95 | LLVMDWARFSourceLanguageSwift, |
| 96 | LLVMDWARFSourceLanguageJulia, |
| 97 | LLVMDWARFSourceLanguageDylan, |
| 98 | LLVMDWARFSourceLanguageC_plus_plus_14, |
| 99 | LLVMDWARFSourceLanguageFortran03, |
| 100 | LLVMDWARFSourceLanguageFortran08, |
| 101 | LLVMDWARFSourceLanguageRenderScript, |
| 102 | LLVMDWARFSourceLanguageBLISS, |
| 103 | // Vendor extensions: |
| 104 | LLVMDWARFSourceLanguageMips_Assembler, |
| 105 | LLVMDWARFSourceLanguageGOOGLE_RenderScript, |
| 106 | LLVMDWARFSourceLanguageBORLAND_Delphi |
| 107 | } LLVMDWARFSourceLanguage; |
| 108 | |
| 109 | /// The amount of debug information to emit. |
| 110 | typedef enum { |
| 111 | LLVMDWARFEmissionNone = 0, |
| 112 | LLVMDWARFEmissionFull, |
| 113 | LLVMDWARFEmissionLineTablesOnly |
| 114 | } LLVMDWARFEmissionKind; |
| 115 | |
| 116 | /// The current debug metadata version number. |
| 117 | unsigned LLVMDebugMetadataVersion(void); |
| 118 | |
| 119 | /// The version of debug metadata that's present in the provided \c Module. |
| 120 | unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module); |
| 121 | |
| 122 | /// Strip debug info in the module if it exists. |
| 123 | /// |
| 124 | /// To do this, we remove all calls to the debugger intrinsics and any named |
| 125 | /// metadata for debugging. We also remove debug locations for instructions. |
| 126 | /// Return true if module is modified. |
| 127 | LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module); |
| 128 | |
| 129 | /// Construct a builder for a module, and do not allow for unresolved nodes |
| 130 | /// attached to the module. |
| 131 | LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M); |
| 132 | |
| 133 | /// Construct a builder for a module and collect unresolved nodes attached |
| 134 | /// to the module in order to resolve cycles during a call to |
| 135 | /// \c LLVMDIBuilderFinalize. |
| 136 | LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M); |
| 137 | |
| 138 | /// Deallocates the DIBuilder and everything it owns. |
| 139 | /// @note You must call \c LLVMDIBuilderFinalize before this |
| 140 | void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder); |
| 141 | |
| 142 | /// Construct any deferred debug info descriptors. |
| 143 | void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder); |
| 144 | |
| 145 | /// A CompileUnit provides an anchor for all debugging |
| 146 | /// information generated during this instance of compilation. |
| 147 | /// \param Lang Source programming language, eg. |
| 148 | /// \c LLVMDWARFSourceLanguageC99 |
NAKAMURA Takumi | 965602a | 2017-11-02 08:03:12 +0000 | [diff] [blame] | 149 | /// \param FileRef File info. |
whitequark | 789164d | 2017-11-01 22:18:52 +0000 | [diff] [blame] | 150 | /// \param Producer Identify the producer of debugging information |
| 151 | /// and code. Usually this is a compiler |
| 152 | /// version string. |
| 153 | /// \param ProducerLen The length of the C string passed to \c Producer. |
| 154 | /// \param isOptimized A boolean flag which indicates whether optimization |
| 155 | /// is enabled or not. |
| 156 | /// \param Flags This string lists command line options. This |
| 157 | /// string is directly embedded in debug info |
| 158 | /// output which may be used by a tool |
| 159 | /// analyzing generated debugging information. |
| 160 | /// \param FlagsLen The length of the C string passed to \c Flags. |
| 161 | /// \param RuntimeVer This indicates runtime version for languages like |
| 162 | /// Objective-C. |
| 163 | /// \param SplitName The name of the file that we'll split debug info |
| 164 | /// out into. |
| 165 | /// \param SplitNameLen The length of the C string passed to \c SplitName. |
| 166 | /// \param Kind The kind of debug information to generate. |
| 167 | /// \param DWOId The DWOId if this is a split skeleton compile unit. |
| 168 | /// \param SplitDebugInlining Whether to emit inline debug info. |
| 169 | /// \param DebugInfoForProfiling Whether to emit extra debug info for |
| 170 | /// profile collection. |
| 171 | LLVMMetadataRef LLVMDIBuilderCreateCompileUnit( |
| 172 | LLVMDIBuilderRef Builder, LLVMDWARFSourceLanguage Lang, |
| 173 | LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen, |
| 174 | LLVMBool isOptimized, const char *Flags, size_t FlagsLen, |
| 175 | unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen, |
| 176 | LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining, |
| 177 | LLVMBool DebugInfoForProfiling); |
| 178 | |
| 179 | /// Create a file descriptor to hold debugging information for a file. |
| 180 | /// \param Builder The DIBuilder. |
| 181 | /// \param Filename File name. |
| 182 | /// \param FilenameLen The length of the C string passed to \c Filename. |
| 183 | /// \param Directory Directory. |
| 184 | /// \param DirectoryLen The length of the C string passed to \c Directory. |
| 185 | LLVMMetadataRef |
| 186 | LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, |
| 187 | size_t FilenameLen, const char *Directory, |
| 188 | size_t DirectoryLen); |
| 189 | |
| 190 | /// Creates a new DebugLocation that describes a source location. |
| 191 | /// \param Line The line in the source file. |
| 192 | /// \param Column The column in the source file. |
| 193 | /// \param Scope The scope in which the location resides. |
| 194 | /// \param InlinedAt The scope where this location was inlined, if at all. |
| 195 | /// (optional). |
| 196 | /// \note If the item to which this location is attached cannot be |
| 197 | /// attributed to a source line, pass 0 for the line and column. |
| 198 | LLVMMetadataRef |
| 199 | LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line, |
| 200 | unsigned Column, LLVMMetadataRef Scope, |
| 201 | LLVMMetadataRef InlinedAt); |
| 202 | |
| 203 | #ifdef __cplusplus |
| 204 | } // end extern "C" |
| 205 | #endif |
Adrian Prantl | f2593d0 | 2017-11-02 20:58:58 +0000 | [diff] [blame^] | 206 | |
| 207 | #endif |