forked from OSchip/llvm-project
AsmPrinter: Change DIEValue to be stored by value
Change `DIEValue` to be stored/passed/etc. by value, instead of reference. It's now a discriminated union, with a `Val` field storing the actual type. The classes that used to inherit from `DIEValue` no longer do. There are two categories of these: - Small values fit in a single pointer and are stored by value. - Large values require auxiliary storage, and are stored by reference. The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp. It was relying on `DIEInteger`s being passed around by reference, so I replaced that assumption with a `PatchLocation` type that stores a safe reference to where the `DIEInteger` lives instead. This commit causes a temporary regression in memory usage, since I've left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit. I measured an increase from 845 MB to 879 MB, around 3.9%. The follow-up drops it lower than the starting point, and I've only recently brought the memory this low anyway, so I'm committing these changes separately to keep them incremental. (I also considered swapping the commits, but the other one first would cause a lot more code churn.) (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238349
This commit is contained in:
parent
bfd05631da
commit
7735b48a8b
|
@ -104,62 +104,14 @@ public:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
|
||||||
/// DIEValue - A debug information entry value. Some of these roughly correlate
|
|
||||||
/// to DWARF attribute classes.
|
|
||||||
///
|
|
||||||
class DIEValue {
|
|
||||||
public:
|
|
||||||
enum Type {
|
|
||||||
isInteger,
|
|
||||||
isString,
|
|
||||||
isExpr,
|
|
||||||
isLabel,
|
|
||||||
isDelta,
|
|
||||||
isEntry,
|
|
||||||
isTypeSignature,
|
|
||||||
isBlock,
|
|
||||||
isLoc,
|
|
||||||
isLocList,
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Ty - Type of data stored in the value.
|
|
||||||
///
|
|
||||||
Type Ty;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit DIEValue(Type T) : Ty(T) {}
|
|
||||||
~DIEValue() {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Accessors
|
|
||||||
Type getType() const { return Ty; }
|
|
||||||
|
|
||||||
/// EmitValue - Emit value via the Dwarf writer.
|
|
||||||
///
|
|
||||||
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
/// SizeOf - Return the size of a value in bytes.
|
|
||||||
///
|
|
||||||
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
void print(raw_ostream &O) const;
|
|
||||||
void dump() const;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIEInteger - An integer value DIE.
|
/// DIEInteger - An integer value DIE.
|
||||||
///
|
///
|
||||||
class DIEInteger : public DIEValue {
|
class DIEInteger {
|
||||||
friend DIEValue;
|
|
||||||
|
|
||||||
uint64_t Integer;
|
uint64_t Integer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {}
|
explicit DIEInteger(uint64_t I) : Integer(I) {}
|
||||||
|
|
||||||
/// BestForm - Choose the best form for integer.
|
/// BestForm - Choose the best form for integer.
|
||||||
///
|
///
|
||||||
|
@ -186,120 +138,91 @@ public:
|
||||||
uint64_t getValue() const { return Integer; }
|
uint64_t getValue() const { return Integer; }
|
||||||
void setValue(uint64_t Val) { Integer = Val; }
|
void setValue(uint64_t Val) { Integer = Val; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *I) { return I->getType() == isInteger; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIEExpr - An expression DIE.
|
/// DIEExpr - An expression DIE.
|
||||||
//
|
//
|
||||||
class DIEExpr : public DIEValue {
|
class DIEExpr {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
const MCExpr *Expr;
|
const MCExpr *Expr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIEExpr(const MCExpr *E) : DIEValue(isExpr), Expr(E) {}
|
explicit DIEExpr(const MCExpr *E) : Expr(E) {}
|
||||||
|
|
||||||
/// getValue - Get MCExpr.
|
/// getValue - Get MCExpr.
|
||||||
///
|
///
|
||||||
const MCExpr *getValue() const { return Expr; }
|
const MCExpr *getValue() const { return Expr; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) { return E->getType() == isExpr; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIELabel - A label DIE.
|
/// DIELabel - A label DIE.
|
||||||
//
|
//
|
||||||
class DIELabel : public DIEValue {
|
class DIELabel {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
const MCSymbol *Label;
|
const MCSymbol *Label;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
|
explicit DIELabel(const MCSymbol *L) : Label(L) {}
|
||||||
|
|
||||||
/// getValue - Get MCSymbol.
|
/// getValue - Get MCSymbol.
|
||||||
///
|
///
|
||||||
const MCSymbol *getValue() const { return Label; }
|
const MCSymbol *getValue() const { return Label; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *L) { return L->getType() == isLabel; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIEDelta - A simple label difference DIE.
|
/// DIEDelta - A simple label difference DIE.
|
||||||
///
|
///
|
||||||
class DIEDelta : public DIEValue {
|
class DIEDelta {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
const MCSymbol *LabelHi;
|
const MCSymbol *LabelHi;
|
||||||
const MCSymbol *LabelLo;
|
const MCSymbol *LabelLo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
|
DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) : LabelHi(Hi), LabelLo(Lo) {}
|
||||||
: DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
|
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *D) { return D->getType() == isDelta; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIEString - A container for string values.
|
/// DIEString - A container for string values.
|
||||||
///
|
///
|
||||||
class DIEString : public DIEValue {
|
class DIEString {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
DwarfStringPoolEntryRef S;
|
DwarfStringPoolEntryRef S;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIEString(DwarfStringPoolEntryRef S) : DIEValue(isString), S(S) {}
|
DIEString(DwarfStringPoolEntryRef S) : S(S) {}
|
||||||
|
|
||||||
/// getString - Grab the string out of the object.
|
/// getString - Grab the string out of the object.
|
||||||
StringRef getString() const { return S.getString(); }
|
StringRef getString() const { return S.getString(); }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *D) { return D->getType() == isString; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -308,60 +231,48 @@ private:
|
||||||
/// this class can also be used as a proxy for a debug information entry not
|
/// this class can also be used as a proxy for a debug information entry not
|
||||||
/// yet defined (ie. types.)
|
/// yet defined (ie. types.)
|
||||||
class DIE;
|
class DIE;
|
||||||
class DIEEntry : public DIEValue {
|
class DIEEntry {
|
||||||
friend class DIEValue;
|
DIE *Entry;
|
||||||
|
|
||||||
DIE &Entry;
|
DIEEntry() = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIEEntry(DIE &E) : DIEValue(isEntry), Entry(E) {
|
explicit DIEEntry(DIE &E) : Entry(&E) {}
|
||||||
}
|
|
||||||
|
|
||||||
DIE &getEntry() const { return Entry; }
|
DIE &getEntry() const { return *Entry; }
|
||||||
|
|
||||||
/// Returns size of a ref_addr entry.
|
/// Returns size of a ref_addr entry.
|
||||||
static unsigned getRefAddrSize(const AsmPrinter *AP);
|
static unsigned getRefAddrSize(const AsmPrinter *AP);
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) { return E->getType() == isEntry; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
|
||||||
return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
|
return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
|
||||||
: sizeof(int32_t);
|
: sizeof(int32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// \brief A signature reference to a type unit.
|
/// \brief A signature reference to a type unit.
|
||||||
class DIETypeSignature : public DIEValue {
|
class DIETypeSignature {
|
||||||
friend class DIEValue;
|
const DwarfTypeUnit *Unit;
|
||||||
|
|
||||||
const DwarfTypeUnit &Unit;
|
DIETypeSignature() = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DIETypeSignature(const DwarfTypeUnit &Unit)
|
explicit DIETypeSignature(const DwarfTypeUnit &Unit) : Unit(&Unit) {}
|
||||||
: DIEValue(isTypeSignature), Unit(Unit) {}
|
|
||||||
|
|
||||||
// \brief Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) {
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
return E->getType() == isTypeSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
|
||||||
assert(Form == dwarf::DW_FORM_ref_sig8);
|
assert(Form == dwarf::DW_FORM_ref_sig8);
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -369,27 +280,125 @@ private:
|
||||||
/// DIELocList - Represents a pointer to a location list in the debug_loc
|
/// DIELocList - Represents a pointer to a location list in the debug_loc
|
||||||
/// section.
|
/// section.
|
||||||
//
|
//
|
||||||
class DIELocList : public DIEValue {
|
class DIELocList {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
// Index into the .debug_loc vector.
|
// Index into the .debug_loc vector.
|
||||||
size_t Index;
|
size_t Index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIELocList(size_t I) : DIEValue(isLocList), Index(I) {}
|
DIELocList(size_t I) : Index(I) {}
|
||||||
|
|
||||||
/// getValue - Grab the current index out.
|
/// getValue - Grab the current index out.
|
||||||
size_t getValue() const { return Index; }
|
size_t getValue() const { return Index; }
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) { return E->getType() == isLocList; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
/// DIEValue - A debug information entry value. Some of these roughly correlate
|
||||||
|
/// to DWARF attribute classes.
|
||||||
|
///
|
||||||
|
class DIEBlock;
|
||||||
|
class DIELoc;
|
||||||
|
class DIEValue {
|
||||||
|
public:
|
||||||
|
enum Type {
|
||||||
|
isNone,
|
||||||
|
isInteger,
|
||||||
|
isString,
|
||||||
|
isExpr,
|
||||||
|
isLabel,
|
||||||
|
isDelta,
|
||||||
|
isEntry,
|
||||||
|
isTypeSignature,
|
||||||
|
isBlock,
|
||||||
|
isLoc,
|
||||||
|
isLocList,
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Ty - Type of data stored in the value.
|
||||||
|
///
|
||||||
|
Type Ty;
|
||||||
|
|
||||||
|
AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel, DIEDelta *,
|
||||||
|
DIEEntry, DIETypeSignature, DIEBlock *, DIELoc *,
|
||||||
|
DIELocList> Val;
|
||||||
|
static_assert(sizeof(Val) == sizeof(uint64_t),
|
||||||
|
"Only small values should be allocated locally");
|
||||||
|
|
||||||
|
public:
|
||||||
|
DIEValue() : Ty(isNone) {}
|
||||||
|
DIEValue(const DIEValue &X) = default;
|
||||||
|
DIEValue &operator=(const DIEValue &X) = default;
|
||||||
|
|
||||||
|
explicit operator bool() const { return Ty; }
|
||||||
|
|
||||||
|
#define CONSTRUCT_FROM_SMALL(Kind) \
|
||||||
|
DIEValue(const DIE##Kind &V) : Ty(is##Kind) { \
|
||||||
|
static_assert(std::is_trivially_copyable<DIE##Kind>::value, \
|
||||||
|
"Expected trivial type"); \
|
||||||
|
new (reinterpret_cast<void *>(Val.buffer)) DIE##Kind(V); \
|
||||||
|
}
|
||||||
|
#define CONSTRUCT_FROM_LARGE(Kind) \
|
||||||
|
DIEValue(const DIE##Kind *V) : Ty(is##Kind) { \
|
||||||
|
assert(V && "Expected valid value"); \
|
||||||
|
*reinterpret_cast<const DIE##Kind **>(Val.buffer) = V; \
|
||||||
|
}
|
||||||
|
CONSTRUCT_FROM_SMALL(Integer)
|
||||||
|
CONSTRUCT_FROM_SMALL(Expr)
|
||||||
|
CONSTRUCT_FROM_SMALL(Label)
|
||||||
|
CONSTRUCT_FROM_SMALL(Entry)
|
||||||
|
CONSTRUCT_FROM_SMALL(TypeSignature)
|
||||||
|
CONSTRUCT_FROM_SMALL(LocList)
|
||||||
|
CONSTRUCT_FROM_SMALL(String)
|
||||||
|
CONSTRUCT_FROM_LARGE(Delta)
|
||||||
|
CONSTRUCT_FROM_LARGE(Block)
|
||||||
|
CONSTRUCT_FROM_LARGE(Loc)
|
||||||
|
#undef CONSTRUCT_FROM_SMALL
|
||||||
|
#undef CONSTRUCT_FROM_LARGE
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
Type getType() const { return Ty; }
|
||||||
|
|
||||||
|
#define GET_VALUE_REF_SMALL(Kind) \
|
||||||
|
const DIE##Kind &getDIE##Kind() const { \
|
||||||
|
assert(getType() == is##Kind && "Expected " #Kind); \
|
||||||
|
return *reinterpret_cast<const DIE##Kind *>(Val.buffer); \
|
||||||
|
}
|
||||||
|
#define GET_VALUE_REF_LARGE(Kind) \
|
||||||
|
const DIE##Kind &getDIE##Kind() const { \
|
||||||
|
assert(getType() == is##Kind && "Expected " #Kind); \
|
||||||
|
return **reinterpret_cast<const DIE##Kind *const *>(Val.buffer); \
|
||||||
|
}
|
||||||
|
GET_VALUE_REF_SMALL(Integer)
|
||||||
|
GET_VALUE_REF_SMALL(Expr)
|
||||||
|
GET_VALUE_REF_SMALL(Label)
|
||||||
|
GET_VALUE_REF_SMALL(Entry)
|
||||||
|
GET_VALUE_REF_SMALL(TypeSignature)
|
||||||
|
GET_VALUE_REF_SMALL(LocList)
|
||||||
|
GET_VALUE_REF_SMALL(String)
|
||||||
|
GET_VALUE_REF_LARGE(Delta)
|
||||||
|
GET_VALUE_REF_LARGE(Block)
|
||||||
|
GET_VALUE_REF_LARGE(Loc)
|
||||||
|
#undef GET_VALUE_REF_SMALL
|
||||||
|
#undef GET_VALUE_REF_LARGE
|
||||||
|
|
||||||
|
/// EmitValue - Emit value via the Dwarf writer.
|
||||||
|
///
|
||||||
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
|
/// SizeOf - Return the size of a value in bytes.
|
||||||
|
///
|
||||||
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void print(raw_ostream &O) const;
|
||||||
|
void dump() const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -424,7 +433,7 @@ protected:
|
||||||
|
|
||||||
/// Attribute values.
|
/// Attribute values.
|
||||||
///
|
///
|
||||||
SmallVector<DIEValue *, 12> Values;
|
SmallVector<DIEValue, 12> Values;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DIE()
|
DIE()
|
||||||
|
@ -446,7 +455,11 @@ public:
|
||||||
const std::vector<std::unique_ptr<DIE>> &getChildren() const {
|
const std::vector<std::unique_ptr<DIE>> &getChildren() const {
|
||||||
return Children;
|
return Children;
|
||||||
}
|
}
|
||||||
const SmallVectorImpl<DIEValue *> &getValues() const { return Values; }
|
const SmallVectorImpl<DIEValue> &getValues() const { return Values; }
|
||||||
|
void setValue(unsigned I, DIEValue New) {
|
||||||
|
assert(I < Values.size());
|
||||||
|
Values[I] = New;
|
||||||
|
}
|
||||||
DIE *getParent() const { return Parent; }
|
DIE *getParent() const { return Parent; }
|
||||||
/// Climb up the parent chain to get the compile or type unit DIE this DIE
|
/// Climb up the parent chain to get the compile or type unit DIE this DIE
|
||||||
/// belongs to.
|
/// belongs to.
|
||||||
|
@ -459,7 +472,7 @@ public:
|
||||||
|
|
||||||
/// addValue - Add a value and attributes to a DIE.
|
/// addValue - Add a value and attributes to a DIE.
|
||||||
///
|
///
|
||||||
void addValue(dwarf::Attribute Attribute, dwarf::Form Form, DIEValue *Value) {
|
void addValue(dwarf::Attribute Attribute, dwarf::Form Form, DIEValue Value) {
|
||||||
Abbrev.AddAttribute(Attribute, Form);
|
Abbrev.AddAttribute(Attribute, Form);
|
||||||
Values.push_back(Value);
|
Values.push_back(Value);
|
||||||
}
|
}
|
||||||
|
@ -473,9 +486,11 @@ public:
|
||||||
Children.push_back(std::move(Child));
|
Children.push_back(std::move(Child));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// findAttribute - Find a value in the DIE with the attribute given,
|
/// Find a value in the DIE with the attribute given.
|
||||||
/// returns NULL if no such attribute exists.
|
///
|
||||||
DIEValue *findAttribute(dwarf::Attribute Attribute) const;
|
/// Returns a default-constructed DIEValue (where \a DIEValue::getType()
|
||||||
|
/// gives \a DIEValue::isNone) if no such attribute exists.
|
||||||
|
DIEValue findAttribute(dwarf::Attribute Attribute) const;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void print(raw_ostream &O, unsigned IndentCount = 0) const;
|
void print(raw_ostream &O, unsigned IndentCount = 0) const;
|
||||||
|
@ -486,12 +501,11 @@ public:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIELoc - Represents an expression location.
|
/// DIELoc - Represents an expression location.
|
||||||
//
|
//
|
||||||
class DIELoc : public DIEValue, public DIE {
|
class DIELoc : public DIE {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
mutable unsigned Size; // Size in bytes excluding size header.
|
mutable unsigned Size; // Size in bytes excluding size header.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIELoc() : DIEValue(isLoc), Size(0) {}
|
DIELoc() : Size(0) {}
|
||||||
|
|
||||||
/// ComputeSize - Calculate the size of the location expression.
|
/// ComputeSize - Calculate the size of the location expression.
|
||||||
///
|
///
|
||||||
|
@ -512,27 +526,22 @@ public:
|
||||||
return dwarf::DW_FORM_block;
|
return dwarf::DW_FORM_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) { return E->getType() == isLoc; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
/// DIEBlock - Represents a block of values.
|
/// DIEBlock - Represents a block of values.
|
||||||
//
|
//
|
||||||
class DIEBlock : public DIEValue, public DIE {
|
class DIEBlock : public DIE {
|
||||||
friend class DIEValue;
|
|
||||||
|
|
||||||
mutable unsigned Size; // Size in bytes excluding size header.
|
mutable unsigned Size; // Size in bytes excluding size header.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIEBlock() : DIEValue(isBlock), Size(0) {}
|
DIEBlock() : Size(0) {}
|
||||||
|
|
||||||
/// ComputeSize - Calculate the size of the location expression.
|
/// ComputeSize - Calculate the size of the location expression.
|
||||||
///
|
///
|
||||||
|
@ -550,15 +559,11 @@ public:
|
||||||
return dwarf::DW_FORM_block;
|
return dwarf::DW_FORM_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement isa/cast/dyncast.
|
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
static bool classof(const DIEValue *E) { return E->getType() == isBlock; }
|
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
unsigned SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const;
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void printImpl(raw_ostream &O) const;
|
void print(raw_ostream &O) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
|
||||||
dwarf::TagString(Abbrev.getTag()));
|
dwarf::TagString(Abbrev.getTag()));
|
||||||
EmitULEB128(Abbrev.getNumber());
|
EmitULEB128(Abbrev.getNumber());
|
||||||
|
|
||||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
const SmallVectorImpl<DIEValue> &Values = Die.getValues();
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
|
|
||||||
// Emit the DIE attribute values.
|
// Emit the DIE attribute values.
|
||||||
|
@ -277,12 +277,12 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
|
||||||
if (isVerbose()) {
|
if (isVerbose()) {
|
||||||
OutStreamer->AddComment(dwarf::AttributeString(Attr));
|
OutStreamer->AddComment(dwarf::AttributeString(Attr));
|
||||||
if (Attr == dwarf::DW_AT_accessibility)
|
if (Attr == dwarf::DW_AT_accessibility)
|
||||||
OutStreamer->AddComment(dwarf::AccessibilityString(
|
OutStreamer->AddComment(
|
||||||
cast<DIEInteger>(Values[i])->getValue()));
|
dwarf::AccessibilityString(Values[i].getDIEInteger().getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit an attribute using the defined form.
|
// Emit an attribute using the defined form.
|
||||||
Values[i]->EmitValue(this, Form);
|
Values[i].EmitValue(this, Form);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit the DIE children if any.
|
// Emit the DIE children if any.
|
||||||
|
|
|
@ -128,8 +128,8 @@ const DIE *DIE::getUnitOrNull() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIEValue *DIE::findAttribute(dwarf::Attribute Attribute) const {
|
DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
|
||||||
const SmallVectorImpl<DIEValue *> &Values = getValues();
|
const SmallVectorImpl<DIEValue> &Values = getValues();
|
||||||
const DIEAbbrev &Abbrevs = getAbbrev();
|
const DIEAbbrev &Abbrevs = getAbbrev();
|
||||||
|
|
||||||
// Iterate through all the attributes until we find the one we're
|
// Iterate through all the attributes until we find the one we're
|
||||||
|
@ -137,7 +137,7 @@ DIEValue *DIE::findAttribute(dwarf::Attribute Attribute) const {
|
||||||
for (size_t i = 0; i < Values.size(); ++i)
|
for (size_t i = 0; i < Values.size(); ++i)
|
||||||
if (Abbrevs.getData()[i].getAttribute() == Attribute)
|
if (Abbrevs.getData()[i].getAttribute() == Attribute)
|
||||||
return Values[i];
|
return Values[i];
|
||||||
return nullptr;
|
return DIEValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -174,7 +174,7 @@ void DIE::print(raw_ostream &O, unsigned IndentCount) const {
|
||||||
O << " "
|
O << " "
|
||||||
<< dwarf::FormEncodingString(Data[i].getForm())
|
<< dwarf::FormEncodingString(Data[i].getForm())
|
||||||
<< " ";
|
<< " ";
|
||||||
Values[i]->print(O);
|
Values[i].print(O);
|
||||||
O << "\n";
|
O << "\n";
|
||||||
}
|
}
|
||||||
IndentCount -= 2;
|
IndentCount -= 2;
|
||||||
|
@ -193,9 +193,11 @@ void DIE::dump() {
|
||||||
|
|
||||||
void DIEValue::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIEValue::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
switch (Ty) {
|
switch (Ty) {
|
||||||
|
case isNone:
|
||||||
|
llvm_unreachable("Expected valid DIEValue");
|
||||||
#define EMIT_VALUE_IMPL(Kind) \
|
#define EMIT_VALUE_IMPL(Kind) \
|
||||||
case is##Kind: \
|
case is##Kind: \
|
||||||
cast<DIE##Kind>(this)->EmitValueImpl(AP, Form); \
|
getDIE##Kind().EmitValue(AP, Form); \
|
||||||
break;
|
break;
|
||||||
EMIT_VALUE_IMPL(Integer)
|
EMIT_VALUE_IMPL(Integer)
|
||||||
EMIT_VALUE_IMPL(String)
|
EMIT_VALUE_IMPL(String)
|
||||||
|
@ -213,9 +215,11 @@ void DIEValue::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
unsigned DIEValue::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEValue::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
switch (Ty) {
|
switch (Ty) {
|
||||||
|
case isNone:
|
||||||
|
llvm_unreachable("Expected valid DIEValue");
|
||||||
#define SIZE_OF_IMPL(Kind) \
|
#define SIZE_OF_IMPL(Kind) \
|
||||||
case is##Kind: \
|
case is##Kind: \
|
||||||
return cast<DIE##Kind>(this)->SizeOfImpl(AP, Form);
|
return getDIE##Kind().SizeOf(AP, Form);
|
||||||
SIZE_OF_IMPL(Integer)
|
SIZE_OF_IMPL(Integer)
|
||||||
SIZE_OF_IMPL(String)
|
SIZE_OF_IMPL(String)
|
||||||
SIZE_OF_IMPL(Expr)
|
SIZE_OF_IMPL(Expr)
|
||||||
|
@ -234,9 +238,11 @@ unsigned DIEValue::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEValue::print(raw_ostream &O) const {
|
void DIEValue::print(raw_ostream &O) const {
|
||||||
switch (Ty) {
|
switch (Ty) {
|
||||||
|
case isNone:
|
||||||
|
llvm_unreachable("Expected valid DIEValue");
|
||||||
#define PRINT_IMPL(Kind) \
|
#define PRINT_IMPL(Kind) \
|
||||||
case is##Kind: \
|
case is##Kind: \
|
||||||
cast<DIE##Kind>(this)->printImpl(O); \
|
getDIE##Kind().print(O); \
|
||||||
break;
|
break;
|
||||||
PRINT_IMPL(Integer)
|
PRINT_IMPL(Integer)
|
||||||
PRINT_IMPL(String)
|
PRINT_IMPL(String)
|
||||||
|
@ -263,7 +269,7 @@ void DIEValue::dump() const {
|
||||||
|
|
||||||
/// EmitValue - Emit integer of appropriate size.
|
/// EmitValue - Emit integer of appropriate size.
|
||||||
///
|
///
|
||||||
void DIEInteger::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
unsigned Size = ~0U;
|
unsigned Size = ~0U;
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
case dwarf::DW_FORM_flag_present:
|
case dwarf::DW_FORM_flag_present:
|
||||||
|
@ -299,7 +305,7 @@ void DIEInteger::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
|
|
||||||
/// SizeOf - Determine size of integer value in bytes.
|
/// SizeOf - Determine size of integer value in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIEInteger::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
case dwarf::DW_FORM_flag_present: return 0;
|
case dwarf::DW_FORM_flag_present: return 0;
|
||||||
case dwarf::DW_FORM_flag: // Fall thru
|
case dwarf::DW_FORM_flag: // Fall thru
|
||||||
|
@ -328,7 +334,7 @@ unsigned DIEInteger::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEInteger::printImpl(raw_ostream &O) const {
|
void DIEInteger::print(raw_ostream &O) const {
|
||||||
O << "Int: " << (int64_t)Integer << " 0x";
|
O << "Int: " << (int64_t)Integer << " 0x";
|
||||||
O.write_hex(Integer);
|
O.write_hex(Integer);
|
||||||
}
|
}
|
||||||
|
@ -340,13 +346,13 @@ void DIEInteger::printImpl(raw_ostream &O) const {
|
||||||
|
|
||||||
/// EmitValue - Emit expression value.
|
/// EmitValue - Emit expression value.
|
||||||
///
|
///
|
||||||
void DIEExpr::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form));
|
AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SizeOf - Determine size of expression value in bytes.
|
/// SizeOf - Determine size of expression value in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIEExpr::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
if (Form == dwarf::DW_FORM_data4) return 4;
|
if (Form == dwarf::DW_FORM_data4) return 4;
|
||||||
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
||||||
if (Form == dwarf::DW_FORM_strp) return 4;
|
if (Form == dwarf::DW_FORM_strp) return 4;
|
||||||
|
@ -354,7 +360,7 @@ unsigned DIEExpr::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEExpr::printImpl(raw_ostream &O) const { O << "Expr: " << *Expr; }
|
void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -363,7 +369,7 @@ void DIEExpr::printImpl(raw_ostream &O) const { O << "Expr: " << *Expr; }
|
||||||
|
|
||||||
/// EmitValue - Emit label value.
|
/// EmitValue - Emit label value.
|
||||||
///
|
///
|
||||||
void DIELabel::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
AP->EmitLabelReference(Label, SizeOf(AP, Form),
|
AP->EmitLabelReference(Label, SizeOf(AP, Form),
|
||||||
Form == dwarf::DW_FORM_strp ||
|
Form == dwarf::DW_FORM_strp ||
|
||||||
Form == dwarf::DW_FORM_sec_offset ||
|
Form == dwarf::DW_FORM_sec_offset ||
|
||||||
|
@ -372,7 +378,7 @@ void DIELabel::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
/// SizeOf - Determine size of label value in bytes.
|
/// SizeOf - Determine size of label value in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIELabel::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
if (Form == dwarf::DW_FORM_data4) return 4;
|
if (Form == dwarf::DW_FORM_data4) return 4;
|
||||||
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
||||||
if (Form == dwarf::DW_FORM_strp) return 4;
|
if (Form == dwarf::DW_FORM_strp) return 4;
|
||||||
|
@ -380,9 +386,7 @@ unsigned DIELabel::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIELabel::printImpl(raw_ostream &O) const {
|
void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); }
|
||||||
O << "Lbl: " << Label->getName();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -391,13 +395,13 @@ void DIELabel::printImpl(raw_ostream &O) const {
|
||||||
|
|
||||||
/// EmitValue - Emit delta value.
|
/// EmitValue - Emit delta value.
|
||||||
///
|
///
|
||||||
void DIEDelta::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
|
AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SizeOf - Determine size of delta value in bytes.
|
/// SizeOf - Determine size of delta value in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIEDelta::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
if (Form == dwarf::DW_FORM_data4) return 4;
|
if (Form == dwarf::DW_FORM_data4) return 4;
|
||||||
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
if (Form == dwarf::DW_FORM_sec_offset) return 4;
|
||||||
if (Form == dwarf::DW_FORM_strp) return 4;
|
if (Form == dwarf::DW_FORM_strp) return 4;
|
||||||
|
@ -405,7 +409,7 @@ unsigned DIEDelta::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEDelta::printImpl(raw_ostream &O) const {
|
void DIEDelta::print(raw_ostream &O) const {
|
||||||
O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
|
O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -416,7 +420,7 @@ void DIEDelta::printImpl(raw_ostream &O) const {
|
||||||
|
|
||||||
/// EmitValue - Emit string value.
|
/// EmitValue - Emit string value.
|
||||||
///
|
///
|
||||||
void DIEString::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
assert(
|
assert(
|
||||||
(Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
|
(Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
|
||||||
"Expected valid string form");
|
"Expected valid string form");
|
||||||
|
@ -440,7 +444,7 @@ void DIEString::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
/// SizeOf - Determine size of delta value in bytes.
|
/// SizeOf - Determine size of delta value in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIEString::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
assert(
|
assert(
|
||||||
(Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
|
(Form == dwarf::DW_FORM_strp || Form == dwarf::DW_FORM_GNU_str_index) &&
|
||||||
"Expected valid string form");
|
"Expected valid string form");
|
||||||
|
@ -458,7 +462,7 @@ unsigned DIEString::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEString::printImpl(raw_ostream &O) const {
|
void DIEString::print(raw_ostream &O) const {
|
||||||
O << "String: " << S.getString();
|
O << "String: " << S.getString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -469,16 +473,16 @@ void DIEString::printImpl(raw_ostream &O) const {
|
||||||
|
|
||||||
/// EmitValue - Emit debug information entry offset.
|
/// EmitValue - Emit debug information entry offset.
|
||||||
///
|
///
|
||||||
void DIEEntry::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
if (Form == dwarf::DW_FORM_ref_addr) {
|
if (Form == dwarf::DW_FORM_ref_addr) {
|
||||||
const DwarfDebug *DD = AP->getDwarfDebug();
|
const DwarfDebug *DD = AP->getDwarfDebug();
|
||||||
unsigned Addr = Entry.getOffset();
|
unsigned Addr = Entry->getOffset();
|
||||||
assert(!DD->useSplitDwarf() && "TODO: dwo files can't have relocations.");
|
assert(!DD->useSplitDwarf() && "TODO: dwo files can't have relocations.");
|
||||||
// For DW_FORM_ref_addr, output the offset from beginning of debug info
|
// For DW_FORM_ref_addr, output the offset from beginning of debug info
|
||||||
// section. Entry->getOffset() returns the offset from start of the
|
// section. Entry->getOffset() returns the offset from start of the
|
||||||
// compile unit.
|
// compile unit.
|
||||||
DwarfCompileUnit *CU = DD->lookupUnit(Entry.getUnit());
|
DwarfCompileUnit *CU = DD->lookupUnit(Entry->getUnit());
|
||||||
assert(CU && "CUDie should belong to a CU.");
|
assert(CU && "CUDie should belong to a CU.");
|
||||||
Addr += CU->getDebugInfoOffset();
|
Addr += CU->getDebugInfoOffset();
|
||||||
if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
|
if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
|
||||||
|
@ -487,7 +491,7 @@ void DIEEntry::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
else
|
else
|
||||||
AP->OutStreamer->EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP));
|
AP->OutStreamer->EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP));
|
||||||
} else
|
} else
|
||||||
AP->EmitInt32(Entry.getOffset());
|
AP->EmitInt32(Entry->getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DIEEntry::getRefAddrSize(const AsmPrinter *AP) {
|
unsigned DIEEntry::getRefAddrSize(const AsmPrinter *AP) {
|
||||||
|
@ -503,7 +507,7 @@ unsigned DIEEntry::getRefAddrSize(const AsmPrinter *AP) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEEntry::printImpl(raw_ostream &O) const {
|
void DIEEntry::print(raw_ostream &O) const {
|
||||||
O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
|
O << format("Die: 0x%lx", (long)(intptr_t)&Entry);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -511,14 +515,15 @@ void DIEEntry::printImpl(raw_ostream &O) const {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// DIETypeSignature Implementation
|
// DIETypeSignature Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
void DIETypeSignature::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
void DIETypeSignature::EmitValue(const AsmPrinter *Asm,
|
||||||
|
dwarf::Form Form) const {
|
||||||
assert(Form == dwarf::DW_FORM_ref_sig8);
|
assert(Form == dwarf::DW_FORM_ref_sig8);
|
||||||
Asm->OutStreamer->EmitIntValue(Unit.getTypeSignature(), 8);
|
Asm->OutStreamer->EmitIntValue(Unit->getTypeSignature(), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIETypeSignature::printImpl(raw_ostream &O) const {
|
void DIETypeSignature::print(raw_ostream &O) const {
|
||||||
O << format("Type Unit: 0x%lx", Unit.getTypeSignature());
|
O << format("Type Unit: 0x%lx", Unit->getTypeSignature());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -532,7 +537,7 @@ unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
|
||||||
if (!Size) {
|
if (!Size) {
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
||||||
Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
|
Size += Values[i].SizeOf(AP, AbbrevData[i].getForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
|
@ -540,7 +545,7 @@ unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const {
|
||||||
|
|
||||||
/// EmitValue - Emit location data.
|
/// EmitValue - Emit location data.
|
||||||
///
|
///
|
||||||
void DIELoc::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
default: llvm_unreachable("Improper form for block");
|
default: llvm_unreachable("Improper form for block");
|
||||||
case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
|
case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
|
||||||
|
@ -553,12 +558,12 @@ void DIELoc::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
|
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
||||||
Values[i]->EmitValue(Asm, AbbrevData[i].getForm());
|
Values[i].EmitValue(Asm, AbbrevData[i].getForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SizeOf - Determine size of location data in bytes.
|
/// SizeOf - Determine size of location data in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIELoc::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
|
case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
|
||||||
case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
|
case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
|
||||||
|
@ -571,7 +576,7 @@ unsigned DIELoc::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIELoc::printImpl(raw_ostream &O) const {
|
void DIELoc::print(raw_ostream &O) const {
|
||||||
O << "ExprLoc: ";
|
O << "ExprLoc: ";
|
||||||
DIE::print(O, 5);
|
DIE::print(O, 5);
|
||||||
}
|
}
|
||||||
|
@ -587,7 +592,7 @@ unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
|
||||||
if (!Size) {
|
if (!Size) {
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
||||||
Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
|
Size += Values[i].SizeOf(AP, AbbrevData[i].getForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
|
@ -595,7 +600,7 @@ unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const {
|
||||||
|
|
||||||
/// EmitValue - Emit block data.
|
/// EmitValue - Emit block data.
|
||||||
///
|
///
|
||||||
void DIEBlock::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
default: llvm_unreachable("Improper form for block");
|
default: llvm_unreachable("Improper form for block");
|
||||||
case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
|
case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
|
||||||
|
@ -606,12 +611,12 @@ void DIEBlock::EmitValueImpl(const AsmPrinter *Asm, dwarf::Form Form) const {
|
||||||
|
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
||||||
Values[i]->EmitValue(Asm, AbbrevData[i].getForm());
|
Values[i].EmitValue(Asm, AbbrevData[i].getForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SizeOf - Determine size of block data in bytes.
|
/// SizeOf - Determine size of block data in bytes.
|
||||||
///
|
///
|
||||||
unsigned DIEBlock::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
switch (Form) {
|
switch (Form) {
|
||||||
case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
|
case dwarf::DW_FORM_block1: return Size + sizeof(int8_t);
|
||||||
case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
|
case dwarf::DW_FORM_block2: return Size + sizeof(int16_t);
|
||||||
|
@ -622,7 +627,7 @@ unsigned DIEBlock::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIEBlock::printImpl(raw_ostream &O) const {
|
void DIEBlock::print(raw_ostream &O) const {
|
||||||
O << "Blk: ";
|
O << "Blk: ";
|
||||||
DIE::print(O, 5);
|
DIE::print(O, 5);
|
||||||
}
|
}
|
||||||
|
@ -632,7 +637,7 @@ void DIEBlock::printImpl(raw_ostream &O) const {
|
||||||
// DIELocList Implementation
|
// DIELocList Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
unsigned DIELocList::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
if (Form == dwarf::DW_FORM_data4)
|
if (Form == dwarf::DW_FORM_data4)
|
||||||
return 4;
|
return 4;
|
||||||
if (Form == dwarf::DW_FORM_sec_offset)
|
if (Form == dwarf::DW_FORM_sec_offset)
|
||||||
|
@ -642,7 +647,7 @@ unsigned DIELocList::SizeOfImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
|
|
||||||
/// EmitValue - Emit label value.
|
/// EmitValue - Emit label value.
|
||||||
///
|
///
|
||||||
void DIELocList::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
DwarfDebug *DD = AP->getDwarfDebug();
|
DwarfDebug *DD = AP->getDwarfDebug();
|
||||||
MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
|
MCSymbol *Label = DD->getDebugLocs().getList(Index).Label;
|
||||||
|
|
||||||
|
@ -653,8 +658,5 @@ void DIELocList::EmitValueImpl(const AsmPrinter *AP, dwarf::Form Form) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void DIELocList::printImpl(raw_ostream &O) const {
|
void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; }
|
||||||
O << "LocList: " << Index;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,18 +31,14 @@ using namespace llvm;
|
||||||
/// \brief Grabs the string in whichever attribute is passed in and returns
|
/// \brief Grabs the string in whichever attribute is passed in and returns
|
||||||
/// a reference to it.
|
/// a reference to it.
|
||||||
static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) {
|
static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr) {
|
||||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
const auto &Values = Die.getValues();
|
||||||
const DIEAbbrev &Abbrevs = Die.getAbbrev();
|
const DIEAbbrev &Abbrevs = Die.getAbbrev();
|
||||||
|
|
||||||
// Iterate through all the attributes until we find the one we're
|
// Iterate through all the attributes until we find the one we're
|
||||||
// looking for, if we can't find it return an empty string.
|
// looking for, if we can't find it return an empty string.
|
||||||
for (size_t i = 0; i < Values.size(); ++i) {
|
for (size_t i = 0; i < Values.size(); ++i) {
|
||||||
if (Abbrevs.getData()[i].getAttribute() == Attr) {
|
if (Abbrevs.getData()[i].getAttribute() == Attr)
|
||||||
DIEValue *V = Values[i];
|
return Values[i].getDIEString().getString();
|
||||||
assert(isa<DIEString>(V) && "String requested. Not a string.");
|
|
||||||
DIEString *S = cast<DIEString>(V);
|
|
||||||
return S->getString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return StringRef("");
|
return StringRef("");
|
||||||
}
|
}
|
||||||
|
@ -123,7 +119,7 @@ void DIEHash::addParentContext(const DIE &Parent) {
|
||||||
|
|
||||||
// Collect all of the attributes for a particular DIE in single structure.
|
// Collect all of the attributes for a particular DIE in single structure.
|
||||||
void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) {
|
void DIEHash::collectAttributes(const DIE &Die, DIEAttrs &Attrs) {
|
||||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
const SmallVectorImpl<DIEValue> &Values = Die.getValues();
|
||||||
const DIEAbbrev &Abbrevs = Die.getAbbrev();
|
const DIEAbbrev &Abbrevs = Die.getAbbrev();
|
||||||
|
|
||||||
#define COLLECT_ATTR(NAME) \
|
#define COLLECT_ATTR(NAME) \
|
||||||
|
@ -274,11 +270,9 @@ void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
|
||||||
|
|
||||||
// Hash all of the values in a block like set of values. This assumes that
|
// Hash all of the values in a block like set of values. This assumes that
|
||||||
// all of the data is going to be added as integers.
|
// all of the data is going to be added as integers.
|
||||||
void DIEHash::hashBlockData(const SmallVectorImpl<DIEValue *> &Values) {
|
void DIEHash::hashBlockData(const SmallVectorImpl<DIEValue> &Values) {
|
||||||
for (SmallVectorImpl<DIEValue *>::const_iterator I = Values.begin(),
|
for (auto I = Values.begin(), E = Values.end(); I != E; ++I)
|
||||||
E = Values.end();
|
Hash.update((uint64_t)I->getDIEInteger().getValue());
|
||||||
I != E; ++I)
|
|
||||||
Hash.update((uint64_t)cast<DIEInteger>(*I)->getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash the contents of a loclistptr class.
|
// Hash the contents of a loclistptr class.
|
||||||
|
@ -293,7 +287,7 @@ void DIEHash::hashLocList(const DIELocList &LocList) {
|
||||||
// Hash an individual attribute \param Attr based on the type of attribute and
|
// Hash an individual attribute \param Attr based on the type of attribute and
|
||||||
// the form.
|
// the form.
|
||||||
void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
const DIEValue *Value = Attr.Val;
|
const DIEValue &Value = Attr.Val;
|
||||||
const DIEAbbrevData *Desc = Attr.Desc;
|
const DIEAbbrevData *Desc = Attr.Desc;
|
||||||
dwarf::Attribute Attribute = Desc->getAttribute();
|
dwarf::Attribute Attribute = Desc->getAttribute();
|
||||||
|
|
||||||
|
@ -304,12 +298,15 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
// computation is limited to the following: DW_FORM_sdata, DW_FORM_flag,
|
// computation is limited to the following: DW_FORM_sdata, DW_FORM_flag,
|
||||||
// DW_FORM_string, and DW_FORM_block.
|
// DW_FORM_string, and DW_FORM_block.
|
||||||
|
|
||||||
switch (Value->getType()) {
|
switch (Value.getType()) {
|
||||||
|
case DIEValue::isNone:
|
||||||
|
llvm_unreachable("Expected valid DIEValue");
|
||||||
|
|
||||||
// 7.27 Step 3
|
// 7.27 Step 3
|
||||||
// ... An attribute that refers to another type entry T is processed as
|
// ... An attribute that refers to another type entry T is processed as
|
||||||
// follows:
|
// follows:
|
||||||
case DIEValue::isEntry:
|
case DIEValue::isEntry:
|
||||||
hashDIEEntry(Attribute, Tag, cast<DIEEntry>(Value)->getEntry());
|
hashDIEEntry(Attribute, Tag, Value.getDIEEntry().getEntry());
|
||||||
break;
|
break;
|
||||||
case DIEValue::isInteger: {
|
case DIEValue::isInteger: {
|
||||||
addULEB128('A');
|
addULEB128('A');
|
||||||
|
@ -322,14 +319,14 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
case dwarf::DW_FORM_udata:
|
case dwarf::DW_FORM_udata:
|
||||||
case dwarf::DW_FORM_sdata:
|
case dwarf::DW_FORM_sdata:
|
||||||
addULEB128(dwarf::DW_FORM_sdata);
|
addULEB128(dwarf::DW_FORM_sdata);
|
||||||
addSLEB128((int64_t)cast<DIEInteger>(Value)->getValue());
|
addSLEB128((int64_t)Value.getDIEInteger().getValue());
|
||||||
break;
|
break;
|
||||||
// DW_FORM_flag_present is just flag with a value of one. We still give it a
|
// DW_FORM_flag_present is just flag with a value of one. We still give it a
|
||||||
// value so just use the value.
|
// value so just use the value.
|
||||||
case dwarf::DW_FORM_flag_present:
|
case dwarf::DW_FORM_flag_present:
|
||||||
case dwarf::DW_FORM_flag:
|
case dwarf::DW_FORM_flag:
|
||||||
addULEB128(dwarf::DW_FORM_flag);
|
addULEB128(dwarf::DW_FORM_flag);
|
||||||
addULEB128((int64_t)cast<DIEInteger>(Value)->getValue());
|
addULEB128((int64_t)Value.getDIEInteger().getValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Unknown integer form!");
|
llvm_unreachable("Unknown integer form!");
|
||||||
|
@ -340,7 +337,7 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
addULEB128('A');
|
addULEB128('A');
|
||||||
addULEB128(Attribute);
|
addULEB128(Attribute);
|
||||||
addULEB128(dwarf::DW_FORM_string);
|
addULEB128(dwarf::DW_FORM_string);
|
||||||
addString(cast<DIEString>(Value)->getString());
|
addString(Value.getDIEString().getString());
|
||||||
break;
|
break;
|
||||||
case DIEValue::isBlock:
|
case DIEValue::isBlock:
|
||||||
case DIEValue::isLoc:
|
case DIEValue::isLoc:
|
||||||
|
@ -348,17 +345,17 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
addULEB128('A');
|
addULEB128('A');
|
||||||
addULEB128(Attribute);
|
addULEB128(Attribute);
|
||||||
addULEB128(dwarf::DW_FORM_block);
|
addULEB128(dwarf::DW_FORM_block);
|
||||||
if (isa<DIEBlock>(Value)) {
|
if (Value.getType() == DIEValue::isBlock) {
|
||||||
addULEB128(cast<DIEBlock>(Value)->ComputeSize(AP));
|
addULEB128(Value.getDIEBlock().ComputeSize(AP));
|
||||||
hashBlockData(cast<DIEBlock>(Value)->getValues());
|
hashBlockData(Value.getDIEBlock().getValues());
|
||||||
} else if (isa<DIELoc>(Value)) {
|
} else if (Value.getType() == DIEValue::isLoc) {
|
||||||
addULEB128(cast<DIELoc>(Value)->ComputeSize(AP));
|
addULEB128(Value.getDIELoc().ComputeSize(AP));
|
||||||
hashBlockData(cast<DIELoc>(Value)->getValues());
|
hashBlockData(Value.getDIELoc().getValues());
|
||||||
} else {
|
} else {
|
||||||
// We could add the block length, but that would take
|
// We could add the block length, but that would take
|
||||||
// a bit of work and not add a lot of uniqueness
|
// a bit of work and not add a lot of uniqueness
|
||||||
// to the hash in some way we could test.
|
// to the hash in some way we could test.
|
||||||
hashLocList(*cast<DIELocList>(Value));
|
hashLocList(Value.getDIELocList());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// FIXME: It's uncertain whether or not we should handle this at the moment.
|
// FIXME: It's uncertain whether or not we should handle this at the moment.
|
||||||
|
@ -375,7 +372,7 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
|
||||||
void DIEHash::hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag) {
|
void DIEHash::hashAttributes(const DIEAttrs &Attrs, dwarf::Tag Tag) {
|
||||||
#define ADD_ATTR(ATTR) \
|
#define ADD_ATTR(ATTR) \
|
||||||
{ \
|
{ \
|
||||||
if (ATTR.Val != 0) \
|
if (ATTR.Val) \
|
||||||
hashAttribute(ATTR, Tag); \
|
hashAttribute(ATTR, Tag); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class DIEHash {
|
||||||
|
|
||||||
// The entry for a particular attribute.
|
// The entry for a particular attribute.
|
||||||
struct AttrEntry {
|
struct AttrEntry {
|
||||||
const DIEValue *Val;
|
DIEValue Val;
|
||||||
const DIEAbbrevData *Desc;
|
const DIEAbbrevData *Desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ private:
|
||||||
|
|
||||||
/// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block or
|
/// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block or
|
||||||
/// DW_FORM_exprloc.
|
/// DW_FORM_exprloc.
|
||||||
void hashBlockData(const SmallVectorImpl<DIEValue *> &Values);
|
void hashBlockData(const SmallVectorImpl<DIEValue> &Values);
|
||||||
|
|
||||||
/// \brief Hashes the contents pointed to in the .debug_loc section.
|
/// \brief Hashes the contents pointed to in the .debug_loc section.
|
||||||
void hashLocList(const DIELocList &LocList);
|
void hashLocList(const DIELocList &LocList);
|
||||||
|
|
|
@ -42,8 +42,7 @@ void DwarfCompileUnit::addLabelAddress(DIE &Die, dwarf::Attribute Attribute,
|
||||||
DD->addArangeLabel(SymbolCU(this, Label));
|
DD->addArangeLabel(SymbolCU(this, Label));
|
||||||
|
|
||||||
unsigned idx = DD->getAddressPool().getIndex(Label);
|
unsigned idx = DD->getAddressPool().getIndex(Label);
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
|
Die.addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, DIEInteger(idx));
|
||||||
Die.addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
|
void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
|
||||||
|
@ -53,8 +52,7 @@ void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
|
||||||
DD->addArangeLabel(SymbolCU(this, Label));
|
DD->addArangeLabel(SymbolCU(this, Label));
|
||||||
|
|
||||||
Die.addValue(Attribute, dwarf::DW_FORM_addr,
|
Die.addValue(Attribute, dwarf::DW_FORM_addr,
|
||||||
Label ? (DIEValue *)new (DIEValueAllocator) DIELabel(Label)
|
Label ? DIEValue(DIELabel(Label)) : DIEValue(DIEInteger(0)));
|
||||||
: new (DIEValueAllocator) DIEInteger(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
|
unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
|
||||||
|
@ -145,7 +143,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
||||||
bool addToAccelTable = false;
|
bool addToAccelTable = false;
|
||||||
if (auto *Global = dyn_cast_or_null<GlobalVariable>(GV->getVariable())) {
|
if (auto *Global = dyn_cast_or_null<GlobalVariable>(GV->getVariable())) {
|
||||||
addToAccelTable = true;
|
addToAccelTable = true;
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
const MCSymbol *Sym = Asm->getSymbol(Global);
|
const MCSymbol *Sym = Asm->getSymbol(Global);
|
||||||
if (Global->isThreadLocal()) {
|
if (Global->isThreadLocal()) {
|
||||||
// FIXME: Make this work with -gsplit-dwarf.
|
// FIXME: Make this work with -gsplit-dwarf.
|
||||||
|
@ -183,7 +181,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
||||||
} else if (const ConstantExpr *CE = getMergedGlobalExpr(GV->getVariable())) {
|
} else if (const ConstantExpr *CE = getMergedGlobalExpr(GV->getVariable())) {
|
||||||
addToAccelTable = true;
|
addToAccelTable = true;
|
||||||
// GV is a merged global.
|
// GV is a merged global.
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
Value *Ptr = CE->getOperand(0);
|
Value *Ptr = CE->getOperand(0);
|
||||||
MCSymbol *Sym = Asm->getSymbol(cast<GlobalValue>(Ptr));
|
MCSymbol *Sym = Asm->getSymbol(cast<GlobalValue>(Ptr));
|
||||||
DD->addArangeLabel(SymbolCU(this, Sym));
|
DD->addArangeLabel(SymbolCU(this, Sym));
|
||||||
|
@ -365,10 +363,9 @@ void DwarfCompileUnit::constructScopeDIE(
|
||||||
|
|
||||||
void DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
|
||||||
const MCSymbol *Hi, const MCSymbol *Lo) {
|
const MCSymbol *Hi, const MCSymbol *Lo) {
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo);
|
|
||||||
Die.addValue(Attribute, DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
|
Die.addValue(Attribute, DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
|
||||||
: dwarf::DW_FORM_data4,
|
: dwarf::DW_FORM_data4,
|
||||||
Value);
|
new (DIEValueAllocator) DIEDelta(Hi, Lo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
|
void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
|
||||||
|
@ -515,7 +512,7 @@ DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
|
||||||
return VariableDie;
|
return VariableDie;
|
||||||
|
|
||||||
auto Expr = DV.getExpression().begin();
|
auto Expr = DV.getExpression().begin();
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
|
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
|
||||||
for (auto FI : DV.getFrameIndex()) {
|
for (auto FI : DV.getFrameIndex()) {
|
||||||
unsigned FrameReg = 0;
|
unsigned FrameReg = 0;
|
||||||
|
@ -739,7 +736,7 @@ void DwarfCompileUnit::addVariableAddress(const DbgVariable &DV, DIE &Die,
|
||||||
/// Add an address attribute to a die based on the location provided.
|
/// Add an address attribute to a die based on the location provided.
|
||||||
void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute,
|
||||||
const MachineLocation &Location) {
|
const MachineLocation &Location) {
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
|
|
||||||
bool validReg;
|
bool validReg;
|
||||||
if (Location.isReg())
|
if (Location.isReg())
|
||||||
|
@ -761,7 +758,7 @@ void DwarfCompileUnit::addAddress(DIE &Die, dwarf::Attribute Attribute,
|
||||||
void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
|
void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
|
||||||
dwarf::Attribute Attribute,
|
dwarf::Attribute Attribute,
|
||||||
const MachineLocation &Location) {
|
const MachineLocation &Location) {
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
|
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
|
||||||
assert(DV.getExpression().size() == 1);
|
assert(DV.getExpression().size() == 1);
|
||||||
const DIExpression *Expr = DV.getExpression().back();
|
const DIExpression *Expr = DV.getExpression().back();
|
||||||
|
@ -782,10 +779,9 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
|
||||||
/// Add a Dwarf loclistptr attribute data and value.
|
/// Add a Dwarf loclistptr attribute data and value.
|
||||||
void DwarfCompileUnit::addLocationList(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfCompileUnit::addLocationList(DIE &Die, dwarf::Attribute Attribute,
|
||||||
unsigned Index) {
|
unsigned Index) {
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIELocList(Index);
|
|
||||||
dwarf::Form Form = DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
|
dwarf::Form Form = DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
|
||||||
: dwarf::DW_FORM_data4;
|
: dwarf::DW_FORM_data4;
|
||||||
Die.addValue(Attribute, Form, Value);
|
Die.addValue(Attribute, Form, DIELocList(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
|
void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
|
||||||
|
@ -802,8 +798,7 @@ void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
|
||||||
/// Add a Dwarf expression attribute data and value.
|
/// Add a Dwarf expression attribute data and value.
|
||||||
void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
|
void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
|
||||||
const MCExpr *Expr) {
|
const MCExpr *Expr) {
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEExpr(Expr);
|
Die.addValue((dwarf::Attribute)0, Form, DIEExpr(Expr));
|
||||||
Die.addValue((dwarf::Attribute)0, Form, Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
|
void DwarfCompileUnit::applySubprogramAttributesToDefinition(
|
||||||
|
|
|
@ -1340,9 +1340,8 @@ static dwarf::PubIndexEntryDescriptor computeIndexValue(DwarfUnit *CU,
|
||||||
|
|
||||||
// We could have a specification DIE that has our most of our knowledge,
|
// We could have a specification DIE that has our most of our knowledge,
|
||||||
// look for that now.
|
// look for that now.
|
||||||
DIEValue *SpecVal = Die->findAttribute(dwarf::DW_AT_specification);
|
if (DIEValue SpecVal = Die->findAttribute(dwarf::DW_AT_specification)) {
|
||||||
if (SpecVal) {
|
DIE &SpecDIE = SpecVal.getDIEEntry().getEntry();
|
||||||
DIE &SpecDIE = cast<DIEEntry>(SpecVal)->getEntry();
|
|
||||||
if (SpecDIE.findAttribute(dwarf::DW_AT_external))
|
if (SpecDIE.findAttribute(dwarf::DW_AT_external))
|
||||||
Linkage = dwarf::GIEL_EXTERNAL;
|
Linkage = dwarf::GIEL_EXTERNAL;
|
||||||
} else if (Die->findAttribute(dwarf::DW_AT_external))
|
} else if (Die->findAttribute(dwarf::DW_AT_external))
|
||||||
|
|
|
@ -94,13 +94,13 @@ unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) {
|
||||||
// Start the size with the size of abbreviation code.
|
// Start the size with the size of abbreviation code.
|
||||||
Offset += getULEB128Size(Die.getAbbrevNumber());
|
Offset += getULEB128Size(Die.getAbbrevNumber());
|
||||||
|
|
||||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
const SmallVectorImpl<DIEValue> &Values = Die.getValues();
|
||||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||||
|
|
||||||
// Size the DIE attribute values.
|
// Size the DIE attribute values.
|
||||||
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
for (unsigned i = 0, N = Values.size(); i < N; ++i)
|
||||||
// Size attribute value.
|
// Size attribute value.
|
||||||
Offset += Values[i]->SizeOf(Asm, AbbrevData[i].getForm());
|
Offset += Values[i].SizeOf(Asm, AbbrevData[i].getForm());
|
||||||
|
|
||||||
// Get the children.
|
// Get the children.
|
||||||
const auto &Children = Die.getChildren();
|
const auto &Children = Die.getChildren();
|
||||||
|
|
|
@ -70,7 +70,6 @@ DwarfUnit::DwarfUnit(unsigned UID, dwarf::Tag UnitTag,
|
||||||
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
|
DD(DW), DU(DWU), IndexTyDie(nullptr), Section(nullptr) {
|
||||||
assert(UnitTag == dwarf::DW_TAG_compile_unit ||
|
assert(UnitTag == dwarf::DW_TAG_compile_unit ||
|
||||||
UnitTag == dwarf::DW_TAG_type_unit);
|
UnitTag == dwarf::DW_TAG_type_unit);
|
||||||
DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
|
DwarfTypeUnit::DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
|
||||||
|
@ -89,11 +88,6 @@ DwarfUnit::~DwarfUnit() {
|
||||||
DIELocs[j]->~DIELoc();
|
DIELocs[j]->~DIELoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
DIEEntry *DwarfUnit::createDIEEntry(DIE &Entry) {
|
|
||||||
DIEEntry *Value = new (DIEValueAllocator) DIEEntry(Entry);
|
|
||||||
return Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t DwarfUnit::getDefaultLowerBound() const {
|
int64_t DwarfUnit::getDefaultLowerBound() const {
|
||||||
switch (getLanguage()) {
|
switch (getLanguage()) {
|
||||||
default:
|
default:
|
||||||
|
@ -190,18 +184,16 @@ void DwarfUnit::insertDIE(const DINode *Desc, DIE *D) {
|
||||||
|
|
||||||
void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
|
void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
|
||||||
if (DD->getDwarfVersion() >= 4)
|
if (DD->getDwarfVersion() >= 4)
|
||||||
Die.addValue(Attribute, dwarf::DW_FORM_flag_present, DIEIntegerOne);
|
Die.addValue(Attribute, dwarf::DW_FORM_flag_present, DIEInteger(1));
|
||||||
else
|
else
|
||||||
Die.addValue(Attribute, dwarf::DW_FORM_flag, DIEIntegerOne);
|
Die.addValue(Attribute, dwarf::DW_FORM_flag, DIEInteger(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addUInt(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfUnit::addUInt(DIE &Die, dwarf::Attribute Attribute,
|
||||||
Optional<dwarf::Form> Form, uint64_t Integer) {
|
Optional<dwarf::Form> Form, uint64_t Integer) {
|
||||||
if (!Form)
|
if (!Form)
|
||||||
Form = DIEInteger::BestForm(false, Integer);
|
Form = DIEInteger::BestForm(false, Integer);
|
||||||
DIEValue *Value = Integer == 1 ? DIEIntegerOne : new (DIEValueAllocator)
|
Die.addValue(Attribute, *Form, DIEInteger(Integer));
|
||||||
DIEInteger(Integer);
|
|
||||||
Die.addValue(Attribute, *Form, Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addUInt(DIE &Block, dwarf::Form Form, uint64_t Integer) {
|
void DwarfUnit::addUInt(DIE &Block, dwarf::Form Form, uint64_t Integer) {
|
||||||
|
@ -212,8 +204,7 @@ void DwarfUnit::addSInt(DIE &Die, dwarf::Attribute Attribute,
|
||||||
Optional<dwarf::Form> Form, int64_t Integer) {
|
Optional<dwarf::Form> Form, int64_t Integer) {
|
||||||
if (!Form)
|
if (!Form)
|
||||||
Form = DIEInteger::BestForm(true, Integer);
|
Form = DIEInteger::BestForm(true, Integer);
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEInteger(Integer);
|
Die.addValue(Attribute, *Form, DIEInteger(Integer));
|
||||||
Die.addValue(Attribute, *Form, Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
|
void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
|
||||||
|
@ -225,14 +216,12 @@ void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
|
||||||
StringRef String) {
|
StringRef String) {
|
||||||
Die.addValue(Attribute,
|
Die.addValue(Attribute,
|
||||||
isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp,
|
isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp,
|
||||||
new (DIEValueAllocator)
|
|
||||||
DIEString(DU->getStringPool().getEntry(*Asm, String)));
|
DIEString(DU->getStringPool().getEntry(*Asm, String)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
|
void DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
|
||||||
const MCSymbol *Label) {
|
const MCSymbol *Label) {
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);
|
Die.addValue(Attribute, Form, DIELabel(Label));
|
||||||
Die.addValue(Attribute, Form, Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label) {
|
void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label) {
|
||||||
|
@ -265,12 +254,12 @@ void DwarfUnit::addOpAddress(DIELoc &Die, const MCSymbol *Sym) {
|
||||||
|
|
||||||
void DwarfUnit::addLabelDelta(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfUnit::addLabelDelta(DIE &Die, dwarf::Attribute Attribute,
|
||||||
const MCSymbol *Hi, const MCSymbol *Lo) {
|
const MCSymbol *Hi, const MCSymbol *Lo) {
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo);
|
Die.addValue(Attribute, dwarf::DW_FORM_data4,
|
||||||
Die.addValue(Attribute, dwarf::DW_FORM_data4, Value);
|
new (DIEValueAllocator) DIEDelta(Hi, Lo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry) {
|
void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry) {
|
||||||
addDIEEntry(Die, Attribute, createDIEEntry(Entry));
|
addDIEEntry(Die, Attribute, DIEEntry(Entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type) {
|
void DwarfUnit::addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type) {
|
||||||
|
@ -281,13 +270,13 @@ void DwarfUnit::addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type) {
|
||||||
addFlag(Die, dwarf::DW_AT_declaration);
|
addFlag(Die, dwarf::DW_AT_declaration);
|
||||||
|
|
||||||
Die.addValue(dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
|
Die.addValue(dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
|
||||||
new (DIEValueAllocator) DIETypeSignature(Type));
|
DIETypeSignature(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
|
||||||
DIEEntry *Entry) {
|
DIEEntry Entry) {
|
||||||
const DIE *DieCU = Die.getUnitOrNull();
|
const DIE *DieCU = Die.getUnitOrNull();
|
||||||
const DIE *EntryCU = Entry->getEntry().getUnitOrNull();
|
const DIE *EntryCU = Entry.getEntry().getUnitOrNull();
|
||||||
if (!DieCU)
|
if (!DieCU)
|
||||||
// We assume that Die belongs to this CU, if it is not linked to any CU yet.
|
// We assume that Die belongs to this CU, if it is not linked to any CU yet.
|
||||||
DieCU = &getUnitDie();
|
DieCU = &getUnitDie();
|
||||||
|
@ -471,7 +460,7 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
|
||||||
|
|
||||||
// Decode the original location, and use that as the start of the byref
|
// Decode the original location, and use that as the start of the byref
|
||||||
// variable's location.
|
// variable's location.
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
|
|
||||||
bool validReg;
|
bool validReg;
|
||||||
if (Location.isReg())
|
if (Location.isReg())
|
||||||
|
@ -588,7 +577,7 @@ static uint64_t getBaseTypeSize(DwarfDebug *DD, const DIDerivedType *Ty) {
|
||||||
|
|
||||||
void DwarfUnit::addConstantFPValue(DIE &Die, const MachineOperand &MO) {
|
void DwarfUnit::addConstantFPValue(DIE &Die, const MachineOperand &MO) {
|
||||||
assert(MO.isFPImm() && "Invalid machine operand!");
|
assert(MO.isFPImm() && "Invalid machine operand!");
|
||||||
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
|
DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
|
||||||
APFloat FPImm = MO.getFPImm()->getValueAPF();
|
APFloat FPImm = MO.getFPImm()->getValueAPF();
|
||||||
|
|
||||||
// Get the raw data form of the floating point.
|
// Get the raw data form of the floating point.
|
||||||
|
@ -644,7 +633,7 @@ void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, bool Unsigned) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
|
DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
|
||||||
|
|
||||||
// Get the raw data form of the large APInt.
|
// Get the raw data form of the large APInt.
|
||||||
const uint64_t *Ptr64 = Val.getRawData();
|
const uint64_t *Ptr64 = Val.getRawData();
|
||||||
|
@ -777,22 +766,7 @@ void DwarfUnit::updateAcceleratorTables(const DIScope *Context,
|
||||||
void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
|
void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
|
||||||
dwarf::Attribute Attribute) {
|
dwarf::Attribute Attribute) {
|
||||||
assert(Ty && "Trying to add a type that doesn't exist?");
|
assert(Ty && "Trying to add a type that doesn't exist?");
|
||||||
|
addDIEEntry(Entity, Attribute, DIEEntry(*getOrCreateTypeDIE(Ty)));
|
||||||
// Check for pre-existence.
|
|
||||||
DIEEntry *Entry = getDIEEntry(Ty);
|
|
||||||
// If it exists then use the existing value.
|
|
||||||
if (Entry) {
|
|
||||||
addDIEEntry(Entity, Attribute, Entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct type.
|
|
||||||
DIE *Buffer = getOrCreateTypeDIE(Ty);
|
|
||||||
|
|
||||||
// Set up proxy.
|
|
||||||
Entry = createDIEEntry(*Buffer);
|
|
||||||
insertDIEEntry(Ty, Entry);
|
|
||||||
addDIEEntry(Entity, Attribute, Entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
|
std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
|
||||||
|
@ -969,12 +943,6 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
|
||||||
if (unsigned PropertyAttributes = Property->getAttributes())
|
if (unsigned PropertyAttributes = Property->getAttributes())
|
||||||
addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, None,
|
addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, None,
|
||||||
PropertyAttributes);
|
PropertyAttributes);
|
||||||
|
|
||||||
DIEEntry *Entry = getDIEEntry(Element);
|
|
||||||
if (!Entry) {
|
|
||||||
Entry = createDIEEntry(ElemDie);
|
|
||||||
insertDIEEntry(Element, Entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1061,7 +1029,7 @@ void DwarfUnit::constructTemplateValueParameterDIE(
|
||||||
else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
|
else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
|
||||||
// For declaration non-type template parameters (such as global values and
|
// For declaration non-type template parameters (such as global values and
|
||||||
// functions)
|
// functions)
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
|
||||||
addOpAddress(*Loc, Asm->getSymbol(GV));
|
addOpAddress(*Loc, Asm->getSymbol(GV));
|
||||||
// Emit DW_OP_stack_value to use the address as the immediate value of the
|
// Emit DW_OP_stack_value to use the address as the immediate value of the
|
||||||
// parameter, rather than a pointer to it.
|
// parameter, rather than a pointer to it.
|
||||||
|
@ -1354,7 +1322,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
|
||||||
// expression to extract appropriate offset from vtable.
|
// expression to extract appropriate offset from vtable.
|
||||||
// BaseAddr = ObAddr + *((*ObAddr) - Offset)
|
// BaseAddr = ObAddr + *((*ObAddr) - Offset)
|
||||||
|
|
||||||
DIELoc *VBaseLocationDie = new (DIEValueAllocator) DIELoc();
|
DIELoc *VBaseLocationDie = new (DIEValueAllocator) DIELoc;
|
||||||
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
|
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
|
||||||
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
|
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
|
||||||
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
|
addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
|
||||||
|
@ -1393,7 +1361,7 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
|
||||||
OffsetInBytes = DT->getOffsetInBits() >> 3;
|
OffsetInBytes = DT->getOffsetInBits() >> 3;
|
||||||
|
|
||||||
if (DD->getDwarfVersion() <= 2) {
|
if (DD->getDwarfVersion() <= 2) {
|
||||||
DIELoc *MemLocationDie = new (DIEValueAllocator) DIELoc();
|
DIELoc *MemLocationDie = new (DIEValueAllocator) DIELoc;
|
||||||
addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
|
addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
|
||||||
addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
|
addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
|
||||||
addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
|
addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
|
||||||
|
@ -1417,10 +1385,10 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
|
||||||
dwarf::DW_VIRTUALITY_virtual);
|
dwarf::DW_VIRTUALITY_virtual);
|
||||||
|
|
||||||
// Objective-C properties.
|
// Objective-C properties.
|
||||||
if (MDNode *PNode = DT->getObjCProperty())
|
if (DINode *PNode = DT->getObjCProperty())
|
||||||
if (DIEEntry *PropertyDie = getDIEEntry(PNode))
|
if (DIE *PDie = getDIE(PNode))
|
||||||
MemberDie.addValue(dwarf::DW_AT_APPLE_property, dwarf::DW_FORM_ref4,
|
MemberDie.addValue(dwarf::DW_AT_APPLE_property, dwarf::DW_FORM_ref4,
|
||||||
PropertyDie);
|
DIEEntry(*PDie));
|
||||||
|
|
||||||
if (DT->isArtificial())
|
if (DT->isArtificial())
|
||||||
addFlag(MemberDie, dwarf::DW_AT_artificial);
|
addFlag(MemberDie, dwarf::DW_AT_artificial);
|
||||||
|
|
|
@ -93,10 +93,6 @@ protected:
|
||||||
/// information entries.
|
/// information entries.
|
||||||
DenseMap<const MDNode *, DIE *> MDNodeToDieMap;
|
DenseMap<const MDNode *, DIE *> MDNodeToDieMap;
|
||||||
|
|
||||||
/// Tracks the mapping of unit level debug information descriptors to debug
|
|
||||||
/// information entries using a DIEEntry proxy.
|
|
||||||
DenseMap<const MDNode *, DIEEntry *> MDNodeToDIEEntryMap;
|
|
||||||
|
|
||||||
/// A list of all the DIEBlocks in use.
|
/// A list of all the DIEBlocks in use.
|
||||||
std::vector<DIEBlock *> DIEBlocks;
|
std::vector<DIEBlock *> DIEBlocks;
|
||||||
|
|
||||||
|
@ -111,9 +107,6 @@ protected:
|
||||||
// All DIEValues are allocated through this allocator.
|
// All DIEValues are allocated through this allocator.
|
||||||
BumpPtrAllocator DIEValueAllocator;
|
BumpPtrAllocator DIEValueAllocator;
|
||||||
|
|
||||||
// A preallocated DIEValue because 1 is used frequently.
|
|
||||||
DIEInteger *DIEIntegerOne;
|
|
||||||
|
|
||||||
/// The section this unit will be emitted in.
|
/// The section this unit will be emitted in.
|
||||||
MCSection *Section;
|
MCSection *Section;
|
||||||
|
|
||||||
|
@ -180,7 +173,7 @@ public:
|
||||||
DIE *getDIE(const DINode *D) const;
|
DIE *getDIE(const DINode *D) const;
|
||||||
|
|
||||||
/// \brief Returns a fresh newly allocated DIELoc.
|
/// \brief Returns a fresh newly allocated DIELoc.
|
||||||
DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc(); }
|
DIELoc *getDIELoc() { return new (DIEValueAllocator) DIELoc; }
|
||||||
|
|
||||||
/// \brief Insert DIE into the map.
|
/// \brief Insert DIE into the map.
|
||||||
///
|
///
|
||||||
|
@ -233,7 +226,7 @@ public:
|
||||||
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry);
|
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry);
|
||||||
|
|
||||||
/// \brief Add a DIE attribute data and value.
|
/// \brief Add a DIE attribute data and value.
|
||||||
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIEEntry *Entry);
|
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIEEntry Entry);
|
||||||
|
|
||||||
void addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type);
|
void addDIETypeSignature(DIE &Die, const DwarfTypeUnit &Type);
|
||||||
|
|
||||||
|
@ -369,26 +362,12 @@ private:
|
||||||
/// If the DWARF version doesn't handle the language, return -1.
|
/// If the DWARF version doesn't handle the language, return -1.
|
||||||
int64_t getDefaultLowerBound() const;
|
int64_t getDefaultLowerBound() const;
|
||||||
|
|
||||||
/// \brief Returns the DIE entry for the specified debug variable.
|
|
||||||
DIEEntry *getDIEEntry(const MDNode *N) const {
|
|
||||||
return MDNodeToDIEEntryMap.lookup(N);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Insert debug information entry into the map.
|
|
||||||
void insertDIEEntry(const MDNode *N, DIEEntry *E) {
|
|
||||||
MDNodeToDIEEntryMap.insert(std::make_pair(N, E));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Get an anonymous type for index type.
|
/// \brief Get an anonymous type for index type.
|
||||||
DIE *getIndexTyDie();
|
DIE *getIndexTyDie();
|
||||||
|
|
||||||
/// \brief Set D as anonymous type for index which can be reused later.
|
/// \brief Set D as anonymous type for index which can be reused later.
|
||||||
void setIndexTyDie(DIE *D) { IndexTyDie = D; }
|
void setIndexTyDie(DIE *D) { IndexTyDie = D; }
|
||||||
|
|
||||||
/// \brief Creates a new DIEEntry to be a proxy for a debug information
|
|
||||||
/// entry.
|
|
||||||
DIEEntry *createDIEEntry(DIE &Entry);
|
|
||||||
|
|
||||||
/// If this is a named finished type then include it in the list of types for
|
/// If this is a named finished type then include it in the list of types for
|
||||||
/// the accelerator tables.
|
/// the accelerator tables.
|
||||||
void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
|
void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
|
||||||
|
|
|
@ -60,6 +60,30 @@ using HalfOpenIntervalMap =
|
||||||
|
|
||||||
typedef HalfOpenIntervalMap<uint64_t, int64_t> FunctionIntervals;
|
typedef HalfOpenIntervalMap<uint64_t, int64_t> FunctionIntervals;
|
||||||
|
|
||||||
|
// FIXME: Delete this structure once DIE::Values has a stable iterator we can
|
||||||
|
// use instead.
|
||||||
|
struct PatchLocation {
|
||||||
|
DIE *Die;
|
||||||
|
unsigned Index;
|
||||||
|
|
||||||
|
PatchLocation() : Die(nullptr), Index(0) {}
|
||||||
|
PatchLocation(DIE &Die, unsigned Index) : Die(&Die), Index(Index) {}
|
||||||
|
|
||||||
|
void set(uint64_t New) const {
|
||||||
|
assert(Die);
|
||||||
|
assert(Index < Die->getValues().size());
|
||||||
|
assert(Die->getValues()[Index].getType() == DIEValue::isInteger);
|
||||||
|
Die->setValue(Index, DIEInteger(New));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t get() const {
|
||||||
|
assert(Die);
|
||||||
|
assert(Index < Die->getValues().size());
|
||||||
|
assert(Die->getValues()[Index].getType() == DIEValue::isInteger);
|
||||||
|
return Die->getValues()[Index].getDIEInteger().getValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief Stores all information relating to a compile unit, be it in
|
/// \brief Stores all information relating to a compile unit, be it in
|
||||||
/// its original instance in the object file to its brand new cloned
|
/// its original instance in the object file to its brand new cloned
|
||||||
/// and linked DIE tree.
|
/// and linked DIE tree.
|
||||||
|
@ -76,7 +100,7 @@ public:
|
||||||
|
|
||||||
CompileUnit(DWARFUnit &OrigUnit, unsigned ID)
|
CompileUnit(DWARFUnit &OrigUnit, unsigned ID)
|
||||||
: OrigUnit(OrigUnit), ID(ID), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(),
|
: OrigUnit(OrigUnit), ID(ID), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(),
|
||||||
Ranges(RangeAlloc), UnitRangeAttribute(nullptr) {
|
Ranges(RangeAlloc) {
|
||||||
Info.resize(OrigUnit.getNumDIEs());
|
Info.resize(OrigUnit.getNumDIEs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,13 +130,15 @@ public:
|
||||||
uint64_t getLowPc() const { return LowPc; }
|
uint64_t getLowPc() const { return LowPc; }
|
||||||
uint64_t getHighPc() const { return HighPc; }
|
uint64_t getHighPc() const { return HighPc; }
|
||||||
|
|
||||||
DIEInteger *getUnitRangesAttribute() const { return UnitRangeAttribute; }
|
Optional<PatchLocation> getUnitRangesAttribute() const {
|
||||||
|
return UnitRangeAttribute;
|
||||||
|
}
|
||||||
const FunctionIntervals &getFunctionRanges() const { return Ranges; }
|
const FunctionIntervals &getFunctionRanges() const { return Ranges; }
|
||||||
const std::vector<DIEInteger *> &getRangesAttributes() const {
|
const std::vector<PatchLocation> &getRangesAttributes() const {
|
||||||
return RangeAttributes;
|
return RangeAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::pair<DIEInteger *, int64_t>> &
|
const std::vector<std::pair<PatchLocation, int64_t>> &
|
||||||
getLocationAttributes() const {
|
getLocationAttributes() const {
|
||||||
return LocationAttributes;
|
return LocationAttributes;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +153,7 @@ public:
|
||||||
/// RefUnit by \p Attr. The attribute should be fixed up later to
|
/// RefUnit by \p Attr. The attribute should be fixed up later to
|
||||||
/// point to the absolute offset of \p Die in the debug_info section.
|
/// point to the absolute offset of \p Die in the debug_info section.
|
||||||
void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
|
void noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
|
||||||
DIEInteger *Attr);
|
PatchLocation Attr);
|
||||||
|
|
||||||
/// \brief Apply all fixups recored by noteForwardReference().
|
/// \brief Apply all fixups recored by noteForwardReference().
|
||||||
void fixupForwardReferences();
|
void fixupForwardReferences();
|
||||||
|
@ -138,11 +164,11 @@ public:
|
||||||
|
|
||||||
/// \brief Keep track of a DW_AT_range attribute that we will need to
|
/// \brief Keep track of a DW_AT_range attribute that we will need to
|
||||||
/// patch up later.
|
/// patch up later.
|
||||||
void noteRangeAttribute(const DIE &Die, DIEInteger *Attr);
|
void noteRangeAttribute(const DIE &Die, PatchLocation Attr);
|
||||||
|
|
||||||
/// \brief Keep track of a location attribute pointing to a location
|
/// \brief Keep track of a location attribute pointing to a location
|
||||||
/// list in the debug_loc section.
|
/// list in the debug_loc section.
|
||||||
void noteLocationAttribute(DIEInteger *Attr, int64_t PcOffset);
|
void noteLocationAttribute(PatchLocation Attr, int64_t PcOffset);
|
||||||
|
|
||||||
/// \brief Add a name accelerator entry for \p Die with \p Name
|
/// \brief Add a name accelerator entry for \p Die with \p Name
|
||||||
/// which is stored in the string table at \p Offset.
|
/// which is stored in the string table at \p Offset.
|
||||||
|
@ -186,7 +212,7 @@ private:
|
||||||
/// The offsets for the attributes in this array couldn't be set while
|
/// The offsets for the attributes in this array couldn't be set while
|
||||||
/// cloning because for cross-cu forward refences the target DIE's
|
/// cloning because for cross-cu forward refences the target DIE's
|
||||||
/// offset isn't known you emit the reference attribute.
|
/// offset isn't known you emit the reference attribute.
|
||||||
std::vector<std::tuple<DIE *, const CompileUnit *, DIEInteger *>>
|
std::vector<std::tuple<DIE *, const CompileUnit *, PatchLocation>>
|
||||||
ForwardDIEReferences;
|
ForwardDIEReferences;
|
||||||
|
|
||||||
FunctionIntervals::Allocator RangeAlloc;
|
FunctionIntervals::Allocator RangeAlloc;
|
||||||
|
@ -198,15 +224,15 @@ private:
|
||||||
/// \brief DW_AT_ranges attributes to patch after we have gathered
|
/// \brief DW_AT_ranges attributes to patch after we have gathered
|
||||||
/// all the unit's function addresses.
|
/// all the unit's function addresses.
|
||||||
/// @{
|
/// @{
|
||||||
std::vector<DIEInteger *> RangeAttributes;
|
std::vector<PatchLocation> RangeAttributes;
|
||||||
DIEInteger *UnitRangeAttribute;
|
Optional<PatchLocation> UnitRangeAttribute;
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \brief Location attributes that need to be transfered from th
|
/// \brief Location attributes that need to be transfered from th
|
||||||
/// original debug_loc section to the liked one. They are stored
|
/// original debug_loc section to the liked one. They are stored
|
||||||
/// along with the PC offset that is to be applied to their
|
/// along with the PC offset that is to be applied to their
|
||||||
/// function's address.
|
/// function's address.
|
||||||
std::vector<std::pair<DIEInteger *, int64_t>> LocationAttributes;
|
std::vector<std::pair<PatchLocation, int64_t>> LocationAttributes;
|
||||||
|
|
||||||
/// \brief Accelerator entries for the unit, both for the pub*
|
/// \brief Accelerator entries for the unit, both for the pub*
|
||||||
/// sections and the apple* ones.
|
/// sections and the apple* ones.
|
||||||
|
@ -229,7 +255,7 @@ uint64_t CompileUnit::computeNextUnitOffset() {
|
||||||
/// \brief Keep track of a forward cross-cu reference from this unit
|
/// \brief Keep track of a forward cross-cu reference from this unit
|
||||||
/// to \p Die that lives in \p RefUnit.
|
/// to \p Die that lives in \p RefUnit.
|
||||||
void CompileUnit::noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
|
void CompileUnit::noteForwardReference(DIE *Die, const CompileUnit *RefUnit,
|
||||||
DIEInteger *Attr) {
|
PatchLocation Attr) {
|
||||||
ForwardDIEReferences.emplace_back(Die, RefUnit, Attr);
|
ForwardDIEReferences.emplace_back(Die, RefUnit, Attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,9 +264,9 @@ void CompileUnit::fixupForwardReferences() {
|
||||||
for (const auto &Ref : ForwardDIEReferences) {
|
for (const auto &Ref : ForwardDIEReferences) {
|
||||||
DIE *RefDie;
|
DIE *RefDie;
|
||||||
const CompileUnit *RefUnit;
|
const CompileUnit *RefUnit;
|
||||||
DIEInteger *Attr;
|
PatchLocation Attr;
|
||||||
std::tie(RefDie, RefUnit, Attr) = Ref;
|
std::tie(RefDie, RefUnit, Attr) = Ref;
|
||||||
Attr->setValue(RefDie->getOffset() + RefUnit->getStartOffset());
|
Attr.set(RefDie->getOffset() + RefUnit->getStartOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,14 +277,14 @@ void CompileUnit::addFunctionRange(uint64_t FuncLowPc, uint64_t FuncHighPc,
|
||||||
this->HighPc = std::max(HighPc, FuncHighPc + PcOffset);
|
this->HighPc = std::max(HighPc, FuncHighPc + PcOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileUnit::noteRangeAttribute(const DIE &Die, DIEInteger *Attr) {
|
void CompileUnit::noteRangeAttribute(const DIE &Die, PatchLocation Attr) {
|
||||||
if (Die.getTag() != dwarf::DW_TAG_compile_unit)
|
if (Die.getTag() != dwarf::DW_TAG_compile_unit)
|
||||||
RangeAttributes.push_back(Attr);
|
RangeAttributes.push_back(Attr);
|
||||||
else
|
else
|
||||||
UnitRangeAttribute = Attr;
|
UnitRangeAttribute = Attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileUnit::noteLocationAttribute(DIEInteger *Attr, int64_t PcOffset) {
|
void CompileUnit::noteLocationAttribute(PatchLocation Attr, int64_t PcOffset) {
|
||||||
LocationAttributes.emplace_back(Attr, PcOffset);
|
LocationAttributes.emplace_back(Attr, PcOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +743,7 @@ void DwarfStreamer::emitUnitRangesEntries(CompileUnit &Unit,
|
||||||
/// point to the new entries.
|
/// point to the new entries.
|
||||||
void DwarfStreamer::emitLocationsForUnit(const CompileUnit &Unit,
|
void DwarfStreamer::emitLocationsForUnit(const CompileUnit &Unit,
|
||||||
DWARFContext &Dwarf) {
|
DWARFContext &Dwarf) {
|
||||||
const std::vector<std::pair<DIEInteger *, int64_t>> &Attributes =
|
const auto &Attributes = Unit.getLocationAttributes();
|
||||||
Unit.getLocationAttributes();
|
|
||||||
|
|
||||||
if (Attributes.empty())
|
if (Attributes.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -737,8 +762,8 @@ void DwarfStreamer::emitLocationsForUnit(const CompileUnit &Unit,
|
||||||
UnitPcOffset = int64_t(OrigLowPc) - Unit.getLowPc();
|
UnitPcOffset = int64_t(OrigLowPc) - Unit.getLowPc();
|
||||||
|
|
||||||
for (const auto &Attr : Attributes) {
|
for (const auto &Attr : Attributes) {
|
||||||
uint32_t Offset = Attr.first->getValue();
|
uint32_t Offset = Attr.first.get();
|
||||||
Attr.first->setValue(LocSectionSize);
|
Attr.first.set(LocSectionSize);
|
||||||
// This is the quantity to add to the old location address to get
|
// This is the quantity to add to the old location address to get
|
||||||
// the correct address for the new one.
|
// the correct address for the new one.
|
||||||
int64_t LocPcOffset = Attr.second + UnitPcOffset;
|
int64_t LocPcOffset = Attr.second + UnitPcOffset;
|
||||||
|
@ -1760,7 +1785,7 @@ unsigned DwarfLinker::cloneStringAttribute(DIE &Die, AttributeSpec AttrSpec,
|
||||||
const char *String = *Val.getAsCString(&U);
|
const char *String = *Val.getAsCString(&U);
|
||||||
unsigned Offset = StringPool.getStringOffset(String);
|
unsigned Offset = StringPool.getStringOffset(String);
|
||||||
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
|
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
|
||||||
new (DIEAlloc) DIEInteger(Offset));
|
DIEInteger(Offset));
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1803,24 +1828,25 @@ unsigned DwarfLinker::cloneDieReferenceAttribute(
|
||||||
// to find the unit offset. (We don't have a DwarfDebug)
|
// to find the unit offset. (We don't have a DwarfDebug)
|
||||||
// FIXME: we should be able to design DIEEntry reliance on
|
// FIXME: we should be able to design DIEEntry reliance on
|
||||||
// DwarfDebug away.
|
// DwarfDebug away.
|
||||||
DIEInteger *Attr;
|
uint64_t Attr;
|
||||||
if (Ref < InputDIE.getOffset()) {
|
if (Ref < InputDIE.getOffset()) {
|
||||||
// We must have already cloned that DIE.
|
// We must have already cloned that DIE.
|
||||||
uint32_t NewRefOffset =
|
uint32_t NewRefOffset =
|
||||||
RefUnit->getStartOffset() + NewRefDie->getOffset();
|
RefUnit->getStartOffset() + NewRefDie->getOffset();
|
||||||
Attr = new (DIEAlloc) DIEInteger(NewRefOffset);
|
Attr = NewRefOffset;
|
||||||
} else {
|
} else {
|
||||||
// A forward reference. Note and fixup later.
|
// A forward reference. Note and fixup later.
|
||||||
Attr = new (DIEAlloc) DIEInteger(0xBADDEF);
|
Attr = 0xBADDEF;
|
||||||
Unit.noteForwardReference(NewRefDie, RefUnit, Attr);
|
Unit.noteForwardReference(NewRefDie, RefUnit,
|
||||||
|
PatchLocation(Die, Die.getValues().size()));
|
||||||
}
|
}
|
||||||
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_ref_addr,
|
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_ref_addr,
|
||||||
Attr);
|
DIEInteger(Attr));
|
||||||
return AttrSize;
|
return AttrSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::Form(AttrSpec.Form),
|
Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::Form(AttrSpec.Form),
|
||||||
new (DIEAlloc) DIEEntry(*NewRefDie));
|
DIEEntry(*NewRefDie));
|
||||||
return AttrSize;
|
return AttrSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1831,23 +1857,23 @@ unsigned DwarfLinker::cloneBlockAttribute(DIE &Die, AttributeSpec AttrSpec,
|
||||||
const DWARFFormValue &Val,
|
const DWARFFormValue &Val,
|
||||||
unsigned AttrSize) {
|
unsigned AttrSize) {
|
||||||
DIE *Attr;
|
DIE *Attr;
|
||||||
DIEValue *Value;
|
DIEValue Value;
|
||||||
DIELoc *Loc = nullptr;
|
DIELoc *Loc = nullptr;
|
||||||
DIEBlock *Block = nullptr;
|
DIEBlock *Block = nullptr;
|
||||||
// Just copy the block data over.
|
// Just copy the block data over.
|
||||||
if (AttrSpec.Form == dwarf::DW_FORM_exprloc) {
|
if (AttrSpec.Form == dwarf::DW_FORM_exprloc) {
|
||||||
Loc = new (DIEAlloc) DIELoc();
|
Loc = new (DIEAlloc) DIELoc;
|
||||||
DIELocs.push_back(Loc);
|
DIELocs.push_back(Loc);
|
||||||
} else {
|
} else {
|
||||||
Block = new (DIEAlloc) DIEBlock();
|
Block = new (DIEAlloc) DIEBlock;
|
||||||
DIEBlocks.push_back(Block);
|
DIEBlocks.push_back(Block);
|
||||||
}
|
}
|
||||||
Attr = Loc ? static_cast<DIE *>(Loc) : static_cast<DIE *>(Block);
|
Attr = Loc ? static_cast<DIE *>(Loc) : static_cast<DIE *>(Block);
|
||||||
Value = Loc ? static_cast<DIEValue *>(Loc) : static_cast<DIEValue *>(Block);
|
Value = Loc ? DIEValue(Loc) : DIEValue(Block);
|
||||||
ArrayRef<uint8_t> Bytes = *Val.getAsBlock();
|
ArrayRef<uint8_t> Bytes = *Val.getAsBlock();
|
||||||
for (auto Byte : Bytes)
|
for (auto Byte : Bytes)
|
||||||
Attr->addValue(static_cast<dwarf::Attribute>(0), dwarf::DW_FORM_data1,
|
Attr->addValue(static_cast<dwarf::Attribute>(0), dwarf::DW_FORM_data1,
|
||||||
new (DIEAlloc) DIEInteger(Byte));
|
DIEInteger(Byte));
|
||||||
// FIXME: If DIEBlock and DIELoc just reuses the Size field of
|
// FIXME: If DIEBlock and DIELoc just reuses the Size field of
|
||||||
// the DIE class, this if could be replaced by
|
// the DIE class, this if could be replaced by
|
||||||
// Attr->setSize(Bytes.size()).
|
// Attr->setSize(Bytes.size()).
|
||||||
|
@ -1893,8 +1919,7 @@ unsigned DwarfLinker::cloneAddressAttribute(DIE &Die, AttributeSpec AttrSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
Die.addValue(static_cast<dwarf::Attribute>(AttrSpec.Attr),
|
Die.addValue(static_cast<dwarf::Attribute>(AttrSpec.Attr),
|
||||||
static_cast<dwarf::Form>(AttrSpec.Form),
|
static_cast<dwarf::Form>(AttrSpec.Form), DIEInteger(Addr));
|
||||||
new (DIEAlloc) DIEInteger(Addr));
|
|
||||||
return Unit.getOrigUnit().getAddressByteSize();
|
return Unit.getOrigUnit().getAddressByteSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1922,15 +1947,16 @@ unsigned DwarfLinker::cloneScalarAttribute(
|
||||||
&Unit.getOrigUnit(), &InputDIE);
|
&Unit.getOrigUnit(), &InputDIE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DIEInteger *Attr = new (DIEAlloc) DIEInteger(Value);
|
DIEInteger Attr(Value);
|
||||||
if (AttrSpec.Attr == dwarf::DW_AT_ranges)
|
if (AttrSpec.Attr == dwarf::DW_AT_ranges)
|
||||||
Unit.noteRangeAttribute(Die, Attr);
|
Unit.noteRangeAttribute(Die, PatchLocation(Die, Die.getValues().size()));
|
||||||
// A more generic way to check for location attributes would be
|
// A more generic way to check for location attributes would be
|
||||||
// nice, but it's very unlikely that any other attribute needs a
|
// nice, but it's very unlikely that any other attribute needs a
|
||||||
// location list.
|
// location list.
|
||||||
else if (AttrSpec.Attr == dwarf::DW_AT_location ||
|
else if (AttrSpec.Attr == dwarf::DW_AT_location ||
|
||||||
AttrSpec.Attr == dwarf::DW_AT_frame_base)
|
AttrSpec.Attr == dwarf::DW_AT_frame_base)
|
||||||
Unit.noteLocationAttribute(Attr, Info.PCOffset);
|
Unit.noteLocationAttribute(PatchLocation(Die, Die.getValues().size()),
|
||||||
|
Info.PCOffset);
|
||||||
else if (AttrSpec.Attr == dwarf::DW_AT_declaration && Value)
|
else if (AttrSpec.Attr == dwarf::DW_AT_declaration && Value)
|
||||||
Info.IsDeclaration = true;
|
Info.IsDeclaration = true;
|
||||||
|
|
||||||
|
@ -2213,8 +2239,8 @@ void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit,
|
||||||
UnitPcOffset = int64_t(OrigLowPc) - Unit.getLowPc();
|
UnitPcOffset = int64_t(OrigLowPc) - Unit.getLowPc();
|
||||||
|
|
||||||
for (const auto &RangeAttribute : Unit.getRangesAttributes()) {
|
for (const auto &RangeAttribute : Unit.getRangesAttributes()) {
|
||||||
uint32_t Offset = RangeAttribute->getValue();
|
uint32_t Offset = RangeAttribute.get();
|
||||||
RangeAttribute->setValue(Streamer->getRangesSectionSize());
|
RangeAttribute.set(Streamer->getRangesSectionSize());
|
||||||
RangeList.extract(RangeExtractor, &Offset);
|
RangeList.extract(RangeExtractor, &Offset);
|
||||||
const auto &Entries = RangeList.getEntries();
|
const auto &Entries = RangeList.getEntries();
|
||||||
const DWARFDebugRangeList::RangeListEntry &First = Entries.front();
|
const DWARFDebugRangeList::RangeListEntry &First = Entries.front();
|
||||||
|
@ -2241,10 +2267,10 @@ void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit,
|
||||||
/// but for the sake of initial bit-for-bit compatibility with legacy
|
/// but for the sake of initial bit-for-bit compatibility with legacy
|
||||||
/// dsymutil, we have to do it in a delayed pass.
|
/// dsymutil, we have to do it in a delayed pass.
|
||||||
void DwarfLinker::generateUnitRanges(CompileUnit &Unit) const {
|
void DwarfLinker::generateUnitRanges(CompileUnit &Unit) const {
|
||||||
DIEInteger *Attr = Unit.getUnitRangesAttribute();
|
auto Attr = Unit.getUnitRangesAttribute();
|
||||||
if (Attr)
|
if (Attr)
|
||||||
Attr->setValue(Streamer->getRangesSectionSize());
|
Attr->set(Streamer->getRangesSectionSize());
|
||||||
Streamer->emitUnitRangesEntries(Unit, Attr != nullptr);
|
Streamer->emitUnitRangesEntries(Unit, static_cast<bool>(Attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Insert the new line info sequence \p Seq into the current
|
/// \brief Insert the new line info sequence \p Seq into the current
|
||||||
|
@ -2301,9 +2327,8 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit,
|
||||||
return AbbrevData.getAttribute() == dwarf::DW_AT_stmt_list;
|
return AbbrevData.getAttribute() == dwarf::DW_AT_stmt_list;
|
||||||
});
|
});
|
||||||
assert(Stmt < Abbrev.end() && "Didn't find DW_AT_stmt_list in cloned DIE!");
|
assert(Stmt < Abbrev.end() && "Didn't find DW_AT_stmt_list in cloned DIE!");
|
||||||
DIEInteger *StmtAttr =
|
OutputDIE->setValue(Stmt - Abbrev.begin(),
|
||||||
cast<DIEInteger>(OutputDIE->getValues()[Stmt - Abbrev.begin()]);
|
DIEInteger(Streamer->getLineSectionSize()));
|
||||||
StmtAttr->setValue(Streamer->getLineSectionSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the original line info for the unit.
|
// Parse the original line info for the unit.
|
||||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(DIEHashTest, Data1) {
|
||||||
DIEHash Hash;
|
DIEHash Hash;
|
||||||
DIE Die(dwarf::DW_TAG_base_type);
|
DIE Die(dwarf::DW_TAG_base_type);
|
||||||
DIEInteger Size(4);
|
DIEInteger Size(4);
|
||||||
Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Size);
|
Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
|
||||||
uint64_t MD5Res = Hash.computeTypeSignature(Die);
|
uint64_t MD5Res = Hash.computeTypeSignature(Die);
|
||||||
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
|
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ TEST_F(DIEHashTest, Data1) {
|
||||||
TEST_F(DIEHashTest, TrivialType) {
|
TEST_F(DIEHashTest, TrivialType) {
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
// Line and file number are ignored.
|
// Line and file number are ignored.
|
||||||
Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
|
||||||
uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
|
uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
|
||||||
|
|
||||||
// The exact same hash GCC produces for this DIE.
|
// The exact same hash GCC produces for this DIE.
|
||||||
|
@ -61,8 +61,8 @@ TEST_F(DIEHashTest, NamedType) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
|
uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
|
||||||
|
|
||||||
|
@ -77,15 +77,15 @@ TEST_F(DIEHashTest, NamespacedType) {
|
||||||
auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace);
|
auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
DIEString SpaceStr = getString("space");
|
DIEString SpaceStr = getString("space");
|
||||||
Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &SpaceStr);
|
Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
|
||||||
// DW_AT_declaration is ignored.
|
// DW_AT_declaration is ignored.
|
||||||
Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
// sibling?
|
// sibling?
|
||||||
|
|
||||||
auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
|
auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIE &N = *Foo;
|
DIE &N = *Foo;
|
||||||
Space->addChild(std::move(Foo));
|
Space->addChild(std::move(Foo));
|
||||||
|
@ -101,24 +101,24 @@ TEST_F(DIEHashTest, NamespacedType) {
|
||||||
TEST_F(DIEHashTest, TypeWithMember) {
|
TEST_F(DIEHashTest, TypeWithMember) {
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Four(4);
|
DIEInteger Four(4);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
|
||||||
|
|
||||||
DIE Int(dwarf::DW_TAG_base_type);
|
DIE Int(dwarf::DW_TAG_base_type);
|
||||||
DIEString IntStr = getString("int");
|
DIEString IntStr = getString("int");
|
||||||
Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr);
|
Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
|
||||||
Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
|
Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
|
||||||
DIEInteger Five(5);
|
DIEInteger Five(5);
|
||||||
Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
|
Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
|
||||||
|
|
||||||
DIEEntry IntRef(Int);
|
DIEEntry IntRef(Int);
|
||||||
|
|
||||||
auto Member = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Member = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemberStr = getString("member");
|
DIEString MemberStr = getString("member");
|
||||||
Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr);
|
Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemberStr);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
|
Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
|
||||||
|
|
||||||
Unnamed.addChild(std::move(Member));
|
Unnamed.addChild(std::move(Member));
|
||||||
|
|
||||||
|
@ -131,34 +131,34 @@ TEST_F(DIEHashTest, TypeWithMember) {
|
||||||
TEST_F(DIEHashTest, ReusedType) {
|
TEST_F(DIEHashTest, ReusedType) {
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Eight(8);
|
DIEInteger Eight(8);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
|
|
||||||
DIEInteger Four(4);
|
DIEInteger Four(4);
|
||||||
DIE Int(dwarf::DW_TAG_base_type);
|
DIE Int(dwarf::DW_TAG_base_type);
|
||||||
DIEString IntStr = getString("int");
|
DIEString IntStr = getString("int");
|
||||||
Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr);
|
Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
|
||||||
Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
|
Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
|
||||||
DIEInteger Five(5);
|
DIEInteger Five(5);
|
||||||
Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
|
Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
|
||||||
|
|
||||||
DIEEntry IntRef(Int);
|
DIEEntry IntRef(Int);
|
||||||
|
|
||||||
auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString Mem1Str = getString("mem1");
|
DIEString Mem1Str = getString("mem1");
|
||||||
Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem1Str);
|
Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
|
Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
|
||||||
|
|
||||||
Unnamed.addChild(std::move(Mem1));
|
Unnamed.addChild(std::move(Mem1));
|
||||||
|
|
||||||
auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString Mem2Str = getString("mem2");
|
DIEString Mem2Str = getString("mem2");
|
||||||
Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem2Str);
|
Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
|
||||||
Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Four);
|
Four);
|
||||||
Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
|
Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
|
||||||
|
|
||||||
Unnamed.addChild(std::move(Mem2));
|
Unnamed.addChild(std::move(Mem2));
|
||||||
|
|
||||||
|
@ -171,15 +171,15 @@ TEST_F(DIEHashTest, ReusedType) {
|
||||||
TEST_F(DIEHashTest, RecursiveType) {
|
TEST_F(DIEHashTest, RecursiveType) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
DIEEntry FooRef(Foo);
|
DIEEntry FooRef(Foo);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
|
||||||
// DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
|
// DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
@ -193,23 +193,23 @@ TEST_F(DIEHashTest, RecursiveType) {
|
||||||
TEST_F(DIEHashTest, Pointer) {
|
TEST_F(DIEHashTest, Pointer) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Eight(8);
|
DIEInteger Eight(8);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
|
||||||
|
|
||||||
DIE FooPtr(dwarf::DW_TAG_pointer_type);
|
DIE FooPtr(dwarf::DW_TAG_pointer_type);
|
||||||
FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEEntry FooRef(Foo);
|
DIEEntry FooRef(Foo);
|
||||||
FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
|
FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
|
||||||
|
|
||||||
DIEEntry FooPtrRef(FooPtr);
|
DIEEntry FooPtrRef(FooPtr);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooPtrRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -222,27 +222,27 @@ TEST_F(DIEHashTest, Pointer) {
|
||||||
TEST_F(DIEHashTest, Reference) {
|
TEST_F(DIEHashTest, Reference) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Eight(8);
|
DIEInteger Eight(8);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
|
||||||
|
|
||||||
DIE FooRef(dwarf::DW_TAG_reference_type);
|
DIE FooRef(dwarf::DW_TAG_reference_type);
|
||||||
FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEEntry FooEntry(Foo);
|
DIEEntry FooEntry(Foo);
|
||||||
FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
|
FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
|
||||||
|
|
||||||
DIE FooRefConst(dwarf::DW_TAG_const_type);
|
DIE FooRefConst(dwarf::DW_TAG_const_type);
|
||||||
DIEEntry FooRefRef(FooRef);
|
DIEEntry FooRefRef(FooRef);
|
||||||
FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef);
|
FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
|
||||||
|
|
||||||
DIEEntry FooRefConstRef(FooRefConst);
|
DIEEntry FooRefConstRef(FooRefConst);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -255,27 +255,27 @@ TEST_F(DIEHashTest, Reference) {
|
||||||
TEST_F(DIEHashTest, RValueReference) {
|
TEST_F(DIEHashTest, RValueReference) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Eight(8);
|
DIEInteger Eight(8);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
|
||||||
|
|
||||||
DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
|
DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
|
||||||
FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEEntry FooEntry(Foo);
|
DIEEntry FooEntry(Foo);
|
||||||
FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
|
FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
|
||||||
|
|
||||||
DIE FooRefConst(dwarf::DW_TAG_const_type);
|
DIE FooRefConst(dwarf::DW_TAG_const_type);
|
||||||
DIEEntry FooRefRef(FooRef);
|
DIEEntry FooRefRef(FooRef);
|
||||||
FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef);
|
FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
|
||||||
|
|
||||||
DIEEntry FooRefConstRef(FooRefConst);
|
DIEEntry FooRefConstRef(FooRefConst);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -288,24 +288,24 @@ TEST_F(DIEHashTest, RValueReference) {
|
||||||
TEST_F(DIEHashTest, PtrToMember) {
|
TEST_F(DIEHashTest, PtrToMember) {
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger Eight(8);
|
DIEInteger Eight(8);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
DIEInteger Zero(0);
|
DIEInteger Zero(0);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
|
||||||
|
|
||||||
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
||||||
DIEEntry FooEntry(Foo);
|
DIEEntry FooEntry(Foo);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
|
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||||
&FooEntry);
|
FooEntry);
|
||||||
|
|
||||||
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -329,27 +329,27 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMatch) {
|
||||||
uint64_t MD5ResDecl;
|
uint64_t MD5ResDecl;
|
||||||
{
|
{
|
||||||
DIE Bar(dwarf::DW_TAG_structure_type);
|
DIE Bar(dwarf::DW_TAG_structure_type);
|
||||||
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
|
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
|
||||||
Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
|
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
|
|
||||||
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
||||||
DIEEntry BarEntry(Bar);
|
DIEEntry BarEntry(Bar);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
|
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
|
||||||
DIEEntry FooEntry(Foo);
|
DIEEntry FooEntry(Foo);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||||
&FooEntry);
|
FooEntry);
|
||||||
|
|
||||||
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -358,27 +358,27 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMatch) {
|
||||||
uint64_t MD5ResDef;
|
uint64_t MD5ResDef;
|
||||||
{
|
{
|
||||||
DIE Bar(dwarf::DW_TAG_structure_type);
|
DIE Bar(dwarf::DW_TAG_structure_type);
|
||||||
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
|
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
|
||||||
Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
|
|
||||||
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
||||||
DIEEntry BarEntry(Bar);
|
DIEEntry BarEntry(Bar);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
|
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
|
||||||
DIEEntry FooEntry(Foo);
|
DIEEntry FooEntry(Foo);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||||
&FooEntry);
|
FooEntry);
|
||||||
|
|
||||||
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -402,26 +402,26 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMisMatch) {
|
||||||
uint64_t MD5ResDecl;
|
uint64_t MD5ResDecl;
|
||||||
{
|
{
|
||||||
DIE Bar(dwarf::DW_TAG_structure_type);
|
DIE Bar(dwarf::DW_TAG_structure_type);
|
||||||
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
|
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
|
||||||
Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
|
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
|
|
||||||
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
||||||
DIEEntry BarEntry(Bar);
|
DIEEntry BarEntry(Bar);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
|
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||||
&BarEntry);
|
BarEntry);
|
||||||
|
|
||||||
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -430,26 +430,26 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMisMatch) {
|
||||||
uint64_t MD5ResDef;
|
uint64_t MD5ResDef;
|
||||||
{
|
{
|
||||||
DIE Bar(dwarf::DW_TAG_structure_type);
|
DIE Bar(dwarf::DW_TAG_structure_type);
|
||||||
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
|
Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
|
||||||
Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
|
||||||
&Zero);
|
Zero);
|
||||||
|
|
||||||
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
|
||||||
DIEEntry BarEntry(Bar);
|
DIEEntry BarEntry(Bar);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
|
PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
|
||||||
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
|
||||||
&BarEntry);
|
BarEntry);
|
||||||
|
|
||||||
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
DIEEntry PtrToFooMemRef(PtrToFooMem);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -473,23 +473,23 @@ TEST_F(DIEHashTest, RefUnnamedType) {
|
||||||
DIEString MemStr = getString("mem");
|
DIEString MemStr = getString("mem");
|
||||||
|
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
|
|
||||||
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
|
||||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
|
||||||
|
|
||||||
DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
|
DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
|
||||||
UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
|
||||||
DIEEntry UnnamedRef(Unnamed);
|
DIEEntry UnnamedRef(Unnamed);
|
||||||
UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedRef);
|
UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedRef);
|
||||||
|
|
||||||
DIEEntry UnnamedPtrRef(UnnamedPtr);
|
DIEEntry UnnamedPtrRef(UnnamedPtr);
|
||||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef);
|
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
|
||||||
|
|
||||||
Foo.addChild(std::move(Mem));
|
Foo.addChild(std::move(Mem));
|
||||||
|
|
||||||
|
@ -502,12 +502,12 @@ TEST_F(DIEHashTest, RefUnnamedType) {
|
||||||
TEST_F(DIEHashTest, NestedType) {
|
TEST_F(DIEHashTest, NestedType) {
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
|
auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
|
||||||
DIEString FooStr = getString("foo");
|
DIEString FooStr = getString("foo");
|
||||||
Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
|
||||||
Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
Unnamed.addChild(std::move(Foo));
|
Unnamed.addChild(std::move(Foo));
|
||||||
|
|
||||||
|
@ -521,11 +521,11 @@ TEST_F(DIEHashTest, NestedType) {
|
||||||
TEST_F(DIEHashTest, MemberFunc) {
|
TEST_F(DIEHashTest, MemberFunc) {
|
||||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
|
auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
|
||||||
DIEString FuncStr = getString("func");
|
DIEString FuncStr = getString("func");
|
||||||
Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr);
|
Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
|
||||||
|
|
||||||
Unnamed.addChild(std::move(Func));
|
Unnamed.addChild(std::move(Func));
|
||||||
|
|
||||||
|
@ -542,21 +542,21 @@ TEST_F(DIEHashTest, MemberFuncFlag) {
|
||||||
DIE A(dwarf::DW_TAG_structure_type);
|
DIE A(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
DIEString AStr = getString("A");
|
DIEString AStr = getString("A");
|
||||||
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
|
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
|
||||||
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
|
auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
|
||||||
DIEString FuncStr = getString("func");
|
DIEString FuncStr = getString("func");
|
||||||
DIEString FuncLinkage = getString("_ZN1A4funcEv");
|
DIEString FuncLinkage = getString("_ZN1A4funcEv");
|
||||||
DIEInteger Two(2);
|
DIEInteger Two(2);
|
||||||
Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
|
Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
|
||||||
Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr);
|
Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
|
||||||
Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
|
Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
|
||||||
Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, &FuncLinkage);
|
Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, FuncLinkage);
|
||||||
Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
|
|
||||||
A.addChild(std::move(Func));
|
A.addChild(std::move(Func));
|
||||||
|
|
||||||
|
@ -575,35 +575,35 @@ TEST_F(DIEHashTest, MemberSdata) {
|
||||||
DIE A(dwarf::DW_TAG_structure_type);
|
DIE A(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
DIEString AStr = getString("A");
|
DIEString AStr = getString("A");
|
||||||
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
|
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
|
||||||
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIEInteger Four(4);
|
DIEInteger Four(4);
|
||||||
DIEInteger Five(5);
|
DIEInteger Five(5);
|
||||||
DIEString FStr = getString("int");
|
DIEString FStr = getString("int");
|
||||||
DIE IntTyDIE(dwarf::DW_TAG_base_type);
|
DIE IntTyDIE(dwarf::DW_TAG_base_type);
|
||||||
IntTyDIE.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
|
IntTyDIE.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
|
||||||
IntTyDIE.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
|
IntTyDIE.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
|
||||||
IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
|
IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
|
||||||
|
|
||||||
DIEEntry IntTy(IntTyDIE);
|
DIEEntry IntTy(IntTyDIE);
|
||||||
auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
|
auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
|
||||||
PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntTy);
|
PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
|
||||||
|
|
||||||
DIEEntry PITy(*PITyDIE);
|
DIEEntry PITy(*PITyDIE);
|
||||||
auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString PIStr = getString("PI");
|
DIEString PIStr = getString("PI");
|
||||||
DIEInteger Two(2);
|
DIEInteger Two(2);
|
||||||
DIEInteger NegThree(-3);
|
DIEInteger NegThree(-3);
|
||||||
PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
|
PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
|
||||||
PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
|
PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
|
||||||
PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
|
PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
|
||||||
PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
|
PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
|
||||||
PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, &NegThree);
|
PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, NegThree);
|
||||||
|
|
||||||
A.addChild(std::move(PI));
|
A.addChild(std::move(PI));
|
||||||
|
|
||||||
|
@ -620,32 +620,32 @@ TEST_F(DIEHashTest, MemberBlock) {
|
||||||
DIE A(dwarf::DW_TAG_structure_type);
|
DIE A(dwarf::DW_TAG_structure_type);
|
||||||
DIEInteger One(1);
|
DIEInteger One(1);
|
||||||
DIEString AStr = getString("A");
|
DIEString AStr = getString("A");
|
||||||
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
|
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
|
||||||
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
|
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
|
||||||
|
|
||||||
DIEInteger Four(4);
|
DIEInteger Four(4);
|
||||||
DIEString FStr = getString("float");
|
DIEString FStr = getString("float");
|
||||||
auto FloatTyDIE = make_unique<DIE>(dwarf::DW_TAG_base_type);
|
auto FloatTyDIE = make_unique<DIE>(dwarf::DW_TAG_base_type);
|
||||||
FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
|
FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
|
||||||
FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Four);
|
FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Four);
|
||||||
FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
|
FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
|
||||||
|
|
||||||
DIEEntry FloatTy(*FloatTyDIE);
|
DIEEntry FloatTy(*FloatTyDIE);
|
||||||
auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
|
auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
|
||||||
PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FloatTy);
|
PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
|
||||||
|
|
||||||
DIEEntry PITy(*PITyDIE);
|
DIEEntry PITy(*PITyDIE);
|
||||||
auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
|
auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
|
||||||
DIEString PIStr = getString("PI");
|
DIEString PIStr = getString("PI");
|
||||||
DIEInteger Two(2);
|
DIEInteger Two(2);
|
||||||
PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
|
PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
|
||||||
PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
|
PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
|
||||||
PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
|
PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
|
||||||
PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
|
PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
|
||||||
PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
|
PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
|
||||||
PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
|
PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
|
||||||
|
|
||||||
DIEBlock PIBlock;
|
DIEBlock PIBlock;
|
||||||
DIEInteger Blk1(0xc3);
|
DIEInteger Blk1(0xc3);
|
||||||
|
@ -653,10 +653,10 @@ TEST_F(DIEHashTest, MemberBlock) {
|
||||||
DIEInteger Blk3(0x48);
|
DIEInteger Blk3(0x48);
|
||||||
DIEInteger Blk4(0x40);
|
DIEInteger Blk4(0x40);
|
||||||
|
|
||||||
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk1);
|
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk1);
|
||||||
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk2);
|
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk2);
|
||||||
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk3);
|
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk3);
|
||||||
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk4);
|
PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk4);
|
||||||
|
|
||||||
PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
|
PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue