summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/PdbYaml.h
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-30 21:53:05 +0000
committerZachary Turner <zturner@google.com>2017-05-30 21:53:05 +0000
commitd427383cb883aee50386a247df985bd12133e2db (patch)
tree3974b9bac0a66cddcc6cd2d87e164aa558ebbc92 /llvm/tools/llvm-pdbdump/PdbYaml.h
parent5e394c3d6f2731b22a4632071b9b0aed116989f9 (diff)
downloadbcm5719-llvm-d427383cb883aee50386a247df985bd12133e2db.tar.gz
bcm5719-llvm-d427383cb883aee50386a247df985bd12133e2db.zip
[CodeView] Move CodeView YAML code to ObjectYAML.
This is the beginning of an effort to move the codeview yaml reader / writer into ObjectYAML so that it can be shared. Currently the only consumer / producer of CodeView YAML is llvm-pdbdump, but CodeView can exist outside of PDB files, and indeed is put into object files and passed to the linker to produce PDB files. Furthermore, there are subtle differences in the types of records that show up in object file CodeView vs PDB file CodeView, but they are otherwise 99% the same. By having this code in ObjectYAML, we can have llvm-pdbdump reuse this code, while teaching obj2yaml and yaml2obj to use this syntax for dealing with object files that can contain CodeView. This patch only adds support for CodeView type information to ObjectYAML. Subsequent patches will add support for CodeView symbol information. llvm-svn: 304248
Diffstat (limited to 'llvm/tools/llvm-pdbdump/PdbYaml.h')
-rw-r--r--llvm/tools/llvm-pdbdump/PdbYaml.h200
1 files changed, 14 insertions, 186 deletions
diff --git a/llvm/tools/llvm-pdbdump/PdbYaml.h b/llvm/tools/llvm-pdbdump/PdbYaml.h
index 423845caeb3..f8c8850a86f 100644
--- a/llvm/tools/llvm-pdbdump/PdbYaml.h
+++ b/llvm/tools/llvm-pdbdump/PdbYaml.h
@@ -19,6 +19,7 @@
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
+#include "llvm/ObjectYAML/CodeViewYAML.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/YAMLTraits.h"
@@ -65,66 +66,11 @@ struct PdbModiStream {
std::vector<PdbSymbolRecord> Symbols;
};
-struct PdbSourceLineEntry {
- uint32_t Offset;
- uint32_t LineStart;
- uint32_t EndDelta;
- bool IsStatement;
-};
-
-struct PdbSourceColumnEntry {
- uint16_t StartColumn;
- uint16_t EndColumn;
-};
-
-struct PdbSourceLineBlock {
- StringRef FileName;
- std::vector<PdbSourceLineEntry> Lines;
- std::vector<PdbSourceColumnEntry> Columns;
-};
-
-struct HexFormattedString {
- std::vector<uint8_t> Bytes;
-};
-
-struct PdbSourceFileChecksumEntry {
- StringRef FileName;
- codeview::FileChecksumKind Kind;
- HexFormattedString ChecksumBytes;
-};
-
-struct PdbSourceLineInfo {
- uint32_t RelocOffset;
- uint32_t RelocSegment;
- codeview::LineFlags Flags;
- uint32_t CodeSize;
-
- std::vector<PdbSourceLineBlock> Blocks;
-};
-
-struct PdbInlineeSite {
- codeview::TypeIndex Inlinee;
- StringRef FileName;
- uint32_t SourceLineNum;
- std::vector<StringRef> ExtraFiles;
-};
-
-struct PdbInlineeInfo {
- bool HasExtraFiles;
- std::vector<PdbInlineeSite> Sites;
-};
-
-struct PdbSourceFileInfo {
- std::vector<PdbSourceFileChecksumEntry> FileChecksums;
- std::vector<PdbSourceLineInfo> LineFragments;
- std::vector<PdbInlineeInfo> Inlinees;
-};
-
struct PdbDbiModuleInfo {
StringRef Obj;
StringRef Mod;
std::vector<StringRef> SourceFiles;
- Optional<PdbSourceFileInfo> FileLineInfo;
+ Optional<CodeViewYAML::SourceFileInfo> FileLineInfo;
Optional<PdbModiStream> Modi;
};
@@ -140,17 +86,9 @@ struct PdbDbiStream {
std::vector<PdbDbiModuleInfo> ModInfos;
};
-struct PdbTpiRecord {
- codeview::CVType Record;
-};
-
-struct PdbTpiFieldListRecord {
- codeview::CVMemberRecord Record;
-};
-
struct PdbTpiStream {
PdbRaw_TpiVer Version = PdbTpiV80;
- std::vector<PdbTpiRecord> Records;
+ std::vector<CodeViewYAML::LeafRecord> Records;
};
struct PdbObject {
@@ -172,126 +110,16 @@ struct PdbObject {
}
}
-namespace llvm {
-namespace yaml {
-
-template <> struct MappingTraits<pdb::yaml::PdbObject> {
- static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
-};
-
-template <> struct MappingTraits<pdb::yaml::MSFHeaders> {
- static void mapping(IO &IO, pdb::yaml::MSFHeaders &Obj);
-};
-
-template <> struct MappingTraits<msf::SuperBlock> {
- static void mapping(IO &IO, msf::SuperBlock &SB);
-};
-
-template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
- static void mapping(IO &IO, pdb::yaml::StreamBlockList &SB);
-};
-
-template <> struct MappingTraits<pdb::yaml::PdbInfoStream> {
- static void mapping(IO &IO, pdb::yaml::PdbInfoStream &Obj);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbDbiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbDbiStream &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbTpiStream &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingTraits<pdb::yaml::NamedStreamMapping> {
- static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbSymbolRecord, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbModiStream, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct MappingContextTraits<pdb::yaml::PdbDbiModuleInfo, pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj, pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceColumnEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceColumnEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineBlock,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineBlock &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceFileChecksumEntry,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceFileChecksumEntry &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct ScalarTraits<pdb::yaml::HexFormattedString> {
- static void output(const pdb::yaml::HexFormattedString &Value, void *ctx,
- llvm::raw_ostream &Out);
- static StringRef input(StringRef Scalar, void *ctxt,
- pdb::yaml::HexFormattedString &Value);
- static bool mustQuote(StringRef) { return false; }
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceLineInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceLineInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbSourceFileInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbSourceFileInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbInlineeInfo,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbInlineeInfo &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbInlineeSite,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbInlineeSite &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiRecord,
- pdb::yaml::SerializationContext> {
- static void mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
- pdb::yaml::SerializationContext &Context);
-};
-}
-}
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbSymbolRecord)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
#endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
OpenPOWER on IntegriCloud