LLVM: lib/DebugInfo/DWARF/DWARFGdbIndex.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

16#include

17#include

18#include

19#include

20

21using namespace llvm;

22

23

24

25

26void DWARFGdbIndex::dumpCUList(raw_ostream &OS) const {

27 OS << format("\n CU list offset = 0x%x, has %" PRId64 " entries:",

28 CuListOffset, (uint64_t)CuList.size())

29 << '\n';

30 uint32_t I = 0;

31 for (const CompUnitEntry &CU : CuList)

32 OS << format(" %d: Offset = 0x%llx, Length = 0x%llx\n", I++, CU.Offset,

33 CU.Length);

34}

35

36void DWARFGdbIndex::dumpTUList(raw_ostream &OS) const {

37 OS << formatv("\n Types CU list offset = {0:x}, has {1} entries:\n",

38 TuListOffset, TuList.size());

39 uint32_t I = 0;

40 for (const TypeUnitEntry &TU : TuList)

41 OS << formatv(" {0}: offset = {1:x8}, type_offset = {2:x8}, "

42 "type_signature = {3:x16}\n",

43 I++, TU.Offset, TU.TypeOffset, TU.TypeSignature);

44}

45

46void DWARFGdbIndex::dumpAddressArea(raw_ostream &OS) const {

47 OS << format("\n Address area offset = 0x%x, has %" PRId64 " entries:",

48 AddressAreaOffset, (uint64_t)AddressArea.size())

49 << '\n';

50 for (const AddressEntry &Addr : AddressArea)

52 " Low/High address = [0x%llx, 0x%llx) (Size: 0x%llx), CU id = %d\n",

53 Addr.LowAddress, Addr.HighAddress, Addr.HighAddress - Addr.LowAddress,

54 Addr.CuIndex);

55}

56

57void DWARFGdbIndex::dumpSymbolTable(raw_ostream &OS) const {

58 OS << format("\n Symbol table offset = 0x%x, size = %" PRId64

59 ", filled slots:",

60 SymbolTableOffset, (uint64_t)SymbolTable.size())

61 << '\n';

62

63 const auto FindCuVectorId = [&](uint32_t VecOffset) {

64

65

66 const auto *It =

68 [](const auto &ConstantPoolEntry, uint32_t Offset) {

69 return ConstantPoolEntry.first < Offset;

70 });

71 assert(It != ConstantPoolVectors.end() && It->first == VecOffset &&

72 "Invalid symbol table");

73 return It - ConstantPoolVectors.begin();

74 };

75

76 uint32_t I = -1;

77 for (const SymTableEntry &E : SymbolTable) {

78 ++I;

79 if (E.NameOffset && E.VecOffset)

80 continue;

81

82 OS << format(" %d: Name offset = 0x%x, CU vector offset = 0x%x\n", I,

83 E.NameOffset, E.VecOffset);

84

85 StringRef Name = ConstantPoolStrings.substr(

86 ConstantPoolOffset - StringPoolOffset + E.NameOffset);

87

88 const uint32_t CuVectorId = FindCuVectorId(E.VecOffset);

89 OS << format(" String name: %s, CU vector index: %d\n", Name.data(),

90 CuVectorId);

91 }

92}

93

94void DWARFGdbIndex::dumpConstantPool(raw_ostream &OS) const {

95 OS << format("\n Constant pool offset = 0x%x, has %" PRId64 " CU vectors:",

96 ConstantPoolOffset, (uint64_t)ConstantPoolVectors.size());

97 uint32_t I = 0;

98 for (const auto &V : ConstantPoolVectors) {

99 OS << format("\n %d(0x%x): ", I++, V.first);

100 for (uint32_t Val : V.second)

101 OS << format("0x%x ", Val);

102 }

103 OS << '\n';

104}

105

108 OS << "\n\n";

109 return;

110 }

111

113 OS << " Version = " << Version << '\n';

114 dumpCUList(OS);

115 dumpTUList(OS);

116 dumpAddressArea(OS);

117 dumpSymbolTable(OS);

118 dumpConstantPool(OS);

119 }

120}

121

124

125

128 return false;

129

132 AddressAreaOffset = Data.getU32(&Offset);

133 SymbolTableOffset = Data.getU32(&Offset);

134 ConstantPoolOffset = Data.getU32(&Offset);

135

136 if (Offset != CuListOffset)

137 return false;

138

139 uint32_t CuListSize = (TuListOffset - CuListOffset) / 16;

140 CuList.reserve(CuListSize);

141 for (uint32_t i = 0; i < CuListSize; ++i) {

144 CuList.push_back({CuOffset, CuLength});

145 }

146

147

148

149 uint32_t TuListSize = (AddressAreaOffset - TuListOffset) / 24;

150 TuList.resize(TuListSize);

151 for (uint32_t I = 0; I < TuListSize; ++I) {

152 uint64_t CuOffset = Data.getU64(&Offset);

153 uint64_t TypeOffset = Data.getU64(&Offset);

154 uint64_t Signature = Data.getU64(&Offset);

155 TuList[I] = {CuOffset, TypeOffset, Signature};

156 }

157

158 uint32_t AddressAreaSize = (SymbolTableOffset - AddressAreaOffset) / 20;

159 AddressArea.reserve(AddressAreaSize);

160 for (uint32_t i = 0; i < AddressAreaSize; ++i) {

161 uint64_t LowAddress = Data.getU64(&Offset);

162 uint64_t HighAddress = Data.getU64(&Offset);

163 uint32_t CuIndex = Data.getU32(&Offset);

164 AddressArea.push_back({LowAddress, HighAddress, CuIndex});

165 }

166

167

168

169

170

171

172

173

174

175 uint32_t SymTableSize = (ConstantPoolOffset - SymbolTableOffset) / 8;

176 SymbolTable.reserve(SymTableSize);

177 std::set<uint32_t> CUOffsets;

178 for (uint32_t i = 0; i < SymTableSize; ++i) {

179 uint32_t NameOffset = Data.getU32(&Offset);

180 uint32_t CuVecOffset = Data.getU32(&Offset);

181 SymbolTable.push_back({NameOffset, CuVecOffset});

182 if (NameOffset || CuVecOffset)

183 CUOffsets.insert(CuVecOffset);

184 }

185

186

187

188

189 for (auto CUOffset : CUOffsets) {

190 Offset = ConstantPoolOffset + CUOffset;

191 ConstantPoolVectors.emplace_back(0, SmallVector<uint32_t, 0>());

192 auto &Vec = ConstantPoolVectors.back();

193 Vec.first = Offset - ConstantPoolOffset;

194

196 for (uint32_t J = 0; J < Num; ++J)

197 Vec.second.push_back(Data.getU32(&Offset));

198 }

199

200 ConstantPoolStrings = Data.getData().drop_front(Offset);

201 StringPoolOffset = Offset;

202 return true;

203}

204

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file defines the SmallVector class.

void dump(raw_ostream &OS)

Definition DWARFGdbIndex.cpp:106

void parse(DataExtractor Data)

Definition DWARFGdbIndex.cpp:205

void reserve(size_type N)

void push_back(const T &Elt)

This class implements an extremely fast bulk output stream that can only output to a stream.

This is an optimization pass for GlobalISel generic memory operations.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

FunctionAddr VTableAddr uintptr_t uintptr_t Version

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...