void EmitULEB128(uint64_t Value, const char *Desc = nullptr,
unsigned PadTo = 0) const;
- /// Emit a .byte 42 directive for a DW_CFA_xxx value.
- void EmitCFAByte(unsigned Val) const;
-
/// Emit a .byte 42 directive that corresponds to an encoding. If verbose
/// assembly output is enabled, we output comments describing the encoding.
/// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
OutStreamer->EmitULEB128IntValue(Value, PadTo);
}
-/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
-void AsmPrinter::EmitCFAByte(unsigned Val) const {
- if (isVerbose()) {
- if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset + 64)
- OutStreamer->AddComment("DW_CFA_offset + Reg (" +
- Twine(Val - dwarf::DW_CFA_offset) + ")");
- else
- OutStreamer->AddComment(dwarf::CallFrameString(Val));
- }
- OutStreamer->EmitIntValue(Val, 1);
-}
-
static const char *DecodeDWARFEncoding(unsigned Encoding) {
switch (Encoding) {
case dwarf::DW_EH_PE_absptr:
Hash.update(makeArrayRef((uint8_t)'\0'));
}
-/// This is based on the type signature computation given in section 7.27 of the
-/// DWARF4 standard. It is the md5 hash of a flattened description of the DIE
-/// with the exception that we are hashing only the context and the name of the
-/// type.
-uint64_t DIEHash::computeDIEODRSignature(const DIE &Die) {
-
- // Add the contexts to the hash. We won't be computing the ODR hash for
- // function local types so it's safe to use the generic context hashing
- // algorithm here.
- // FIXME: If we figure out how to account for linkage in some way we could
- // actually do this with a slight modification to the parent hash algorithm.
- if (const DIE *Parent = Die.getParent())
- addParentContext(*Parent);
-
- // Add the current DIE information.
-
- // Add the DWARF tag of the DIE.
- addULEB128(Die.getTag());
-
- // Add the name of the type to the hash.
- addString(getDIEStringAttr(Die, dwarf::DW_AT_name));
-
- // Now get the result.
- MD5::MD5Result Result;
- Hash.final(Result);
-
- // ... take the least significant 8 bytes and return those. Our MD5
- // implementation always returns its results in little endian, swap bytes
- // appropriately.
- return support::endian::read64le(Result + 8);
-}
-
/// This is based on the type signature computation given in section 7.27 of the
/// DWARF4 standard. It is an md5 hash of the flattened description of the DIE
/// with the inclusion of the full CU and all top level CU entities.
public:
DIEHash(AsmPrinter *A = nullptr) : AP(A) {}
- /// \brief Computes the ODR signature.
- uint64_t computeDIEODRSignature(const DIE &Die);
-
/// \brief Computes the CU signature.
uint64_t computeCUSignature(const DIE &Die);
DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
: Asm(A), MMI(Asm->MMI), DebugLocs(A->OutStreamer->isVerboseAsm()),
PrevLabel(nullptr), InfoHolder(A, "info_string", DIEValueAllocator),
- UsedNonDefaultText(false),
SkeletonHolder(A, "skel_string", DIEValueAllocator),
IsDarwin(Triple(A->getTargetTriple()).isOSDarwin()),
AccelNames(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
}
}
-/// isSubprogramContext - Return true if Context is either a subprogram
-/// or another context nested inside a subprogram.
-bool DwarfDebug::isSubprogramContext(const MDNode *Context) {
- if (!Context)
- return false;
- if (isa<DISubprogram>(Context))
- return true;
- if (auto *T = dyn_cast<DIType>(Context))
- return isSubprogramContext(resolve(T->getScope()));
- return false;
-}
-
/// Check whether we should create a DIE for the given Scope, return true
/// if we don't create a DIE (the corresponding DIE is null).
bool DwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
class DwarfUnit;
class MachineModuleInfo;
-//===----------------------------------------------------------------------===//
-/// This class is used to record source line correspondence.
-class SrcLineInfo {
- unsigned Line; // Source line number.
- unsigned Column; // Source column.
- unsigned SourceID; // Source ID number.
- MCSymbol *Label; // Label in code ID number.
-public:
- SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
- : Line(L), Column(C), SourceID(S), Label(label) {}
-
- // Accessors
- unsigned getLine() const { return Line; }
- unsigned getColumn() const { return Column; }
- unsigned getSourceID() const { return SourceID; }
- MCSymbol *getLabel() const { return Label; }
-};
-
//===----------------------------------------------------------------------===//
/// This class is used to track local variable information.
///
/// Whether to emit the pubnames/pubtypes sections.
bool HasDwarfPubSections;
- /// Whether or not to use AT_ranges for compilation units.
- bool HasCURanges;
-
- /// Whether we emitted a function into a section other than the
- /// default text.
- bool UsedNonDefaultText;
-
/// Whether to use the GNU TLS opcode (instead of the standard opcode).
bool UseGNUTLSOpcode;
/// Construct a DIE for this abstract scope.
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
- /// Compute the size and offset of a DIE given an incoming Offset.
- unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
-
- /// Compute the size and offset of all the DIEs.
- void computeSizeAndOffsets();
-
/// Collect info for variables that were optimized out.
void collectDeadVariables();
/// Emit visible names into a debug ranges section.
void emitDebugRanges();
- /// Emit inline info using custom format.
- void emitDebugInlineInfo();
-
/// DWARF 5 Experimental Split Dwarf Emitters
/// Initialize common features of skeleton units.
/// section.
DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
- /// Construct the split debug info compile unit for the debug info
- /// section.
- DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
-
/// Emit the debug info dwo section.
void emitDebugInfoDWO();
DwarfCompileUnit *lookupUnit(const DIE *CU) const {
return CUDieMap.lookup(CU);
}
- /// isSubprogramContext - Return true if Context is either a subprogram
- /// or another context nested inside a subprogram.
- bool isSubprogramContext(const MDNode *Context);
void addSubprogramNames(const DISubprogram *SP, DIE &Die);
DwarfUnit(unsigned UID, dwarf::Tag, const DICompileUnit *CU, AsmPrinter *A,
DwarfDebug *DW, DwarfFile *DWU);
- /// Add a string attribute data and value.
- ///
- /// This is guaranteed to be in the local string pool instead of indirected.
- void addLocalString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
-
- void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
-
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie);
public:
virtual void addGlobalType(const DIType *Ty, const DIE &Die,
const DIScope *Context) {}
- /// Add a new name to the namespace accelerator table.
- void addAccelNamespace(StringRef Name, const DIE &Die);
-
/// Returns the DIE map slot for the specified debug variable.
///
/// We delegate the request to DwarfDebug when the MDNode can be part of the