29 #define DEBUG_TYPE "dwarfdebug"
36 for (
const auto &V : Die.
values())
37 if (V.getAttribute() == Attr)
38 return V.getDIEString().getString();
46 DEBUG(
dbgs() <<
"Adding string " << Str <<
" to hash.\n");
56 DEBUG(
dbgs() <<
"Adding ULEB128 " << Value <<
" to hash.\n");
58 uint8_t Byte = Value & 0x7f;
67 DEBUG(
dbgs() <<
"Adding ULEB128 " << Value <<
" to hash.\n");
70 uint8_t Byte = Value & 0x7f;
72 More = !((((Value == 0) && ((Byte & 0x40) == 0)) ||
73 ((Value == -1) && ((Byte & 0x40) != 0))));
81 void DIEHash::addParentContext(
const DIE &Parent) {
83 DEBUG(
dbgs() <<
"Adding parent context to hash...\n");
88 const DIE *Cur = &Parent;
94 Cur->
getTag() == dwarf::DW_TAG_type_unit);
101 const DIE &Die = **
I;
111 DEBUG(
dbgs() <<
"... adding context: " << Name <<
"\n");
118 void DIEHash::collectAttributes(
const DIE &Die, DIEAttrs &Attrs) {
119 #define COLLECT_ATTR(NAME) \
124 for (
const auto &V : Die.
values()) {
128 switch (V.getAttribute()) {
194 addParentContext(*Parent);
211 unsigned DieNumber) {
225 assert(Tag != dwarf::DW_TAG_friend &&
"No current LLVM clients emit friend "
226 "tags. Add support here when there's "
230 if ((Tag == dwarf::DW_TAG_pointer_type ||
231 Tag == dwarf::DW_TAG_reference_type ||
232 Tag == dwarf::DW_TAG_rvalue_reference_type ||
233 Tag == dwarf::DW_TAG_ptr_to_member_type) &&
238 Attribute == dwarf::DW_AT_type) {
242 hashShallowTypeReference(Attribute, Entry, Name);
247 unsigned &DieNumber = Numbering[&Entry];
249 hashRepeatedTypeReference(Attribute, DieNumber);
260 DieNumber = Numbering.size();
267 for (
const auto &V : Values)
268 Hash.
update((uint64_t)V.getDIEInteger().getValue());
272 void DIEHash::hashLocList(
const DIELocList &LocList) {
299 case DIEValue::isEntry:
300 hashDIEEntry(Attribute, Tag, Value.getDIEEntry().getEntry());
302 case DIEValue::isInteger: {
306 case dwarf::DW_FORM_data1:
307 case dwarf::DW_FORM_data2:
308 case dwarf::DW_FORM_data4:
309 case dwarf::DW_FORM_data8:
310 case dwarf::DW_FORM_udata:
311 case dwarf::DW_FORM_sdata:
313 addSLEB128((int64_t)Value.getDIEInteger().getValue());
317 case dwarf::DW_FORM_flag_present:
318 case dwarf::DW_FORM_flag:
320 addULEB128((int64_t)Value.getDIEInteger().getValue());
327 case DIEValue::isString:
331 addString(Value.getDIEString().getString());
333 case DIEValue::isInlineString:
337 addString(Value.getDIEInlineString().getString());
339 case DIEValue::isBlock:
340 case DIEValue::isLoc:
341 case DIEValue::isLocList:
345 if (Value.
getType() == DIEValue::isBlock) {
346 addULEB128(Value.getDIEBlock().ComputeSize(AP));
347 hashBlockData(Value.getDIEBlock().values());
348 }
else if (Value.
getType() == DIEValue::isLoc) {
349 addULEB128(Value.getDIELoc().ComputeSize(AP));
350 hashBlockData(Value.getDIELoc().values());
355 hashLocList(Value.getDIELocList());
359 case DIEValue::isExpr:
360 case DIEValue::isLabel:
361 case DIEValue::isDelta:
368 void DIEHash::hashAttributes(
const DIEAttrs &Attrs,
dwarf::Tag Tag) {
369 #define ADD_ATTR(ATTR) \
372 hashAttribute(ATTR, Tag); \
376 ADD_ATTR(Attrs.DW_AT_accessibility);
377 ADD_ATTR(Attrs.DW_AT_address_class);
389 ADD_ATTR(Attrs.DW_AT_containing_type);
391 ADD_ATTR(Attrs.DW_AT_data_bit_offset);
392 ADD_ATTR(Attrs.DW_AT_data_location);
393 ADD_ATTR(Attrs.DW_AT_data_member_location);
394 ADD_ATTR(Attrs.DW_AT_decimal_scale);
396 ADD_ATTR(Attrs.DW_AT_default_value);
410 ADD_ATTR(Attrs.DW_AT_picture_string);
414 ADD_ATTR(Attrs.DW_AT_string_length);
415 ADD_ATTR(Attrs.DW_AT_threads_scaled);
419 ADD_ATTR(Attrs.DW_AT_variable_parameter);
422 ADD_ATTR(Attrs.DW_AT_vtable_elem_location);
429 void DIEHash::addAttributes(
const DIE &Die) {
431 collectAttributes(Die, Attrs);
432 hashAttributes(Attrs, Die.
getTag());
435 void DIEHash::hashNestedType(
const DIE &Die,
StringRef Name) {
450 void DIEHash::computeHash(
const DIE &Die) {
462 if (
isType(
C.getTag()) ||
C.getTag() == dwarf::DW_TAG_subprogram) {
466 hashNestedType(
C, Name);
507 addParentContext(*Parent);
ArrayRef< Entry > getEntries(const List &L) const
void push_back(const T &Elt)
uint64_t computeCUSignature(const DIE &Die)
Computes the CU signature.
void addULEB128(uint64_t Value)
Encodes and adds.
Collects and handles dwarf debug information.
Represents a pointer to a location list in the debug_loc section.
size_t getValue() const
Grab the current index out.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
#define COLLECT_ATTR(NAME)
const List & getList(size_t LI) const
StringRef AttributeString(unsigned Attribute)
uint64_t computeTypeSignature(const DIE &Die)
Computes the type signature.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
dwarf::Tag getTag() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
A structured debug information entry.
DwarfDebug * getDwarfDebug()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
dwarf::Attribute getAttribute() const
dwarf::Form getForm() const
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry)
Emit an entry for the debug loc section.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
uint64_t read64le(const void *P)
void addSLEB128(int64_t Value)
Encodes and adds.
Type getType() const
Accessors.
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
Byte stream of .debug_loc entries.
static StringRef getDIEStringAttr(const DIE &Die, uint16_t Attr)
Grabs the string in whichever attribute is passed in and returns a reference to it.
static bool isType(const Metadata *MD)
iterator_range< const_value_iterator > const_value_range