Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 1 | //===--- lib/CodeGen/DIE.cpp - DWARF Info Entries -------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Data structures for DWARF info entries. |
Eric Christopher | b800ff7 | 2013-01-07 22:40:45 +0000 | [diff] [blame] | 11 | // |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Frederic Riss | e541e0b | 2015-01-05 21:29:41 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/DIE.h" |
David Blaikie | 37c5231 | 2014-10-04 15:49:50 +0000 | [diff] [blame] | 15 | #include "DwarfCompileUnit.h" |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 16 | #include "DwarfDebug.h" |
David Blaikie | 47f615e | 2013-12-17 23:32:35 +0000 | [diff] [blame] | 17 | #include "DwarfUnit.h" |
Benjamin Kramer | 4d128a2 | 2010-01-17 07:46:39 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/Twine.h" |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/AsmPrinter.h" |
Nico Weber | 432a388 | 2018-04-30 14:59:11 +0000 | [diff] [blame] | 20 | #include "llvm/Config/llvm-config.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 21 | #include "llvm/IR/DataLayout.h" |
Chris Lattner | 7b26fce | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCAsmInfo.h" |
Rafael Espindola | 74dd854 | 2014-10-21 00:25:49 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCContext.h" |
Chris Lattner | 71601e8 | 2010-01-20 07:41:15 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCStreamer.h" |
Chris Lattner | 06d45f6 | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 25 | #include "llvm/MC/MCSymbol.h" |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Debug.h" |
Torok Edwin | 56d0659 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 27 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 28 | #include "llvm/Support/Format.h" |
Chris Lattner | f5c834f | 2010-01-22 22:09:00 +0000 | [diff] [blame] | 29 | #include "llvm/Support/FormattedStream.h" |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 30 | #include "llvm/Support/LEB128.h" |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 31 | #include "llvm/Support/MD5.h" |
Benjamin Kramer | 799003b | 2015-03-23 19:32:43 +0000 | [diff] [blame] | 32 | #include "llvm/Support/raw_ostream.h" |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 33 | using namespace llvm; |
| 34 | |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 35 | #define DEBUG_TYPE "dwarfdebug" |
| 36 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 37 | //===----------------------------------------------------------------------===// |
| 38 | // DIEAbbrevData Implementation |
| 39 | //===----------------------------------------------------------------------===// |
| 40 | |
| 41 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 42 | /// |
| 43 | void DIEAbbrevData::Profile(FoldingSetNodeID &ID) const { |
Reid Kleckner | ad65f10 | 2013-10-21 19:18:31 +0000 | [diff] [blame] | 44 | // Explicitly cast to an integer type for which FoldingSetNodeID has |
| 45 | // overloads. Otherwise MSVC 2010 thinks this call is ambiguous. |
| 46 | ID.AddInteger(unsigned(Attribute)); |
| 47 | ID.AddInteger(unsigned(Form)); |
Victor Leschuk | d7bfa40 | 2017-03-01 22:13:42 +0000 | [diff] [blame] | 48 | if (Form == dwarf::DW_FORM_implicit_const) |
| 49 | ID.AddInteger(Value); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | //===----------------------------------------------------------------------===// |
| 53 | // DIEAbbrev Implementation |
| 54 | //===----------------------------------------------------------------------===// |
| 55 | |
| 56 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 57 | /// |
| 58 | void DIEAbbrev::Profile(FoldingSetNodeID &ID) const { |
Reid Kleckner | ad65f10 | 2013-10-21 19:18:31 +0000 | [diff] [blame] | 59 | ID.AddInteger(unsigned(Tag)); |
Eric Christopher | e8f1072 | 2014-03-05 01:44:58 +0000 | [diff] [blame] | 60 | ID.AddInteger(unsigned(Children)); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 61 | |
| 62 | // For each attribute description. |
| 63 | for (unsigned i = 0, N = Data.size(); i < N; ++i) |
| 64 | Data[i].Profile(ID); |
| 65 | } |
| 66 | |
| 67 | /// Emit - Print the abbreviation using the specified asm printer. |
| 68 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 69 | void DIEAbbrev::Emit(const AsmPrinter *AP) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 70 | // Emit its Dwarf tag type. |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 71 | AP->EmitULEB128(Tag, dwarf::TagString(Tag).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 72 | |
| 73 | // Emit whether it has children DIEs. |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 74 | AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 75 | |
| 76 | // For each attribute description. |
| 77 | for (unsigned i = 0, N = Data.size(); i < N; ++i) { |
| 78 | const DIEAbbrevData &AttrData = Data[i]; |
| 79 | |
| 80 | // Emit attribute type. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 81 | AP->EmitULEB128(AttrData.getAttribute(), |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 82 | dwarf::AttributeString(AttrData.getAttribute()).data()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 83 | |
| 84 | // Emit form type. |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 85 | #ifndef NDEBUG |
| 86 | // Could be an assertion, but this way we can see the failing form code |
| 87 | // easily, which helps track down where it came from. |
| 88 | if (!dwarf::isValidFormForVersion(AttrData.getForm(), |
| 89 | AP->getDwarfVersion())) { |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 90 | LLVM_DEBUG(dbgs() << "Invalid form " << format("0x%x", AttrData.getForm()) |
| 91 | << " for DWARF version " << AP->getDwarfVersion() |
| 92 | << "\n"); |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 93 | llvm_unreachable("Invalid form for specified DWARF version"); |
| 94 | } |
| 95 | #endif |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 96 | AP->EmitULEB128(AttrData.getForm(), |
Mehdi Amini | 149f6ea | 2016-10-05 05:59:29 +0000 | [diff] [blame] | 97 | dwarf::FormEncodingString(AttrData.getForm()).data()); |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 98 | |
| 99 | // Emit value for DW_FORM_implicit_const. |
Paul Robinson | 70b3453 | 2017-04-20 19:16:51 +0000 | [diff] [blame] | 100 | if (AttrData.getForm() == dwarf::DW_FORM_implicit_const) |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 101 | AP->EmitSLEB128(AttrData.getValue()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | // Mark end of abbreviation. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 105 | AP->EmitULEB128(0, "EOM(1)"); |
| 106 | AP->EmitULEB128(0, "EOM(2)"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 109 | LLVM_DUMP_METHOD |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 110 | void DIEAbbrev::print(raw_ostream &O) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 111 | O << "Abbreviation @" |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 112 | << format("0x%lx", (long)(intptr_t)this) |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 113 | << " " |
| 114 | << dwarf::TagString(Tag) |
| 115 | << " " |
Eric Christopher | e8f1072 | 2014-03-05 01:44:58 +0000 | [diff] [blame] | 116 | << dwarf::ChildrenString(Children) |
Chris Lattner | 7472571 | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 117 | << '\n'; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 118 | |
| 119 | for (unsigned i = 0, N = Data.size(); i < N; ++i) { |
| 120 | O << " " |
| 121 | << dwarf::AttributeString(Data[i].getAttribute()) |
| 122 | << " " |
Victor Leschuk | d7bfa40 | 2017-03-01 22:13:42 +0000 | [diff] [blame] | 123 | << dwarf::FormEncodingString(Data[i].getForm()); |
| 124 | |
| 125 | if (Data[i].getForm() == dwarf::DW_FORM_implicit_const) |
| 126 | O << " " << Data[i].getValue(); |
| 127 | |
| 128 | O << '\n'; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 129 | } |
| 130 | } |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 131 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 132 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 133 | LLVM_DUMP_METHOD void DIEAbbrev::dump() const { |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 134 | print(dbgs()); |
| 135 | } |
| 136 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 137 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 138 | //===----------------------------------------------------------------------===// |
| 139 | // DIEAbbrevSet Implementation |
| 140 | //===----------------------------------------------------------------------===// |
| 141 | |
| 142 | DIEAbbrevSet::~DIEAbbrevSet() { |
| 143 | for (DIEAbbrev *Abbrev : Abbreviations) |
| 144 | Abbrev->~DIEAbbrev(); |
| 145 | } |
| 146 | |
| 147 | DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) { |
| 148 | |
| 149 | FoldingSetNodeID ID; |
| 150 | DIEAbbrev Abbrev = Die.generateAbbrev(); |
| 151 | Abbrev.Profile(ID); |
| 152 | |
| 153 | void *InsertPos; |
| 154 | if (DIEAbbrev *Existing = |
| 155 | AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) { |
| 156 | Die.setAbbrevNumber(Existing->getNumber()); |
| 157 | return *Existing; |
| 158 | } |
| 159 | |
| 160 | // Move the abbreviation to the heap and assign a number. |
| 161 | DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev)); |
| 162 | Abbreviations.push_back(New); |
| 163 | New->setNumber(Abbreviations.size()); |
| 164 | Die.setAbbrevNumber(Abbreviations.size()); |
| 165 | |
| 166 | // Store it for lookup. |
| 167 | AbbreviationsSet.InsertNode(New, InsertPos); |
| 168 | return *New; |
| 169 | } |
| 170 | |
| 171 | void DIEAbbrevSet::Emit(const AsmPrinter *AP, MCSection *Section) const { |
| 172 | if (!Abbreviations.empty()) { |
| 173 | // Start the debug abbrev section. |
| 174 | AP->OutStreamer->SwitchSection(Section); |
| 175 | AP->emitDwarfAbbrevs(Abbreviations); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | //===----------------------------------------------------------------------===// |
| 180 | // DIE Implementation |
| 181 | //===----------------------------------------------------------------------===// |
| 182 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 183 | DIE *DIE::getParent() const { |
| 184 | return Owner.dyn_cast<DIE*>(); |
| 185 | } |
| 186 | |
Duncan P. N. Exon Smith | 815a6eb5 | 2015-05-27 22:31:41 +0000 | [diff] [blame] | 187 | DIEAbbrev DIE::generateAbbrev() const { |
| 188 | DIEAbbrev Abbrev(Tag, hasChildren()); |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 189 | for (const DIEValue &V : values()) |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 190 | if (V.getForm() == dwarf::DW_FORM_implicit_const) |
| 191 | Abbrev.AddImplicitConstAttribute(V.getAttribute(), |
| 192 | V.getDIEInteger().getValue()); |
| 193 | else |
| 194 | Abbrev.AddAttribute(V.getAttribute(), V.getForm()); |
Duncan P. N. Exon Smith | 815a6eb5 | 2015-05-27 22:31:41 +0000 | [diff] [blame] | 195 | return Abbrev; |
| 196 | } |
| 197 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 198 | unsigned DIE::getDebugSectionOffset() const { |
| 199 | const DIEUnit *Unit = getUnit(); |
| 200 | assert(Unit && "DIE must be owned by a DIEUnit to get its absolute offset"); |
Benjamin Kramer | 6a8704c | 2016-12-01 19:10:10 +0000 | [diff] [blame] | 201 | return Unit->getDebugSectionOffset() + getOffset(); |
Manman Ren | 4dbdc90 | 2013-10-31 17:54:35 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 204 | const DIE *DIE::getUnitDie() const { |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 205 | const DIE *p = this; |
| 206 | while (p) { |
David Blaikie | 409dd9c | 2013-11-19 23:08:21 +0000 | [diff] [blame] | 207 | if (p->getTag() == dwarf::DW_TAG_compile_unit || |
| 208 | p->getTag() == dwarf::DW_TAG_type_unit) |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 209 | return p; |
| 210 | p = p->getParent(); |
| 211 | } |
Craig Topper | 353eda4 | 2014-04-24 06:44:33 +0000 | [diff] [blame] | 212 | return nullptr; |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 215 | const DIEUnit *DIE::getUnit() const { |
| 216 | const DIE *UnitDie = getUnitDie(); |
| 217 | if (UnitDie) |
| 218 | return UnitDie->Owner.dyn_cast<DIEUnit*>(); |
| 219 | return nullptr; |
| 220 | } |
| 221 | |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 222 | DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const { |
Eric Christopher | 8552e22 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 223 | // Iterate through all the attributes until we find the one we're |
| 224 | // looking for, if we can't find it return NULL. |
Duncan P. N. Exon Smith | 88a8fc5 | 2015-05-27 22:44:06 +0000 | [diff] [blame] | 225 | for (const auto &V : values()) |
| 226 | if (V.getAttribute() == Attribute) |
| 227 | return V; |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 228 | return DIEValue(); |
Eric Christopher | 8552e22 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 231 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 232 | static void printValues(raw_ostream &O, const DIEValueList &Values, |
| 233 | StringRef Type, unsigned Size, unsigned IndentCount) { |
| 234 | O << Type << ": Size: " << Size << "\n"; |
| 235 | |
| 236 | unsigned I = 0; |
| 237 | const std::string Indent(IndentCount, ' '); |
| 238 | for (const auto &V : Values.values()) { |
| 239 | O << Indent; |
| 240 | O << "Blk[" << I++ << "]"; |
| 241 | O << " " << dwarf::FormEncodingString(V.getForm()) << " "; |
| 242 | V.print(O); |
| 243 | O << "\n"; |
| 244 | } |
| 245 | } |
| 246 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 247 | LLVM_DUMP_METHOD |
Eric Christopher | 6c6de84 | 2013-05-06 17:50:50 +0000 | [diff] [blame] | 248 | void DIE::print(raw_ostream &O, unsigned IndentCount) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 249 | const std::string Indent(IndentCount, ' '); |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 250 | O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this) |
| 251 | << ", Offset: " << Offset << ", Size: " << Size << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 252 | |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 253 | O << Indent << dwarf::TagString(getTag()) << " " |
| 254 | << dwarf::ChildrenString(hasChildren()) << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 255 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 256 | IndentCount += 2; |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 257 | for (const auto &V : values()) { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 258 | O << Indent; |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 259 | O << dwarf::AttributeString(V.getAttribute()); |
Duncan P. N. Exon Smith | 4fb1f9c | 2015-06-25 23:46:41 +0000 | [diff] [blame] | 260 | O << " " << dwarf::FormEncodingString(V.getForm()) << " "; |
| 261 | V.print(O); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 262 | O << "\n"; |
| 263 | } |
| 264 | IndentCount -= 2; |
| 265 | |
Duncan P. N. Exon Smith | 827200c | 2015-06-25 23:52:10 +0000 | [diff] [blame] | 266 | for (const auto &Child : children()) |
| 267 | Child.print(O, IndentCount + 4); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 268 | |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 269 | O << "\n"; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 272 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Sam Clegg | 705f798 | 2017-06-21 22:19:17 +0000 | [diff] [blame] | 273 | LLVM_DUMP_METHOD void DIE::dump() const { |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 274 | print(dbgs()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 275 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 276 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 277 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 278 | unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP, |
| 279 | DIEAbbrevSet &AbbrevSet, |
| 280 | unsigned CUOffset) { |
| 281 | // Unique the abbreviation and fill in the abbreviation number so this DIE |
| 282 | // can be emitted. |
| 283 | const DIEAbbrev &Abbrev = AbbrevSet.uniqueAbbreviation(*this); |
| 284 | |
| 285 | // Set compile/type unit relative offset of this DIE. |
| 286 | setOffset(CUOffset); |
| 287 | |
| 288 | // Add the byte size of the abbreviation code. |
| 289 | CUOffset += getULEB128Size(getAbbrevNumber()); |
| 290 | |
| 291 | // Add the byte size of all the DIE attribute values. |
| 292 | for (const auto &V : values()) |
| 293 | CUOffset += V.SizeOf(AP); |
| 294 | |
| 295 | // Let the children compute their offsets and abbreviation numbers. |
| 296 | if (hasChildren()) { |
| 297 | (void)Abbrev; |
| 298 | assert(Abbrev.hasChildren() && "Children flag not set"); |
| 299 | |
| 300 | for (auto &Child : children()) |
| 301 | CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset); |
| 302 | |
| 303 | // Each child chain is terminated with a zero byte, adjust the offset. |
| 304 | CUOffset += sizeof(int8_t); |
| 305 | } |
| 306 | |
| 307 | // Compute the byte size of this DIE and all of its children correctly. This |
| 308 | // is needed so that top level DIE can help the compile unit set its length |
| 309 | // correctly. |
| 310 | setSize(CUOffset - getOffset()); |
| 311 | return CUOffset; |
| 312 | } |
| 313 | |
| 314 | //===----------------------------------------------------------------------===// |
| 315 | // DIEUnit Implementation |
| 316 | //===----------------------------------------------------------------------===// |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 317 | DIEUnit::DIEUnit(uint16_t V, uint8_t A, dwarf::Tag UnitTag) |
| 318 | : Die(UnitTag), Section(nullptr), Offset(0), Length(0), Version(V), |
| 319 | AddrSize(A) |
| 320 | { |
David Blaikie | e40caae | 2016-12-01 21:59:09 +0000 | [diff] [blame] | 321 | Die.Owner = this; |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 322 | assert((UnitTag == dwarf::DW_TAG_compile_unit || |
| 323 | UnitTag == dwarf::DW_TAG_type_unit || |
| 324 | UnitTag == dwarf::DW_TAG_partial_unit) && "expected a unit TAG"); |
| 325 | } |
| 326 | |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 327 | void DIEValue::EmitValue(const AsmPrinter *AP) const { |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 328 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 329 | case isNone: |
| 330 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 331 | #define HANDLE_DIEVALUE(T) \ |
| 332 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 333 | getDIE##T().EmitValue(AP, Form); \ |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 334 | break; |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 335 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 339 | unsigned DIEValue::SizeOf(const AsmPrinter *AP) const { |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 340 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 341 | case isNone: |
| 342 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 343 | #define HANDLE_DIEVALUE(T) \ |
| 344 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 345 | return getDIE##T().SizeOf(AP, Form); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 346 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 347 | } |
Aaron Ballman | c681c3d | 2015-05-23 14:46:49 +0000 | [diff] [blame] | 348 | llvm_unreachable("Unknown DIE kind"); |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 349 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 350 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 351 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 352 | void DIEValue::print(raw_ostream &O) const { |
| 353 | switch (Ty) { |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 354 | case isNone: |
| 355 | llvm_unreachable("Expected valid DIEValue"); |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 356 | #define HANDLE_DIEVALUE(T) \ |
| 357 | case is##T: \ |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 358 | getDIE##T().print(O); \ |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 359 | break; |
Duncan P. N. Exon Smith | ff18927 | 2015-05-27 21:15:43 +0000 | [diff] [blame] | 360 | #include "llvm/CodeGen/DIEValue.def" |
Duncan P. N. Exon Smith | 68b3f30 | 2015-05-23 01:45:07 +0000 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 364 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 365 | LLVM_DUMP_METHOD void DIEValue::dump() const { |
David Greene | 8bc072c | 2009-12-24 00:27:55 +0000 | [diff] [blame] | 366 | print(dbgs()); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 367 | } |
Matthias Braun | 8c209aa | 2017-01-28 02:02:38 +0000 | [diff] [blame] | 368 | #endif |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 369 | |
| 370 | //===----------------------------------------------------------------------===// |
| 371 | // DIEInteger Implementation |
| 372 | //===----------------------------------------------------------------------===// |
| 373 | |
| 374 | /// EmitValue - Emit integer of appropriate size. |
| 375 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 376 | void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 377 | switch (Form) { |
Victor Leschuk | cbddae7 | 2017-01-10 21:18:26 +0000 | [diff] [blame] | 378 | case dwarf::DW_FORM_implicit_const: |
Eric Christopher | bb69a27 | 2012-08-24 01:14:27 +0000 | [diff] [blame] | 379 | case dwarf::DW_FORM_flag_present: |
| 380 | // Emit something to keep the lines and comments in sync. |
| 381 | // FIXME: Is there a better way to do this? |
Lang Hames | 9ff69c8 | 2015-04-24 19:11:51 +0000 | [diff] [blame] | 382 | Asm->OutStreamer->AddBlankLine(); |
Eric Christopher | bb69a27 | 2012-08-24 01:14:27 +0000 | [diff] [blame] | 383 | return; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 384 | case dwarf::DW_FORM_flag: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 385 | case dwarf::DW_FORM_ref1: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 386 | case dwarf::DW_FORM_data1: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 387 | case dwarf::DW_FORM_strx1: |
| 388 | case dwarf::DW_FORM_addrx1: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 389 | case dwarf::DW_FORM_ref2: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 390 | case dwarf::DW_FORM_data2: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 391 | case dwarf::DW_FORM_strx2: |
| 392 | case dwarf::DW_FORM_addrx2: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 393 | case dwarf::DW_FORM_strx3: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 394 | case dwarf::DW_FORM_strp: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 395 | case dwarf::DW_FORM_ref4: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 396 | case dwarf::DW_FORM_data4: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 397 | case dwarf::DW_FORM_ref_sup4: |
| 398 | case dwarf::DW_FORM_strx4: |
| 399 | case dwarf::DW_FORM_addrx4: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 400 | case dwarf::DW_FORM_ref8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 401 | case dwarf::DW_FORM_ref_sig8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 402 | case dwarf::DW_FORM_data8: |
Paul Robinson | f96e21a | 2017-03-06 22:20:03 +0000 | [diff] [blame] | 403 | case dwarf::DW_FORM_ref_sup8: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 404 | case dwarf::DW_FORM_GNU_ref_alt: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 405 | case dwarf::DW_FORM_GNU_strp_alt: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 406 | case dwarf::DW_FORM_line_strp: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 407 | case dwarf::DW_FORM_sec_offset: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 408 | case dwarf::DW_FORM_strp_sup: |
Eric Christopher | e8a7b1b | 2012-09-10 23:34:03 +0000 | [diff] [blame] | 409 | case dwarf::DW_FORM_addr: |
Frederic Riss | ee17fb9b | 2015-03-04 22:07:36 +0000 | [diff] [blame] | 410 | case dwarf::DW_FORM_ref_addr: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 411 | Asm->OutStreamer->EmitIntValue(Integer, SizeOf(Asm, Form)); |
| 412 | return; |
| 413 | case dwarf::DW_FORM_GNU_str_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 414 | case dwarf::DW_FORM_GNU_addr_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 415 | case dwarf::DW_FORM_ref_udata: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 416 | case dwarf::DW_FORM_strx: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 417 | case dwarf::DW_FORM_udata: |
| 418 | Asm->EmitULEB128(Integer); |
| 419 | return; |
| 420 | case dwarf::DW_FORM_sdata: |
| 421 | Asm->EmitSLEB128(Integer); |
| 422 | return; |
Torok Edwin | fbcc663 | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 423 | default: llvm_unreachable("DIE Value form not supported yet"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | |
| 427 | /// SizeOf - Determine size of integer value in bytes. |
| 428 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 429 | unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Pavel Labath | 8ed6582b | 2018-03-14 11:31:17 +0000 | [diff] [blame] | 430 | dwarf::FormParams Params = {0, 0, dwarf::DWARF32}; |
Pavel Labath | 322711f | 2018-03-14 09:39:54 +0000 | [diff] [blame] | 431 | if (AP) |
| 432 | Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()), |
| 433 | AP->OutStreamer->getContext().getDwarfFormat()}; |
| 434 | |
| 435 | if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params)) |
| 436 | return *FixedSize; |
| 437 | |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 438 | switch (Form) { |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 439 | case dwarf::DW_FORM_GNU_str_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 440 | case dwarf::DW_FORM_GNU_addr_index: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 441 | case dwarf::DW_FORM_ref_udata: |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 442 | case dwarf::DW_FORM_strx: |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 443 | case dwarf::DW_FORM_udata: |
| 444 | return getULEB128Size(Integer); |
| 445 | case dwarf::DW_FORM_sdata: |
| 446 | return getSLEB128Size(Integer); |
David Blaikie | 46a9f01 | 2012-01-20 21:51:11 +0000 | [diff] [blame] | 447 | default: llvm_unreachable("DIE Value form not supported yet"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 448 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 449 | } |
| 450 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 451 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 452 | void DIEInteger::print(raw_ostream &O) const { |
Benjamin Kramer | f3da529 | 2011-11-05 08:57:40 +0000 | [diff] [blame] | 453 | O << "Int: " << (int64_t)Integer << " 0x"; |
| 454 | O.write_hex(Integer); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 455 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 456 | |
| 457 | //===----------------------------------------------------------------------===// |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 458 | // DIEExpr Implementation |
| 459 | //===----------------------------------------------------------------------===// |
| 460 | |
| 461 | /// EmitValue - Emit expression value. |
| 462 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 463 | void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Simon Dardis | 2e8cdbd | 2017-02-08 19:03:46 +0000 | [diff] [blame] | 464 | AP->EmitDebugThreadLocal(Expr, SizeOf(AP, Form)); |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /// SizeOf - Determine size of expression value in bytes. |
| 468 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 469 | unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 470 | if (Form == dwarf::DW_FORM_data4) return 4; |
| 471 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
| 472 | if (Form == dwarf::DW_FORM_strp) return 4; |
Mehdi Amini | 1660cab | 2015-07-16 05:59:25 +0000 | [diff] [blame] | 473 | return AP->getPointerSize(); |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 474 | } |
| 475 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 476 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 477 | void DIEExpr::print(raw_ostream &O) const { O << "Expr: " << *Expr; } |
Ulrich Weigand | 396ba8b | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 478 | |
| 479 | //===----------------------------------------------------------------------===// |
Chris Lattner | 8dcf41e | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 480 | // DIELabel Implementation |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 481 | //===----------------------------------------------------------------------===// |
| 482 | |
| 483 | /// EmitValue - Emit label value. |
| 484 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 485 | void DIELabel::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
David Blaikie | f244319 | 2013-10-21 17:28:37 +0000 | [diff] [blame] | 486 | AP->EmitLabelReference(Label, SizeOf(AP, Form), |
| 487 | Form == dwarf::DW_FORM_strp || |
| 488 | Form == dwarf::DW_FORM_sec_offset || |
Keno Fischer | f7d84ee | 2017-01-02 03:00:19 +0000 | [diff] [blame] | 489 | Form == dwarf::DW_FORM_ref_addr || |
| 490 | Form == dwarf::DW_FORM_data4); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /// SizeOf - Determine size of label value in bytes. |
| 494 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 495 | unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 496 | if (Form == dwarf::DW_FORM_data4) return 4; |
Eric Christopher | 4c7765f | 2013-01-17 03:00:04 +0000 | [diff] [blame] | 497 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
Nick Lewycky | d59c0ca | 2011-10-27 06:44:11 +0000 | [diff] [blame] | 498 | if (Form == dwarf::DW_FORM_strp) return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 499 | return AP->MAI->getCodePointerSize(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 502 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 503 | void DIELabel::print(raw_ostream &O) const { O << "Lbl: " << Label->getName(); } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 504 | |
| 505 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 506 | // DIEDelta Implementation |
| 507 | //===----------------------------------------------------------------------===// |
| 508 | |
| 509 | /// EmitValue - Emit delta value. |
| 510 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 511 | void DIEDelta::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Chris Lattner | 5a00dea | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 512 | AP->EmitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form)); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /// SizeOf - Determine size of delta value in bytes. |
| 516 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 517 | unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 518 | if (Form == dwarf::DW_FORM_data4) return 4; |
Eric Christopher | 33ff697 | 2013-11-21 23:46:41 +0000 | [diff] [blame] | 519 | if (Form == dwarf::DW_FORM_sec_offset) return 4; |
Nick Lewycky | d59c0ca | 2011-10-27 06:44:11 +0000 | [diff] [blame] | 520 | if (Form == dwarf::DW_FORM_strp) return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 521 | return AP->MAI->getCodePointerSize(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 522 | } |
| 523 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 524 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 525 | void DIEDelta::print(raw_ostream &O) const { |
Chris Lattner | bc9210c | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 526 | O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName(); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 527 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 528 | |
| 529 | //===----------------------------------------------------------------------===// |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 530 | // DIEString Implementation |
| 531 | //===----------------------------------------------------------------------===// |
| 532 | |
| 533 | /// EmitValue - Emit string value. |
| 534 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 535 | void DIEString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 536 | // Index of string in symbol table. |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 537 | switch (Form) { |
| 538 | case dwarf::DW_FORM_GNU_str_index: |
| 539 | case dwarf::DW_FORM_strx: |
| 540 | case dwarf::DW_FORM_strx1: |
| 541 | case dwarf::DW_FORM_strx2: |
| 542 | case dwarf::DW_FORM_strx3: |
| 543 | case dwarf::DW_FORM_strx4: |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 544 | DIEInteger(S.getIndex()).EmitValue(AP, Form); |
| 545 | return; |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 546 | case dwarf::DW_FORM_strp: |
| 547 | if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) |
| 548 | DIELabel(S.getSymbol()).EmitValue(AP, Form); |
| 549 | else |
| 550 | DIEInteger(S.getOffset()).EmitValue(AP, Form); |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 551 | return; |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 552 | default: |
| 553 | llvm_unreachable("Expected valid string form"); |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 554 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | /// SizeOf - Determine size of delta value in bytes. |
| 558 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 559 | unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 560 | // Index of string in symbol table. |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 561 | switch (Form) { |
| 562 | case dwarf::DW_FORM_GNU_str_index: |
| 563 | case dwarf::DW_FORM_strx: |
| 564 | case dwarf::DW_FORM_strx1: |
| 565 | case dwarf::DW_FORM_strx2: |
| 566 | case dwarf::DW_FORM_strx3: |
| 567 | case dwarf::DW_FORM_strx4: |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 568 | return DIEInteger(S.getIndex()).SizeOf(AP, Form); |
Wolfgang Pieb | 456b555 | 2018-01-26 18:52:58 +0000 | [diff] [blame] | 569 | case dwarf::DW_FORM_strp: |
| 570 | if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) |
| 571 | return DIELabel(S.getSymbol()).SizeOf(AP, Form); |
| 572 | return DIEInteger(S.getOffset()).SizeOf(AP, Form); |
| 573 | default: |
| 574 | llvm_unreachable("Expected valid string form"); |
| 575 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 576 | } |
| 577 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 578 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 579 | void DIEString::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | f73bcf4 | 2015-05-24 16:40:47 +0000 | [diff] [blame] | 580 | O << "String: " << S.getString(); |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 581 | } |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 582 | |
| 583 | //===----------------------------------------------------------------------===// |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 584 | // DIEInlineString Implementation |
| 585 | //===----------------------------------------------------------------------===// |
| 586 | void DIEInlineString::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
| 587 | if (Form == dwarf::DW_FORM_string) { |
| 588 | for (char ch : S) |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 589 | AP->emitInt8(ch); |
| 590 | AP->emitInt8(0); |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 591 | return; |
| 592 | } |
| 593 | llvm_unreachable("Expected valid string form"); |
| 594 | } |
| 595 | |
| 596 | unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
| 597 | // Emit string bytes + NULL byte. |
| 598 | return S.size() + 1; |
| 599 | } |
| 600 | |
| 601 | LLVM_DUMP_METHOD |
| 602 | void DIEInlineString::print(raw_ostream &O) const { |
Benjamin Kramer | eedc405 | 2016-12-09 13:33:41 +0000 | [diff] [blame] | 603 | O << "InlineString: " << S; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 607 | // DIEEntry Implementation |
| 608 | //===----------------------------------------------------------------------===// |
| 609 | |
| 610 | /// EmitValue - Emit debug information entry offset. |
| 611 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 612 | void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | dd50838 | 2014-03-06 00:00:56 +0000 | [diff] [blame] | 613 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 614 | switch (Form) { |
| 615 | case dwarf::DW_FORM_ref1: |
| 616 | case dwarf::DW_FORM_ref2: |
| 617 | case dwarf::DW_FORM_ref4: |
| 618 | case dwarf::DW_FORM_ref8: |
| 619 | AP->OutStreamer->EmitIntValue(Entry->getOffset(), SizeOf(AP, Form)); |
| 620 | return; |
| 621 | |
| 622 | case dwarf::DW_FORM_ref_udata: |
| 623 | AP->EmitULEB128(Entry->getOffset()); |
| 624 | return; |
| 625 | |
| 626 | case dwarf::DW_FORM_ref_addr: { |
Greg Clayton | 35630c3 | 2016-12-01 18:56:29 +0000 | [diff] [blame] | 627 | // Get the absolute offset for this DIE within the debug info/types section. |
| 628 | unsigned Addr = Entry->getDebugSectionOffset(); |
David Blaikie | 85366ac | 2017-04-22 07:53:44 +0000 | [diff] [blame] | 629 | if (const MCSymbol *SectionSym = |
| 630 | Entry->getUnit()->getCrossSectionRelativeBaseAddress()) { |
| 631 | AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true); |
| 632 | return; |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 633 | } |
David Blaikie | 85366ac | 2017-04-22 07:53:44 +0000 | [diff] [blame] | 634 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 635 | AP->OutStreamer->EmitIntValue(Addr, SizeOf(AP, Form)); |
| 636 | return; |
| 637 | } |
| 638 | default: |
| 639 | llvm_unreachable("Improper form for DIE reference"); |
| 640 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 641 | } |
| 642 | |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 643 | unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
| 644 | switch (Form) { |
| 645 | case dwarf::DW_FORM_ref1: |
| 646 | return 1; |
| 647 | case dwarf::DW_FORM_ref2: |
| 648 | return 2; |
| 649 | case dwarf::DW_FORM_ref4: |
| 650 | return 4; |
| 651 | case dwarf::DW_FORM_ref8: |
| 652 | return 8; |
| 653 | case dwarf::DW_FORM_ref_udata: |
| 654 | return getULEB128Size(Entry->getOffset()); |
| 655 | case dwarf::DW_FORM_ref_addr: |
| 656 | if (AP->getDwarfVersion() == 2) |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 657 | return AP->MAI->getCodePointerSize(); |
Greg Clayton | 3462a42 | 2016-12-08 01:03:48 +0000 | [diff] [blame] | 658 | switch (AP->OutStreamer->getContext().getDwarfFormat()) { |
| 659 | case dwarf::DWARF32: |
| 660 | return 4; |
| 661 | case dwarf::DWARF64: |
| 662 | return 8; |
| 663 | } |
| 664 | llvm_unreachable("Invalid DWARF format"); |
| 665 | |
| 666 | default: |
| 667 | llvm_unreachable("Improper form for DIE reference"); |
| 668 | } |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 669 | } |
| 670 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 671 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 672 | void DIEEntry::print(raw_ostream &O) const { |
David Blaikie | 8dbcc3f | 2014-04-25 19:33:43 +0000 | [diff] [blame] | 673 | O << format("Die: 0x%lx", (long)(intptr_t)&Entry); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 674 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 675 | |
| 676 | //===----------------------------------------------------------------------===// |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 677 | // DIELoc Implementation |
| 678 | //===----------------------------------------------------------------------===// |
| 679 | |
| 680 | /// ComputeSize - calculate the size of the location expression. |
| 681 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 682 | unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const { |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 683 | if (!Size) { |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 684 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 685 | Size += V.SizeOf(AP); |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 686 | } |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 687 | |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 688 | return Size; |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | /// EmitValue - Emit location data. |
| 692 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 693 | void DIELoc::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 694 | switch (Form) { |
| 695 | default: llvm_unreachable("Improper form for block"); |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 696 | case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break; |
| 697 | case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break; |
| 698 | case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break; |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 699 | case dwarf::DW_FORM_block: |
| 700 | case dwarf::DW_FORM_exprloc: |
| 701 | Asm->EmitULEB128(Size); break; |
| 702 | } |
| 703 | |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 704 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 705 | V.EmitValue(Asm); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | /// SizeOf - Determine size of location data in bytes. |
| 709 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 710 | unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 711 | switch (Form) { |
| 712 | case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); |
| 713 | case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); |
| 714 | case dwarf::DW_FORM_block4: return Size + sizeof(int32_t); |
| 715 | case dwarf::DW_FORM_block: |
| 716 | case dwarf::DW_FORM_exprloc: |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 717 | return Size + getULEB128Size(Size); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 718 | default: llvm_unreachable("Improper form for block"); |
| 719 | } |
| 720 | } |
| 721 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 722 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 723 | void DIELoc::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 724 | printValues(O, *this, "ExprLoc", Size, 5); |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 725 | } |
Eric Christopher | 4a74104 | 2014-02-16 08:46:55 +0000 | [diff] [blame] | 726 | |
| 727 | //===----------------------------------------------------------------------===// |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 728 | // DIEBlock Implementation |
| 729 | //===----------------------------------------------------------------------===// |
| 730 | |
| 731 | /// ComputeSize - calculate the size of the block. |
| 732 | /// |
Frederic Riss | cd04434 | 2015-03-04 02:30:08 +0000 | [diff] [blame] | 733 | unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const { |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 734 | if (!Size) { |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 735 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 736 | Size += V.SizeOf(AP); |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 737 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 738 | |
Eric Christopher | 8bdab43 | 2014-02-27 18:36:10 +0000 | [diff] [blame] | 739 | return Size; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /// EmitValue - Emit block data. |
| 743 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 744 | void DIEBlock::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 745 | switch (Form) { |
Craig Topper | ee4dab5 | 2012-02-05 08:31:47 +0000 | [diff] [blame] | 746 | default: llvm_unreachable("Improper form for block"); |
Rafael Espindola | 4b4d85f | 2018-03-29 23:32:54 +0000 | [diff] [blame] | 747 | case dwarf::DW_FORM_block1: Asm->emitInt8(Size); break; |
| 748 | case dwarf::DW_FORM_block2: Asm->emitInt16(Size); break; |
| 749 | case dwarf::DW_FORM_block4: Asm->emitInt32(Size); break; |
Chris Lattner | 9efd118 | 2010-04-04 19:09:29 +0000 | [diff] [blame] | 750 | case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break; |
Jonas Devlieghere | 9e3e7a9 | 2018-04-02 10:40:43 +0000 | [diff] [blame] | 751 | case dwarf::DW_FORM_string: break; |
Paul Robinson | a06f8dc | 2017-12-18 19:08:35 +0000 | [diff] [blame] | 752 | case dwarf::DW_FORM_data16: break; |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 753 | } |
| 754 | |
Duncan P. N. Exon Smith | 1ad5ebc | 2015-08-02 20:42:45 +0000 | [diff] [blame] | 755 | for (const auto &V : values()) |
Duncan P. N. Exon Smith | 9dbb501 | 2015-06-24 18:48:11 +0000 | [diff] [blame] | 756 | V.EmitValue(Asm); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | /// SizeOf - Determine size of block data in bytes. |
| 760 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 761 | unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 762 | switch (Form) { |
| 763 | case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); |
| 764 | case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); |
| 765 | case dwarf::DW_FORM_block4: return Size + sizeof(int32_t); |
Logan Chien | 5b776b7 | 2014-02-22 14:00:39 +0000 | [diff] [blame] | 766 | case dwarf::DW_FORM_block: return Size + getULEB128Size(Size); |
Paul Robinson | a06f8dc | 2017-12-18 19:08:35 +0000 | [diff] [blame] | 767 | case dwarf::DW_FORM_data16: return 16; |
David Blaikie | 46a9f01 | 2012-01-20 21:51:11 +0000 | [diff] [blame] | 768 | default: llvm_unreachable("Improper form for block"); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 769 | } |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 772 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 773 | void DIEBlock::print(raw_ostream &O) const { |
Duncan P. N. Exon Smith | c582114 | 2015-08-02 20:46:49 +0000 | [diff] [blame] | 774 | printValues(O, *this, "Blk", Size, 5); |
Bill Wendling | 47054f3 | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 775 | } |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 776 | |
| 777 | //===----------------------------------------------------------------------===// |
| 778 | // DIELocList Implementation |
| 779 | //===----------------------------------------------------------------------===// |
| 780 | |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 781 | unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 782 | if (Form == dwarf::DW_FORM_data4) |
| 783 | return 4; |
| 784 | if (Form == dwarf::DW_FORM_sec_offset) |
| 785 | return 4; |
Konstantin Zhuravlyov | dc77b2e | 2017-04-17 17:41:25 +0000 | [diff] [blame] | 786 | return AP->MAI->getCodePointerSize(); |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | /// EmitValue - Emit label value. |
| 790 | /// |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 791 | void DIELocList::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { |
David Blaikie | 9c550ac | 2014-03-25 01:44:02 +0000 | [diff] [blame] | 792 | DwarfDebug *DD = AP->getDwarfDebug(); |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 793 | MCSymbol *Label = DD->getDebugLocs().getList(Index).Label; |
Rafael Espindola | 857546e | 2015-06-16 23:22:02 +0000 | [diff] [blame] | 794 | AP->emitDwarfSymbolReference(Label, /*ForceOffset*/ DD->useSplitDwarf()); |
Eric Christopher | a27220f | 2014-03-05 22:41:20 +0000 | [diff] [blame] | 795 | } |
| 796 | |
Davide Italiano | c304a0d | 2015-11-24 02:21:43 +0000 | [diff] [blame] | 797 | LLVM_DUMP_METHOD |
Duncan P. N. Exon Smith | e7e1d0c | 2015-05-27 22:14:58 +0000 | [diff] [blame] | 798 | void DIELocList::print(raw_ostream &O) const { O << "LocList: " << Index; } |