File: | lib/DebugInfo/CodeView/SymbolRecordMapping.cpp |
Warning: | line 56, column 5 1st function call argument is an uninitialized value |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | //===- SymbolRecordMapping.cpp -----------------------------------*- C++-*-===// | |||||
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 | #include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" | |||||
11 | ||||||
12 | using namespace llvm; | |||||
13 | using namespace llvm::codeview; | |||||
14 | ||||||
15 | #define error(X)if (auto EC = X) return EC; \ | |||||
16 | if (auto EC = X) \ | |||||
17 | return EC; | |||||
18 | ||||||
19 | namespace { | |||||
20 | struct MapGap { | |||||
21 | Error operator()(CodeViewRecordIO &IO, LocalVariableAddrGap &Gap) const { | |||||
22 | error(IO.mapInteger(Gap.GapStartOffset))if (auto EC = IO.mapInteger(Gap.GapStartOffset)) return EC;; | |||||
23 | error(IO.mapInteger(Gap.Range))if (auto EC = IO.mapInteger(Gap.Range)) return EC;; | |||||
24 | return Error::success(); | |||||
25 | } | |||||
26 | }; | |||||
27 | } | |||||
28 | ||||||
29 | static Error mapLocalVariableAddrRange(CodeViewRecordIO &IO, | |||||
30 | LocalVariableAddrRange &Range) { | |||||
31 | error(IO.mapInteger(Range.OffsetStart))if (auto EC = IO.mapInteger(Range.OffsetStart)) return EC;; | |||||
32 | error(IO.mapInteger(Range.ISectStart))if (auto EC = IO.mapInteger(Range.ISectStart)) return EC;; | |||||
33 | error(IO.mapInteger(Range.Range))if (auto EC = IO.mapInteger(Range.Range)) return EC;; | |||||
34 | return Error::success(); | |||||
35 | } | |||||
36 | ||||||
37 | Error SymbolRecordMapping::visitSymbolBegin(CVSymbol &Record) { | |||||
38 | error(IO.beginRecord(MaxRecordLength - sizeof(RecordPrefix)))if (auto EC = IO.beginRecord(MaxRecordLength - sizeof(RecordPrefix ))) return EC;; | |||||
39 | return Error::success(); | |||||
40 | } | |||||
41 | ||||||
42 | Error SymbolRecordMapping::visitSymbolEnd(CVSymbol &Record) { | |||||
43 | error(IO.padToAlignment(alignOf(Container)))if (auto EC = IO.padToAlignment(alignOf(Container))) return EC ;; | |||||
44 | error(IO.endRecord())if (auto EC = IO.endRecord()) return EC;; | |||||
45 | return Error::success(); | |||||
46 | } | |||||
47 | ||||||
48 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { | |||||
49 | ||||||
50 | error(IO.mapInteger(Block.Parent))if (auto EC = IO.mapInteger(Block.Parent)) return EC;; | |||||
51 | error(IO.mapInteger(Block.End))if (auto EC = IO.mapInteger(Block.End)) return EC;; | |||||
52 | error(IO.mapInteger(Block.CodeSize))if (auto EC = IO.mapInteger(Block.CodeSize)) return EC;; | |||||
53 | error(IO.mapInteger(Block.CodeOffset))if (auto EC = IO.mapInteger(Block.CodeOffset)) return EC;; | |||||
54 | error(IO.mapInteger(Block.Segment))if (auto EC = IO.mapInteger(Block.Segment)) return EC;; | |||||
55 | error(IO.mapStringZ(Block.Name))if (auto EC = IO.mapStringZ(Block.Name)) return EC;; | |||||
56 | ||||||
57 | return Error::success(); | |||||
58 | } | |||||
59 | ||||||
60 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { | |||||
61 | ||||||
62 | error(IO.mapInteger(Thunk.Parent))if (auto EC = IO.mapInteger(Thunk.Parent)) return EC;; | |||||
63 | error(IO.mapInteger(Thunk.End))if (auto EC = IO.mapInteger(Thunk.End)) return EC;; | |||||
64 | error(IO.mapInteger(Thunk.Next))if (auto EC = IO.mapInteger(Thunk.Next)) return EC;; | |||||
65 | error(IO.mapInteger(Thunk.Offset))if (auto EC = IO.mapInteger(Thunk.Offset)) return EC;; | |||||
66 | error(IO.mapInteger(Thunk.Segment))if (auto EC = IO.mapInteger(Thunk.Segment)) return EC;; | |||||
67 | error(IO.mapInteger(Thunk.Length))if (auto EC = IO.mapInteger(Thunk.Length)) return EC;; | |||||
68 | error(IO.mapEnum(Thunk.Thunk))if (auto EC = IO.mapEnum(Thunk.Thunk)) return EC;; | |||||
69 | error(IO.mapStringZ(Thunk.Name))if (auto EC = IO.mapStringZ(Thunk.Name)) return EC;; | |||||
70 | error(IO.mapByteVectorTail(Thunk.VariantData))if (auto EC = IO.mapByteVectorTail(Thunk.VariantData)) return EC;; | |||||
71 | ||||||
72 | return Error::success(); | |||||
73 | } | |||||
74 | ||||||
75 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
76 | TrampolineSym &Tramp) { | |||||
77 | ||||||
78 | error(IO.mapEnum(Tramp.Type))if (auto EC = IO.mapEnum(Tramp.Type)) return EC;; | |||||
79 | error(IO.mapInteger(Tramp.Size))if (auto EC = IO.mapInteger(Tramp.Size)) return EC;; | |||||
80 | error(IO.mapInteger(Tramp.ThunkOffset))if (auto EC = IO.mapInteger(Tramp.ThunkOffset)) return EC;; | |||||
81 | error(IO.mapInteger(Tramp.TargetOffset))if (auto EC = IO.mapInteger(Tramp.TargetOffset)) return EC;; | |||||
82 | error(IO.mapInteger(Tramp.ThunkSection))if (auto EC = IO.mapInteger(Tramp.ThunkSection)) return EC;; | |||||
83 | error(IO.mapInteger(Tramp.TargetSection))if (auto EC = IO.mapInteger(Tramp.TargetSection)) return EC;; | |||||
84 | ||||||
85 | return Error::success(); | |||||
86 | } | |||||
87 | ||||||
88 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
89 | SectionSym &Section) { | |||||
90 | uint8_t Padding = 0; | |||||
91 | ||||||
92 | error(IO.mapInteger(Section.SectionNumber))if (auto EC = IO.mapInteger(Section.SectionNumber)) return EC ;; | |||||
93 | error(IO.mapInteger(Section.Alignment))if (auto EC = IO.mapInteger(Section.Alignment)) return EC;; | |||||
94 | error(IO.mapInteger(Padding))if (auto EC = IO.mapInteger(Padding)) return EC;; | |||||
95 | error(IO.mapInteger(Section.Rva))if (auto EC = IO.mapInteger(Section.Rva)) return EC;; | |||||
96 | error(IO.mapInteger(Section.Length))if (auto EC = IO.mapInteger(Section.Length)) return EC;; | |||||
97 | error(IO.mapInteger(Section.Characteristics))if (auto EC = IO.mapInteger(Section.Characteristics)) return EC ;; | |||||
98 | error(IO.mapStringZ(Section.Name))if (auto EC = IO.mapStringZ(Section.Name)) return EC;; | |||||
99 | ||||||
100 | return Error::success(); | |||||
101 | } | |||||
102 | ||||||
103 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
104 | CoffGroupSym &CoffGroup) { | |||||
105 | ||||||
106 | error(IO.mapInteger(CoffGroup.Size))if (auto EC = IO.mapInteger(CoffGroup.Size)) return EC;; | |||||
107 | error(IO.mapInteger(CoffGroup.Characteristics))if (auto EC = IO.mapInteger(CoffGroup.Characteristics)) return EC;; | |||||
108 | error(IO.mapInteger(CoffGroup.Offset))if (auto EC = IO.mapInteger(CoffGroup.Offset)) return EC;; | |||||
109 | error(IO.mapInteger(CoffGroup.Segment))if (auto EC = IO.mapInteger(CoffGroup.Segment)) return EC;; | |||||
110 | error(IO.mapStringZ(CoffGroup.Name))if (auto EC = IO.mapStringZ(CoffGroup.Name)) return EC;; | |||||
111 | ||||||
112 | return Error::success(); | |||||
113 | } | |||||
114 | ||||||
115 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
116 | BPRelativeSym &BPRel) { | |||||
117 | ||||||
118 | error(IO.mapInteger(BPRel.Offset))if (auto EC = IO.mapInteger(BPRel.Offset)) return EC;; | |||||
119 | error(IO.mapInteger(BPRel.Type))if (auto EC = IO.mapInteger(BPRel.Type)) return EC;; | |||||
120 | error(IO.mapStringZ(BPRel.Name))if (auto EC = IO.mapStringZ(BPRel.Name)) return EC;; | |||||
121 | ||||||
122 | return Error::success(); | |||||
123 | } | |||||
124 | ||||||
125 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
126 | BuildInfoSym &BuildInfo) { | |||||
127 | ||||||
128 | error(IO.mapInteger(BuildInfo.BuildId))if (auto EC = IO.mapInteger(BuildInfo.BuildId)) return EC;; | |||||
129 | ||||||
130 | return Error::success(); | |||||
131 | } | |||||
132 | ||||||
133 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
134 | CallSiteInfoSym &CallSiteInfo) { | |||||
135 | uint16_t Padding = 0; | |||||
136 | ||||||
137 | error(IO.mapInteger(CallSiteInfo.CodeOffset))if (auto EC = IO.mapInteger(CallSiteInfo.CodeOffset)) return EC ;; | |||||
138 | error(IO.mapInteger(CallSiteInfo.Segment))if (auto EC = IO.mapInteger(CallSiteInfo.Segment)) return EC;; | |||||
139 | error(IO.mapInteger(Padding))if (auto EC = IO.mapInteger(Padding)) return EC;; | |||||
140 | error(IO.mapInteger(CallSiteInfo.Type))if (auto EC = IO.mapInteger(CallSiteInfo.Type)) return EC;; | |||||
141 | ||||||
142 | return Error::success(); | |||||
143 | } | |||||
144 | ||||||
145 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
146 | EnvBlockSym &EnvBlock) { | |||||
147 | ||||||
148 | uint8_t Reserved = 0; | |||||
149 | error(IO.mapInteger(Reserved))if (auto EC = IO.mapInteger(Reserved)) return EC;; | |||||
150 | error(IO.mapStringZVectorZ(EnvBlock.Fields))if (auto EC = IO.mapStringZVectorZ(EnvBlock.Fields)) return EC ;; | |||||
151 | ||||||
152 | return Error::success(); | |||||
153 | } | |||||
154 | ||||||
155 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
156 | FileStaticSym &FileStatic) { | |||||
157 | ||||||
158 | error(IO.mapInteger(FileStatic.Index))if (auto EC = IO.mapInteger(FileStatic.Index)) return EC;; | |||||
159 | error(IO.mapInteger(FileStatic.ModFilenameOffset))if (auto EC = IO.mapInteger(FileStatic.ModFilenameOffset)) return EC;; | |||||
160 | error(IO.mapEnum(FileStatic.Flags))if (auto EC = IO.mapEnum(FileStatic.Flags)) return EC;; | |||||
161 | error(IO.mapStringZ(FileStatic.Name))if (auto EC = IO.mapStringZ(FileStatic.Name)) return EC;; | |||||
162 | ||||||
163 | return Error::success(); | |||||
164 | } | |||||
165 | ||||||
166 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { | |||||
167 | ||||||
168 | error(IO.mapInteger(Export.Ordinal))if (auto EC = IO.mapInteger(Export.Ordinal)) return EC;; | |||||
169 | error(IO.mapEnum(Export.Flags))if (auto EC = IO.mapEnum(Export.Flags)) return EC;; | |||||
170 | error(IO.mapStringZ(Export.Name))if (auto EC = IO.mapStringZ(Export.Name)) return EC;; | |||||
171 | ||||||
172 | return Error::success(); | |||||
173 | } | |||||
174 | ||||||
175 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
176 | Compile2Sym &Compile2) { | |||||
177 | ||||||
178 | error(IO.mapEnum(Compile2.Flags))if (auto EC = IO.mapEnum(Compile2.Flags)) return EC;; | |||||
179 | error(IO.mapEnum(Compile2.Machine))if (auto EC = IO.mapEnum(Compile2.Machine)) return EC;; | |||||
180 | error(IO.mapInteger(Compile2.VersionFrontendMajor))if (auto EC = IO.mapInteger(Compile2.VersionFrontendMajor)) return EC;; | |||||
181 | error(IO.mapInteger(Compile2.VersionFrontendMinor))if (auto EC = IO.mapInteger(Compile2.VersionFrontendMinor)) return EC;; | |||||
182 | error(IO.mapInteger(Compile2.VersionFrontendBuild))if (auto EC = IO.mapInteger(Compile2.VersionFrontendBuild)) return EC;; | |||||
183 | error(IO.mapInteger(Compile2.VersionBackendMajor))if (auto EC = IO.mapInteger(Compile2.VersionBackendMajor)) return EC;; | |||||
184 | error(IO.mapInteger(Compile2.VersionBackendMinor))if (auto EC = IO.mapInteger(Compile2.VersionBackendMinor)) return EC;; | |||||
185 | error(IO.mapInteger(Compile2.VersionBackendBuild))if (auto EC = IO.mapInteger(Compile2.VersionBackendBuild)) return EC;; | |||||
186 | error(IO.mapStringZ(Compile2.Version))if (auto EC = IO.mapStringZ(Compile2.Version)) return EC;; | |||||
187 | error(IO.mapStringZVectorZ(Compile2.ExtraStrings))if (auto EC = IO.mapStringZVectorZ(Compile2.ExtraStrings)) return EC;; | |||||
188 | ||||||
189 | return Error::success(); | |||||
190 | } | |||||
191 | ||||||
192 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
193 | Compile3Sym &Compile3) { | |||||
194 | ||||||
195 | error(IO.mapEnum(Compile3.Flags))if (auto EC = IO.mapEnum(Compile3.Flags)) return EC;; | |||||
196 | error(IO.mapEnum(Compile3.Machine))if (auto EC = IO.mapEnum(Compile3.Machine)) return EC;; | |||||
197 | error(IO.mapInteger(Compile3.VersionFrontendMajor))if (auto EC = IO.mapInteger(Compile3.VersionFrontendMajor)) return EC;; | |||||
198 | error(IO.mapInteger(Compile3.VersionFrontendMinor))if (auto EC = IO.mapInteger(Compile3.VersionFrontendMinor)) return EC;; | |||||
199 | error(IO.mapInteger(Compile3.VersionFrontendBuild))if (auto EC = IO.mapInteger(Compile3.VersionFrontendBuild)) return EC;; | |||||
200 | error(IO.mapInteger(Compile3.VersionFrontendQFE))if (auto EC = IO.mapInteger(Compile3.VersionFrontendQFE)) return EC;; | |||||
201 | error(IO.mapInteger(Compile3.VersionBackendMajor))if (auto EC = IO.mapInteger(Compile3.VersionBackendMajor)) return EC;; | |||||
202 | error(IO.mapInteger(Compile3.VersionBackendMinor))if (auto EC = IO.mapInteger(Compile3.VersionBackendMinor)) return EC;; | |||||
203 | error(IO.mapInteger(Compile3.VersionBackendBuild))if (auto EC = IO.mapInteger(Compile3.VersionBackendBuild)) return EC;; | |||||
204 | error(IO.mapInteger(Compile3.VersionBackendQFE))if (auto EC = IO.mapInteger(Compile3.VersionBackendQFE)) return EC;; | |||||
205 | error(IO.mapStringZ(Compile3.Version))if (auto EC = IO.mapStringZ(Compile3.Version)) return EC;; | |||||
206 | ||||||
207 | return Error::success(); | |||||
208 | } | |||||
209 | ||||||
210 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
211 | ConstantSym &Constant) { | |||||
212 | ||||||
213 | error(IO.mapInteger(Constant.Type))if (auto EC = IO.mapInteger(Constant.Type)) return EC;; | |||||
214 | error(IO.mapEncodedInteger(Constant.Value))if (auto EC = IO.mapEncodedInteger(Constant.Value)) return EC ;; | |||||
215 | error(IO.mapStringZ(Constant.Name))if (auto EC = IO.mapStringZ(Constant.Name)) return EC;; | |||||
216 | ||||||
217 | return Error::success(); | |||||
218 | } | |||||
219 | ||||||
220 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { | |||||
221 | ||||||
222 | error(IO.mapInteger(Data.Type))if (auto EC = IO.mapInteger(Data.Type)) return EC;; | |||||
223 | error(IO.mapInteger(Data.DataOffset))if (auto EC = IO.mapInteger(Data.DataOffset)) return EC;; | |||||
224 | error(IO.mapInteger(Data.Segment))if (auto EC = IO.mapInteger(Data.Segment)) return EC;; | |||||
225 | error(IO.mapStringZ(Data.Name))if (auto EC = IO.mapStringZ(Data.Name)) return EC;; | |||||
226 | ||||||
227 | return Error::success(); | |||||
228 | } | |||||
229 | ||||||
230 | Error SymbolRecordMapping::visitKnownRecord( | |||||
231 | CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) { | |||||
232 | ||||||
233 | error(IO.mapInteger(DefRangeFramePointerRel.Offset))if (auto EC = IO.mapInteger(DefRangeFramePointerRel.Offset)) return EC;; | |||||
234 | error(mapLocalVariableAddrRange(IO, DefRangeFramePointerRel.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRangeFramePointerRel .Range)) return EC;; | |||||
235 | error(IO.mapVectorTail(DefRangeFramePointerRel.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRangeFramePointerRel.Gaps, MapGap ())) return EC;; | |||||
236 | ||||||
237 | return Error::success(); | |||||
238 | } | |||||
239 | ||||||
240 | Error SymbolRecordMapping::visitKnownRecord( | |||||
241 | CVSymbol &CVR, | |||||
242 | DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) { | |||||
243 | ||||||
244 | error(IO.mapInteger(DefRangeFramePointerRelFullScope.Offset))if (auto EC = IO.mapInteger(DefRangeFramePointerRelFullScope. Offset)) return EC;; | |||||
245 | ||||||
246 | return Error::success(); | |||||
247 | } | |||||
248 | ||||||
249 | Error SymbolRecordMapping::visitKnownRecord( | |||||
250 | CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { | |||||
251 | ||||||
252 | error(IO.mapObject(DefRangeRegisterRel.Hdr.Register))if (auto EC = IO.mapObject(DefRangeRegisterRel.Hdr.Register)) return EC;; | |||||
253 | error(IO.mapObject(DefRangeRegisterRel.Hdr.Flags))if (auto EC = IO.mapObject(DefRangeRegisterRel.Hdr.Flags)) return EC;; | |||||
254 | error(IO.mapObject(DefRangeRegisterRel.Hdr.BasePointerOffset))if (auto EC = IO.mapObject(DefRangeRegisterRel.Hdr.BasePointerOffset )) return EC;; | |||||
255 | error(mapLocalVariableAddrRange(IO, DefRangeRegisterRel.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRangeRegisterRel .Range)) return EC;; | |||||
256 | error(IO.mapVectorTail(DefRangeRegisterRel.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRangeRegisterRel.Gaps, MapGap ())) return EC;; | |||||
257 | ||||||
258 | return Error::success(); | |||||
259 | } | |||||
260 | ||||||
261 | Error SymbolRecordMapping::visitKnownRecord( | |||||
262 | CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { | |||||
263 | ||||||
264 | error(IO.mapObject(DefRangeRegister.Hdr.Register))if (auto EC = IO.mapObject(DefRangeRegister.Hdr.Register)) return EC;; | |||||
265 | error(IO.mapObject(DefRangeRegister.Hdr.MayHaveNoName))if (auto EC = IO.mapObject(DefRangeRegister.Hdr.MayHaveNoName )) return EC;; | |||||
266 | error(mapLocalVariableAddrRange(IO, DefRangeRegister.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRangeRegister. Range)) return EC;; | |||||
267 | error(IO.mapVectorTail(DefRangeRegister.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRangeRegister.Gaps, MapGap( ))) return EC;; | |||||
268 | ||||||
269 | return Error::success(); | |||||
270 | } | |||||
271 | ||||||
272 | Error SymbolRecordMapping::visitKnownRecord( | |||||
273 | CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { | |||||
274 | ||||||
275 | error(IO.mapObject(DefRangeSubfieldRegister.Hdr.Register))if (auto EC = IO.mapObject(DefRangeSubfieldRegister.Hdr.Register )) return EC;; | |||||
276 | error(IO.mapObject(DefRangeSubfieldRegister.Hdr.MayHaveNoName))if (auto EC = IO.mapObject(DefRangeSubfieldRegister.Hdr.MayHaveNoName )) return EC;; | |||||
277 | error(IO.mapObject(DefRangeSubfieldRegister.Hdr.OffsetInParent))if (auto EC = IO.mapObject(DefRangeSubfieldRegister.Hdr.OffsetInParent )) return EC;; | |||||
| ||||||
278 | error(mapLocalVariableAddrRange(IO, DefRangeSubfieldRegister.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRangeSubfieldRegister .Range)) return EC;; | |||||
279 | error(IO.mapVectorTail(DefRangeSubfieldRegister.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRangeSubfieldRegister.Gaps, MapGap())) return EC;; | |||||
280 | ||||||
281 | return Error::success(); | |||||
282 | } | |||||
283 | ||||||
284 | Error SymbolRecordMapping::visitKnownRecord( | |||||
285 | CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) { | |||||
286 | ||||||
287 | error(IO.mapInteger(DefRangeSubfield.Program))if (auto EC = IO.mapInteger(DefRangeSubfield.Program)) return EC;; | |||||
288 | error(IO.mapInteger(DefRangeSubfield.OffsetInParent))if (auto EC = IO.mapInteger(DefRangeSubfield.OffsetInParent)) return EC;; | |||||
289 | error(mapLocalVariableAddrRange(IO, DefRangeSubfield.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRangeSubfield. Range)) return EC;; | |||||
290 | error(IO.mapVectorTail(DefRangeSubfield.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRangeSubfield.Gaps, MapGap( ))) return EC;; | |||||
291 | ||||||
292 | return Error::success(); | |||||
293 | } | |||||
294 | ||||||
295 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
296 | DefRangeSym &DefRange) { | |||||
297 | ||||||
298 | error(IO.mapInteger(DefRange.Program))if (auto EC = IO.mapInteger(DefRange.Program)) return EC;; | |||||
299 | error(mapLocalVariableAddrRange(IO, DefRange.Range))if (auto EC = mapLocalVariableAddrRange(IO, DefRange.Range)) return EC;; | |||||
300 | error(IO.mapVectorTail(DefRange.Gaps, MapGap()))if (auto EC = IO.mapVectorTail(DefRange.Gaps, MapGap())) return EC;; | |||||
301 | ||||||
302 | return Error::success(); | |||||
303 | } | |||||
304 | ||||||
305 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
306 | FrameCookieSym &FrameCookie) { | |||||
307 | ||||||
308 | error(IO.mapInteger(FrameCookie.CodeOffset))if (auto EC = IO.mapInteger(FrameCookie.CodeOffset)) return EC ;; | |||||
309 | error(IO.mapInteger(FrameCookie.Register))if (auto EC = IO.mapInteger(FrameCookie.Register)) return EC;; | |||||
310 | error(IO.mapEnum(FrameCookie.CookieKind))if (auto EC = IO.mapEnum(FrameCookie.CookieKind)) return EC;; | |||||
311 | error(IO.mapInteger(FrameCookie.Flags))if (auto EC = IO.mapInteger(FrameCookie.Flags)) return EC;; | |||||
312 | ||||||
313 | return Error::success(); | |||||
314 | } | |||||
315 | ||||||
316 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
317 | FrameProcSym &FrameProc) { | |||||
318 | error(IO.mapInteger(FrameProc.TotalFrameBytes))if (auto EC = IO.mapInteger(FrameProc.TotalFrameBytes)) return EC;; | |||||
319 | error(IO.mapInteger(FrameProc.PaddingFrameBytes))if (auto EC = IO.mapInteger(FrameProc.PaddingFrameBytes)) return EC;; | |||||
320 | error(IO.mapInteger(FrameProc.OffsetToPadding))if (auto EC = IO.mapInteger(FrameProc.OffsetToPadding)) return EC;; | |||||
321 | error(IO.mapInteger(FrameProc.BytesOfCalleeSavedRegisters))if (auto EC = IO.mapInteger(FrameProc.BytesOfCalleeSavedRegisters )) return EC;; | |||||
322 | error(IO.mapInteger(FrameProc.OffsetOfExceptionHandler))if (auto EC = IO.mapInteger(FrameProc.OffsetOfExceptionHandler )) return EC;; | |||||
323 | error(IO.mapInteger(FrameProc.SectionIdOfExceptionHandler))if (auto EC = IO.mapInteger(FrameProc.SectionIdOfExceptionHandler )) return EC;; | |||||
324 | error(IO.mapEnum(FrameProc.Flags))if (auto EC = IO.mapEnum(FrameProc.Flags)) return EC;; | |||||
325 | ||||||
326 | return Error::success(); | |||||
327 | } | |||||
328 | ||||||
329 | Error SymbolRecordMapping::visitKnownRecord( | |||||
330 | CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) { | |||||
331 | ||||||
332 | error(IO.mapInteger(HeapAllocSite.CodeOffset))if (auto EC = IO.mapInteger(HeapAllocSite.CodeOffset)) return EC;; | |||||
333 | error(IO.mapInteger(HeapAllocSite.Segment))if (auto EC = IO.mapInteger(HeapAllocSite.Segment)) return EC ;; | |||||
334 | error(IO.mapInteger(HeapAllocSite.CallInstructionSize))if (auto EC = IO.mapInteger(HeapAllocSite.CallInstructionSize )) return EC;; | |||||
335 | error(IO.mapInteger(HeapAllocSite.Type))if (auto EC = IO.mapInteger(HeapAllocSite.Type)) return EC;; | |||||
336 | ||||||
337 | return Error::success(); | |||||
338 | } | |||||
339 | ||||||
340 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
341 | InlineSiteSym &InlineSite) { | |||||
342 | ||||||
343 | error(IO.mapInteger(InlineSite.Parent))if (auto EC = IO.mapInteger(InlineSite.Parent)) return EC;; | |||||
344 | error(IO.mapInteger(InlineSite.End))if (auto EC = IO.mapInteger(InlineSite.End)) return EC;; | |||||
345 | error(IO.mapInteger(InlineSite.Inlinee))if (auto EC = IO.mapInteger(InlineSite.Inlinee)) return EC;; | |||||
346 | error(IO.mapByteVectorTail(InlineSite.AnnotationData))if (auto EC = IO.mapByteVectorTail(InlineSite.AnnotationData) ) return EC;; | |||||
347 | ||||||
348 | return Error::success(); | |||||
349 | } | |||||
350 | ||||||
351 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
352 | RegisterSym &Register) { | |||||
353 | ||||||
354 | error(IO.mapInteger(Register.Index))if (auto EC = IO.mapInteger(Register.Index)) return EC;; | |||||
355 | error(IO.mapEnum(Register.Register))if (auto EC = IO.mapEnum(Register.Register)) return EC;; | |||||
356 | error(IO.mapStringZ(Register.Name))if (auto EC = IO.mapStringZ(Register.Name)) return EC;; | |||||
357 | ||||||
358 | return Error::success(); | |||||
359 | } | |||||
360 | ||||||
361 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
362 | PublicSym32 &Public) { | |||||
363 | ||||||
364 | error(IO.mapEnum(Public.Flags))if (auto EC = IO.mapEnum(Public.Flags)) return EC;; | |||||
365 | error(IO.mapInteger(Public.Offset))if (auto EC = IO.mapInteger(Public.Offset)) return EC;; | |||||
366 | error(IO.mapInteger(Public.Segment))if (auto EC = IO.mapInteger(Public.Segment)) return EC;; | |||||
367 | error(IO.mapStringZ(Public.Name))if (auto EC = IO.mapStringZ(Public.Name)) return EC;; | |||||
368 | ||||||
369 | return Error::success(); | |||||
370 | } | |||||
371 | ||||||
372 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
373 | ProcRefSym &ProcRef) { | |||||
374 | ||||||
375 | error(IO.mapInteger(ProcRef.SumName))if (auto EC = IO.mapInteger(ProcRef.SumName)) return EC;; | |||||
376 | error(IO.mapInteger(ProcRef.SymOffset))if (auto EC = IO.mapInteger(ProcRef.SymOffset)) return EC;; | |||||
377 | error(IO.mapInteger(ProcRef.Module))if (auto EC = IO.mapInteger(ProcRef.Module)) return EC;; | |||||
378 | error(IO.mapStringZ(ProcRef.Name))if (auto EC = IO.mapStringZ(ProcRef.Name)) return EC;; | |||||
379 | ||||||
380 | return Error::success(); | |||||
381 | } | |||||
382 | ||||||
383 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { | |||||
384 | ||||||
385 | error(IO.mapInteger(Label.CodeOffset))if (auto EC = IO.mapInteger(Label.CodeOffset)) return EC;; | |||||
386 | error(IO.mapInteger(Label.Segment))if (auto EC = IO.mapInteger(Label.Segment)) return EC;; | |||||
387 | error(IO.mapEnum(Label.Flags))if (auto EC = IO.mapEnum(Label.Flags)) return EC;; | |||||
388 | error(IO.mapStringZ(Label.Name))if (auto EC = IO.mapStringZ(Label.Name)) return EC;; | |||||
389 | ||||||
390 | return Error::success(); | |||||
391 | } | |||||
392 | ||||||
393 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { | |||||
394 | error(IO.mapInteger(Local.Type))if (auto EC = IO.mapInteger(Local.Type)) return EC;; | |||||
395 | error(IO.mapEnum(Local.Flags))if (auto EC = IO.mapEnum(Local.Flags)) return EC;; | |||||
396 | error(IO.mapStringZ(Local.Name))if (auto EC = IO.mapStringZ(Local.Name)) return EC;; | |||||
397 | ||||||
398 | return Error::success(); | |||||
399 | } | |||||
400 | ||||||
401 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
402 | ObjNameSym &ObjName) { | |||||
403 | ||||||
404 | error(IO.mapInteger(ObjName.Signature))if (auto EC = IO.mapInteger(ObjName.Signature)) return EC;; | |||||
405 | error(IO.mapStringZ(ObjName.Name))if (auto EC = IO.mapStringZ(ObjName.Name)) return EC;; | |||||
406 | ||||||
407 | return Error::success(); | |||||
408 | } | |||||
409 | ||||||
410 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { | |||||
411 | error(IO.mapInteger(Proc.Parent))if (auto EC = IO.mapInteger(Proc.Parent)) return EC;; | |||||
412 | error(IO.mapInteger(Proc.End))if (auto EC = IO.mapInteger(Proc.End)) return EC;; | |||||
413 | error(IO.mapInteger(Proc.Next))if (auto EC = IO.mapInteger(Proc.Next)) return EC;; | |||||
414 | error(IO.mapInteger(Proc.CodeSize))if (auto EC = IO.mapInteger(Proc.CodeSize)) return EC;; | |||||
415 | error(IO.mapInteger(Proc.DbgStart))if (auto EC = IO.mapInteger(Proc.DbgStart)) return EC;; | |||||
416 | error(IO.mapInteger(Proc.DbgEnd))if (auto EC = IO.mapInteger(Proc.DbgEnd)) return EC;; | |||||
417 | error(IO.mapInteger(Proc.FunctionType))if (auto EC = IO.mapInteger(Proc.FunctionType)) return EC;; | |||||
418 | error(IO.mapInteger(Proc.CodeOffset))if (auto EC = IO.mapInteger(Proc.CodeOffset)) return EC;; | |||||
419 | error(IO.mapInteger(Proc.Segment))if (auto EC = IO.mapInteger(Proc.Segment)) return EC;; | |||||
420 | error(IO.mapEnum(Proc.Flags))if (auto EC = IO.mapEnum(Proc.Flags)) return EC;; | |||||
421 | error(IO.mapStringZ(Proc.Name))if (auto EC = IO.mapStringZ(Proc.Name)) return EC;; | |||||
422 | return Error::success(); | |||||
423 | } | |||||
424 | ||||||
425 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
426 | ScopeEndSym &ScopeEnd) { | |||||
427 | return Error::success(); | |||||
428 | } | |||||
429 | ||||||
430 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { | |||||
431 | error(IO.mapVectorN<uint32_t>(if (auto EC = IO.mapVectorN<uint32_t>( Caller.Indices, [ ](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger (N); })) return EC; | |||||
432 | Caller.Indices,if (auto EC = IO.mapVectorN<uint32_t>( Caller.Indices, [ ](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger (N); })) return EC; | |||||
433 | [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); }))if (auto EC = IO.mapVectorN<uint32_t>( Caller.Indices, [ ](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger (N); })) return EC;; | |||||
434 | return Error::success(); | |||||
435 | } | |||||
436 | ||||||
437 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
438 | RegRelativeSym &RegRel) { | |||||
439 | ||||||
440 | error(IO.mapInteger(RegRel.Offset))if (auto EC = IO.mapInteger(RegRel.Offset)) return EC;; | |||||
441 | error(IO.mapInteger(RegRel.Type))if (auto EC = IO.mapInteger(RegRel.Type)) return EC;; | |||||
442 | error(IO.mapEnum(RegRel.Register))if (auto EC = IO.mapEnum(RegRel.Register)) return EC;; | |||||
443 | error(IO.mapStringZ(RegRel.Name))if (auto EC = IO.mapStringZ(RegRel.Name)) return EC;; | |||||
444 | ||||||
445 | return Error::success(); | |||||
446 | } | |||||
447 | ||||||
448 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, | |||||
449 | ThreadLocalDataSym &Data) { | |||||
450 | ||||||
451 | error(IO.mapInteger(Data.Type))if (auto EC = IO.mapInteger(Data.Type)) return EC;; | |||||
452 | error(IO.mapInteger(Data.DataOffset))if (auto EC = IO.mapInteger(Data.DataOffset)) return EC;; | |||||
453 | error(IO.mapInteger(Data.Segment))if (auto EC = IO.mapInteger(Data.Segment)) return EC;; | |||||
454 | error(IO.mapStringZ(Data.Name))if (auto EC = IO.mapStringZ(Data.Name)) return EC;; | |||||
455 | ||||||
456 | return Error::success(); | |||||
457 | } | |||||
458 | ||||||
459 | Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { | |||||
460 | ||||||
461 | error(IO.mapInteger(UDT.Type))if (auto EC = IO.mapInteger(UDT.Type)) return EC;; | |||||
462 | error(IO.mapStringZ(UDT.Name))if (auto EC = IO.mapStringZ(UDT.Name)) return EC;; | |||||
463 | ||||||
464 | return Error::success(); | |||||
465 | } |
1 | //===- CodeViewRecordIO.h ---------------------------------------*- C++ -*-===// | |||
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 | #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H | |||
11 | #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H | |||
12 | ||||
13 | #include "llvm/ADT/APSInt.h" | |||
14 | #include "llvm/ADT/None.h" | |||
15 | #include "llvm/ADT/Optional.h" | |||
16 | #include "llvm/ADT/SmallVector.h" | |||
17 | #include "llvm/ADT/StringRef.h" | |||
18 | #include "llvm/DebugInfo/CodeView/CodeViewError.h" | |||
19 | #include "llvm/DebugInfo/CodeView/TypeRecord.h" | |||
20 | #include "llvm/Support/BinaryStreamReader.h" | |||
21 | #include "llvm/Support/BinaryStreamWriter.h" | |||
22 | #include "llvm/Support/Error.h" | |||
23 | #include <cassert> | |||
24 | #include <cstdint> | |||
25 | #include <type_traits> | |||
26 | ||||
27 | namespace llvm { | |||
28 | namespace codeview { | |||
29 | ||||
30 | class CodeViewRecordIO { | |||
31 | uint32_t getCurrentOffset() const { | |||
32 | return (isWriting()) ? Writer->getOffset() : Reader->getOffset(); | |||
33 | } | |||
34 | ||||
35 | public: | |||
36 | explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {} | |||
37 | explicit CodeViewRecordIO(BinaryStreamWriter &Writer) : Writer(&Writer) {} | |||
38 | ||||
39 | Error beginRecord(Optional<uint32_t> MaxLength); | |||
40 | Error endRecord(); | |||
41 | ||||
42 | Error mapInteger(TypeIndex &TypeInd); | |||
43 | ||||
44 | bool isReading() const { return Reader != nullptr; } | |||
45 | bool isWriting() const { return !isReading(); } | |||
46 | ||||
47 | uint32_t maxFieldLength() const; | |||
48 | ||||
49 | template <typename T> Error mapObject(T &Value) { | |||
50 | if (isWriting()) | |||
51 | return Writer->writeObject(Value); | |||
52 | ||||
53 | const T *ValuePtr; | |||
54 | if (auto EC = Reader->readObject(ValuePtr)) | |||
55 | return EC; | |||
56 | Value = *ValuePtr; | |||
| ||||
57 | return Error::success(); | |||
58 | } | |||
59 | ||||
60 | template <typename T> Error mapInteger(T &Value) { | |||
61 | if (isWriting()) | |||
62 | return Writer->writeInteger(Value); | |||
63 | ||||
64 | return Reader->readInteger(Value); | |||
65 | } | |||
66 | ||||
67 | template <typename T> Error mapEnum(T &Value) { | |||
68 | if (sizeof(Value) > maxFieldLength()) | |||
69 | return make_error<CodeViewError>(cv_error_code::insufficient_buffer); | |||
70 | ||||
71 | using U = typename std::underlying_type<T>::type; | |||
72 | U X; | |||
73 | if (isWriting()) | |||
74 | X = static_cast<U>(Value); | |||
75 | ||||
76 | if (auto EC = mapInteger(X)) | |||
77 | return EC; | |||
78 | if (isReading()) | |||
79 | Value = static_cast<T>(X); | |||
80 | return Error::success(); | |||
81 | } | |||
82 | ||||
83 | Error mapEncodedInteger(int64_t &Value); | |||
84 | Error mapEncodedInteger(uint64_t &Value); | |||
85 | Error mapEncodedInteger(APSInt &Value); | |||
86 | Error mapStringZ(StringRef &Value); | |||
87 | Error mapGuid(GUID &Guid); | |||
88 | ||||
89 | Error mapStringZVectorZ(std::vector<StringRef> &Value); | |||
90 | ||||
91 | template <typename SizeType, typename T, typename ElementMapper> | |||
92 | Error mapVectorN(T &Items, const ElementMapper &Mapper) { | |||
93 | SizeType Size; | |||
94 | if (isWriting()) { | |||
95 | Size = static_cast<SizeType>(Items.size()); | |||
96 | if (auto EC = Writer->writeInteger(Size)) | |||
97 | return EC; | |||
98 | ||||
99 | for (auto &X : Items) { | |||
100 | if (auto EC = Mapper(*this, X)) | |||
101 | return EC; | |||
102 | } | |||
103 | } else { | |||
104 | if (auto EC = Reader->readInteger(Size)) | |||
105 | return EC; | |||
106 | for (SizeType I = 0; I < Size; ++I) { | |||
107 | typename T::value_type Item; | |||
108 | if (auto EC = Mapper(*this, Item)) | |||
109 | return EC; | |||
110 | Items.push_back(Item); | |||
111 | } | |||
112 | } | |||
113 | ||||
114 | return Error::success(); | |||
115 | } | |||
116 | ||||
117 | template <typename T, typename ElementMapper> | |||
118 | Error mapVectorTail(T &Items, const ElementMapper &Mapper) { | |||
119 | if (isWriting()) { | |||
120 | for (auto &Item : Items) { | |||
121 | if (auto EC = Mapper(*this, Item)) | |||
122 | return EC; | |||
123 | } | |||
124 | } else { | |||
125 | typename T::value_type Field; | |||
126 | // Stop when we run out of bytes or we hit record padding bytes. | |||
127 | while (!Reader->empty() && Reader->peek() < 0xf0 /* LF_PAD0 */) { | |||
128 | if (auto EC = Mapper(*this, Field)) | |||
129 | return EC; | |||
130 | Items.push_back(Field); | |||
131 | } | |||
132 | } | |||
133 | return Error::success(); | |||
134 | } | |||
135 | ||||
136 | Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes); | |||
137 | Error mapByteVectorTail(std::vector<uint8_t> &Bytes); | |||
138 | ||||
139 | Error padToAlignment(uint32_t Align); | |||
140 | Error skipPadding(); | |||
141 | ||||
142 | private: | |||
143 | Error writeEncodedSignedInteger(const int64_t &Value); | |||
144 | Error writeEncodedUnsignedInteger(const uint64_t &Value); | |||
145 | ||||
146 | struct RecordLimit { | |||
147 | uint32_t BeginOffset; | |||
148 | Optional<uint32_t> MaxLength; | |||
149 | ||||
150 | Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const { | |||
151 | if (!MaxLength.hasValue()) | |||
152 | return None; | |||
153 | assert(CurrentOffset >= BeginOffset)(static_cast <bool> (CurrentOffset >= BeginOffset) ? void (0) : __assert_fail ("CurrentOffset >= BeginOffset", "/build/llvm-toolchain-snapshot-7~svn326246/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h" , 153, __extension__ __PRETTY_FUNCTION__)); | |||
154 | ||||
155 | uint32_t BytesUsed = CurrentOffset - BeginOffset; | |||
156 | if (BytesUsed >= *MaxLength) | |||
157 | return 0; | |||
158 | return *MaxLength - BytesUsed; | |||
159 | } | |||
160 | }; | |||
161 | ||||
162 | SmallVector<RecordLimit, 2> Limits; | |||
163 | ||||
164 | BinaryStreamReader *Reader = nullptr; | |||
165 | BinaryStreamWriter *Writer = nullptr; | |||
166 | }; | |||
167 | ||||
168 | } // end namespace codeview | |||
169 | } // end namespace llvm | |||
170 | ||||
171 | #endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H |