mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[CodeView] Fix dumping of public symbol record flags
I noticed nonsensical type information while dumping PDBs produced by MSVC. llvm-svn: 305708
This commit is contained in:
parent
fe895e47d9
commit
6531ce0849
@ -402,6 +402,16 @@ enum class LocalSymFlags : uint16_t {
|
||||
};
|
||||
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
|
||||
|
||||
/// Corresponds to the CV_PUBSYMFLAGS bitfield.
|
||||
enum class PublicSymFlags : uint32_t {
|
||||
None = 0,
|
||||
Code = 1 << 0,
|
||||
Function = 1 << 1,
|
||||
Managed = 1 << 2,
|
||||
MSIL = 1 << 3,
|
||||
};
|
||||
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags)
|
||||
|
||||
/// Corresponds to the CV_PROCFLAGS bitfield.
|
||||
enum class ProcSymFlags : uint8_t {
|
||||
None = 0,
|
||||
|
@ -22,6 +22,7 @@ namespace codeview {
|
||||
ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames();
|
||||
ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames();
|
||||
ArrayRef<EnumEntry<uint16_t>> getRegisterNames();
|
||||
ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames();
|
||||
ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames();
|
||||
ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames();
|
||||
ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames();
|
||||
|
@ -363,7 +363,7 @@ public:
|
||||
: SymbolRecord(SymbolRecordKind::PublicSym32),
|
||||
RecordOffset(RecordOffset) {}
|
||||
|
||||
TypeIndex Index;
|
||||
PublicSymFlags Flags;
|
||||
uint32_t Offset;
|
||||
uint16_t Segment;
|
||||
StringRef Name;
|
||||
|
@ -82,6 +82,13 @@ static const EnumEntry<uint16_t> RegisterNames[] = {
|
||||
CV_ENUM_CLASS_ENT(RegisterId, R15),
|
||||
};
|
||||
|
||||
static const EnumEntry<uint32_t> PublicSymFlagNames[] = {
|
||||
CV_ENUM_CLASS_ENT(PublicSymFlags, Code),
|
||||
CV_ENUM_CLASS_ENT(PublicSymFlags, Function),
|
||||
CV_ENUM_CLASS_ENT(PublicSymFlags, Managed),
|
||||
CV_ENUM_CLASS_ENT(PublicSymFlags, MSIL),
|
||||
};
|
||||
|
||||
static const EnumEntry<uint8_t> ProcSymFlagNames[] = {
|
||||
CV_ENUM_CLASS_ENT(ProcSymFlags, HasFP),
|
||||
CV_ENUM_CLASS_ENT(ProcSymFlags, HasIRET),
|
||||
@ -338,6 +345,9 @@ ArrayRef<EnumEntry<uint16_t>> getRegisterNames() {
|
||||
return makeArrayRef(RegisterNames);
|
||||
}
|
||||
|
||||
ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames() {
|
||||
return makeArrayRef(PublicSymFlagNames);
|
||||
}
|
||||
ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames() {
|
||||
return makeArrayRef(ProcSymFlagNames);
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
|
||||
|
||||
Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
|
||||
DictScope S(W, "PublicSym");
|
||||
printTypeIndex("Type", Public.Index);
|
||||
W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames());
|
||||
W.printNumber("Seg", Public.Segment);
|
||||
W.printNumber("Off", Public.Offset);
|
||||
W.printString("Name", Public.Name);
|
||||
|
@ -361,7 +361,7 @@ Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
|
||||
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
|
||||
PublicSym32 &Public) {
|
||||
|
||||
error(IO.mapInteger(Public.Index));
|
||||
error(IO.mapEnum(Public.Flags));
|
||||
error(IO.mapInteger(Public.Offset));
|
||||
error(IO.mapInteger(Public.Segment));
|
||||
error(IO.mapStringZ(Public.Name));
|
||||
|
@ -40,6 +40,7 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(FrameCookieKind)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(CompileSym2Flags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(CompileSym3Flags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(ExportFlags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(PublicSymFlags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(LocalSymFlags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(ProcSymFlags)
|
||||
LLVM_YAML_DECLARE_BITSET_TRAITS(FrameProcedureOptions)
|
||||
@ -93,6 +94,14 @@ void ScalarBitSetTraits<ExportFlags>::bitset(IO &io, ExportFlags &Flags) {
|
||||
}
|
||||
}
|
||||
|
||||
void ScalarBitSetTraits<PublicSymFlags>::bitset(IO &io, PublicSymFlags &Flags) {
|
||||
auto FlagNames = getProcSymFlagNames();
|
||||
for (const auto &E : FlagNames) {
|
||||
io.bitSetCase(Flags, E.Name.str().c_str(),
|
||||
static_cast<PublicSymFlags>(E.Value));
|
||||
}
|
||||
}
|
||||
|
||||
void ScalarBitSetTraits<LocalSymFlags>::bitset(IO &io, LocalSymFlags &Flags) {
|
||||
auto FlagNames = getLocalFlagNames();
|
||||
for (const auto &E : FlagNames) {
|
||||
@ -298,7 +307,7 @@ template <> void SymbolRecordImpl<RegisterSym>::map(IO &IO) {
|
||||
}
|
||||
|
||||
template <> void SymbolRecordImpl<PublicSym32>::map(IO &IO) {
|
||||
IO.mapRequired("Type", Symbol.Index);
|
||||
IO.mapRequired("Flags", Symbol.Flags);
|
||||
IO.mapRequired("Seg", Symbol.Segment);
|
||||
IO.mapRequired("Off", Symbol.Offset);
|
||||
IO.mapRequired("Name", Symbol.Name);
|
||||
|
@ -458,9 +458,9 @@ ALL: Hash Adjusters:
|
||||
ALL: Public Symbols
|
||||
ALL-NEXT: ============================================================
|
||||
ALL-NEXT: - S_PUB32 [size = 36] `?__purecall@@3PAXA`
|
||||
ALL-NEXT: type = <no type>, addr = 0003:0000
|
||||
ALL-NEXT: flags = none, addr = 0003:0000
|
||||
ALL-NEXT: - S_PUB32 [size = 20] `_main`
|
||||
ALL-NEXT: type = 0x0002 (<unknown simple type>), addr = 0001:0016
|
||||
ALL-NEXT: flags = function, addr = 0001:0016
|
||||
ALL-NEXT: - S_PROCREF [size = 20] `main`
|
||||
ALL-NEXT: module = 1, sum name = 0, offset = 120
|
||||
ALL-NEXT: - S_GDATA32 [size = 28] `__purecall`
|
||||
|
@ -146,6 +146,19 @@ static std::string formatFrameProcedureOptions(uint32_t IndentLevel,
|
||||
return typesetItemList(Opts, 4, IndentLevel, " | ");
|
||||
}
|
||||
|
||||
static std::string formatPublicSymFlags(uint32_t IndentLevel,
|
||||
PublicSymFlags Flags) {
|
||||
std::vector<std::string> Opts;
|
||||
if (Flags == PublicSymFlags::None)
|
||||
return "none";
|
||||
|
||||
PUSH_FLAG(PublicSymFlags, Code, Flags, "code");
|
||||
PUSH_FLAG(PublicSymFlags, Function, Flags, "function");
|
||||
PUSH_FLAG(PublicSymFlags, Managed, Flags, "managed");
|
||||
PUSH_FLAG(PublicSymFlags, MSIL, Flags, "msil");
|
||||
return typesetItemList(Opts, 4, IndentLevel, " | ");
|
||||
}
|
||||
|
||||
static std::string formatProcSymFlags(uint32_t IndentLevel,
|
||||
ProcSymFlags Flags) {
|
||||
std::vector<std::string> Opts;
|
||||
@ -659,7 +672,8 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
|
||||
PublicSym32 &Public) {
|
||||
P.format(" `{0}`", Public.Name);
|
||||
AutoIndent Indent(P);
|
||||
P.formatLine("type = {0}, addr = {1}", typeIndex(Public.Index),
|
||||
P.formatLine("flags = {0}, addr = {1}",
|
||||
formatPublicSymFlags(P.getIndentLevel() + 9, Public.Flags),
|
||||
formatSegmentOffset(Public.Segment, Public.Offset));
|
||||
return Error::success();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user