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

1

2

3

4

5

6

7

8

12#include

13#include

14

15using namespace llvm;

16

20

21void DWARFAbbreviationDeclarationSet::clear() {

23 FirstAbbrCode = 0;

24 Decls.clear();

25}

26

29 clear();

30 const uint64_t BeginOffset = *OffsetPtr;

31 Offset = BeginOffset;

34 while (true) {

37 if (!ES)

39

41 break;

42

43 if (FirstAbbrCode == 0) {

44 FirstAbbrCode = AbbrDecl.getCode();

45 } else if (PrevAbbrCode + 1 != AbbrDecl.getCode()) {

46

47 FirstAbbrCode = UINT32_MAX;

48 }

49 PrevAbbrCode = AbbrDecl.getCode();

50 Decls.push_back(std::move(AbbrDecl));

51 }

53}

54

56 for (const auto &Decl : Decls)

57 Decl.dump(OS);

58}

59

63 if (FirstAbbrCode == UINT32_MAX) {

64 for (const auto &Decl : Decls) {

65 if (Decl.getCode() == AbbrCode)

66 return &Decl;

67 }

68 return nullptr;

69 }

70 if (AbbrCode < FirstAbbrCode || AbbrCode >= FirstAbbrCode + Decls.size())

71 return nullptr;

72 return &Decls[AbbrCode - FirstAbbrCode];

73}

74

76

77 std::vector<uint32_t> Codes;

78 Codes.reserve(Decls.size());

79 for (const auto &Decl : Decls)

80 Codes.push_back(Decl.getCode());

81

82 std::string Buffer;

84

85

86 for (auto Current = Codes.begin(), End = Codes.end(); Current != End;) {

87 uint32_t RangeStart = *Current;

88

89 Stream << *Current;

90 uint32_t RangeEnd = RangeStart;

91

92 while (++Current != End && *Current == RangeEnd + 1)

93 ++RangeEnd;

94

95 if (RangeStart != RangeEnd)

96 Stream << "-" << RangeEnd;

97

98 if (Current != End)

99 Stream << ", ";

100 }

101 return Buffer;

102}

103

105 : AbbrDeclSets(), PrevAbbrOffsetPos(AbbrDeclSets.end()), Data(Data) {}

106

108 if (!Data)

111 auto I = AbbrDeclSets.begin();

112 while (Data->isValidOffset(Offset)) {

113 while (I != AbbrDeclSets.end() && I->first < Offset)

114 ++I;

118 Data = std::nullopt;

119 return Err;

120 }

121 AbbrDeclSets.insert(I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls)));

122 }

123 Data = std::nullopt;

125}

126

129

131

132 if (AbbrDeclSets.empty()) {

133 OS << "< EMPTY >\n";

134 return;

135 }

136

137 for (const auto &I : AbbrDeclSets) {

138 OS << format("Abbrev table for offset: 0x%8.8" PRIx64 "\n", I.first);

139 I.second.dump(OS);

140 }

141}

142

145 const auto End = AbbrDeclSets.end();

146 if (PrevAbbrOffsetPos != End && PrevAbbrOffsetPos->first == CUAbbrOffset) {

147 return &PrevAbbrOffsetPos->second;

148 }

149

150 const auto Pos = AbbrDeclSets.find(CUAbbrOffset);

151 if (Pos != End) {

152 PrevAbbrOffsetPos = Pos;

153 return &Pos->second;

154 }

155

156 if (!Data || CUAbbrOffset >= Data->getData().size())

158 "the abbreviation offset into the .debug_abbrev section is not valid");

159

163 return std::move(Err);

164

165 PrevAbbrOffsetPos =

166 AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls)))

167 .first;

168 return &PrevAbbrOffsetPos->second;

169}

LLVM_ABI void dump(raw_ostream &OS) const

Definition DWARFDebugAbbrev.cpp:55

LLVM_ABI DWARFAbbreviationDeclarationSet()

Definition DWARFDebugAbbrev.cpp:17

LLVM_ABI const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const

Definition DWARFDebugAbbrev.cpp:61

LLVM_ABI Error extract(DataExtractor Data, uint64_t *OffsetPtr)

Definition DWARFDebugAbbrev.cpp:27

LLVM_ABI std::string getCodeRange() const

Definition DWARFDebugAbbrev.cpp:75

LLVM_ABI llvm::Expected< ExtractState > extract(DataExtractor Data, uint64_t *OffsetPtr)

LLVM_ABI Expected< const DWARFAbbreviationDeclarationSet * > getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const

Definition DWARFDebugAbbrev.cpp:144

LLVM_ABI Error parse() const

Definition DWARFDebugAbbrev.cpp:107

DWARFAbbreviationDeclarationSetMap::const_iterator end() const

LLVM_ABI DWARFDebugAbbrev(DataExtractor Data)

Definition DWARFDebugAbbrev.cpp:104

LLVM_ABI void dump(raw_ostream &OS) const

Definition DWARFDebugAbbrev.cpp:127

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

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

A raw_ostream that writes to an std::string.

This is an optimization pass for GlobalISel generic memory operations.

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

These are helper functions used to produce formatted output.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

void consumeError(Error Err)

Consume a Error without doing anything.