Bill Wendling | 0310d76 | 2009-05-15 09:23:25 +0000 | [diff] [blame^] | 1 | //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===// |
| 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 contains support for writing dwarf debug info into asm files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef CODEGEN_ASMPRINTER_DWARFDEBUG_H__ |
| 15 | #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__ |
| 16 | |
| 17 | #include "DIE.h" |
| 18 | #include "DwarfPrinter.h" |
| 19 | #include "llvm/CodeGen/AsmPrinter.h" |
| 20 | #include "llvm/CodeGen/MachineLocation.h" |
| 21 | #include "llvm/Analysis/DebugInfo.h" |
| 22 | #include "llvm/Support/raw_ostream.h" |
| 23 | #include "llvm/ADT/DenseMap.h" |
| 24 | #include "llvm/ADT/FoldingSet.h" |
| 25 | #include "llvm/ADT/StringMap.h" |
| 26 | #include "llvm/ADT/UniqueVector.h" |
| 27 | #include <string> |
| 28 | |
| 29 | namespace llvm { |
| 30 | |
| 31 | class CompileUnit; |
| 32 | class DbgVariable; |
| 33 | class DbgScope; |
| 34 | class DbgConcreteScope; |
| 35 | class MachineFrameInfo; |
| 36 | class MachineModuleInfo; |
| 37 | class TargetAsmInfo; |
| 38 | class Timer; |
| 39 | |
| 40 | //===----------------------------------------------------------------------===// |
| 41 | /// SrcLineInfo - This class is used to record source line correspondence. |
| 42 | /// |
| 43 | class VISIBILITY_HIDDEN SrcLineInfo { |
| 44 | unsigned Line; // Source line number. |
| 45 | unsigned Column; // Source column. |
| 46 | unsigned SourceID; // Source ID number. |
| 47 | unsigned LabelID; // Label in code ID number. |
| 48 | public: |
| 49 | SrcLineInfo(unsigned L, unsigned C, unsigned S, unsigned I) |
| 50 | : Line(L), Column(C), SourceID(S), LabelID(I) {} |
| 51 | |
| 52 | // Accessors |
| 53 | unsigned getLine() const { return Line; } |
| 54 | unsigned getColumn() const { return Column; } |
| 55 | unsigned getSourceID() const { return SourceID; } |
| 56 | unsigned getLabelID() const { return LabelID; } |
| 57 | }; |
| 58 | |
| 59 | class VISIBILITY_HIDDEN DwarfDebug : public Dwarf { |
| 60 | //===--------------------------------------------------------------------===// |
| 61 | // Attributes used to construct specific Dwarf sections. |
| 62 | // |
| 63 | |
| 64 | /// CompileUnitMap - A map of global variables representing compile units to |
| 65 | /// compile units. |
| 66 | DenseMap<Value *, CompileUnit *> CompileUnitMap; |
| 67 | |
| 68 | /// CompileUnits - All the compile units in this module. |
| 69 | /// |
| 70 | SmallVector<CompileUnit *, 8> CompileUnits; |
| 71 | |
| 72 | /// MainCU - Some platform prefers one compile unit per .o file. In such |
| 73 | /// cases, all dies are inserted in MainCU. |
| 74 | CompileUnit *MainCU; |
| 75 | |
| 76 | /// AbbreviationsSet - Used to uniquely define abbreviations. |
| 77 | /// |
| 78 | FoldingSet<DIEAbbrev> AbbreviationsSet; |
| 79 | |
| 80 | /// Abbreviations - A list of all the unique abbreviations in use. |
| 81 | /// |
| 82 | std::vector<DIEAbbrev *> Abbreviations; |
| 83 | |
| 84 | /// DirectoryIdMap - Directory name to directory id map. |
| 85 | /// |
| 86 | StringMap<unsigned> DirectoryIdMap; |
| 87 | |
| 88 | /// DirectoryNames - A list of directory names. |
| 89 | SmallVector<std::string, 8> DirectoryNames; |
| 90 | |
| 91 | /// SourceFileIdMap - Source file name to source file id map. |
| 92 | /// |
| 93 | StringMap<unsigned> SourceFileIdMap; |
| 94 | |
| 95 | /// SourceFileNames - A list of source file names. |
| 96 | SmallVector<std::string, 8> SourceFileNames; |
| 97 | |
| 98 | /// SourceIdMap - Source id map, i.e. pair of directory id and source file |
| 99 | /// id mapped to a unique id. |
| 100 | DenseMap<std::pair<unsigned, unsigned>, unsigned> SourceIdMap; |
| 101 | |
| 102 | /// SourceIds - Reverse map from source id to directory id + file id pair. |
| 103 | /// |
| 104 | SmallVector<std::pair<unsigned, unsigned>, 8> SourceIds; |
| 105 | |
| 106 | /// Lines - List of of source line correspondence. |
| 107 | std::vector<SrcLineInfo> Lines; |
| 108 | |
| 109 | /// ValuesSet - Used to uniquely define values. |
| 110 | /// |
| 111 | FoldingSet<DIEValue> ValuesSet; |
| 112 | |
| 113 | /// Values - A list of all the unique values in use. |
| 114 | /// |
| 115 | std::vector<DIEValue *> Values; |
| 116 | |
| 117 | /// StringPool - A UniqueVector of strings used by indirect references. |
| 118 | /// |
| 119 | UniqueVector<std::string> StringPool; |
| 120 | |
| 121 | /// SectionMap - Provides a unique id per text section. |
| 122 | /// |
| 123 | UniqueVector<const Section*> SectionMap; |
| 124 | |
| 125 | /// SectionSourceLines - Tracks line numbers per text section. |
| 126 | /// |
| 127 | std::vector<std::vector<SrcLineInfo> > SectionSourceLines; |
| 128 | |
| 129 | /// didInitial - Flag to indicate if initial emission has been done. |
| 130 | /// |
| 131 | bool didInitial; |
| 132 | |
| 133 | /// shouldEmit - Flag to indicate if debug information should be emitted. |
| 134 | /// |
| 135 | bool shouldEmit; |
| 136 | |
| 137 | // FunctionDbgScope - Top level scope for the current function. |
| 138 | // |
| 139 | DbgScope *FunctionDbgScope; |
| 140 | |
| 141 | /// DbgScopeMap - Tracks the scopes in the current function. |
| 142 | DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap; |
| 143 | |
| 144 | /// DbgAbstractScopeMap - Tracks abstract instance scopes in the current |
| 145 | /// function. |
| 146 | DenseMap<GlobalVariable *, DbgScope *> DbgAbstractScopeMap; |
| 147 | |
| 148 | /// DbgConcreteScopeMap - Tracks concrete instance scopes in the current |
| 149 | /// function. |
| 150 | DenseMap<GlobalVariable *, |
| 151 | SmallVector<DbgScope *, 8> > DbgConcreteScopeMap; |
| 152 | |
| 153 | /// InlineInfo - Keep track of inlined functions and their location. This |
| 154 | /// information is used to populate debug_inlined section. |
| 155 | DenseMap<GlobalVariable *, SmallVector<unsigned, 4> > InlineInfo; |
| 156 | |
| 157 | /// InlinedVariableScopes - Scopes information for the inlined subroutine |
| 158 | /// variables. |
| 159 | DenseMap<const MachineInstr *, DbgScope *> InlinedVariableScopes; |
| 160 | |
| 161 | /// AbstractInstanceRootMap - Map of abstract instance roots of inlined |
| 162 | /// functions. These are subroutine entries that contain a DW_AT_inline |
| 163 | /// attribute. |
| 164 | DenseMap<const GlobalVariable *, DbgScope *> AbstractInstanceRootMap; |
| 165 | |
| 166 | /// AbstractInstanceRootList - List of abstract instance roots of inlined |
| 167 | /// functions. These are subroutine entries that contain a DW_AT_inline |
| 168 | /// attribute. |
| 169 | SmallVector<DbgScope *, 32> AbstractInstanceRootList; |
| 170 | |
| 171 | /// LexicalScopeStack - A stack of lexical scopes. The top one is the current |
| 172 | /// scope. |
| 173 | SmallVector<DbgScope *, 16> LexicalScopeStack; |
| 174 | |
| 175 | /// CompileUnitOffsets - A vector of the offsets of the compile units. This is |
| 176 | /// used when calculating the "origin" of a concrete instance of an inlined |
| 177 | /// function. |
| 178 | DenseMap<CompileUnit *, unsigned> CompileUnitOffsets; |
| 179 | |
| 180 | /// DebugTimer - Timer for the Dwarf debug writer. |
| 181 | Timer *DebugTimer; |
| 182 | |
| 183 | struct FunctionDebugFrameInfo { |
| 184 | unsigned Number; |
| 185 | std::vector<MachineMove> Moves; |
| 186 | |
| 187 | FunctionDebugFrameInfo(unsigned Num, const std::vector<MachineMove> &M) |
| 188 | : Number(Num), Moves(M) {} |
| 189 | }; |
| 190 | |
| 191 | std::vector<FunctionDebugFrameInfo> DebugFrames; |
| 192 | |
| 193 | /// getSourceDirectoryAndFileIds - Return the directory and file ids that |
| 194 | /// maps to the source id. Source id starts at 1. |
| 195 | std::pair<unsigned, unsigned> |
| 196 | getSourceDirectoryAndFileIds(unsigned SId) const { |
| 197 | return SourceIds[SId-1]; |
| 198 | } |
| 199 | |
| 200 | /// getNumSourceDirectories - Return the number of source directories in the |
| 201 | /// debug info. |
| 202 | unsigned getNumSourceDirectories() const { |
| 203 | return DirectoryNames.size(); |
| 204 | } |
| 205 | |
| 206 | /// getSourceDirectoryName - Return the name of the directory corresponding |
| 207 | /// to the id. |
| 208 | const std::string &getSourceDirectoryName(unsigned Id) const { |
| 209 | return DirectoryNames[Id - 1]; |
| 210 | } |
| 211 | |
| 212 | /// getSourceFileName - Return the name of the source file corresponding |
| 213 | /// to the id. |
| 214 | const std::string &getSourceFileName(unsigned Id) const { |
| 215 | return SourceFileNames[Id - 1]; |
| 216 | } |
| 217 | |
| 218 | /// getNumSourceIds - Return the number of unique source ids. |
| 219 | unsigned getNumSourceIds() const { |
| 220 | return SourceIds.size(); |
| 221 | } |
| 222 | |
| 223 | /// AssignAbbrevNumber - Define a unique number for the abbreviation. |
| 224 | /// |
| 225 | void AssignAbbrevNumber(DIEAbbrev &Abbrev); |
| 226 | |
| 227 | /// NewString - Add a string to the constant pool and returns a label. |
| 228 | /// |
| 229 | DWLabel NewString(const std::string &String) { |
| 230 | unsigned StringID = StringPool.insert(String); |
| 231 | return DWLabel("string", StringID); |
| 232 | } |
| 233 | |
| 234 | /// NewDIEEntry - Creates a new DIEEntry to be a proxy for a debug information |
| 235 | /// entry. |
| 236 | DIEEntry *NewDIEEntry(DIE *Entry = NULL); |
| 237 | |
| 238 | /// SetDIEEntry - Set a DIEEntry once the debug information entry is defined. |
| 239 | /// |
| 240 | void SetDIEEntry(DIEEntry *Value, DIE *Entry); |
| 241 | |
| 242 | /// AddUInt - Add an unsigned integer attribute data and value. |
| 243 | /// |
| 244 | void AddUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer); |
| 245 | |
| 246 | /// AddSInt - Add an signed integer attribute data and value. |
| 247 | /// |
| 248 | void AddSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer); |
| 249 | |
| 250 | /// AddString - Add a string attribute data and value. |
| 251 | /// |
| 252 | void AddString(DIE *Die, unsigned Attribute, unsigned Form, |
| 253 | const std::string &String); |
| 254 | |
| 255 | /// AddLabel - Add a Dwarf label attribute data and value. |
| 256 | /// |
| 257 | void AddLabel(DIE *Die, unsigned Attribute, unsigned Form, |
| 258 | const DWLabel &Label); |
| 259 | |
| 260 | /// AddObjectLabel - Add an non-Dwarf label attribute data and value. |
| 261 | /// |
| 262 | void AddObjectLabel(DIE *Die, unsigned Attribute, unsigned Form, |
| 263 | const std::string &Label); |
| 264 | |
| 265 | /// AddSectionOffset - Add a section offset label attribute data and value. |
| 266 | /// |
| 267 | void AddSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, |
| 268 | const DWLabel &Label, const DWLabel &Section, |
| 269 | bool isEH = false, bool useSet = true); |
| 270 | |
| 271 | /// AddDelta - Add a label delta attribute data and value. |
| 272 | /// |
| 273 | void AddDelta(DIE *Die, unsigned Attribute, unsigned Form, |
| 274 | const DWLabel &Hi, const DWLabel &Lo); |
| 275 | |
| 276 | /// AddDIEEntry - Add a DIE attribute data and value. |
| 277 | /// |
| 278 | void AddDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry) { |
| 279 | Die->AddValue(Attribute, Form, NewDIEEntry(Entry)); |
| 280 | } |
| 281 | |
| 282 | /// AddBlock - Add block data. |
| 283 | /// |
| 284 | void AddBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block); |
| 285 | |
| 286 | /// AddSourceLine - Add location information to specified debug information |
| 287 | /// entry. |
| 288 | void AddSourceLine(DIE *Die, const DIVariable *V); |
| 289 | |
| 290 | /// AddSourceLine - Add location information to specified debug information |
| 291 | /// entry. |
| 292 | void AddSourceLine(DIE *Die, const DIGlobal *G); |
| 293 | |
| 294 | void AddSourceLine(DIE *Die, const DIType *Ty); |
| 295 | |
| 296 | /// AddAddress - Add an address attribute to a die based on the location |
| 297 | /// provided. |
| 298 | void AddAddress(DIE *Die, unsigned Attribute, |
| 299 | const MachineLocation &Location); |
| 300 | |
| 301 | /// AddType - Add a new type attribute to the specified entity. |
| 302 | void AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty); |
| 303 | |
| 304 | /// ConstructTypeDIE - Construct basic type die from DIBasicType. |
| 305 | void ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, |
| 306 | DIBasicType BTy); |
| 307 | |
| 308 | /// ConstructTypeDIE - Construct derived type die from DIDerivedType. |
| 309 | void ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, |
| 310 | DIDerivedType DTy); |
| 311 | |
| 312 | /// ConstructTypeDIE - Construct type DIE from DICompositeType. |
| 313 | void ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, |
| 314 | DICompositeType CTy); |
| 315 | |
| 316 | /// ConstructSubrangeDIE - Construct subrange DIE from DISubrange. |
| 317 | void ConstructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy); |
| 318 | |
| 319 | /// ConstructArrayTypeDIE - Construct array type DIE from DICompositeType. |
| 320 | void ConstructArrayTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, |
| 321 | DICompositeType *CTy); |
| 322 | |
| 323 | /// ConstructEnumTypeDIE - Construct enum type DIE from DIEnumerator. |
| 324 | DIE *ConstructEnumTypeDIE(CompileUnit *DW_Unit, DIEnumerator *ETy); |
| 325 | |
| 326 | /// CreateGlobalVariableDIE - Create new DIE using GV. |
| 327 | DIE *CreateGlobalVariableDIE(CompileUnit *DW_Unit, |
| 328 | const DIGlobalVariable &GV); |
| 329 | |
| 330 | /// CreateMemberDIE - Create new member DIE. |
| 331 | DIE *CreateMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT); |
| 332 | |
| 333 | /// CreateSubprogramDIE - Create new DIE using SP. |
| 334 | DIE *CreateSubprogramDIE(CompileUnit *DW_Unit, |
| 335 | const DISubprogram &SP, |
| 336 | bool IsConstructor = false); |
| 337 | |
| 338 | /// FindCompileUnit - Get the compile unit for the given descriptor. |
| 339 | /// |
| 340 | CompileUnit &FindCompileUnit(DICompileUnit Unit) const; |
| 341 | |
| 342 | /// NewDbgScopeVariable - Create a new scope variable. |
| 343 | /// |
| 344 | DIE *NewDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit); |
| 345 | |
| 346 | /// getOrCreateScope - Returns the scope associated with the given descriptor. |
| 347 | /// |
| 348 | DbgScope *getOrCreateScope(GlobalVariable *V); |
| 349 | |
| 350 | /// ConstructDbgScope - Construct the components of a scope. |
| 351 | /// |
| 352 | void ConstructDbgScope(DbgScope *ParentScope, |
| 353 | unsigned ParentStartID, unsigned ParentEndID, |
| 354 | DIE *ParentDie, CompileUnit *Unit); |
| 355 | |
| 356 | /// ConstructFunctionDbgScope - Construct the scope for the subprogram. |
| 357 | /// |
| 358 | void ConstructFunctionDbgScope(DbgScope *RootScope); |
| 359 | |
| 360 | /// ConstructFunctionDbgScope - Construct the scope for the abstract debug |
| 361 | /// scope. |
| 362 | /// |
| 363 | void ConstructAbstractDbgScope(DbgScope *AbsScope); |
| 364 | |
| 365 | /// ConstructDefaultDbgScope - Construct a default scope for the subprogram. |
| 366 | /// |
| 367 | void ConstructDefaultDbgScope(MachineFunction *MF); |
| 368 | |
| 369 | /// EmitInitial - Emit initial Dwarf declarations. This is necessary for cc |
| 370 | /// tools to recognize the object file contains Dwarf information. |
| 371 | void EmitInitial(); |
| 372 | |
| 373 | /// EmitDIE - Recusively Emits a debug information entry. |
| 374 | /// |
| 375 | void EmitDIE(DIE *Die); |
| 376 | |
| 377 | /// SizeAndOffsetDie - Compute the size and offset of a DIE. |
| 378 | /// |
| 379 | unsigned SizeAndOffsetDie(DIE *Die, unsigned Offset, bool Last); |
| 380 | |
| 381 | /// SizeAndOffsets - Compute the size and offset of all the DIEs. |
| 382 | /// |
| 383 | void SizeAndOffsets(); |
| 384 | |
| 385 | /// EmitDebugInfo / EmitDebugInfoPerCU - Emit the debug info section. |
| 386 | /// |
| 387 | void EmitDebugInfoPerCU(CompileUnit *Unit); |
| 388 | |
| 389 | void EmitDebugInfo(); |
| 390 | |
| 391 | /// EmitAbbreviations - Emit the abbreviation section. |
| 392 | /// |
| 393 | void EmitAbbreviations() const; |
| 394 | |
| 395 | /// EmitEndOfLineMatrix - Emit the last address of the section and the end of |
| 396 | /// the line matrix. |
| 397 | /// |
| 398 | void EmitEndOfLineMatrix(unsigned SectionEnd); |
| 399 | |
| 400 | /// EmitDebugLines - Emit source line information. |
| 401 | /// |
| 402 | void EmitDebugLines(); |
| 403 | |
| 404 | /// EmitCommonDebugFrame - Emit common frame info into a debug frame section. |
| 405 | /// |
| 406 | void EmitCommonDebugFrame(); |
| 407 | |
| 408 | /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame |
| 409 | /// section. |
| 410 | void EmitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo); |
| 411 | |
| 412 | void EmitDebugPubNamesPerCU(CompileUnit *Unit); |
| 413 | |
| 414 | /// EmitDebugPubNames - Emit visible names into a debug pubnames section. |
| 415 | /// |
| 416 | void EmitDebugPubNames(); |
| 417 | |
| 418 | /// EmitDebugStr - Emit visible names into a debug str section. |
| 419 | /// |
| 420 | void EmitDebugStr(); |
| 421 | |
| 422 | /// EmitDebugLoc - Emit visible names into a debug loc section. |
| 423 | /// |
| 424 | void EmitDebugLoc(); |
| 425 | |
| 426 | /// EmitDebugARanges - Emit visible names into a debug aranges section. |
| 427 | /// |
| 428 | void EmitDebugARanges(); |
| 429 | |
| 430 | /// EmitDebugRanges - Emit visible names into a debug ranges section. |
| 431 | /// |
| 432 | void EmitDebugRanges(); |
| 433 | |
| 434 | /// EmitDebugMacInfo - Emit visible names into a debug macinfo section. |
| 435 | /// |
| 436 | void EmitDebugMacInfo(); |
| 437 | |
| 438 | /// EmitDebugInlineInfo - Emit inline info using following format. |
| 439 | /// Section Header: |
| 440 | /// 1. length of section |
| 441 | /// 2. Dwarf version number |
| 442 | /// 3. address size. |
| 443 | /// |
| 444 | /// Entries (one "entry" for each function that was inlined): |
| 445 | /// |
| 446 | /// 1. offset into __debug_str section for MIPS linkage name, if exists; |
| 447 | /// otherwise offset into __debug_str for regular function name. |
| 448 | /// 2. offset into __debug_str section for regular function name. |
| 449 | /// 3. an unsigned LEB128 number indicating the number of distinct inlining |
| 450 | /// instances for the function. |
| 451 | /// |
| 452 | /// The rest of the entry consists of a {die_offset, low_pc} pair for each |
| 453 | /// inlined instance; the die_offset points to the inlined_subroutine die in |
| 454 | /// the __debug_info section, and the low_pc is the starting address for the |
| 455 | /// inlining instance. |
| 456 | void EmitDebugInlineInfo(); |
| 457 | |
| 458 | /// GetOrCreateSourceID - Look up the source id with the given directory and |
| 459 | /// source file names. If none currently exists, create a new id and insert it |
| 460 | /// in the SourceIds map. This can update DirectoryNames and SourceFileNames maps |
| 461 | /// as well. |
| 462 | unsigned GetOrCreateSourceID(const std::string &DirName, |
| 463 | const std::string &FileName); |
| 464 | |
| 465 | void ConstructCompileUnit(GlobalVariable *GV); |
| 466 | |
| 467 | /// ConstructCompileUnits - Create a compile unit DIEs. |
| 468 | void ConstructCompileUnits(); |
| 469 | |
| 470 | bool ConstructGlobalVariableDIE(GlobalVariable *GV); |
| 471 | |
| 472 | /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally |
| 473 | /// visible global variables. Return true if at least one global DIE is |
| 474 | /// created. |
| 475 | bool ConstructGlobalVariableDIEs(); |
| 476 | |
| 477 | bool ConstructSubprogram(GlobalVariable *GV); |
| 478 | |
| 479 | /// ConstructSubprograms - Create DIEs for each of the externally visible |
| 480 | /// subprograms. Return true if at least one subprogram DIE is created. |
| 481 | bool ConstructSubprograms(); |
| 482 | public: |
| 483 | //===--------------------------------------------------------------------===// |
| 484 | // Main entry points. |
| 485 | // |
| 486 | DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T); |
| 487 | virtual ~DwarfDebug(); |
| 488 | |
| 489 | /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should |
| 490 | /// be emitted. |
| 491 | bool ShouldEmitDwarfDebug() const { return shouldEmit; } |
| 492 | |
| 493 | /// SetDebugInfo - Create global DIEs and emit initial debug info sections. |
| 494 | /// This is inovked by the target AsmPrinter. |
| 495 | void SetDebugInfo(MachineModuleInfo *mmi); |
| 496 | |
| 497 | /// BeginModule - Emit all Dwarf sections that should come prior to the |
| 498 | /// content. |
| 499 | void BeginModule(Module *M) { |
| 500 | this->M = M; |
| 501 | } |
| 502 | |
| 503 | /// EndModule - Emit all Dwarf sections that should come after the content. |
| 504 | /// |
| 505 | void EndModule(); |
| 506 | |
| 507 | /// BeginFunction - Gather pre-function debug information. Assumes being |
| 508 | /// emitted immediately after the function entry point. |
| 509 | void BeginFunction(MachineFunction *MF); |
| 510 | |
| 511 | /// EndFunction - Gather and emit post-function debug information. |
| 512 | /// |
| 513 | void EndFunction(MachineFunction *MF); |
| 514 | |
| 515 | /// RecordSourceLine - Records location information and associates it with a |
| 516 | /// label. Returns a unique label ID used to generate a label and provide |
| 517 | /// correspondence to the source line list. |
| 518 | unsigned RecordSourceLine(Value *V, unsigned Line, unsigned Col); |
| 519 | |
| 520 | /// RecordSourceLine - Records location information and associates it with a |
| 521 | /// label. Returns a unique label ID used to generate a label and provide |
| 522 | /// correspondence to the source line list. |
| 523 | unsigned RecordSourceLine(unsigned Line, unsigned Col, DICompileUnit CU); |
| 524 | |
| 525 | /// getRecordSourceLineCount - Return the number of source lines in the debug |
| 526 | /// info. |
| 527 | unsigned getRecordSourceLineCount() const { |
| 528 | return Lines.size(); |
| 529 | } |
| 530 | |
| 531 | /// getOrCreateSourceID - Public version of GetOrCreateSourceID. This can be |
| 532 | /// timed. Look up the source id with the given directory and source file |
| 533 | /// names. If none currently exists, create a new id and insert it in the |
| 534 | /// SourceIds map. This can update DirectoryNames and SourceFileNames maps as |
| 535 | /// well. |
| 536 | unsigned getOrCreateSourceID(const std::string &DirName, |
| 537 | const std::string &FileName); |
| 538 | |
| 539 | /// RecordRegionStart - Indicate the start of a region. |
| 540 | unsigned RecordRegionStart(GlobalVariable *V); |
| 541 | |
| 542 | /// RecordRegionEnd - Indicate the end of a region. |
| 543 | unsigned RecordRegionEnd(GlobalVariable *V); |
| 544 | |
| 545 | /// RecordVariable - Indicate the declaration of a local variable. |
| 546 | void RecordVariable(GlobalVariable *GV, unsigned FrameIndex, |
| 547 | const MachineInstr *MI); |
| 548 | |
| 549 | //// RecordInlinedFnStart - Indicate the start of inlined subroutine. |
| 550 | unsigned RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU, |
| 551 | unsigned Line, unsigned Col); |
| 552 | |
| 553 | /// RecordInlinedFnEnd - Indicate the end of inlined subroutine. |
| 554 | unsigned RecordInlinedFnEnd(DISubprogram &SP); |
| 555 | |
| 556 | /// RecordVariableScope - Record scope for the variable declared by |
| 557 | /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes |
| 558 | /// for only inlined subroutine variables. Other variables's scopes are |
| 559 | /// determined during RecordVariable(). |
| 560 | void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI); |
| 561 | }; |
| 562 | |
| 563 | } // End of namespace llvm |
| 564 | |
| 565 | #endif |