llvm.org GIT mirror llvm / e3e384a
[LLD/PDB] Write actual records to the globals stream. Previously we were writing an empty globals stream. Windows tools interpret this as "private symbols are not present in this PDB", even when they are, so we need to fix this. Regardless, without it we don't have information about global variables, so we need to fix it anyway. This patch does that. With this patch, the "lm" command in WinDbg correctly reports that we have private symbols available, but the "dv" command still refuses to display local variables. Differential Revision: https://reviews.llvm.org/D36535 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310743 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
11 changed file(s) with 387 addition(s) and 281 deletion(s). Raw diff Collapse all Expand all
0 //===- RecordName.h ------------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H
10 #define LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H
11
12 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
13 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
14 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
15
16 namespace llvm {
17 namespace codeview {
18 std::string computeTypeName(TypeCollection &Types, TypeIndex Index);
19 StringRef getSymbolName(CVSymbol Sym);
20 } // namespace codeview
21 } // namespace llvm
22
23 #endif
5353
5454 template
5555 static Expected deserializeAs(ArrayRef Data) {
56 CVType CVT;
57 CVT.RecordData = Data;
58 MappingInfo I(CVT.content());
5956 const RecordPrefix *Prefix =
6057 reinterpret_cast(Data.data());
6158 TypeRecordKind K =
6259 static_cast(uint16_t(Prefix->RecordKind));
6360 T Record(K);
61 CVType CVT(static_cast(K), Data);
6462 if (auto EC = deserializeAs(CVT, Record))
6563 return std::move(EC);
6664 return Record;
+0
-22
include/llvm/DebugInfo/CodeView/TypeName.h less more
None //===- TypeName.h --------------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H
10 #define LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H
11
12 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
13 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
14
15 namespace llvm {
16 namespace codeview {
17 std::string computeTypeName(TypeCollection &Types, TypeIndex Index);
18 }
19 } // namespace llvm
20
21 #endif
411411 return (Options & ClassOptions::HasUniqueName) != ClassOptions::None;
412412 }
413413
414 bool isNested() const {
415 return (Options & ClassOptions::Nested) != ClassOptions::None;
416 }
417
414418 uint16_t getMemberCount() const { return MemberCount; }
415419 ClassOptions getOptions() const { return Options; }
416420 TypeIndex getFieldList() const { return FieldList; }
5757
5858 void addPublicSymbol(const codeview::PublicSym32 &Pub);
5959
60 void addGlobalSymbol(const codeview::ProcRefSym &Sym);
61 void addGlobalSymbol(const codeview::DataSym &Sym);
62 void addGlobalSymbol(const codeview::ConstantSym &Sym);
63 void addGlobalSymbol(const codeview::UDTSym &Sym);
64 void addGlobalSymbol(const codeview::CVSymbol &Sym);
65
6066 private:
6167 uint32_t calculatePublicsHashStreamSize() const;
6268 uint32_t calculateGlobalsHashStreamSize() const;
1818 Formatters.cpp
1919 LazyRandomTypeCollection.cpp
2020 Line.cpp
21 RecordName.cpp
2122 RecordSerialization.cpp
2223 StringsAndChecksums.cpp
2324 SymbolRecordMapping.cpp
2627 TypeDumpVisitor.cpp
2728 TypeIndex.cpp
2829 TypeIndexDiscovery.cpp
29 TypeName.cpp
3030 TypeRecordMapping.cpp
3131 TypeSerializer.cpp
3232 TypeStreamMerger.cpp
1212 #include "llvm/ADT/StringExtras.h"
1313 #include "llvm/ADT/StringRef.h"
1414 #include "llvm/DebugInfo/CodeView/CodeViewError.h"
15 #include "llvm/DebugInfo/CodeView/TypeName.h"
15 #include "llvm/DebugInfo/CodeView/RecordName.h"
1616 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
1717 #include "llvm/Support/BinaryStreamReader.h"
1818 #include "llvm/Support/Endian.h"
0 //===- RecordName.cpp ----------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/CodeView/RecordName.h"
10
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
13 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
14 #include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h"
15 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
16 #include "llvm/Support/FormatVariadic.h"
17
18 using namespace llvm;
19 using namespace llvm::codeview;
20
21 namespace {
22 class TypeNameComputer : public TypeVisitorCallbacks {
23 /// The type collection. Used to calculate names of nested types.
24 TypeCollection &Types;
25 TypeIndex CurrentTypeIndex = TypeIndex::None();
26
27 /// Name of the current type. Only valid before visitTypeEnd.
28 SmallString<256> Name;
29
30 public:
31 explicit TypeNameComputer(TypeCollection &Types) : Types(Types) {}
32
33 StringRef name() const { return Name; }
34
35 /// Paired begin/end actions for all types. Receives all record data,
36 /// including the fixed-length record prefix.
37 Error visitTypeBegin(CVType &Record) override;
38 Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
39 Error visitTypeEnd(CVType &Record) override;
40
41 #define TYPE_RECORD(EnumName, EnumVal, Name) \
42 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
43 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
44 #define MEMBER_RECORD(EnumName, EnumVal, Name)
45 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
46 };
47 } // namespace
48
49 Error TypeNameComputer::visitTypeBegin(CVType &Record) {
50 llvm_unreachable("Must call visitTypeBegin with a TypeIndex!");
51 return Error::success();
52 }
53
54 Error TypeNameComputer::visitTypeBegin(CVType &Record, TypeIndex Index) {
55 // Reset Name to the empty string. If the visitor sets it, we know it.
56 Name = "";
57 CurrentTypeIndex = Index;
58 return Error::success();
59 }
60
61 Error TypeNameComputer::visitTypeEnd(CVType &CVR) { return Error::success(); }
62
63 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
64 FieldListRecord &FieldList) {
65 Name = "";
66 return Error::success();
67 }
68
69 Error TypeNameComputer::visitKnownRecord(CVRecord &CVR,
70 StringIdRecord &String) {
71 Name = String.getString();
72 return Error::success();
73 }
74
75 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
76 auto Indices = Args.getIndices();
77 uint32_t Size = Indices.size();
78 Name = "(";
79 for (uint32_t I = 0; I < Size; ++I) {
80 assert(Indices[I] < CurrentTypeIndex);
81
82 Name.append(Types.getTypeName(Indices[I]));
83 if (I + 1 != Size)
84 Name.append(", ");
85 }
86 Name.push_back(')');
87 return Error::success();
88 }
89
90 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
91 StringListRecord &Strings) {
92 auto Indices = Strings.getIndices();
93 uint32_t Size = Indices.size();
94 Name = "\"";
95 for (uint32_t I = 0; I < Size; ++I) {
96 Name.append(Types.getTypeName(Indices[I]));
97 if (I + 1 != Size)
98 Name.append("\" \"");
99 }
100 Name.push_back('\"');
101 return Error::success();
102 }
103
104 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
105 Name = Class.getName();
106 return Error::success();
107 }
108
109 Error TypeNameComputer::visitKnownRecord(CVType &CVR, UnionRecord &Union) {
110 Name = Union.getName();
111 return Error::success();
112 }
113
114 Error TypeNameComputer::visitKnownRecord(CVType &CVR, EnumRecord &Enum) {
115 Name = Enum.getName();
116 return Error::success();
117 }
118
119 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ArrayRecord &AT) {
120 Name = AT.getName();
121 return Error::success();
122 }
123
124 Error TypeNameComputer::visitKnownRecord(CVType &CVR, VFTableRecord &VFT) {
125 Name = VFT.getName();
126 return Error::success();
127 }
128
129 Error TypeNameComputer::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Id) {
130 Name = Id.getName();
131 return Error::success();
132 }
133
134 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ProcedureRecord &Proc) {
135 StringRef Ret = Types.getTypeName(Proc.getReturnType());
136 StringRef Params = Types.getTypeName(Proc.getArgumentList());
137 Name = formatv("{0} {1}", Ret, Params).sstr<256>();
138 return Error::success();
139 }
140
141 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
142 MemberFunctionRecord &MF) {
143 StringRef Ret = Types.getTypeName(MF.getReturnType());
144 StringRef Class = Types.getTypeName(MF.getClassType());
145 StringRef Params = Types.getTypeName(MF.getArgumentList());
146 Name = formatv("{0} {1}::{2}", Ret, Class, Params).sstr<256>();
147 return Error::success();
148 }
149
150 Error TypeNameComputer::visitKnownRecord(CVType &CVR, FuncIdRecord &Func) {
151 Name = Func.getName();
152 return Error::success();
153 }
154
155 Error TypeNameComputer::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
156 Name = TS.getName();
157 return Error::success();
158 }
159
160 Error TypeNameComputer::visitKnownRecord(CVType &CVR, PointerRecord &Ptr) {
161
162 if (Ptr.isPointerToMember()) {
163 const MemberPointerInfo &MI = Ptr.getMemberInfo();
164
165 StringRef Pointee = Types.getTypeName(Ptr.getReferentType());
166 StringRef Class = Types.getTypeName(MI.getContainingType());
167 Name = formatv("{0} {1}::*", Pointee, Class);
168 } else {
169 if (Ptr.isConst())
170 Name.append("const ");
171 if (Ptr.isVolatile())
172 Name.append("volatile ");
173 if (Ptr.isUnaligned())
174 Name.append("__unaligned ");
175
176 Name.append(Types.getTypeName(Ptr.getReferentType()));
177
178 if (Ptr.getMode() == PointerMode::LValueReference)
179 Name.append("&");
180 else if (Ptr.getMode() == PointerMode::RValueReference)
181 Name.append("&&");
182 else if (Ptr.getMode() == PointerMode::Pointer)
183 Name.append("*");
184 }
185 return Error::success();
186 }
187
188 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ModifierRecord &Mod) {
189 uint16_t Mods = static_cast(Mod.getModifiers());
190
191 SmallString<256> TypeName;
192 if (Mods & uint16_t(ModifierOptions::Const))
193 Name.append("const ");
194 if (Mods & uint16_t(ModifierOptions::Volatile))
195 Name.append("volatile ");
196 if (Mods & uint16_t(ModifierOptions::Unaligned))
197 Name.append("__unaligned ");
198 Name.append(Types.getTypeName(Mod.getModifiedType()));
199 return Error::success();
200 }
201
202 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
203 VFTableShapeRecord &Shape) {
204 Name = formatv("", Shape.getEntryCount());
205 return Error::success();
206 }
207
208 Error TypeNameComputer::visitKnownRecord(
209 CVType &CVR, UdtModSourceLineRecord &ModSourceLine) {
210 return Error::success();
211 }
212
213 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
214 UdtSourceLineRecord &SourceLine) {
215 return Error::success();
216 }
217
218 Error TypeNameComputer::visitKnownRecord(CVType &CVR, BitFieldRecord &BF) {
219 return Error::success();
220 }
221
222 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
223 MethodOverloadListRecord &Overloads) {
224 return Error::success();
225 }
226
227 Error TypeNameComputer::visitKnownRecord(CVType &CVR, BuildInfoRecord &BI) {
228 return Error::success();
229 }
230
231 Error TypeNameComputer::visitKnownRecord(CVType &CVR, LabelRecord &R) {
232 return Error::success();
233 }
234
235 std::string llvm::codeview::computeTypeName(TypeCollection &Types,
236 TypeIndex Index) {
237 TypeNameComputer Computer(Types);
238 CVType Record = Types.getType(Index);
239 if (auto EC = visitTypeRecord(Record, Index, Computer)) {
240 consumeError(std::move(EC));
241 return "";
242 }
243 return Computer.name();
244 }
245
246 static int getSymbolNameOffset(CVSymbol Sym) {
247 switch (Sym.kind()) {
248 // See ProcSym
249 case SymbolKind::S_GPROC32:
250 case SymbolKind::S_LPROC32:
251 case SymbolKind::S_GPROC32_ID:
252 case SymbolKind::S_LPROC32_ID:
253 case SymbolKind::S_LPROC32_DPC:
254 case SymbolKind::S_LPROC32_DPC_ID:
255 return 35;
256 // See Thunk32Sym
257 case SymbolKind::S_THUNK32:
258 return 21;
259 // See SectionSym
260 case SymbolKind::S_SECTION:
261 return 16;
262 // See CoffGroupSym
263 case SymbolKind::S_COFFGROUP:
264 return 14;
265 // See PublicSym32, FileStaticSym, RegRelativeSym, DataSym, ThreadLocalDataSym
266 case SymbolKind::S_PUB32:
267 case SymbolKind::S_FILESTATIC:
268 case SymbolKind::S_REGREL32:
269 case SymbolKind::S_GDATA32:
270 case SymbolKind::S_LDATA32:
271 case SymbolKind::S_LMANDATA:
272 case SymbolKind::S_GMANDATA:
273 case SymbolKind::S_LTHREAD32:
274 case SymbolKind::S_GTHREAD32:
275 return 10;
276 // See RegisterSym and LocalSym
277 case SymbolKind::S_REGISTER:
278 case SymbolKind::S_LOCAL:
279 return 6;
280 // See BlockSym
281 case SymbolKind::S_BLOCK32:
282 return 18;
283 // See LabelSym
284 case SymbolKind::S_LABEL32:
285 return 7;
286 // See ObjNameSym, ExportSym, and UDTSym
287 case SymbolKind::S_OBJNAME:
288 case SymbolKind::S_EXPORT:
289 case SymbolKind::S_UDT:
290 return 4;
291 // See BPRelativeSym
292 case SymbolKind::S_BPREL32:
293 return 8;
294 default:
295 return -1;
296 }
297 }
298
299 StringRef llvm::codeview::getSymbolName(CVSymbol Sym) {
300 if (Sym.kind() == SymbolKind::S_CONSTANT) {
301 // S_CONSTANT is preceded by an APSInt, which has a variable length. So we
302 // have to do a full deserialization.
303 BinaryStreamReader Reader(Sym.content(), llvm::support::little);
304 // The container doesn't matter for single records.
305 SymbolRecordMapping Mapping(Reader, CodeViewContainer::ObjectFile);
306 ConstantSym Const(SymbolKind::S_CONSTANT);
307 cantFail(Mapping.visitSymbolBegin(Sym));
308 cantFail(Mapping.visitKnownRecord(Sym, Const));
309 cantFail(Mapping.visitSymbolEnd(Sym));
310 return Const.Name;
311 }
312
313 int Offset = getSymbolNameOffset(Sym);
314 if (Offset == -1)
315 return StringRef();
316
317 StringRef StringData = toStringRef(Sym.content()).drop_front(Offset);
318 return StringData.split('\0').first;
319 }
+0
-243
lib/DebugInfo/CodeView/TypeName.cpp less more
None //===- TypeName.cpp ------------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/CodeView/TypeName.h"
10
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
13 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
14 #include "llvm/Support/FormatVariadic.h"
15
16 using namespace llvm;
17 using namespace llvm::codeview;
18
19 namespace {
20 class TypeNameComputer : public TypeVisitorCallbacks {
21 /// The type collection. Used to calculate names of nested types.
22 TypeCollection &Types;
23 TypeIndex CurrentTypeIndex = TypeIndex::None();
24
25 /// Name of the current type. Only valid before visitTypeEnd.
26 SmallString<256> Name;
27
28 public:
29 explicit TypeNameComputer(TypeCollection &Types) : Types(Types) {}
30
31 StringRef name() const { return Name; }
32
33 /// Paired begin/end actions for all types. Receives all record data,
34 /// including the fixed-length record prefix.
35 Error visitTypeBegin(CVType &Record) override;
36 Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
37 Error visitTypeEnd(CVType &Record) override;
38
39 #define TYPE_RECORD(EnumName, EnumVal, Name) \
40 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
41 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
42 #define MEMBER_RECORD(EnumName, EnumVal, Name)
43 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
44 };
45 } // namespace
46
47 Error TypeNameComputer::visitTypeBegin(CVType &Record) {
48 llvm_unreachable("Must call visitTypeBegin with a TypeIndex!");
49 return Error::success();
50 }
51
52 Error TypeNameComputer::visitTypeBegin(CVType &Record, TypeIndex Index) {
53 // Reset Name to the empty string. If the visitor sets it, we know it.
54 Name = "";
55 CurrentTypeIndex = Index;
56 return Error::success();
57 }
58
59 Error TypeNameComputer::visitTypeEnd(CVType &CVR) { return Error::success(); }
60
61 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
62 FieldListRecord &FieldList) {
63 Name = "";
64 return Error::success();
65 }
66
67 Error TypeNameComputer::visitKnownRecord(CVRecord &CVR,
68 StringIdRecord &String) {
69 Name = String.getString();
70 return Error::success();
71 }
72
73 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
74 auto Indices = Args.getIndices();
75 uint32_t Size = Indices.size();
76 Name = "(";
77 for (uint32_t I = 0; I < Size; ++I) {
78 assert(Indices[I] < CurrentTypeIndex);
79
80 Name.append(Types.getTypeName(Indices[I]));
81 if (I + 1 != Size)
82 Name.append(", ");
83 }
84 Name.push_back(')');
85 return Error::success();
86 }
87
88 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
89 StringListRecord &Strings) {
90 auto Indices = Strings.getIndices();
91 uint32_t Size = Indices.size();
92 Name = "\"";
93 for (uint32_t I = 0; I < Size; ++I) {
94 Name.append(Types.getTypeName(Indices[I]));
95 if (I + 1 != Size)
96 Name.append("\" \"");
97 }
98 Name.push_back('\"');
99 return Error::success();
100 }
101
102 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
103 Name = Class.getName();
104 return Error::success();
105 }
106
107 Error TypeNameComputer::visitKnownRecord(CVType &CVR, UnionRecord &Union) {
108 Name = Union.getName();
109 return Error::success();
110 }
111
112 Error TypeNameComputer::visitKnownRecord(CVType &CVR, EnumRecord &Enum) {
113 Name = Enum.getName();
114 return Error::success();
115 }
116
117 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ArrayRecord &AT) {
118 Name = AT.getName();
119 return Error::success();
120 }
121
122 Error TypeNameComputer::visitKnownRecord(CVType &CVR, VFTableRecord &VFT) {
123 Name = VFT.getName();
124 return Error::success();
125 }
126
127 Error TypeNameComputer::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Id) {
128 Name = Id.getName();
129 return Error::success();
130 }
131
132 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ProcedureRecord &Proc) {
133 StringRef Ret = Types.getTypeName(Proc.getReturnType());
134 StringRef Params = Types.getTypeName(Proc.getArgumentList());
135 Name = formatv("{0} {1}", Ret, Params).sstr<256>();
136 return Error::success();
137 }
138
139 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
140 MemberFunctionRecord &MF) {
141 StringRef Ret = Types.getTypeName(MF.getReturnType());
142 StringRef Class = Types.getTypeName(MF.getClassType());
143 StringRef Params = Types.getTypeName(MF.getArgumentList());
144 Name = formatv("{0} {1}::{2}", Ret, Class, Params).sstr<256>();
145 return Error::success();
146 }
147
148 Error TypeNameComputer::visitKnownRecord(CVType &CVR, FuncIdRecord &Func) {
149 Name = Func.getName();
150 return Error::success();
151 }
152
153 Error TypeNameComputer::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
154 Name = TS.getName();
155 return Error::success();
156 }
157
158 Error TypeNameComputer::visitKnownRecord(CVType &CVR, PointerRecord &Ptr) {
159
160 if (Ptr.isPointerToMember()) {
161 const MemberPointerInfo &MI = Ptr.getMemberInfo();
162
163 StringRef Pointee = Types.getTypeName(Ptr.getReferentType());
164 StringRef Class = Types.getTypeName(MI.getContainingType());
165 Name = formatv("{0} {1}::*", Pointee, Class);
166 } else {
167 if (Ptr.isConst())
168 Name.append("const ");
169 if (Ptr.isVolatile())
170 Name.append("volatile ");
171 if (Ptr.isUnaligned())
172 Name.append("__unaligned ");
173
174 Name.append(Types.getTypeName(Ptr.getReferentType()));
175
176 if (Ptr.getMode() == PointerMode::LValueReference)
177 Name.append("&");
178 else if (Ptr.getMode() == PointerMode::RValueReference)
179 Name.append("&&");
180 else if (Ptr.getMode() == PointerMode::Pointer)
181 Name.append("*");
182 }
183 return Error::success();
184 }
185
186 Error TypeNameComputer::visitKnownRecord(CVType &CVR, ModifierRecord &Mod) {
187 uint16_t Mods = static_cast(Mod.getModifiers());
188
189 SmallString<256> TypeName;
190 if (Mods & uint16_t(ModifierOptions::Const))
191 Name.append("const ");
192 if (Mods & uint16_t(ModifierOptions::Volatile))
193 Name.append("volatile ");
194 if (Mods & uint16_t(ModifierOptions::Unaligned))
195 Name.append("__unaligned ");
196 Name.append(Types.getTypeName(Mod.getModifiedType()));
197 return Error::success();
198 }
199
200 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
201 VFTableShapeRecord &Shape) {
202 Name = formatv("", Shape.getEntryCount());
203 return Error::success();
204 }
205
206 Error TypeNameComputer::visitKnownRecord(
207 CVType &CVR, UdtModSourceLineRecord &ModSourceLine) {
208 return Error::success();
209 }
210
211 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
212 UdtSourceLineRecord &SourceLine) {
213 return Error::success();
214 }
215
216 Error TypeNameComputer::visitKnownRecord(CVType &CVR, BitFieldRecord &BF) {
217 return Error::success();
218 }
219
220 Error TypeNameComputer::visitKnownRecord(CVType &CVR,
221 MethodOverloadListRecord &Overloads) {
222 return Error::success();
223 }
224
225 Error TypeNameComputer::visitKnownRecord(CVType &CVR, BuildInfoRecord &BI) {
226 return Error::success();
227 }
228
229 Error TypeNameComputer::visitKnownRecord(CVType &CVR, LabelRecord &R) {
230 return Error::success();
231 }
232
233 std::string llvm::codeview::computeTypeName(TypeCollection &Types,
234 TypeIndex Index) {
235 TypeNameComputer Computer(Types);
236 CVType Record = Types.getType(Index);
237 if (auto EC = visitTypeRecord(Record, Index, Computer)) {
238 consumeError(std::move(EC));
239 return "";
240 }
241 return Computer.name();
242 }
99 #include "llvm/DebugInfo/CodeView/TypeTableCollection.h"
1010
1111 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
12 #include "llvm/DebugInfo/CodeView/TypeName.h"
12 #include "llvm/DebugInfo/CodeView/RecordName.h"
1313 #include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
1414 #include "llvm/Support/BinaryByteStream.h"
1515 #include "llvm/Support/BinaryStreamReader.h"
88
99 #include "llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h"
1010
11 #include "llvm/DebugInfo/CodeView/RecordName.h"
1112 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
1213 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
1314 #include "llvm/DebugInfo/CodeView/SymbolSerializer.h"
2627 using namespace llvm::pdb;
2728 using namespace llvm::codeview;
2829
29 static StringRef getSymbolName(const CVSymbol &Sym) {
30 assert(Sym.kind() == S_PUB32 && "handle other kinds");
31 PublicSym32 PSL =
32 cantFail(SymbolDeserializer::deserializeAs(Sym));
33 return PSL.Name;
34 }
35
3630 struct llvm::pdb::GSIHashStreamBuilder {
3731 std::vector Records;
3832 uint32_t StreamIndex;
4438 uint32_t calculateRecordByteSize() const;
4539 Error commit(BinaryStreamWriter &Writer);
4640 void finalizeBuckets(uint32_t RecordZeroOffset);
41
42 template void addSymbol(const T &Symbol, MSFBuilder &Msf) {
43 T Copy(Symbol);
44 Records.push_back(SymbolSerializer::writeOneSymbol(Copy, Msf.getAllocator(),
45 CodeViewContainer::Pdb));
46 }
47 void addSymbol(const CVSymbol &Symbol) { Records.push_back(Symbol); }
4748 };
4849
4950 uint32_t GSIHashStreamBuilder::calculateSerializedLength() const {
221222 }
222223
223224 void GSIStreamBuilder::addPublicSymbol(const PublicSym32 &Pub) {
224 PublicSym32 Copy(Pub);
225 PSH->Records.push_back(SymbolSerializer::writeOneSymbol(
226 Copy, Msf.getAllocator(), CodeViewContainer::Pdb));
225 PSH->addSymbol(Pub, Msf);
226 }
227
228 void GSIStreamBuilder::addGlobalSymbol(const ProcRefSym &Sym) {
229 GSH->addSymbol(Sym, Msf);
230 }
231
232 void GSIStreamBuilder::addGlobalSymbol(const DataSym &Sym) {
233 GSH->addSymbol(Sym, Msf);
234 }
235
236 void GSIStreamBuilder::addGlobalSymbol(const ConstantSym &Sym) {
237 GSH->addSymbol(Sym, Msf);
238 }
239
240 void GSIStreamBuilder::addGlobalSymbol(const UDTSym &Sym) {
241 GSH->addSymbol(Sym, Msf);
242 }
243
244 void GSIStreamBuilder::addGlobalSymbol(const codeview::CVSymbol &Sym) {
245 GSH->addSymbol(Sym);
227246 }
228247
229248 static Error writeRecords(BinaryStreamWriter &Writer,