X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAsmPrinter%2FDwarfDebug.cpp;h=90f370ccf7161be63cfdf2899d4cf57d0f138387;hb=a3507d4883b8ec5fd068b28dda7e928f450ba883;hp=6613aac87d567e7af63746b22bfbed6dbc562b6f;hpb=2d5d104c5b945a214c117328fd9982360782cef0;p=oota-llvm.git diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 6613aac87d5..90f370ccf71 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -240,6 +240,12 @@ static MCSymbol *emitSectionSym(AsmPrinter *Asm, const MCSection *Section, return TmpSym; } +DwarfUnits::~DwarfUnits() { + for (SmallVectorImpl::iterator I = CUs.begin(), E = CUs.end(); + I != E; ++I) + delete *I; +} + MCSymbol *DwarfUnits::getStringPoolSym() { return Asm->GetTempSymbol(StringPref); } @@ -475,11 +481,11 @@ DIE *DwarfDebug::constructLexicalScopeDIE(CompileUnit *TheCU, // If we have multiple ranges, emit them into the range section. if (Ranges.size() > 1) { // .debug_range section has not been laid out yet. Emit offset in - // .debug_range as a uint, size 4, for now. emitDIE will handle - // DW_AT_ranges appropriately. - TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, - DebugRangeSymbols.size() * - Asm->getDataLayout().getPointerSize()); + // .debug_range as a relocatable label. emitDIE will handle + // emitting it appropriately. + unsigned Offset = DebugRangeSymbols.size(); + TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, + Asm->GetTempSymbol("debug_ranges", Offset)); for (SmallVectorImpl::const_iterator RI = Ranges.begin(), RE = Ranges.end(); RI != RE; ++RI) { @@ -531,11 +537,11 @@ DIE *DwarfDebug::constructInlinedScopeDIE(CompileUnit *TheCU, if (Ranges.size() > 1) { // .debug_range section has not been laid out yet. Emit offset in - // .debug_range as a uint, size 4, for now. emitDIE will handle - // DW_AT_ranges appropriately. - TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, - DebugRangeSymbols.size() * - Asm->getDataLayout().getPointerSize()); + // .debug_range as a relocatable label. emitDIE will handle + // emitting it appropriately. + unsigned Offset = DebugRangeSymbols.size(); + TheCU->addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, + Asm->GetTempSymbol("debug_ranges", Offset)); for (SmallVectorImpl::const_iterator RI = Ranges.begin(), RE = Ranges.end(); RI != RE; ++RI) { @@ -1201,15 +1207,6 @@ void DwarfDebug::endModule() { // clean up. SPMap.clear(); - for (DenseMap::iterator I = CUMap.begin(), - E = CUMap.end(); - I != E; ++I) - delete I->second; - - for (SmallVectorImpl::iterator I = SkeletonCUs.begin(), - E = SkeletonCUs.end(); - I != E; ++I) - delete *I; // Reset these for the next Module if we have one. FirstCU = NULL; @@ -2083,14 +2080,12 @@ void DwarfDebug::emitDIE(DIE *Die, ArrayRef Abbrevs) { } case dwarf::DW_AT_ranges: { // DW_AT_range Value encodes offset in debug_range section. - DIEInteger *V = cast(Values[i]); + DIELabel *V = cast(Values[i]); - if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) { - Asm->EmitLabelPlusOffset(DwarfDebugRangeSectionSym, V->getValue(), 4); - } else { - Asm->EmitLabelOffsetDifference(DwarfDebugRangeSectionSym, V->getValue(), - DwarfDebugRangeSectionSym, 4); - } + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) + Asm->EmitSectionOffset(V->getValue(), DwarfDebugRangeSectionSym); + else + Asm->EmitLabelDifference(V->getValue(), DwarfDebugRangeSectionSym, 4); break; } case dwarf::DW_AT_location: { @@ -2928,12 +2923,15 @@ void DwarfDebug::emitDebugRanges() { Asm->OutStreamer.SwitchSection( Asm->getObjFileLowering().getDwarfRangesSection()); unsigned char Size = Asm->getDataLayout().getPointerSize(); - for (SmallVectorImpl::iterator - I = DebugRangeSymbols.begin(), - E = DebugRangeSymbols.end(); - I != E; ++I) { - if (*I) - Asm->OutStreamer.EmitSymbolValue(const_cast(*I), Size); + for (uint32_t i = 0, e = DebugRangeSymbols.size(); i < e; ++i) { + // Only emit a symbol for every range pair for now. + // FIXME: Make this per range list. + if ((i % 2) == 0) + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_ranges", i)); + + const MCSymbol *I = DebugRangeSymbols[i]; + if (I) + Asm->OutStreamer.EmitSymbolValue(I, Size); else Asm->OutStreamer.EmitIntValue(0, Size); } @@ -3020,7 +3018,6 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const CompileUnit *CU) { } SkeletonHolder.addUnit(NewCU); - SkeletonCUs.push_back(NewCU); return NewCU; }