diff options
| author | Devang Patel <dpatel@apple.com> | 2009-01-05 23:11:11 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-01-05 23:11:11 +0000 |
| commit | 245a73ac16371c003936aab1a58d6fa58e121910 (patch) | |
| tree | f5283f83a17b183b8c2d71be772f53077577d85e /llvm/lib | |
| parent | 610c87cad6ceddea181c3ab544a1b9c6f2c3029b (diff) | |
| download | bcm5719-llvm-245a73ac16371c003936aab1a58d6fa58e121910.tar.gz bcm5719-llvm-245a73ac16371c003936aab1a58d6fa58e121910.zip | |
Construct global variable DIEs using DebugInfo.
llvm-svn: 61771
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 401252460c4..026671436c0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -3116,7 +3116,7 @@ private: Asm->EOL(); } - /// ConstructCompileUnitDIEs - Create a compile unit DIEs. + /// ConstructCompileUnits - Create a compile unit DIEs. void ConstructCompileUnits() { std::string CUName = "llvm.dbg.compile_units"; std::vector<GlobalVariable*> Result; @@ -3155,6 +3155,53 @@ private: } } + /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally + /// visible global variables. + void ConstructGlobalVariableDIEs() { + std::string GVName = "llvm.dbg.global_variables"; + std::vector<GlobalVariable*> Result; + getGlobalVariablesUsing(*M, GVName, Result); + for (std::vector<GlobalVariable *>::iterator GVI = Result.begin(), + GVE = Result.end(); GVI != GVE; ++GVI) { + DIGlobalVariable *DI_GV = new DIGlobalVariable(*GVI); + CompileUnit *DW_Unit = FindCompileUnit(DI_GV->getCompileUnit()); + + // Check for pre-existence. + DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV->getGV()); + if (Slot) continue; + + DIE *VariableDie = new DIE(DW_TAG_variable); + AddString(VariableDie, DW_AT_name, DW_FORM_string, DI_GV->getName()); + const std::string &LinkageName = DI_GV->getLinkageName(); + if (!LinkageName.empty()) + AddString(VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string, + LinkageName); + AddType(DW_Unit, VariableDie, DI_GV->getType()); + + if (!DI_GV->isLocalToUnit()) + AddUInt(VariableDie, DW_AT_external, DW_FORM_flag, 1); + + // Add source line info, if available. + AddSourceLine(VariableDie, DI_GV); + + // Add address. + DIEBlock *Block = new DIEBlock(); + AddUInt(Block, 0, DW_FORM_data1, DW_OP_addr); + AddObjectLabel(Block, 0, DW_FORM_udata, + Asm->getGlobalLinkName(DI_GV->getGV())); + AddBlock(VariableDie, DW_AT_location, 0, Block); + + //Add to map. + Slot = VariableDie; + + //Add to context owner. + DW_Unit->getDie()->AddChild(VariableDie); + + //Expose as global. FIXME - need to check external flag. + DW_Unit->AddGlobal(DI_GV->getName(), VariableDie); + } + } + /// ConstructGlobalDIEs - Create DIEs for each of the externally visible /// global variables. void ConstructGlobalDIEs() { |

