diff options
author | Devang Patel <dpatel@apple.com> | 2010-04-16 23:33:45 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-04-16 23:33:45 +0000 |
commit | f2548caaa8b290aa598bf49c27dff72f7751ba5c (patch) | |
tree | 7c78f9dc2f734a62f7264ce6b77901ad09742630 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | cf7fbd41be73c2738ee07fded656d23f798976df (diff) |
Add support to emit dwarf ranges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101575 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index ff69f54942..07d60732d9 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -302,7 +302,7 @@ DbgScope::~DbgScope() { DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) : Asm(A), MMI(Asm->MMI), ModuleCU(0), AbbreviationsSet(InitAbbreviationsSetSize), - CurrentFnDbgScope(0) { + CurrentFnDbgScope(0), PrevLabel(NULL) { NextStringPoolNumber = 0; DwarfFrameSectionSym = DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0; @@ -2354,6 +2354,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { InsnBeforeLabelMap.clear(); InsnAfterLabelMap.clear(); Lines.clear(); + PrevLabel = NULL; } /// recordSourceLine - Register a source line with debug info. Returns the @@ -2490,7 +2491,8 @@ void DwarfDebug::EmitSectionLabels() { EmitSectionSym(Asm, TLOF.getDwarfPubTypesSection()); DwarfStrSectionSym = EmitSectionSym(Asm, TLOF.getDwarfStrSection(), "section_str"); - EmitSectionSym(Asm, TLOF.getDwarfRangesSection()); + DwarfDebugRangeSectionSym = EmitSectionSym(Asm, TLOF.getDwarfRangesSection(), + "debug_range"); TextSectionSym = EmitSectionSym(Asm, TLOF.getTextSection(), "text_begin"); EmitSectionSym(Asm, TLOF.getDataSection()); @@ -2534,6 +2536,15 @@ void DwarfDebug::emitDIE(DIE *Die) { Asm->EmitInt32(Addr); break; } + case dwarf::DW_AT_ranges: { + // DW_AT_range Value encodes offset in debug_range section. + DIEInteger *V = cast<DIEInteger>(Values[i]); + Asm->EmitLabelOffsetDifference(DwarfDebugRangeSectionSym, + V->getValue(), + DwarfDebugRangeSectionSym, + 4); + break; + } default: // Emit an attribute using the defined form. Values[i]->EmitValue(Asm, Form); @@ -3055,7 +3066,16 @@ void DwarfDebug::EmitDebugARanges() { void DwarfDebug::emitDebugRanges() { // Start the dwarf ranges section. Asm->OutStreamer.SwitchSection( - Asm->getObjFileLowering().getDwarfRangesSection()); + Asm->getObjFileLowering().getDwarfRangesSection()); + for (SmallVector<const MCSymbol *, 8>::const_iterator I = DebugRangeSymbols.begin(), + E = DebugRangeSymbols.end(); I != E; ++I) { + if (*I) + Asm->EmitLabelDifference(*I, TextSectionSym, + Asm->getTargetData().getPointerSize()); + else + Asm->OutStreamer.EmitIntValue(0, Asm->getTargetData().getPointerSize(), + /*addrspace*/0); + } } /// emitDebugMacInfo - Emit visible names into a debug macinfo section. |