1//===- llvm/CodeGen/DwarfFile.cpp - Dwarf Debug Framework -----------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 21 : Asm(AP), Abbrevs(AbbrevAllocator), StrPool(DA, *Asm, Pref) {}
24 CUs.push_back(std::move(U));
27// Emit the various dwarf units to the unit section USection with 28// the abbreviations going into ASection. 30for (
constauto &TheU : CUs)
43// Skip CUs that ended up not being needed (split CUs that were abandoned 44// because they added no information beyond the non-split CU) 56// Compute the size and offset for each DIE. 58// Offset from the first CU in the debug info section is 0 initially. 61// Iterate over each compile unit and set the size and offsets for each 62// DIE within each compile unit. All offsets are CU relative. 63for (
constauto &TheU : CUs) {
64if (TheU->getCUNode()->isDebugDirectivesOnly())
67// Skip CUs that ended up not being needed (split CUs that were abandoned 68// because they added no information beyond the non-split CU) 69if (TheU->getUnitDie().values().empty())
72 TheU->setDebugSectionOffset(SecOffset);
75if (SecOffset > UINT32_MAX && !Asm->
isDwarf64())
77"for the 32-bit DWARF format.");
81// CU-relative offset is reset to 0 here. 85// The return value here is CU-relative, after laying out 90// Compute the size and offset of a DIE. The offset is relative to start of the 91// CU. It returns the offset after laying out the DIE. 99// Emit strings into a string section. 101bool UseRelativeOffsets) {
102 StrPool.
emit(*Asm, StrSection, OffsetSection, UseRelativeOffsets);
106auto &ScopeVars = ScopeVariables[LS];
108if (
unsigned ArgNum = DV->
getArg()) {
109auto Ret = ScopeVars.Args.insert({ArgNum, Var});
113 ScopeVars.Locals.push_back(Var);
122std::pair<uint32_t, RangeSpanList *>
124bool CanReuseLastRange =
false;
126if (!CURangeLists.empty()) {
127autoLast = CURangeLists.back();
129 CanReuseLastRange =
true;
133if (!CanReuseLastRange) {
138return std::make_pair(CURangeLists.size() - 1, &CURangeLists.back());
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class is intended to be used as a driving class for all asm writers.
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
unsigned int getUnitLengthFieldByteSize() const
Returns 4 for DWARF32 and 12 for DWARF64.
MCSymbol * createTempSymbol(const Twine &Name) const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
dwarf::FormParams getDwarfFormParams() const
Returns information about the byte size of DW_FORM values.
Allocate memory in an ever growing pool, as if by bump-pointer.
bool isDebugDirectivesOnly() const
void Emit(const AsmPrinter *AP, MCSection *Section) const
Print all abbreviations using the specified asm printer.
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
A structured debug information entry.
unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset)
Compute the offset of this DIE and all its children.
This class is used to track label information.
This class is used to track local variable information.
const DILocalVariable * getVariable() const
unsigned computeSizeAndOffset(DIE &Die, unsigned Offset)
Compute the size and offset of a DIE given an incoming Offset.
void addScopeLabel(LexicalScope *LS, DbgLabel *Label)
void addUnit(std::unique_ptr< DwarfCompileUnit > U)
Add a unit to the list of CUs.
void computeSizeAndOffsets()
Compute the size and offset of all the DIEs.
unsigned computeSizeAndOffsetsForUnit(DwarfUnit *TheU)
Compute the size and offset of all the DIEs in the given unit.
void emitUnits(bool UseOffsets)
Emit all of the units to the section listed with the given abbreviation section.
void emitUnit(DwarfUnit *TheU, bool UseOffsets)
Emit the given unit to its section.
void emitAbbrevs(MCSection *)
Emit a set of abbreviations to the specific section.
DwarfFile(AsmPrinter *AP, StringRef Pref, BumpPtrAllocator &DA)
void emitStrings(MCSection *StrSection, MCSection *OffsetSection=nullptr, bool UseRelativeOffsets=false)
Emit all of the strings to the section given.
void addScopeVariable(LexicalScope *LS, DbgVariable *Var)
std::pair< uint32_t, RangeSpanList * > addRange(const DwarfCompileUnit &CU, SmallVector< RangeSpan, 2 > R)
void emit(AsmPrinter &Asm, MCSection *StrSection, MCSection *OffsetSection=nullptr, bool UseRelativeOffsets=false)
This dwarf writer support class manages information associated with a source file.
virtual void emitHeader(bool UseOffsets)=0
Emit the header for this unit, not including the initial length field.
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
MCSymbol * getEndLabel() const
const DICompileUnit * getCUNode() const
LexicalScope - This class is used to track scope information.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.