llvm.org GIT mirror llvm / 73e3fb6
AsmPrinter: Convert DIE::Values to a linked list Change `DIE::Values` to a singly linked list, where each node is allocated on a `BumpPtrAllocator`. In order to support `push_back()`, the list is circular, and points at the tail element instead of the head. I abstracted the core list logic out to `IntrusiveBackList` so that it can be reused for `DIE::Children`, which also cares about `push_back()`. This drops llc memory usage from 799 MB down to 735 MB, about 8%. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240733 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
11 changed file(s) with 481 addition(s) and 286 deletion(s). Raw diff Collapse all Expand all
161161 int>::type = 0)
162162 : I(std::forward(u)) {}
163163
164 const WrappedIteratorT &wrapped() const { return I; }
165
164166 public:
165167 typedef DifferenceTypeT difference_type;
166168
1414 #define LLVM_LIB_CODEGEN_ASMPRINTER_DIE_H
1515
1616 #include "llvm/ADT/FoldingSet.h"
17 #include "llvm/ADT/PointerIntPair.h"
18 #include "llvm/ADT/STLExtras.h"
1719 #include "llvm/ADT/SmallVector.h"
1820 #include "llvm/CodeGen/DwarfStringPoolEntry.h"
1921 #include "llvm/Support/Dwarf.h"
447449 #endif
448450 };
449451
452 struct IntrusiveBackListNode {
453 PointerIntPair Next;
454 IntrusiveBackListNode() : Next(this, true) {}
455
456 IntrusiveBackListNode *getNext() const {
457 return Next.getInt() ? nullptr : Next.getPointer();
458 }
459 };
460
461 struct IntrusiveBackListBase {
462 typedef IntrusiveBackListNode Node;
463 Node *Last = nullptr;
464
465 bool empty() const { return !Last; }
466 void push_back(Node &N) {
467 assert(N.Next.getPointer() == &N && "Expected unlinked node");
468 assert(N.Next.getInt() == true && "Expected unlinked node");
469
470 if (Last) {
471 N.Next = Last->Next;
472 Last->Next.setPointerAndInt(&N, false);
473 }
474 Last = &N;
475 }
476 };
477
478 template class IntrusiveBackList : IntrusiveBackListBase {
479 public:
480 using IntrusiveBackListBase::empty;
481 void push_back(T &N) { IntrusiveBackListBase::push_back(N); }
482 T &back() { return *static_cast(Last); }
483 const T &back() const { return *static_cast(Last); }
484
485 class const_iterator;
486 class iterator
487 : public iterator_facade_base {
488 friend class const_iterator;
489 Node *N = nullptr;
490
491 public:
492 iterator() = default;
493 explicit iterator(T *N) : N(N) {}
494
495 iterator &operator++() {
496 N = N->getNext();
497 return *this;
498 }
499
500 explicit operator bool() const { return N; }
501 T &operator*() const { return *static_cast(N); }
502
503 bool operator==(const iterator &X) const { return N == X.N; }
504 bool operator!=(const iterator &X) const { return N != X.N; }
505 };
506
507 class const_iterator
508 : public iterator_facade_base
509 const T> {
510 const Node *N = nullptr;
511
512 public:
513 const_iterator() = default;
514 const_iterator(iterator X) : N(X.N) {}
515 explicit const_iterator(const T *N) : N(N) {}
516
517 const_iterator &operator++() {
518 N = N->getNext();
519 return *this;
520 }
521
522 explicit operator bool() const { return N; }
523 const T &operator*() const { return *static_cast(N); }
524
525 bool operator==(const const_iterator &X) const { return N == X.N; }
526 bool operator!=(const const_iterator &X) const { return N != X.N; }
527 };
528
529 iterator begin() {
530 return Last ? iterator(static_cast(Last->Next.getPointer())) : end();
531 }
532 const_iterator begin() const {
533 return const_cast(this)->begin();
534 }
535 iterator end() { return iterator(); }
536 const_iterator end() const { return const_iterator(); }
537
538 static iterator toIterator(T &N) { return iterator(&N); }
539 static const_iterator toIterator(const T &N) { return const_iterator(&N); }
540 };
541
542 /// A list of DIE values.
543 ///
544 /// This is a singly-linked list, but instead of reversing the order of
545 /// insertion, we keep a pointer to the back of the list so we can push in
546 /// order.
547 class DIEValueList {
548 struct Node : IntrusiveBackListNode {
549 DIEValue V;
550 explicit Node(DIEValue V) : V(V) {}
551 };
552
553 typedef IntrusiveBackList ListTy;
554 ListTy List;
555
556 public:
557 bool empty() const { return List.empty(); }
558
559 class const_iterator;
560 class iterator
561 : public iterator_adaptor_base
562 std::forward_iterator_tag, DIEValue> {
563 friend class const_iterator;
564 typedef iterator_adaptor_base
565 std::forward_iterator_tag,
566 DIEValue> iterator_adaptor;
567
568 public:
569 iterator() = default;
570 explicit iterator(ListTy::iterator X) : iterator_adaptor(X) {}
571
572 explicit operator bool() const { return bool(wrapped()); }
573 DIEValue &operator*() const { return wrapped()->V; }
574 };
575
576 class const_iterator
577 : public iterator_adaptor_base
578 std::forward_iterator_tag,
579 const DIEValue> {
580 typedef iterator_adaptor_base
581 std::forward_iterator_tag,
582 const DIEValue> iterator_adaptor;
583
584 public:
585 const_iterator() = default;
586 const_iterator(DIEValueList::iterator X) : iterator_adaptor(X.wrapped()) {}
587 explicit const_iterator(ListTy::const_iterator X) : iterator_adaptor(X) {}
588
589 explicit operator bool() const { return bool(wrapped()); }
590 const DIEValue &operator*() const { return wrapped()->V; }
591 };
592
593 iterator insert(BumpPtrAllocator &Alloc, DIEValue V) {
594 List.push_back(*new (Alloc) Node(V));
595 return iterator(ListTy::toIterator(List.back()));
596 }
597 template
598 iterator emplace(BumpPtrAllocator &Alloc, Ts &&... Args) {
599 return insert(Alloc, DIEValue(std::forward(Args)...));
600 }
601
602 iterator begin() { return iterator(List.begin()); }
603 iterator end() { return iterator(List.end()); }
604 const_iterator begin() const { return const_iterator(List.begin()); }
605 const_iterator end() const { return const_iterator(List.end()); }
606 };
607
450608 //===--------------------------------------------------------------------===//
451609 /// DIE - A structured debug information entry. Has an abbreviation which
452610 /// describes its organization.
480638
481639 /// Attribute values.
482640 ///
483 SmallVector Values;
641 DIEValueList Values;
484642
485643 protected:
486644 DIE() : Offset(0), Size(0), Parent(nullptr) {}
503661 return llvm::make_range(Children.begin(), Children.end());
504662 }
505663
506 typedef SmallVectorImpl::const_iterator value_iterator;
664 typedef DIEValueList::iterator value_iterator;
507665 typedef iterator_range value_range;
508666
509 value_iterator values_begin() const { return Values.begin(); }
510 value_iterator values_end() const { return Values.end(); }
511 value_range values() const {
512 return llvm::make_range(values_begin(), values_end());
513 }
514
515 void setValue(unsigned I, DIEValue New) {
516 assert(I < Values.size());
517 Values[I] = New;
518 }
667 value_range values() {
668 return llvm::make_range(Values.begin(), Values.end());
669 }
670
671 typedef DIEValueList::const_iterator const_value_iterator;
672 typedef iterator_range const_value_range;
673
674 const_value_range values() const {
675 return llvm::make_range(Values.begin(), Values.end());
676 }
677
519678 DIE *getParent() const { return Parent; }
520679
521680 /// Generate the abbreviation for this DIE.
538697
539698 /// addValue - Add a value and attributes to a DIE.
540699 ///
541 void addValue(DIEValue Value) { Values.push_back(Value); }
700 value_iterator addValue(BumpPtrAllocator &Alloc, DIEValue Value) {
701 return Values.insert(Alloc, Value);
702 }
542703 template
543 void addValue(dwarf::Attribute Attribute, dwarf::Form Form, T &&Value) {
544 Values.emplace_back(Attribute, Form, std::forward(Value));
704 value_iterator addValue(BumpPtrAllocator &Alloc, dwarf::Attribute Attribute,
705 dwarf::Form Form, T &&Value) {
706 return Values.emplace(Alloc, Attribute, Form, std::forward(Value));
545707 }
546708
547709 /// addChild - Add a child to the DIE.
164164 }
165165
166166 IndentCount += 2;
167 for (unsigned i = 0, N = Values.size(); i < N; ++i) {
167 unsigned I = 0;
168 for (const auto &V : Values) {
168169 O << Indent;
169170
170171 if (!isBlock)
171 O << dwarf::AttributeString(Values[i].getAttribute());
172 O << dwarf::AttributeString(V.getAttribute());
172173 else
173 O << "Blk[" << i << "]";
174
175 O << " "
176 << dwarf::FormEncodingString(Values[i].getForm())
177 << " ";
178 Values[i].print(O);
174 O << "Blk[" << I++ << "]";
175
176 O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
177 V.print(O);
179178 O << "\n";
180179 }
181180 IndentCount -= 2;
262262
263263 // Hash all of the values in a block like set of values. This assumes that
264264 // all of the data is going to be added as integers.
265 void DIEHash::hashBlockData(const DIE::value_range &Values) {
265 void DIEHash::hashBlockData(const DIE::const_value_range &Values) {
266266 for (const auto &V : Values)
267267 Hash.update((uint64_t)V.getDIEInteger().getValue());
268268 }
127127
128128 /// \brief Hashes the data in a block like DIEValue, e.g. DW_FORM_block or
129129 /// DW_FORM_exprloc.
130 void hashBlockData(const DIE::value_range &Values);
130 void hashBlockData(const DIE::const_value_range &Values);
131131
132132 /// \brief Hashes the contents pointed to in the .debug_loc section.
133133 void hashLocList(const DIELocList &LocList);
4141 DD->addArangeLabel(SymbolCU(this, Label));
4242
4343 unsigned idx = DD->getAddressPool().getIndex(Label);
44 Die.addValue(Attribute, dwarf::DW_FORM_GNU_addr_index, DIEInteger(idx));
44 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_GNU_addr_index,
45 DIEInteger(idx));
4546 }
4647
4748 void DwarfCompileUnit::addLocalLabelAddress(DIE &Die,
5152 DD->addArangeLabel(SymbolCU(this, Label));
5253
5354 if (Label)
54 Die.addValue(Attribute, dwarf::DW_FORM_addr, DIELabel(Label));
55 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_addr,
56 DIELabel(Label));
5557 else
56 Die.addValue(Attribute, dwarf::DW_FORM_addr, DIEInteger(0));
58 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_addr,
59 DIEInteger(0));
5760 }
5861
5962 unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
224227 CURanges.back().setEnd(Range.getEnd());
225228 }
226229
227 void DwarfCompileUnit::addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
228 const MCSymbol *Label,
229 const MCSymbol *Sec) {
230 DIE::value_iterator
231 DwarfCompileUnit::addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
232 const MCSymbol *Label, const MCSymbol *Sec) {
230233 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
231 addLabel(Die, Attribute,
232 DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
233 : dwarf::DW_FORM_data4,
234 Label);
235 else
236 addSectionDelta(Die, Attribute, Label, Sec);
234 return addLabel(Die, Attribute,
235 DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
236 : dwarf::DW_FORM_data4,
237 Label);
238 return addSectionDelta(Die, Attribute, Label, Sec);
237239 }
238240
239241 void DwarfCompileUnit::initStmtList() {
240242 // Define start line table label for each Compile Unit.
241243 MCSymbol *LineTableStartSym =
242244 Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());
243
244 stmtListIndex = std::distance(UnitDie.values_begin(), UnitDie.values_end());
245245
246246 // DW_AT_stmt_list is a offset of line number information for this
247247 // compile unit in debug_line section. For split dwarf this is
249249 // The line table entries are not always emitted in assembly, so it
250250 // is not okay to use line_table_start here.
251251 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
252 addSectionLabel(UnitDie, dwarf::DW_AT_stmt_list, LineTableStartSym,
253 TLOF.getDwarfLineSection()->getBeginSymbol());
252 StmtListValue =
253 addSectionLabel(UnitDie, dwarf::DW_AT_stmt_list, LineTableStartSym,
254 TLOF.getDwarfLineSection()->getBeginSymbol());
254255 }
255256
256257 void DwarfCompileUnit::applyStmtList(DIE &D) {
257 D.addValue(UnitDie.values_begin()[stmtListIndex]);
258 D.addValue(DIEValueAllocator, *StmtListValue);
258259 }
259260
260261 void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
360361 FinalChildren.push_back(std::move(ScopeDIE));
361362 }
362363
363 void DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
364 const MCSymbol *Hi, const MCSymbol *Lo) {
365 Die.addValue(Attribute, DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
366 : dwarf::DW_FORM_data4,
367 new (DIEValueAllocator) DIEDelta(Hi, Lo));
364 DIE::value_iterator
365 DwarfCompileUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
366 const MCSymbol *Hi, const MCSymbol *Lo) {
367 return Die.addValue(DIEValueAllocator, Attribute,
368 DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
369 : dwarf::DW_FORM_data4,
370 new (DIEValueAllocator) DIEDelta(Hi, Lo));
368371 }
369372
370373 void DwarfCompileUnit::addScopeRangeList(DIE &ScopeDIE,
780783 unsigned Index) {
781784 dwarf::Form Form = DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
782785 : dwarf::DW_FORM_data4;
783 Die.addValue(Attribute, Form, DIELocList(Index));
786 Die.addValue(DIEValueAllocator, Attribute, Form, DIELocList(Index));
784787 }
785788
786789 void DwarfCompileUnit::applyVariableAttributes(const DbgVariable &Var,
797800 /// Add a Dwarf expression attribute data and value.
798801 void DwarfCompileUnit::addExpr(DIELoc &Die, dwarf::Form Form,
799802 const MCExpr *Expr) {
800 Die.addValue((dwarf::Attribute)0, Form, DIEExpr(Expr));
803 Die.addValue(DIEValueAllocator, (dwarf::Attribute)0, Form, DIEExpr(Expr));
801804 }
802805
803806 void DwarfCompileUnit::applySubprogramAttributesToDefinition(
3030 class DwarfCompileUnit : public DwarfUnit {
3131 /// The attribute index of DW_AT_stmt_list in the compile unit DIE, avoiding
3232 /// the need to search for it in applyStmtList.
33 unsigned stmtListIndex;
33 DIE::value_iterator StmtListValue;
3434
3535 /// Skeleton unit associated with this unit.
3636 DwarfCompileUnit *Skeleton;
9191 const MCSymbol *Label);
9292
9393 /// addSectionDelta - Add a label delta attribute data and value.
94 void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
95 const MCSymbol *Lo);
94 DIE::value_iterator addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
95 const MCSymbol *Hi, const MCSymbol *Lo);
9696
9797 DwarfCompileUnit &getCU() override { return *this; }
9898
105105
106106 /// addSectionLabel - Add a Dwarf section label attribute data and value.
107107 ///
108 void addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
109 const MCSymbol *Label, const MCSymbol *Sec);
108 DIE::value_iterator addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
109 const MCSymbol *Label,
110 const MCSymbol *Sec);
110111
111112 /// \brief Find DIE for the given subprogram and attach appropriate
112113 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
183183
184184 void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
185185 if (DD->getDwarfVersion() >= 4)
186 Die.addValue(Attribute, dwarf::DW_FORM_flag_present, DIEInteger(1));
186 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_flag_present,
187 DIEInteger(1));
187188 else
188 Die.addValue(Attribute, dwarf::DW_FORM_flag, DIEInteger(1));
189 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_flag,
190 DIEInteger(1));
189191 }
190192
191193 void DwarfUnit::addUInt(DIE &Die, dwarf::Attribute Attribute,
192194 Optional Form, uint64_t Integer) {
193195 if (!Form)
194196 Form = DIEInteger::BestForm(false, Integer);
195 Die.addValue(Attribute, *Form, DIEInteger(Integer));
197 Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
196198 }
197199
198200 void DwarfUnit::addUInt(DIE &Block, dwarf::Form Form, uint64_t Integer) {
203205 Optional Form, int64_t Integer) {
204206 if (!Form)
205207 Form = DIEInteger::BestForm(true, Integer);
206 Die.addValue(Attribute, *Form, DIEInteger(Integer));
208 Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
207209 }
208210
209211 void DwarfUnit::addSInt(DIELoc &Die, Optional Form,
213215
214216 void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
215217 StringRef String) {
216 Die.addValue(Attribute,
218 Die.addValue(DIEValueAllocator, Attribute,
217219 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp,
218220 DIEString(DU->getStringPool().getEntry(*Asm, String)));
219221 }
220222
221 void DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
222 const MCSymbol *Label) {
223 Die.addValue(Attribute, Form, DIELabel(Label));
223 DIE::value_iterator DwarfUnit::addLabel(DIE &Die, dwarf::Attribute Attribute,
224 dwarf::Form Form,
225 const MCSymbol *Label) {
226 return Die.addValue(DIEValueAllocator, Attribute, Form, DIELabel(Label));
224227 }
225228
226229 void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label) {
253256
254257 void DwarfUnit::addLabelDelta(DIE &Die, dwarf::Attribute Attribute,
255258 const MCSymbol *Hi, const MCSymbol *Lo) {
256 Die.addValue(Attribute, dwarf::DW_FORM_data4,
259 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_data4,
257260 new (DIEValueAllocator) DIEDelta(Hi, Lo));
258261 }
259262
268271 // and think this is a full definition.
269272 addFlag(Die, dwarf::DW_AT_declaration);
270273
271 Die.addValue(dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
272 DIETypeSignature(Type));
274 Die.addValue(DIEValueAllocator, dwarf::DW_AT_signature,
275 dwarf::DW_FORM_ref_sig8, DIETypeSignature(Type));
273276 }
274277
275278 void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
281284 DieCU = &getUnitDie();
282285 if (!EntryCU)
283286 EntryCU = &getUnitDie();
284 Die.addValue(Attribute,
287 Die.addValue(DIEValueAllocator, Attribute,
285288 EntryCU == DieCU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
286289 Entry);
287290 }
298301 void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc) {
299302 Loc->ComputeSize(Asm);
300303 DIELocs.push_back(Loc); // Memoize so we can call the destructor later on.
301 Die.addValue(Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc);
304 Die.addValue(DIEValueAllocator, Attribute,
305 Loc->BestForm(DD->getDwarfVersion()), Loc);
302306 }
303307
304308 void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute,
305309 DIEBlock *Block) {
306310 Block->ComputeSize(Asm);
307311 DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on.
308 Die.addValue(Attribute, Block->BestForm(), Block);
312 Die.addValue(DIEValueAllocator, Attribute, Block->BestForm(), Block);
309313 }
310314
311315 void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, StringRef File,
13851389 // Objective-C properties.
13861390 if (DINode *PNode = DT->getObjCProperty())
13871391 if (DIE *PDie = getDIE(PNode))
1388 MemberDie.addValue(dwarf::DW_AT_APPLE_property, dwarf::DW_FORM_ref4,
1389 DIEEntry(*PDie));
1392 MemberDie.addValue(DIEValueAllocator, dwarf::DW_AT_APPLE_property,
1393 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
13901394
13911395 if (DT->isArtificial())
13921396 addFlag(MemberDie, dwarf::DW_AT_artificial);
7272 /// MDNode for the compile unit.
7373 const DICompileUnit *CUNode;
7474
75 // All DIEValues are allocated through this allocator.
76 BumpPtrAllocator DIEValueAllocator;
77
7578 /// Unit debug information entry.
7679 DIE UnitDie;
7780
102105 /// DW_AT_containing_type attribute. This attribute points to a DIE that
103106 /// corresponds to the MDNode mapped with the subprogram DIE.
104107 DenseMap ContainingTypeMap;
105
106 // All DIEValues are allocated through this allocator.
107 BumpPtrAllocator DIEValueAllocator;
108108
109109 /// The section this unit will be emitted in.
110110 MCSection *Section;
205205 void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
206206
207207 /// \brief Add a Dwarf label attribute data and value.
208 void addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
209 const MCSymbol *Label);
208 DIE::value_iterator addLabel(DIE &Die, dwarf::Attribute Attribute,
209 dwarf::Form Form, const MCSymbol *Label);
210210
211211 void addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label);
212212
5959
6060 typedef HalfOpenIntervalMap FunctionIntervals;
6161
62 // FIXME: Delete this structure once DIE::Values has a stable iterator we can
63 // use instead.
62 // FIXME: Delete this structure.
6463 struct PatchLocation {
65 DIE *Die;
66 unsigned Index;
67
68 PatchLocation() : Die(nullptr), Index(0) {}
69 PatchLocation(DIE &Die, unsigned Index) : Die(&Die), Index(Index) {}
70 PatchLocation(DIE &Die)
71 : Die(&Die), Index(std::distance(Die.values_begin(), Die.values_end())) {}
64 DIE::value_iterator I;
65
66 PatchLocation() = default;
67 PatchLocation(DIE::value_iterator I) : I(I) {}
7268
7369 void set(uint64_t New) const {
74 assert(Die);
75 assert((signed)Index <
76 std::distance(Die->values_begin(), Die->values_end()));
77 const auto &Old = Die->values_begin()[Index];
70 assert(I);
71 const auto &Old = *I;
7872 assert(Old.getType() == DIEValue::isInteger);
79 Die->setValue(Index,
80 DIEValue(Old.getAttribute(), Old.getForm(), DIEInteger(New)));
73 *I = DIEValue(Old.getAttribute(), Old.getForm(), DIEInteger(New));
8174 }
8275
8376 uint64_t get() const {
84 assert(Die);
85 assert((signed)Index <
86 std::distance(Die->values_begin(), Die->values_end()));
87 assert(Die->values_begin()[Index].getType() == DIEValue::isInteger);
88 return Die->values_begin()[Index].getDIEInteger().getValue();
77 assert(I);
78 return I->getDIEInteger().getValue();
8979 }
9080 };
9181
18361826 // Switch everything to out of line strings.
18371827 const char *String = *Val.getAsCString(&U);
18381828 unsigned Offset = StringPool.getStringOffset(String);
1839 Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
1829 Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_strp,
18401830 DIEInteger(Offset));
18411831 return 4;
18421832 }
18861876 uint32_t NewRefOffset =
18871877 RefUnit->getStartOffset() + NewRefDie->getOffset();
18881878 Attr = NewRefOffset;
1879 Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
1880 dwarf::DW_FORM_ref_addr, DIEInteger(Attr));
18891881 } else {
18901882 // A forward reference. Note and fixup later.
18911883 Attr = 0xBADDEF;
1892 Unit.noteForwardReference(NewRefDie, RefUnit, PatchLocation(Die));
1893 }
1894 Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::DW_FORM_ref_addr,
1895 DIEInteger(Attr));
1884 Unit.noteForwardReference(
1885 NewRefDie, RefUnit,
1886 Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
1887 dwarf::DW_FORM_ref_addr, DIEInteger(Attr)));
1888 }
18961889 return AttrSize;
18971890 }
18981891
1899 Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::Form(AttrSpec.Form),
1900 DIEEntry(*NewRefDie));
1892 Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
1893 dwarf::Form(AttrSpec.Form), DIEEntry(*NewRefDie));
19011894 return AttrSize;
19021895 }
19031896
19291922 dwarf::Form(AttrSpec.Form), Block);
19301923 ArrayRef Bytes = *Val.getAsBlock();
19311924 for (auto Byte : Bytes)
1932 Attr->addValue(static_cast(0), dwarf::DW_FORM_data1,
1933 DIEInteger(Byte));
1925 Attr->addValue(DIEAlloc, static_cast(0),
1926 dwarf::DW_FORM_data1, DIEInteger(Byte));
19341927 // FIXME: If DIEBlock and DIELoc just reuses the Size field of
19351928 // the DIE class, this if could be replaced by
19361929 // Attr->setSize(Bytes.size()).
19401933 else
19411934 Block->ComputeSize(&Streamer->getAsmPrinter());
19421935 }
1943 Die.addValue(Value);
1936 Die.addValue(DIEAlloc, Value);
19441937 return AttrSize;
19451938 }
19461939
19741967 Addr = (Info.OrigHighPc ? Info.OrigHighPc : Addr) + Info.PCOffset;
19751968 }
19761969
1977 Die.addValue(static_cast(AttrSpec.Attr),
1970 Die.addValue(DIEAlloc, static_cast(AttrSpec.Attr),
19781971 static_cast(AttrSpec.Form), DIEInteger(Addr));
19791972 return Unit.getOrigUnit().getAddressByteSize();
19801973 }
20031996 &Unit.getOrigUnit(), &InputDIE);
20041997 return 0;
20051998 }
2006 DIEInteger Attr(Value);
1999 PatchLocation Patch =
2000 Die.addValue(DIEAlloc, dwarf::Attribute(AttrSpec.Attr),
2001 dwarf::Form(AttrSpec.Form), DIEInteger(Value));
20072002 if (AttrSpec.Attr == dwarf::DW_AT_ranges)
2008 Unit.noteRangeAttribute(Die, PatchLocation(Die));
2003 Unit.noteRangeAttribute(Die, Patch);
20092004 // A more generic way to check for location attributes would be
20102005 // nice, but it's very unlikely that any other attribute needs a
20112006 // location list.
20122007 else if (AttrSpec.Attr == dwarf::DW_AT_location ||
20132008 AttrSpec.Attr == dwarf::DW_AT_frame_base)
2014 Unit.noteLocationAttribute(PatchLocation(Die), Info.PCOffset);
2009 Unit.noteLocationAttribute(Patch, Info.PCOffset);
20152010 else if (AttrSpec.Attr == dwarf::DW_AT_declaration && Value)
20162011 Info.IsDeclaration = true;
20172012
2018 Die.addValue(dwarf::Attribute(AttrSpec.Attr), dwarf::Form(AttrSpec.Form),
2019 Attr);
20202013 return AttrSize;
20212014 }
20222015
23662359 static void patchStmtList(DIE &Die, DIEInteger Offset) {
23672360 for (auto &V : Die.values())
23682361 if (V.getAttribute() == dwarf::DW_AT_stmt_list) {
2369 Die.setValue(&V - Die.values_begin(),
2370 DIEValue(V.getAttribute(), V.getForm(), Offset));
2362 V = DIEValue(V.getAttribute(), V.getForm(), Offset);
23712363 return;
23722364 }
23732365
2121
2222 // Test fixture
2323 class DIEHashTest : public testing::Test {
24 public:
25 BumpPtrAllocator Alloc;
26
27 private:
2428 StringMap Pool;
2529
2630 public:
3539 DIEHash Hash;
3640 DIE Die(dwarf::DW_TAG_base_type);
3741 DIEInteger Size(4);
38 Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
42 Die.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
3943 uint64_t MD5Res = Hash.computeTypeSignature(Die);
4044 ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
4145 }
4448 TEST_F(DIEHashTest, TrivialType) {
4549 DIE Unnamed(dwarf::DW_TAG_structure_type);
4650 DIEInteger One(1);
47 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
51 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
4852
4953 // Line and file number are ignored.
50 Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
51 Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
54 Unnamed.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
55 Unnamed.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
5256 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
5357
5458 // The exact same hash GCC produces for this DIE.
6064 DIE Foo(dwarf::DW_TAG_structure_type);
6165 DIEInteger One(1);
6266 DIEString FooStr = getString("foo");
63 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
64 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
67 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
68 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
6569
6670 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
6771
7680 auto Space = make_unique(dwarf::DW_TAG_namespace);
7781 DIEInteger One(1);
7882 DIEString SpaceStr = getString("space");
79 Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
83 Space->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
8084 // DW_AT_declaration is ignored.
81 Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
85 Space->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
86 One);
8287 // sibling?
8388
8489 auto Foo = make_unique(dwarf::DW_TAG_structure_type);
8590 DIEString FooStr = getString("foo");
86 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
87 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
91 Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
92 Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
8893
8994 DIE &N = *Foo;
9095 Space->addChild(std::move(Foo));
100105 TEST_F(DIEHashTest, TypeWithMember) {
101106 DIE Unnamed(dwarf::DW_TAG_structure_type);
102107 DIEInteger Four(4);
103 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
108 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
104109
105110 DIE Int(dwarf::DW_TAG_base_type);
106111 DIEString IntStr = getString("int");
107 Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
108 Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
112 Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
113 Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
109114 DIEInteger Five(5);
110 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
115 Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
111116
112117 DIEEntry IntRef(Int);
113118
114119 auto Member = make_unique(dwarf::DW_TAG_member);
115120 DIEString MemberStr = getString("member");
116 Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemberStr);
117 DIEInteger Zero(0);
118 Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
119 Zero);
120 Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
121 Member->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemberStr);
122 DIEInteger Zero(0);
123 Member->addValue(Alloc, dwarf::DW_AT_data_member_location,
124 dwarf::DW_FORM_data1, Zero);
125 Member->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
121126
122127 Unnamed.addChild(std::move(Member));
123128
130135 TEST_F(DIEHashTest, ReusedType) {
131136 DIE Unnamed(dwarf::DW_TAG_structure_type);
132137 DIEInteger Eight(8);
133 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
138 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
134139
135140 DIEInteger Four(4);
136141 DIE Int(dwarf::DW_TAG_base_type);
137142 DIEString IntStr = getString("int");
138 Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
139 Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
143 Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
144 Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
140145 DIEInteger Five(5);
141 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
146 Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
142147
143148 DIEEntry IntRef(Int);
144149
145150 auto Mem1 = make_unique(dwarf::DW_TAG_member);
146151 DIEString Mem1Str = getString("mem1");
147 Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
148 DIEInteger Zero(0);
149 Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
152 Mem1->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
153 DIEInteger Zero(0);
154 Mem1->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
150155 Zero);
151 Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
156 Mem1->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
152157
153158 Unnamed.addChild(std::move(Mem1));
154159
155160 auto Mem2 = make_unique(dwarf::DW_TAG_member);
156161 DIEString Mem2Str = getString("mem2");
157 Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
158 Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
162 Mem2->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
163 Mem2->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
159164 Four);
160 Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
165 Mem2->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
161166
162167 Unnamed.addChild(std::move(Mem2));
163168
170175 TEST_F(DIEHashTest, RecursiveType) {
171176 DIE Foo(dwarf::DW_TAG_structure_type);
172177 DIEInteger One(1);
173 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
174 DIEString FooStr = getString("foo");
175 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
178 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
179 DIEString FooStr = getString("foo");
180 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
176181
177182 auto Mem = make_unique(dwarf::DW_TAG_member);
178183 DIEString MemStr = getString("mem");
179 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
184 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
180185 DIEEntry FooRef(Foo);
181 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
186 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
182187 // DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
183188
184189 Foo.addChild(std::move(Mem));
192197 TEST_F(DIEHashTest, Pointer) {
193198 DIE Foo(dwarf::DW_TAG_structure_type);
194199 DIEInteger Eight(8);
195 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
196 DIEString FooStr = getString("foo");
197 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
200 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
201 DIEString FooStr = getString("foo");
202 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
198203
199204 auto Mem = make_unique(dwarf::DW_TAG_member);
200205 DIEString MemStr = getString("mem");
201 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
202 DIEInteger Zero(0);
203 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
206 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
207 DIEInteger Zero(0);
208 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
209 Zero);
204210
205211 DIE FooPtr(dwarf::DW_TAG_pointer_type);
206 FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
212 FooPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
207213 DIEEntry FooRef(Foo);
208 FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
214 FooPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
209215
210216 DIEEntry FooPtrRef(FooPtr);
211 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
217 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
212218
213219 Foo.addChild(std::move(Mem));
214220
221227 TEST_F(DIEHashTest, Reference) {
222228 DIE Foo(dwarf::DW_TAG_structure_type);
223229 DIEInteger Eight(8);
224 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
225 DIEString FooStr = getString("foo");
226 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
230 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
231 DIEString FooStr = getString("foo");
232 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
227233
228234 auto Mem = make_unique(dwarf::DW_TAG_member);
229235 DIEString MemStr = getString("mem");
230 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
231 DIEInteger Zero(0);
232 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
236 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
237 DIEInteger Zero(0);
238 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
239 Zero);
233240
234241 DIE FooRef(dwarf::DW_TAG_reference_type);
235 FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
242 FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
236243 DIEEntry FooEntry(Foo);
237 FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
244 FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
238245
239246 DIE FooRefConst(dwarf::DW_TAG_const_type);
240247 DIEEntry FooRefRef(FooRef);
241 FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
248 FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
249 FooRefRef);
242250
243251 DIEEntry FooRefConstRef(FooRefConst);
244 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
252 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
245253
246254 Foo.addChild(std::move(Mem));
247255
254262 TEST_F(DIEHashTest, RValueReference) {
255263 DIE Foo(dwarf::DW_TAG_structure_type);
256264 DIEInteger Eight(8);
257 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
258 DIEString FooStr = getString("foo");
259 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
265 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
266 DIEString FooStr = getString("foo");
267 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
260268
261269 auto Mem = make_unique(dwarf::DW_TAG_member);
262270 DIEString MemStr = getString("mem");
263 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
264 DIEInteger Zero(0);
265 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
271 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
272 DIEInteger Zero(0);
273 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
274 Zero);
266275
267276 DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
268 FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
277 FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
269278 DIEEntry FooEntry(Foo);
270 FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
279 FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
271280
272281 DIE FooRefConst(dwarf::DW_TAG_const_type);
273282 DIEEntry FooRefRef(FooRef);
274 FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
283 FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
284 FooRefRef);
275285
276286 DIEEntry FooRefConstRef(FooRefConst);
277 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
287 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
278288
279289 Foo.addChild(std::move(Mem));
280290
287297 TEST_F(DIEHashTest, PtrToMember) {
288298 DIE Foo(dwarf::DW_TAG_structure_type);
289299 DIEInteger Eight(8);
290 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
291 DIEString FooStr = getString("foo");
292 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
300 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
301 DIEString FooStr = getString("foo");
302 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
293303
294304 auto Mem = make_unique(dwarf::DW_TAG_member);
295305 DIEString MemStr = getString("mem");
296 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
297 DIEInteger Zero(0);
298 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
306 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
307 DIEInteger Zero(0);
308 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
309 Zero);
299310
300311 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
301312 DIEEntry FooEntry(Foo);
302 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
303 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
313 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
314 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
304315 FooEntry);
305316
306317 DIEEntry PtrToFooMemRef(PtrToFooMem);
307 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
318 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
308319
309320 Foo.addChild(std::move(Mem));
310321
328339 uint64_t MD5ResDecl;
329340 {
330341 DIE Bar(dwarf::DW_TAG_structure_type);
331 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
332 Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
342 Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
343 Bar.addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
344 One);
333345
334346 DIE Foo(dwarf::DW_TAG_structure_type);
335 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
336 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
347 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
348 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
337349
338350 auto Mem = make_unique(dwarf::DW_TAG_member);
339 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
340 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
341 Zero);
351 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
352 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
353 dwarf::DW_FORM_data1, Zero);
342354
343355 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
344356 DIEEntry BarEntry(Bar);
345 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
357 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
358 BarEntry);
346359 DIEEntry FooEntry(Foo);
347 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
348 FooEntry);
360 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
361 dwarf::DW_FORM_ref4, FooEntry);
349362
350363 DIEEntry PtrToFooMemRef(PtrToFooMem);
351 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
364 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
365 PtrToFooMemRef);
352366
353367 Foo.addChild(std::move(Mem));
354368
357371 uint64_t MD5ResDef;
358372 {
359373 DIE Bar(dwarf::DW_TAG_structure_type);
360 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
361 Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
374 Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
375 Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
362376
363377 DIE Foo(dwarf::DW_TAG_structure_type);
364 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
365 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
378 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
379 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
366380
367381 auto Mem = make_unique(dwarf::DW_TAG_member);
368 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
369 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
370 Zero);
382 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
383 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
384 dwarf::DW_FORM_data1, Zero);
371385
372386 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
373387 DIEEntry BarEntry(Bar);
374 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
388 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
389 BarEntry);
375390 DIEEntry FooEntry(Foo);
376 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
377 FooEntry);
391 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
392 dwarf::DW_FORM_ref4, FooEntry);
378393
379394 DIEEntry PtrToFooMemRef(PtrToFooMem);
380 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
395 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
396 PtrToFooMemRef);
381397
382398 Foo.addChild(std::move(Mem));
383399
401417 uint64_t MD5ResDecl;
402418 {
403419 DIE Bar(dwarf::DW_TAG_structure_type);
404 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
405 Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
420 Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
421 Bar.addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
422 One);
406423
407424 DIE Foo(dwarf::DW_TAG_structure_type);
408 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
409 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
425 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
426 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
410427
411428 auto Mem = make_unique(dwarf::DW_TAG_member);
412 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
413 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
414 Zero);
429 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
430 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
431 dwarf::DW_FORM_data1, Zero);
415432
416433 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
417434 DIEEntry BarEntry(Bar);
418 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
419 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
435 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
420436 BarEntry);
437 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
438 dwarf::DW_FORM_ref4, BarEntry);
421439
422440 DIEEntry PtrToFooMemRef(PtrToFooMem);
423 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
441 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
442 PtrToFooMemRef);
424443
425444 Foo.addChild(std::move(Mem));
426445
429448 uint64_t MD5ResDef;
430449 {
431450 DIE Bar(dwarf::DW_TAG_structure_type);
432 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
433 Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
451 Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
452 Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
434453
435454 DIE Foo(dwarf::DW_TAG_structure_type);
436 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
437 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
455 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
456 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
438457
439458 auto Mem = make_unique(dwarf::DW_TAG_member);
440 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
441 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
442 Zero);
459 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
460 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
461 dwarf::DW_FORM_data1, Zero);
443462
444463 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
445464 DIEEntry BarEntry(Bar);
446 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
447 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
465 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
448466 BarEntry);
467 PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
468 dwarf::DW_FORM_ref4, BarEntry);
449469
450470 DIEEntry PtrToFooMemRef(PtrToFooMem);
451 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
471 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
472 PtrToFooMemRef);
452473
453474 Foo.addChild(std::move(Mem));
454475
472493 DIEString MemStr = getString("mem");
473494
474495 DIE Unnamed(dwarf::DW_TAG_structure_type);
475 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
496 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
476497
477498 DIE Foo(dwarf::DW_TAG_structure_type);
478 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
479 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
499 Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
500 Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
480501
481502 auto Mem = make_unique(dwarf::DW_TAG_member);
482 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
483 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, Zero);
503 Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
504 Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
505 Zero);
484506
485507 DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
486 UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
508 UnnamedPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
509 Eight);
487510 DIEEntry UnnamedRef(Unnamed);
488 UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedRef);
511 UnnamedPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
512 UnnamedRef);
489513
490514 DIEEntry UnnamedPtrRef(UnnamedPtr);
491 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
515 Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
492516
493517 Foo.addChild(std::move(Mem));
494518
501525 TEST_F(DIEHashTest, NestedType) {
502526 DIE Unnamed(dwarf::DW_TAG_structure_type);
503527 DIEInteger One(1);
504 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
528 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
505529
506530 auto Foo = make_unique(dwarf::DW_TAG_structure_type);
507531 DIEString FooStr = getString("foo");
508 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
509 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
532 Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
533 Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
510534
511535 Unnamed.addChild(std::move(Foo));
512536
520544 TEST_F(DIEHashTest, MemberFunc) {
521545 DIE Unnamed(dwarf::DW_TAG_structure_type);
522546 DIEInteger One(1);
523 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
547 Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
524548
525549 auto Func = make_unique(dwarf::DW_TAG_subprogram);
526550 DIEString FuncStr = getString("func");
527 Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
551 Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
528552
529553 Unnamed.addChild(std::move(Func));
530554
541565 DIE A(dwarf::DW_TAG_structure_type);
542566 DIEInteger One(1);
543567 DIEString AStr = getString("A");
544 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
545 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
546 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
547 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
568 A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
569 A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
570 A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
571 A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
548572
549573 auto Func = make_unique(dwarf::DW_TAG_subprogram);
550574 DIEString FuncStr = getString("func");
551575 DIEString FuncLinkage = getString("_ZN1A4funcEv");
552576 DIEInteger Two(2);
553 Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
554 Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
555 Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
556 Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
557 Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, FuncLinkage);
558 Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
577 Func->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present,
578 One);
579 Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
580 Func->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
581 Func->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
582 Func->addValue(Alloc, dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp,
583 FuncLinkage);
584 Func->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
585 One);
559586
560587 A.addChild(std::move(Func));
561588
574601 DIE A(dwarf::DW_TAG_structure_type);
575602 DIEInteger One(1);
576603 DIEString AStr = getString("A");
577 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
578 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
579 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
580 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
604 A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
605 A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
606 A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
607 A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
581608
582609 DIEInteger Four(4);
583610 DIEInteger Five(5);
584611 DIEString FStr = getString("int");
585612 DIE IntTyDIE(dwarf::DW_TAG_base_type);
586 IntTyDIE.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
587 IntTyDIE.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
588 IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
613 IntTyDIE.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
614 IntTyDIE.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
615 IntTyDIE.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
589616
590617 DIEEntry IntTy(IntTyDIE);
591618 auto PITyDIE = make_unique(dwarf::DW_TAG_const_type);
592 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
619 PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
593620
594621 DIEEntry PITy(*PITyDIE);
595622 auto PI = make_unique(dwarf::DW_TAG_member);
596623 DIEString PIStr = getString("PI");
597624 DIEInteger Two(2);
598625 DIEInteger NegThree(-3);
599 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
600 PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
601 PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
602 PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
603 PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
604 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
605 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, NegThree);
626 PI->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
627 PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
628 PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
629 PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
630 PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
631 PI->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
632 One);
633 PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, NegThree);
606634
607635 A.addChild(std::move(PI));
608636
619647 DIE A(dwarf::DW_TAG_structure_type);
620648 DIEInteger One(1);
621649 DIEString AStr = getString("A");
622 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
623 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
624 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
625 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
650 A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
651 A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
652 A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
653 A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
626654
627655 DIEInteger Four(4);
628656 DIEString FStr = getString("float");
629657 auto FloatTyDIE = make_unique(dwarf::DW_TAG_base_type);
630 FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
631 FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Four);
632 FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
658 FloatTyDIE->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
659 Four);
660 FloatTyDIE->addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
661 Four);
662 FloatTyDIE->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
633663
634664 DIEEntry FloatTy(*FloatTyDIE);
635665 auto PITyDIE = make_unique(dwarf::DW_TAG_const_type);
636 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
666 PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
637667
638668 DIEEntry PITy(*PITyDIE);
639669 auto PI = make_unique(dwarf::DW_TAG_member);
640670 DIEString PIStr = getString("PI");
641671 DIEInteger Two(2);
642 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
643 PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
644 PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
645 PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
646 PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
647 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
672 PI->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
673 PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
674 PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
675 PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
676 PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
677 PI->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
678 One);
648679
649680 DIEBlock PIBlock;
650681 DIEInteger Blk1(0xc3);
652683 DIEInteger Blk3(0x48);
653684 DIEInteger Blk4(0x40);
654685
655 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk1);
656 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk2);
657 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk3);
658 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk4);
659
660 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
686 PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk1);
687 PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk2);
688 PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk3);
689 PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk4);
690
691 PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_block1,
692 &PIBlock);
661693
662694 A.addChild(std::move(PI));
663695