: dwarf::OperationEncodingString(Op));
}
-void DebugLocDwarfExpression::EmitSigned(int Value) {
+void DebugLocDwarfExpression::EmitSigned(int64_t Value) {
BS.EmitSLEB128(Value, Twine(Value));
}
-void DebugLocDwarfExpression::EmitUnsigned(unsigned Value) {
+void DebugLocDwarfExpression::EmitUnsigned(uint64_t Value) {
BS.EmitULEB128(Value, Twine(Value));
}
DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags, dwarf::DW_FORM_data1)};
DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
- : Asm(A), MMI(Asm->MMI), PrevLabel(nullptr), GlobalRangeCount(0),
+ : Asm(A), MMI(Asm->MMI), PrevLabel(nullptr),
InfoHolder(A, "info_string", DIEValueAllocator),
UsedNonDefaultText(false),
SkeletonHolder(A, "skel_string", DIEValueAllocator),
// Define out of line so we don't have to include DwarfUnit.h in DwarfDebug.h.
DwarfDebug::~DwarfDebug() { }
-// Switch to the specified MCSection and emit an assembler
-// temporary label to it if SymbolStem is specified.
-static void emitSectionSym(AsmPrinter *Asm, const MCSection *Section,
- StringRef SymbolStem) {
- Asm->OutStreamer.SwitchSection(Section);
- MCSymbol *TmpSym = Asm->GetTempSymbol(SymbolStem);
- Asm->OutStreamer.EmitLabel(TmpSym);
- Section->setBeginSymbol(*TmpSym);
-}
-
static bool isObjCClass(StringRef Name) {
return Name.startswith("+") || Name.startswith("-");
}
return;
TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
- // Emit initial sections so we can reference labels later.
- emitSectionLabels();
-
SingleCU = CU_Nodes->getNumOperands() == 1;
for (MDNode *N : CU_Nodes->operands()) {
// Emit all Dwarf sections that should come after the content.
void DwarfDebug::endModule() {
- const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
assert(CurFn == nullptr);
assert(CurMI == nullptr);
// If we aren't actually generating debug info (check beginModule -
// conditionalized on !DisableDebugInfoPrinting and the presence of the
// llvm.dbg.cu metadata node)
- if (!TLOF.getDwarfInfoSection()->getBeginSymbol())
+ if (!MMI->hasDebugInfo())
return;
// Finalize the debug info for the module.
// Emit info into a debug loc section.
emitDebugLoc();
- // Emit all the DIEs into a debug info section.
- emitDebugInfo();
-
// Corresponding abbreviations into a abbrev section.
emitAbbreviations();
+ // Emit all the DIEs into a debug info section.
+ emitDebugInfo();
+
// Emit info into a debug aranges section.
if (GenerateARangeSection)
emitDebugARanges();
DotDebugLocEntries.resize(DotDebugLocEntries.size() + 1);
DebugLocList &LocList = DotDebugLocEntries.back();
LocList.CU = &TheCU;
- LocList.Label =
- Asm->GetTempSymbol("debug_loc", DotDebugLocEntries.size() - 1);
+ LocList.Label = Asm->createTempSymbol("debug_loc");
// Build the location list for this variable.
buildLocationList(LocList.List, Ranges);
// Emit Methods
//===----------------------------------------------------------------------===//
-// Emit initial Dwarf sections with a label at the start of each one.
-void DwarfDebug::emitSectionLabels() {
- const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
-
- // Dwarf sections base addresses.
- emitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info");
- if (useSplitDwarf()) {
- emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection(), "section_info_dwo");
- emitSectionSym(Asm, TLOF.getDwarfTypesDWOSection(), "section_types_dwo");
- }
- emitSectionSym(Asm, TLOF.getDwarfAbbrevSection(), "section_abbrev");
- if (useSplitDwarf())
- emitSectionSym(Asm, TLOF.getDwarfAbbrevDWOSection(), "section_abbrev_dwo");
-
- emitSectionSym(Asm, TLOF.getDwarfLineSection(), "section_line");
- emitSectionSym(Asm, TLOF.getDwarfStrSection(), "info_string");
- if (useSplitDwarf()) {
- emitSectionSym(Asm, TLOF.getDwarfStrDWOSection(), "skel_string");
- emitSectionSym(Asm, TLOF.getDwarfAddrSection(), "addr_sec");
- emitSectionSym(Asm, TLOF.getDwarfLocDWOSection(), "skel_loc");
- } else
- emitSectionSym(Asm, TLOF.getDwarfLocSection(), "section_debug_loc");
- emitSectionSym(Asm, TLOF.getDwarfRangesSection(), "debug_range");
-}
-
// Emit the debug info section.
void DwarfDebug::emitDebugInfo() {
DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
Holder.emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevSection());
}
-// Emit the last address of the section and the end of the line matrix.
-void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
- // Define last address of section.
- Asm->OutStreamer.AddComment("Extended Op");
- Asm->EmitInt8(0);
-
- Asm->OutStreamer.AddComment("Op size");
- Asm->EmitInt8(Asm->getDataLayout().getPointerSize() + 1);
- Asm->OutStreamer.AddComment("DW_LNE_set_address");
- Asm->EmitInt8(dwarf::DW_LNE_set_address);
-
- Asm->OutStreamer.AddComment("Section end label");
-
- Asm->OutStreamer.EmitSymbolValue(
- Asm->GetTempSymbol("section_end", SectionEnd),
- Asm->getDataLayout().getPointerSize());
-
- // Mark end of matrix.
- Asm->OutStreamer.AddComment("DW_LNE_end_sequence");
- Asm->EmitInt8(0);
- Asm->EmitInt8(1);
- Asm->EmitInt8(1);
-}
-
void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
- StringRef TableName, StringRef SymName) {
+ StringRef TableName) {
Accel.FinalizeTable(Asm, TableName);
- emitSectionSym(Asm, Section, SymName);
+ Asm->OutStreamer.SwitchSection(Section);
// Emit the full data.
Accel.emit(Asm, Section->getBeginSymbol(), this);
// Emit visible names into a hashed accelerator table section.
void DwarfDebug::emitAccelNames() {
emitAccel(AccelNames, Asm->getObjFileLowering().getDwarfAccelNamesSection(),
- "Names", "names_begin");
+ "Names");
}
// Emit objective C classes and categories into a hashed accelerator table
// section.
void DwarfDebug::emitAccelObjC() {
emitAccel(AccelObjC, Asm->getObjFileLowering().getDwarfAccelObjCSection(),
- "ObjC", "objc_begin");
+ "ObjC");
}
// Emit namespace dies into a hashed accelerator table.
void DwarfDebug::emitAccelNamespaces() {
emitAccel(AccelNamespace,
Asm->getObjFileLowering().getDwarfAccelNamespaceSection(),
- "namespac", "namespac_begin");
+ "namespac");
}
// Emit type dies into a hashed accelerator table.
void DwarfDebug::emitAccelTypes() {
emitAccel(AccelTypes, Asm->getObjFileLowering().getDwarfAccelTypesSection(),
- "types", "types_begin");
+ "types");
}
// Public name handling.
if (auto *Skeleton = TheU->getSkeleton())
TheU = Skeleton;
- unsigned ID = TheU->getUniqueID();
// Start the dwarf pubnames section.
Asm->OutStreamer.SwitchSection(PSec);
// Emit the header.
Asm->OutStreamer.AddComment("Length of Public " + Name + " Info");
- MCSymbol *BeginLabel = Asm->GetTempSymbol("pub" + Name + "_begin", ID);
- MCSymbol *EndLabel = Asm->GetTempSymbol("pub" + Name + "_end", ID);
+ MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
+ MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
Asm->OutStreamer.EmitLabel(BeginLabel);
const DebugLocEntry::Value &Value,
unsigned PieceOffsetInBits) {
DIVariable DV = Value.getVariable();
- DebugLocDwarfExpression DwarfExpr(
- *AP.TM.getSubtargetImpl()->getRegisterInfo(),
- AP.getDwarfDebug()->getDwarfVersion(), Streamer);
+ DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
+ AP.getDwarfDebug()->getDwarfVersion(),
+ Streamer);
// Regular entry.
if (Value.isInt()) {
DIBasicType BTy(DV.getType().resolve(TypeIdentifierMap));
assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
if (Offset < PieceOffset) {
// The DWARF spec seriously mandates pieces with no locations for gaps.
- DebugLocDwarfExpression Expr(
- *AP.TM.getSubtargetImpl()->getRegisterInfo(),
- AP.getDwarfDebug()->getDwarfVersion(), Streamer);
+ DebugLocDwarfExpression Expr(*AP.MF->getSubtarget().getRegisterInfo(),
+ AP.getDwarfDebug()->getDwarfVersion(),
+ Streamer);
Expr.AddOpPiece(PieceOffset-Offset, 0);
Offset += PieceOffset-Offset;
}
}
// Add terminating symbols for each section.
- unsigned ID = 0;
for (const auto &I : SectionMap) {
const MCSection *Section = I.first;
MCSymbol *Sym = nullptr;
// if we know the section name up-front. For user-created sections, the
// resulting label may not be valid to use as a label. (section names can
// use a greater set of characters on some systems)
- Sym = Asm->GetTempSymbol("debug_end", ID);
+ Sym = Asm->createTempSymbol("debug_end");
Asm->OutStreamer.SwitchSection(Section);
Asm->OutStreamer.EmitLabel(Sym);
}
// Insert a final terminator.
SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
- ++ID;
}
DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;