llvm.org GIT mirror llvm / 12385e6
Make DWARFAcceleratorTable::dump() const. As dump() methods should be. To allow that, do not store the DWARFFormValue objects used for the dump in the header data. Per Alexey's suggestion! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222436 91177308-0d34-0410-b5e6-96231b3b80d8 Frederic Riss 5 years ago
2 changed file(s) with 12 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
3939
4040 for (unsigned i = 0; i < NumAtoms; ++i) {
4141 uint16_t AtomType = AccelSection.getU16(&Offset);
42 DWARFFormValue AtomForm(AccelSection.getU16(&Offset));
42 uint16_t AtomForm = AccelSection.getU16(&Offset);
4343 HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
4444 }
4545
4646 return true;
4747 }
4848
49 void DWARFAcceleratorTable::dump(raw_ostream &OS) {
49 void DWARFAcceleratorTable::dump(raw_ostream &OS) const {
5050 // Dump the header.
5151 OS << "Magic = " << format("0x%08x", Hdr.Magic) << '\n'
5252 << "Version = " << format("0x%04x", Hdr.Version) << '\n'
5858 << "Number of atoms = " << HdrData.Atoms.size() << '\n';
5959
6060 unsigned i = 0;
61 SmallVector AtomForms;
6162 for (const auto &Atom: HdrData.Atoms) {
6263 OS << format("Atom[%d] Type: ", i++);
6364 if (const char *TypeString = dwarf::AtomTypeString(Atom.first))
6566 else
6667 OS << format("DW_ATOM_Unknown_0x%x", Atom.first);
6768 OS << " Form: ";
68 if (const char *FormString = dwarf::FormEncodingString(Atom.second.getForm()))
69 if (const char *FormString = dwarf::FormEncodingString(Atom.second))
6970 OS << FormString;
7071 else
71 OS << format("DW_FORM_Unknown_0x%x", Atom.second.getForm());
72 OS << format("DW_FORM_Unknown_0x%x", Atom.second);
7273 OS << '\n';
74 AtomForms.push_back(DWARFFormValue(Atom.second));
7375 }
7476
7577 // Now go through the actual tables and dump them.
113115 for (unsigned Data = 0; Data < NumData; ++Data) {
114116 OS << format(" Data[%d] => ", Data);
115117 unsigned i = 0;
116 for (auto &Atom : HdrData.Atoms) {
118 for (auto &Atom : AtomForms) {
117119 OS << format("{Atom[%d]: ", i++);
118 if (Atom.second.extractValue(AccelSection, &DataOffset, nullptr))
119 Atom.second.dump(OS, nullptr);
120 if (Atom.extractValue(AccelSection, &DataOffset, nullptr))
121 Atom.dump(OS, nullptr);
120122 else
121123 OS << "Error extracting the value";
122124 OS << "} ";
2828
2929 struct HeaderData {
3030 typedef uint16_t AtomType;
31 typedef uint16_t Form;
3132 uint32_t DIEOffsetBase;
32 SmallVectorDWARFFormValue>, 1> Atoms;
33 SmallVectorForm>, 3> Atoms;
3334 };
3435
3536 struct Header Hdr;
4344 : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {}
4445
4546 bool extract();
46 void dump(raw_ostream &OS);
47 void dump(raw_ostream &OS) const;
4748 };
4849
4950 }