llvm.org GIT mirror llvm / e075b10
[CodeView] Fix dumping of public symbol record flags I noticed nonsensical type information while dumping PDBs produced by MSVC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305708 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 2 years ago
9 changed file(s) with 51 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
401401 };
402402 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
403403
404 /// Corresponds to the CV_PUBSYMFLAGS bitfield.
405 enum class PublicSymFlags : uint32_t {
406 None = 0,
407 Code = 1 << 0,
408 Function = 1 << 1,
409 Managed = 1 << 2,
410 MSIL = 1 << 3,
411 };
412 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags)
413
404414 /// Corresponds to the CV_PROCFLAGS bitfield.
405415 enum class ProcSymFlags : uint8_t {
406416 None = 0,
2121 ArrayRef> getSymbolTypeNames();
2222 ArrayRef> getTypeLeafNames();
2323 ArrayRef> getRegisterNames();
24 ArrayRef> getPublicSymFlagNames();
2425 ArrayRef> getProcSymFlagNames();
2526 ArrayRef> getLocalFlagNames();
2627 ArrayRef> getFrameCookieKindNames();
362362 : SymbolRecord(SymbolRecordKind::PublicSym32),
363363 RecordOffset(RecordOffset) {}
364364
365 TypeIndex Index;
365 PublicSymFlags Flags;
366366 uint32_t Offset;
367367 uint16_t Segment;
368368 StringRef Name;
7979 CV_ENUM_CLASS_ENT(RegisterId, R13),
8080 CV_ENUM_CLASS_ENT(RegisterId, R14),
8181 CV_ENUM_CLASS_ENT(RegisterId, R15),
82 };
83
84 static const EnumEntry PublicSymFlagNames[] = {
85 CV_ENUM_CLASS_ENT(PublicSymFlags, Code),
86 CV_ENUM_CLASS_ENT(PublicSymFlags, Function),
87 CV_ENUM_CLASS_ENT(PublicSymFlags, Managed),
88 CV_ENUM_CLASS_ENT(PublicSymFlags, MSIL),
8289 };
8390
8491 static const EnumEntry ProcSymFlagNames[] = {
337344 return makeArrayRef(RegisterNames);
338345 }
339346
347 ArrayRef> getPublicSymFlagNames() {
348 return makeArrayRef(PublicSymFlagNames);
349 }
340350 ArrayRef> getProcSymFlagNames() {
341351 return makeArrayRef(ProcSymFlagNames);
342352 }
523523
524524 Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
525525 DictScope S(W, "PublicSym");
526 printTypeIndex("Type", Public.Index);
526 W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames());
527527 W.printNumber("Seg", Public.Segment);
528528 W.printNumber("Off", Public.Offset);
529529 W.printString("Name", Public.Name);
360360 Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
361361 PublicSym32 &Public) {
362362
363 error(IO.mapInteger(Public.Index));
363 error(IO.mapEnum(Public.Flags));
364364 error(IO.mapInteger(Public.Offset));
365365 error(IO.mapInteger(Public.Segment));
366366 error(IO.mapStringZ(Public.Name));
3939 LLVM_YAML_DECLARE_BITSET_TRAITS(CompileSym2Flags)
4040 LLVM_YAML_DECLARE_BITSET_TRAITS(CompileSym3Flags)
4141 LLVM_YAML_DECLARE_BITSET_TRAITS(ExportFlags)
42 LLVM_YAML_DECLARE_BITSET_TRAITS(PublicSymFlags)
4243 LLVM_YAML_DECLARE_BITSET_TRAITS(LocalSymFlags)
4344 LLVM_YAML_DECLARE_BITSET_TRAITS(ProcSymFlags)
4445 LLVM_YAML_DECLARE_BITSET_TRAITS(FrameProcedureOptions)
8990 for (const auto &E : FlagNames) {
9091 io.bitSetCase(Flags, E.Name.str().c_str(),
9192 static_cast(E.Value));
93 }
94 }
95
96 void ScalarBitSetTraits::bitset(IO &io, PublicSymFlags &Flags) {
97 auto FlagNames = getProcSymFlagNames();
98 for (const auto &E : FlagNames) {
99 io.bitSetCase(Flags, E.Name.str().c_str(),
100 static_cast(E.Value));
92101 }
93102 }
94103
297306 }
298307
299308 template <> void SymbolRecordImpl::map(IO &IO) {
300 IO.mapRequired("Type", Symbol.Index);
309 IO.mapRequired("Flags", Symbol.Flags);
301310 IO.mapRequired("Seg", Symbol.Segment);
302311 IO.mapRequired("Off", Symbol.Offset);
303312 IO.mapRequired("Name", Symbol.Name);
457457 ALL: Public Symbols
458458 ALL-NEXT: ============================================================
459459 ALL-NEXT: - S_PUB32 [size = 36] `?__purecall@@3PAXA`
460 ALL-NEXT: type = , addr = 0003:0000
460 ALL-NEXT: flags = none, addr = 0003:0000
461461 ALL-NEXT: - S_PUB32 [size = 20] `_main`
462 ALL-NEXT: type = 0x0002 (), addr = 0001:0016
462 ALL-NEXT: flags = function, addr = 0001:0016
463463 ALL-NEXT: - S_PROCREF [size = 20] `main`
464464 ALL-NEXT: module = 1, sum name = 0, offset = 120
465465 ALL-NEXT: - S_GDATA32 [size = 28] `__purecall`
142142 PUSH_FLAG(FrameProcedureOptions, OptimizedForSpeed, FPO, "opt speed");
143143 PUSH_FLAG(FrameProcedureOptions, GuardCfg, FPO, "guard cfg");
144144 PUSH_FLAG(FrameProcedureOptions, GuardCfw, FPO, "guard cfw");
145 return typesetItemList(Opts, 4, IndentLevel, " | ");
146 }
147
148 static std::string formatPublicSymFlags(uint32_t IndentLevel,
149 PublicSymFlags Flags) {
150 std::vector Opts;
151 if (Flags == PublicSymFlags::None)
152 return "none";
153
154 PUSH_FLAG(PublicSymFlags, Code, Flags, "code");
155 PUSH_FLAG(PublicSymFlags, Function, Flags, "function");
156 PUSH_FLAG(PublicSymFlags, Managed, Flags, "managed");
157 PUSH_FLAG(PublicSymFlags, MSIL, Flags, "msil");
145158 return typesetItemList(Opts, 4, IndentLevel, " | ");
146159 }
147160
658671 PublicSym32 &Public) {
659672 P.format(" `{0}`", Public.Name);
660673 AutoIndent Indent(P);
661 P.formatLine("type = {0}, addr = {1}", typeIndex(Public.Index),
674 P.formatLine("flags = {0}, addr = {1}",
675 formatPublicSymFlags(P.getIndentLevel() + 9, Public.Flags),
662676 formatSegmentOffset(Public.Segment, Public.Offset));
663677 return Error::success();
664678 }