-//===-- DIContext.h ---------------------------------------------*- C++ -*-===//
+//===- DIContext.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
struct DILineInfo {
std::string FileName;
std::string FunctionName;
- uint32_t Line;
- uint32_t Column;
- uint32_t StartLine;
+ uint32_t Line = 0;
+ uint32_t Column = 0;
+ uint32_t StartLine = 0;
// DWARF-specific.
- uint32_t Discriminator;
+ uint32_t Discriminator = 0;
- DILineInfo()
- : FileName("<invalid>"), FunctionName("<invalid>"), Line(0), Column(0),
- StartLine(0), Discriminator(0) {}
+ DILineInfo() : FileName("<invalid>"), FunctionName("<invalid>") {}
bool operator==(const DILineInfo &RHS) const {
return Line == RHS.Line && Column == RHS.Column &&
/// DIGlobal - container for description of a global variable.
struct DIGlobal {
std::string Name;
- uint64_t Start;
- uint64_t Size;
+ uint64_t Start = 0;
+ uint64_t Size = 0;
- DIGlobal() : Name("<invalid>"), Start(0), Size(0) {}
+ DIGlobal() : Name("<invalid>") {}
};
/// A DINameKind is passed to name search methods to specify a
/// on the fly.
class LoadedObjectInfo {
protected:
- LoadedObjectInfo(const LoadedObjectInfo &) = default;
LoadedObjectInfo() = default;
+ LoadedObjectInfo(const LoadedObjectInfo &) = default;
public:
virtual ~LoadedObjectInfo() = default;
-//===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===//
+//===- DWARFAbbreviationDeclaration.h ---------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
-#define LLVM_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
+#ifndef LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
+#define LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
+#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+
namespace llvm {
-class DWARFUnit;
class DWARFFormValue;
+class DWARFUnit;
class raw_ostream;
class DWARFAbbreviationDeclaration {
struct AttributeSpec {
AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<int64_t> V)
: Attr(A), Form(F), ByteSizeOrValue(V) {}
+
dwarf::Attribute Attr;
dwarf::Form Form;
/// The following field is used for ByteSize for non-implicit_const
/// * Form == DW_FORM_implicit_const:
/// ByteSizeOrValue contains value for the implicit_const attribute.
Optional<int64_t> ByteSizeOrValue;
+
bool isImplicitConst() const {
return Form == dwarf::DW_FORM_implicit_const;
}
+
/// Get the fixed byte size of this Form if possible. This function might
/// use the DWARFUnit to calculate the size of the Form, like for
/// DW_AT_address and DW_AT_ref_addr, so this isn't just an accessor for
/// abbreviation declaration.
struct FixedSizeInfo {
/// The fixed byte size for fixed size forms.
- uint16_t NumBytes;
+ uint16_t NumBytes = 0;
/// Number of DW_FORM_address forms in this abbrevation declaration.
- uint8_t NumAddrs;
+ uint8_t NumAddrs = 0;
/// Number of DW_FORM_ref_addr forms in this abbrevation declaration.
- uint8_t NumRefAddrs;
+ uint8_t NumRefAddrs = 0;
/// Number of 4 byte in DWARF32 and 8 byte in DWARF64 forms.
- uint8_t NumDwarfOffsets;
- /// Constructor
- FixedSizeInfo()
- : NumBytes(0), NumAddrs(0), NumRefAddrs(0), NumDwarfOffsets(0) {}
+ uint8_t NumDwarfOffsets = 0;
+
+ FixedSizeInfo() = default;
+
/// Calculate the fixed size in bytes given a DWARFUnit.
///
/// \param U the DWARFUnit to use when determing the byte size.
Optional<FixedSizeInfo> FixedAttributeSize;
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
-//===--- DWARFAcceleratorTable.h --------------------------------*- C++ -*-===//
+//===- DWARFAcceleratorTable.h ----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFACCELERATORTABLE_H
-#define LLVM_LIB_DEBUGINFO_DWARFACCELERATORTABLE_H
+#ifndef LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H
+#define LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H
#include "llvm/ADT/SmallVector.h"
-#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
+#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
#include <cstdint>
+#include <utility>
namespace llvm {
-class DWARFAcceleratorTable {
+class raw_ostream;
+class DWARFAcceleratorTable {
struct Header {
uint32_t Magic;
uint16_t Version;
DataExtractor AccelSection;
DataExtractor StringSection;
const RelocAddrMap& Relocs;
+
public:
DWARFAcceleratorTable(DataExtractor AccelSection, DataExtractor StringSection,
const RelocAddrMap &Relocs)
void dump(raw_ostream &OS) const;
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H
-//===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//
+//===- DWARFAttribute.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFATTRIBUTE_H
-#define LLVM_LIB_DEBUGINFO_DWARFATTRIBUTE_H
+#ifndef LLVM_DEBUGINFO_DWARFATTRIBUTE_H
+#define LLVM_DEBUGINFO_DWARFATTRIBUTE_H
-#include "llvm/Support/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
+#include "llvm/Support/Dwarf.h"
+#include <cstdint>
namespace llvm {
/// attributes in a DWARFDie.
struct DWARFAttribute {
/// The debug info/types offset for this attribute.
- uint32_t Offset;
+ uint32_t Offset = 0;
/// The debug info/types section byte size of the data for this attribute.
- uint32_t ByteSize;
+ uint32_t ByteSize = 0;
/// The attribute enumeration of this attribute.
dwarf::Attribute Attr;
/// The form and value for this attribute.
DWARFFormValue Value;
DWARFAttribute(uint32_t O, dwarf::Attribute A = dwarf::Attribute(0),
- dwarf::Form F = dwarf::Form(0)) :
- Offset(0), ByteSize(0), Attr(A), Value(F) {}
+ dwarf::Form F = dwarf::Form(0)) : Attr(A), Value(F) {}
bool isValid() const {
return Offset != 0 && Attr != dwarf::Attribute(0);
}
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFATTRIBUTE_H
-//===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===//
+//===- DWARFCompileUnit.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H
-#define LLVM_LIB_DEBUGINFO_DWARFCOMPILEUNIT_H
+#ifndef LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H
+#define LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
namespace llvm {
const DWARFUnitIndex::Entry *Entry)
: DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
UnitSection, Entry) {}
- void dump(raw_ostream &OS);
- static const DWARFSectionKind Section = DW_SECT_INFO;
+
// VTable anchor.
~DWARFCompileUnit() override;
+
+ void dump(raw_ostream &OS);
+
+ static const DWARFSectionKind Section = DW_SECT_INFO;
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H
-//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===//
+//===- DWARFDebugAbbrev.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H
-#define LLVM_LIB_DEBUGINFO_DWARFDEBUGABBREV_H
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
+#define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
+#include "llvm/Support/DataExtractor.h"
+#include <cstdint>
#include <map>
#include <vector>
void clear();
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
-//===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===//
+//===- DWARFDebugArangeSet.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H
-#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGESET_H
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
+#define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/DataExtractor.h"
+#include <cstdint>
#include <vector>
namespace llvm {
struct Descriptor {
uint64_t Address;
uint64_t Length;
+
uint64_t getEndAddress() const { return Address + Length; }
};
public:
DWARFDebugArangeSet() { clear(); }
+
void clear();
bool extract(DataExtractor data, uint32_t *offset_ptr);
void dump(raw_ostream &OS) const;
}
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H
-//===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===//
+//===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H
-#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
+#define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
#include "llvm/ADT/DenseSet.h"
#include "llvm/Support/DataExtractor.h"
+#include <cstdint>
#include <vector>
namespace llvm {
else
Length = HighPC - LowPC;
}
+
uint64_t HighPC() const {
if (Length)
return LowPC + Length;
bool containsAddress(uint64_t Address) const {
return LowPC <= Address && Address < HighPC();
}
+
bool operator<(const Range &other) const {
return LowPC < other.LowPC;
}
}
};
-
typedef std::vector<Range> RangeColl;
typedef RangeColl::const_iterator RangeCollIterator;
DenseSet<uint32_t> ParsedCUOffsets;
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
-//===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===//
+//===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
-#define LLVM_LIB_DEBUGINFO_DWARFDEBUGINFOENTRY_H
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
+#define LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
-#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Dwarf.h"
+#include <cstdint>
namespace llvm {
-class DWARFDebugAranges;
-class DWARFCompileUnit;
+class DataExtractor;
class DWARFUnit;
-class DWARFContext;
-class DWARFFormValue;
-struct DWARFDebugInfoEntryInlinedChain;
/// DWARFDebugInfoEntry - A DIE with only the minimum required data.
class DWARFDebugInfoEntry {
/// Offset within the .debug_info of the start of this entry.
- uint32_t Offset;
+ uint32_t Offset = 0;
/// The integer depth of this DIE within the compile unit DIEs where the
/// compile/type unit DIE has a depth of zero.
- uint32_t Depth;
+ uint32_t Depth = 0;
+
+ const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr;
- const DWARFAbbreviationDeclaration *AbbrevDecl;
public:
- DWARFDebugInfoEntry()
- : Offset(0), Depth(0), AbbrevDecl(nullptr) {}
+ DWARFDebugInfoEntry() = default;
/// Extracts a debug info entry, which is a child of a given unit,
/// starting at a given offset. If DIE can't be extracted, returns false and
/// doesn't change OffsetPtr.
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr);
+
/// High performance extraction should use this call.
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
const DataExtractor &DebugInfoData,
uint32_t getOffset() const { return Offset; }
uint32_t getDepth() const { return Depth; }
+
dwarf::Tag getTag() const {
return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
}
+
bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
+
const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
return AbbrevDecl;
}
};
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
-//===-- DWARFDebugLine.h ----------------------------------------*- C++ -*-===//
+//===- DWARFDebugLine.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H
-#define LLVM_LIB_DEBUGINFO_DWARFDEBUGLINE_H
+#ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H
+#define LLVM_DEBUGINFO_DWARFDEBUGLINE_H
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/DataExtractor.h"
+#include <cstdint>
#include <map>
#include <string>
#include <vector>
class DWARFDebugLine {
public:
DWARFDebugLine(const RelocAddrMap* LineInfoRelocMap) : RelocMap(LineInfoRelocMap) {}
+
struct FileNameEntry {
- FileNameEntry() : Name(nullptr), DirIdx(0), ModTime(0), Length(0) {}
+ FileNameEntry() = default;
- const char *Name;
- uint64_t DirIdx;
- uint64_t ModTime;
- uint64_t Length;
+ const char *Name = nullptr;
+ uint64_t DirIdx = 0;
+ uint64_t ModTime = 0;
+ uint64_t Length = 0;
};
struct Prologue {
std::vector<FileNameEntry> FileNames;
bool IsDWARF64;
+
uint32_t sizeofTotalLength() const {
return IsDWARF64 ? 12 : 4;
}
+
uint32_t sizeofPrologueLength() const {
return IsDWARF64 ? 8 : 4;
}
return PrologueLength + sizeofTotalLength() + sizeof(Version) +
sizeofPrologueLength();
}
+
// Length of the line table data in bytes (not including the prologue).
uint32_t getStatementTableLength() const {
return TotalLength + sizeofTotalLength() - getLength();
}
+
int32_t getMaxLineIncrementForSpecialOpcode() const {
return LineBase + (int8_t)LineRange - 1;
}
// compilation unit may consist of multiple sequences, which are not
// guaranteed to be in the order of ascending instruction address.
struct Sequence {
+ Sequence();
+
// Sequence describes instructions at address range [LowPC, HighPC)
// and is described by line table rows [FirstRowIndex, LastRowIndex).
uint64_t LowPC;
unsigned LastRowIndex;
bool Empty;
- Sequence();
void reset();
static bool orderByLowPC(const Sequence& LHS, const Sequence& RHS) {
return LHS.LowPC < RHS.LowPC;
}
+
bool isValid() const {
return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex);
}
+
bool containsPC(uint64_t pc) const {
return (LowPC <= pc && pc < HighPC);
}
void appendRow(const DWARFDebugLine::Row &R) {
Rows.push_back(R);
}
+
void appendSequence(const DWARFDebugLine::Sequence &S) {
Sequences.push_back(S);
}
const RelocAddrMap *RelocMap;
LineTableMapTy LineTableMap;
};
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_DEBUGINFO_DWARFDEBUGLINE_H
-//===-- DWARFDie.h --------------------------------------------------------===//
+//===- DWARFDie.h -----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DEBUGINFO_DWARFDIE_H
-#define LLVM_LIB_DEBUGINFO_DWARFDIE_H
+#ifndef LLVM_DEBUGINFO_DWARFDIE_H
+#define LLVM_DEBUGINFO_DWARFDIE_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFAttribute.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
+#include "llvm/Support/Dwarf.h"
+#include <cassert>
+#include <cstdint>
+#include <iterator>
namespace llvm {
class DWARFUnit;
-class DWARFDebugInfoEntry;
class raw_ostream;
//===----------------------------------------------------------------------===//
/// also simplifies the attribute extraction calls by not having to specify the
/// DWARFUnit for each call.
class DWARFDie {
- DWARFUnit *U;
- const DWARFDebugInfoEntry *Die;
+ DWARFUnit *U = nullptr;
+ const DWARFDebugInfoEntry *Die = nullptr;
+
public:
- DWARFDie() : U(nullptr), Die(nullptr) {}
+ DWARFDie() = default;
DWARFDie(DWARFUnit *Unit, const DWARFDebugInfoEntry * D) : U(Unit), Die(D) {}
bool isValid() const { return U && Die; }
const DWARFDebugInfoEntry *getDebugInfoEntry() const { return Die; }
DWARFUnit *getDwarfUnit() const { return U; }
-
/// Get the abbreviation declaration for this DIE.
///
/// \returns the abbreviation declaration or NULL for null tags.
bool isNULL() const {
return getAbbreviationDeclarationPtr() == nullptr;
}
+
/// Returns true if DIE represents a subprogram (not inlined).
bool isSubprogramDIE() const;
/// error will be set if the Err member variable is non-NULL and the iterator
/// will be set to the end value so iteration stops.
void updateForIndex(const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I);
+
public:
attribute_iterator() = delete;
explicit attribute_iterator(DWARFDie D, bool End);
+
attribute_iterator &operator++();
explicit operator bool() const { return AttrValue.isValid(); }
const DWARFAttribute &operator*() const { return AttrValue; }
bool operator==(const attribute_iterator &X) const { return Index == X.Index; }
};
-
inline bool operator==(const DWARFDie &LHS, const DWARFDie &RHS) {
return LHS.getDebugInfoEntry() == RHS.getDebugInfoEntry() &&
LHS.getDwarfUnit() == RHS.getDwarfUnit();
}
public:
iterator() = default;
+
explicit iterator(DWARFDie D) : Die(D) {
// If we start out with only a Null DIE then invalidate.
skipNull();
}
+
iterator &operator++() {
Die = Die.getSibling();
// Don't include the NULL die when iterating.
skipNull();
return *this;
}
+
explicit operator bool() const { return Die.isValid(); }
const DWARFDie &operator*() const { return Die; }
bool operator==(const iterator &X) const { return Die == X.Die; }
} // end namespace llvm
-#endif // LLVM_LIB_DEBUGINFO_DWARFDIE_H
+#endif // LLVM_DEBUGINFO_DWARFDIE_H
-//===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
+//===- DWARFFormValue.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
#define LLVM_DEBUGINFO_DWARFFORMVALUE_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
+#include <cstdint>
namespace llvm {
-template <typename T> class ArrayRef;
class DWARFUnit;
class raw_ostream;
private:
struct ValueType {
- ValueType() : data(nullptr) {
+ ValueType() {
uval = 0;
}
int64_t sval;
const char* cstr;
};
- const uint8_t* data;
+ const uint8_t* data = nullptr;
};
dwarf::Form Form; // Form for this value.
ValueType Value; // Contains all data for the form.
- const DWARFUnit *U; // Remember the DWARFUnit at extract time.
+ const DWARFUnit *U = nullptr; // Remember the DWARFUnit at extract time.
public:
- DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F), U(nullptr) {}
+ DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {}
+
dwarf::Form getForm() const { return Form; }
void setForm(dwarf::Form F) { Form = F; }
void setUValue(uint64_t V) { Value.uval = V; }
void setSValue(int64_t V) { Value.sval = V; }
void setPValue(const char *V) { Value.cstr = V; }
+
void setBlockValue(const ArrayRef<uint8_t> &Data) {
Value.data = Data.data();
setUValue(Data.size());
}
+
bool isFormClass(FormClass FC) const;
const DWARFUnit *getUnit() const { return U; }
void dump(raw_ostream &OS) const;
/// \returns whether the extraction succeeded.
bool extractValue(const DataExtractor &Data, uint32_t *OffsetPtr,
const DWARFUnit *U);
+
bool isInlinedCStr() const {
return Value.data != nullptr && Value.data == (const uint8_t*)Value.cstr;
}
Optional<ArrayRef<uint8_t>> getAsBlock() const;
Optional<uint64_t> getAsCStringOffset() const;
Optional<uint64_t> getAsReferenceUVal() const;
+
/// Get the fixed byte size for a given form.
///
/// If the form always has a fixed valid byte size that doesn't depend on a
/// and was needed to calculate the byte size.
static Optional<uint8_t> getFixedByteSize(dwarf::Form Form,
const DWARFUnit *U = nullptr);
+
/// Get the fixed byte size for a given form.
///
/// If the form has a fixed byte size given a valid DWARF version and address
/// \returns true on success, false if the form was not skipped.
bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
const DWARFUnit *U) const;
+
/// Skip a form in \p debug_info_data at offset specified by \p offset_ptr.
///
/// Skips the bytes for this form in the debug info and updates the offset.
/// \returns true on success, false if the form was not skipped.
static bool skipValue(dwarf::Form form, DataExtractor debug_info_data,
uint32_t *offset_ptr, const DWARFUnit *U);
+
/// Skip a form in \p debug_info_data at offset specified by \p offset_ptr.
///
/// Skips the bytes for this form in the debug info and updates the offset.
};
namespace dwarf {
+
/// Take an optional DWARFFormValue and try to extract a string value from it.
///
/// \param V and optional DWARFFormValue to attempt to extract the value from.
} // end namespace dwarf
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_DWARFFORMVALUE_H
-//===-- DWARFAbbreviationDeclaration.cpp ----------------------------------===//
+//===- DWARFAbbreviationDeclaration.cpp -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
+#include <cstddef>
+#include <cstdint>
+
using namespace llvm;
using namespace dwarf;
-//===--- DWARFAcceleratorTable.cpp ----------------------------------------===//
+//===- DWARFAcceleratorTable.cpp ------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/SmallVector.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
+#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
+#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/Dwarf.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
+#include <cstddef>
+#include <cstdint>
+#include <utility>
-namespace llvm {
+using namespace llvm;
bool DWARFAcceleratorTable::extract() {
uint32_t Offset = 0;
}
}
}
-}
-//===-- DWARFDebugAbbrev.cpp ----------------------------------------------===//
+//===- DWARFDebugAbbrev.cpp -----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cinttypes>
+#include <cstdint>
+
using namespace llvm;
DWARFAbbreviationDeclarationSet::DWARFAbbreviationDeclarationSet() {
-//===-- DWARFDebugArangeSet.cpp -------------------------------------------===//
+//===- DWARFDebugArangeSet.cpp --------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
-#include <algorithm>
#include <cassert>
+#include <cinttypes>
+#include <cstdint>
+#include <cstring>
+
using namespace llvm;
void DWARFDebugArangeSet::clear() {
-//===-- DWARFDebugAranges.cpp -----------------------------------*- C++ -*-===//
+//===- DWARFDebugAranges.cpp ----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/DataExtractor.h"
#include <algorithm>
#include <cassert>
+#include <cstdint>
#include <set>
+#include <vector>
+
using namespace llvm;
void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
std::sort(Endpoints.begin(), Endpoints.end());
uint64_t PrevAddress = -1ULL;
for (const auto &E : Endpoints) {
- if (PrevAddress < E.Address && ValidCUs.size() > 0) {
+ if (PrevAddress < E.Address && !ValidCUs.empty()) {
// If the address range between two endpoints is described by some
// CU, first try to extend the last range in Aranges. If we can't
// do it, start a new range.
-//===-- DWARFDebugInfoEntry.cpp -------------------------------------------===//
+//===- DWARFDebugInfoEntry.cpp --------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#include "SyntaxHighlighting.h"
-#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
-#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Dwarf.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
+#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/Support/DataExtractor.h"
+#include <cstddef>
+#include <cstdint>
+
using namespace llvm;
using namespace dwarf;
-using namespace syntax;
bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U,
uint32_t *OffsetPtr) {
const uint32_t UEndOffset = U.getNextUnitOffset();
return extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0);
}
+
bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
const DataExtractor &DebugInfoData,
uint32_t UEndOffset, uint32_t D) {
-//===-- DWARFDebugLine.cpp ------------------------------------------------===//
+//===- DWARFDebugLine.cpp -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/SmallString.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
+#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
+#include <cassert>
+#include <cinttypes>
+#include <cstdint>
+#include <cstdio>
+#include <utility>
+
using namespace llvm;
using namespace dwarf;
+
typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind;
DWARFDebugLine::Prologue::Prologue() { clear(); }
-//===-- DWARFDie.cpp ------------------------------------------------------===//
+//===- DWARFDie.cpp -------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "SyntaxHighlighting.h"
-#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
-#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
-#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
+#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
+#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
+#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cinttypes>
+#include <cstdint>
+#include <string>
+#include <utility>
using namespace llvm;
using namespace dwarf;
using namespace syntax;
-namespace {
- static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) {
+static void dumpApplePropertyAttribute(raw_ostream &OS, uint64_t Val) {
OS << " (";
do {
uint64_t Shift = countTrailingZeros(Val);
OS << ")\n";
}
-} // end anonymous namespace
-
bool DWARFDie::isSubprogramDIE() const {
return getTag() == DW_TAG_subprogram;
}
}
}
-
void DWARFDie::getInlinedChainForAddress(
const uint64_t Address, SmallVectorImpl<DWARFDie> &InlinedChain) const {
if (isNULL())
-//===-- DWARFFormValue.cpp ------------------------------------------------===//
+//===- DWARFFormValue.cpp -------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
#include "SyntaxHighlighting.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
-#include "llvm/Support/Debug.h"
+#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
+#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/Support/Dwarf.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
-#include <cassert>
+#include <cinttypes>
+#include <cstdint>
#include <limits>
+
using namespace llvm;
using namespace dwarf;
using namespace syntax;
public:
FormSizeHelper(uint16_t V, uint8_t A, llvm::dwarf::DwarfFormat F)
- : Version(V), AddrSize(A), Format(F) {}
+ : Version(V), AddrSize(A), Format(F) {}
+
uint8_t getAddressByteSize() const { return AddrSize; }
+
uint8_t getRefAddrByteSize() const {
if (Version == 2)
return AddrSize;
return getDwarfOffsetByteSize();
}
+
uint8_t getDwarfOffsetByteSize() const {
switch (Format) {
case dwarf::DwarfFormat::DWARF32:
case DW_FORM_sdata: OS << Value.sval; break;
case DW_FORM_udata: OS << Value.uval; break;
- case DW_FORM_strp: {
+ case DW_FORM_strp:
OS << format(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
dumpString(OS);
break;
- }
- case DW_FORM_GNU_str_index: {
+ case DW_FORM_GNU_str_index:
OS << format(" indexed (%8.8x) string = ", (uint32_t)uvalue);
dumpString(OS);
break;
- }
- case DW_FORM_GNU_strp_alt: {
+ case DW_FORM_GNU_strp_alt:
OS << format("alt indirect string, offset: 0x%" PRIx64 "", uvalue);
dumpString(OS);
break;
- }
case DW_FORM_ref_addr:
OS << format("0x%016" PRIx64, uvalue);
break;
return None;
return Value.uval;
}
-