[llvm] r283641 - [pdb] Dump Module Symbols to Yaml.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 18:12:02 PDT 2016


Author: zturner
Date: Fri Oct  7 20:12:01 2016
New Revision: 283641

URL: http://llvm.org/viewvc/llvm-project?rev=283641&view=rev
Log:
[pdb] Dump Module Symbols to Yaml.

This is the first step towards round-tripping symbol information,
and thusly being able to write symbol information to a PDB.

This patch writes the symbol information for each compiland to
the Yaml when running in pdb2yaml mode.  There's still some loose
ends, such as what to do about relocations (necessary in order to
print linkage names), how to print enums with friendly names, and
how to give the dumper access to the StringTable, but this is a
good first start.

Added:
    llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test
    llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp
    llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.h
    llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp
      - copied, changed from r283639, llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp
    llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.h
      - copied, changed from r283639, llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h
Removed:
    llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp
    llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h
Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
    llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
    llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt
    llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp
    llvm/trunk/tools/llvm-pdbdump/PdbYaml.h
    llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp
    llvm/trunk/tools/llvm-pdbdump/YamlSerializationContext.h
    llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
    llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Fri Oct  7 20:12:01 2016
@@ -524,7 +524,7 @@ enum class RegisterId : uint16_t {
 };
 
 /// These values correspond to the THUNK_ORDINAL enumeration.
-enum class ThunkOrdinal {
+enum class ThunkOrdinal : uint8_t {
   Standard,
   ThisAdjustor,
   Vcall,

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h Fri Oct  7 20:12:01 2016
@@ -32,6 +32,8 @@ public:
 
   Error reload();
 
+  uint32_t signature() const { return Signature; }
+
   iterator_range<codeview::CVSymbolArray::Iterator>
   symbols(bool *HadError) const;
 
@@ -43,6 +45,8 @@ public:
 private:
   const ModInfo &Mod;
 
+  uint32_t Signature;
+
   std::unique_ptr<msf::MappedBlockStream> Stream;
 
   codeview::CVSymbolArray SymbolsSubstream;

Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp Fri Oct  7 20:12:01 2016
@@ -38,8 +38,7 @@ Error ModStream::reload() {
 
   ReadableStreamRef S;
 
-  uint32_t SymbolSubstreamSig = 0;
-  if (auto EC = Reader.readInteger(SymbolSubstreamSig))
+  if (auto EC = Reader.readInteger(Signature))
     return EC;
   if (auto EC = Reader.readArray(SymbolsSubstream, SymbolSize - 4))
     return EC;

Added: llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test?rev=283641&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test (added)
+++ llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test Fri Oct  7 20:12:01 2016
@@ -0,0 +1,186 @@
+; RUN: llvm-pdbdump pdb2yaml -dbi-module-syms %p/Inputs/empty.pdb \
+; RUN:   | FileCheck -check-prefix=YAML %s
+
+
+YAML: ---
+YAML: MSF:
+YAML:   SuperBlock:
+YAML:     BlockSize:       4096
+YAML:     FreeBlockMap:    2
+YAML:     NumBlocks:       25
+YAML:     NumDirectoryBytes: 136
+YAML:     Unknown1:        0
+YAML:     BlockMapAddr:    24
+YAML:   NumDirectoryBlocks: 1
+YAML:   DirectoryBlocks: [ 23 ]
+YAML:   NumStreams:      0
+YAML:   FileSize:        102400
+YAML: DbiStream:
+YAML:   VerHeader:       V70
+YAML:   Age:             1
+YAML:   BuildNumber:     35840
+YAML:   PdbDllVersion:   31101
+YAML:   PdbDllRbld:      0
+YAML:   Flags:           1
+YAML:   MachineType:     x86
+YAML:   Modules:
+YAML:     - Module:          'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
+YAML:       ObjFile:         'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
+YAML:       Modi:
+YAML:         Signature:       4
+YAML:         Records:
+YAML:           - Kind:            S_OBJNAME
+YAML:             ObjNameSym:
+YAML:               Signature:       0
+YAML:               ObjectName:      'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
+YAML:           - Kind:            S_COMPILE3
+YAML:             Compile3Sym:
+YAML:               Flags:           8193
+YAML:               Machine:         7
+YAML:               FrontendMajor:   18
+YAML:               FrontendMinor:   0
+YAML:               FrontendBuild:   31101
+YAML:               FrontendQFE:     0
+YAML:               BackendMajor:    18
+YAML:               BackendMinor:    0
+YAML:               BackendBuild:    31101
+YAML:               BackendQFE:      0
+YAML:               Version:         'Microsoft (R) Optimizing Compiler'
+YAML:           - Kind:            S_GPROC32
+YAML:             ProcSym:
+YAML:               PtrParent:       0
+YAML:               PtrEnd:          196
+YAML:               PtrNext:         0
+YAML:               CodeSize:        10
+YAML:               DbgStart:        3
+YAML:               DbgEnd:          8
+YAML:               FunctionType:    4097
+YAML:               Segment:         1
+YAML:               Flags:           1
+YAML:               DisplayName:     main
+YAML:           - Kind:            S_FRAMEPROC
+YAML:             FrameProcSym:
+YAML:               TotalFrameBytes: 0
+YAML:               PaddingFrameBytes: 0
+YAML:               OffsetToPadding: 0
+YAML:               BytesOfCalleeSavedRegisters: 0
+YAML:               OffsetOfExceptionHandler: 0
+YAML:               SectionIdOfExceptionHandler: 0
+YAML:               Flags:           1212928
+YAML:           - Kind:            S_END
+YAML:             ScopeEndSym:
+YAML:           - Kind:            S_BUILDINFO
+YAML:             BuildInfoSym:
+YAML:               BuildId:         4110
+YAML:     - Module:          '* Linker *'
+YAML:       ObjFile:         ''
+YAML:       Modi:
+YAML:         Signature:       4
+YAML:         Records:
+YAML:           - Kind:            S_OBJNAME
+YAML:             ObjNameSym:
+YAML:               Signature:       0
+YAML:               ObjectName:      '* Linker *'
+YAML:           - Kind:            S_COMPILE3
+YAML:             Compile3Sym:
+YAML:               Flags:           7
+YAML:               Machine:         3
+YAML:               FrontendMajor:   0
+YAML:               FrontendMinor:   0
+YAML:               FrontendBuild:   0
+YAML:               FrontendQFE:     0
+YAML:               BackendMajor:    12
+YAML:               BackendMinor:    0
+YAML:               BackendBuild:    31101
+YAML:               BackendQFE:      0
+YAML:               Version:         'Microsoft (R) LINK'
+YAML:           - Kind:            S_ENVBLOCK
+YAML:             EnvBlockSym:
+YAML:               Reserved:        0
+YAML:               Entries:
+YAML:                 - cwd
+YAML:                 - 'd:\src\llvm\test\DebugInfo\PDB\Inputs'
+YAML:                 - exe
+YAML:                 - 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.exe'
+YAML:                 - pdb
+YAML:                 - 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.pdb'
+YAML:           - Kind:            S_TRAMPOLINE
+YAML:             TrampolineSym:
+YAML:               Type:            0
+YAML:               Size:            5
+YAML:               ThunkOff:        5
+YAML:               TargetOff:       16
+YAML:               ThunkSection:    1
+YAML:               TargetSection:   1
+YAML:           - Kind:            S_SECTION
+YAML:             SectionSym:
+YAML:               SectionNumber:   1
+YAML:               Alignment:       12
+YAML:               Reserved:        0
+YAML:               Rva:             4096
+YAML:               Length:          4122
+YAML:               Characteristics: 1610612768
+YAML:               Name:            .text
+YAML:           - Kind:            S_COFFGROUP
+YAML:             CoffGroupSym:
+YAML:               Size:            4122
+YAML:               Characteristics: 1610612768
+YAML:               Offset:          0
+YAML:               Segment:         1
+YAML:               Name:            '.text$mn'
+YAML:           - Kind:            S_SECTION
+YAML:             SectionSym:
+YAML:               SectionNumber:   2
+YAML:               Alignment:       12
+YAML:               Reserved:        0
+YAML:               Rva:             12288
+YAML:               Length:          690
+YAML:               Characteristics: 1073741888
+YAML:               Name:            .rdata
+YAML:           - Kind:            S_COFFGROUP
+YAML:             CoffGroupSym:
+YAML:               Size:            323
+YAML:               Characteristics: 1073741888
+YAML:               Offset:          0
+YAML:               Segment:         2
+YAML:               Name:            .rdata
+YAML:           - Kind:            S_COFFGROUP
+YAML:             CoffGroupSym:
+YAML:               Size:            0
+YAML:               Characteristics: 1073741888
+YAML:               Offset:          323
+YAML:               Segment:         2
+YAML:               Name:            .edata
+YAML:           - Kind:            S_COFFGROUP
+YAML:             CoffGroupSym:
+YAML:               Size:            366
+YAML:               Characteristics: 1073741888
+YAML:               Offset:          324
+YAML:               Segment:         2
+YAML:               Name:            '.rdata$debug'
+YAML:           - Kind:            S_SECTION
+YAML:             SectionSym:
+YAML:               SectionNumber:   3
+YAML:               Alignment:       12
+YAML:               Reserved:        0
+YAML:               Rva:             16384
+YAML:               Length:          4
+YAML:               Characteristics: 3221225536
+YAML:               Name:            .data
+YAML:           - Kind:            S_COFFGROUP
+YAML:             CoffGroupSym:
+YAML:               Size:            4
+YAML:               Characteristics: 3221225600
+YAML:               Offset:          0
+YAML:               Segment:         3
+YAML:               Name:            .bss
+YAML:           - Kind:            S_SECTION
+YAML:             SectionSym:
+YAML:               SectionNumber:   4
+YAML:               Alignment:       12
+YAML:               Reserved:        0
+YAML:               Rva:             20480
+YAML:               Length:          8
+YAML:               Characteristics: 1107296320
+YAML:               Name:            .reloc
+YAML: ...
\ No newline at end of file

Modified: llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt Fri Oct  7 20:12:01 2016
@@ -10,7 +10,8 @@ add_llvm_tool(llvm-pdbdump
   llvm-pdbdump.cpp
   BuiltinDumper.cpp
   ClassDefinitionDumper.cpp
-  CodeViewYaml.cpp
+  YamlSymbolDumper.cpp
+  YamlTypeDumper.cpp
   CompilandDumper.cpp
   EnumDumper.cpp
   ExternalSymbolDumper.cpp

Removed: llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp?rev=283640&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp (removed)
@@ -1,594 +0,0 @@
-//===- PdbYAML.cpp -------------------------------------------- *- C++ --*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CodeViewYaml.h"
-#include "PdbYaml.h"
-#include "YamlSerializationContext.h"
-
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/EnumTables.h"
-#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeSerializationVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
-#include "llvm/DebugInfo/PDB/Raw/TpiHashing.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::codeview::yaml;
-
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
-LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint64_t)
-LLVM_YAML_IS_SEQUENCE_VECTOR(OneMethodRecord)
-LLVM_YAML_IS_SEQUENCE_VECTOR(VFTableSlotKind)
-LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
-LLVM_YAML_IS_SEQUENCE_VECTOR(CVType)
-LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbTpiFieldListRecord)
-
-namespace {
-struct FieldListRecordSplitter : public TypeVisitorCallbacks {
-public:
-  explicit FieldListRecordSplitter(
-      std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> &Records)
-      : Records(Records) {}
-
-#define TYPE_RECORD(EnumName, EnumVal, Name)
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
-  Error visitKnownMember(CVMemberRecord &CVT, Name##Record &Record) override { \
-    visitKnownMemberImpl(CVT);                                                 \
-    return Error::success();                                                   \
-  }
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-
-private:
-  void visitKnownMemberImpl(CVMemberRecord &CVT) {
-    llvm::pdb::yaml::PdbTpiFieldListRecord R;
-    R.Record = CVT;
-    Records.push_back(std::move(R));
-  }
-
-  std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> &Records;
-};
-}
-
-namespace llvm {
-namespace yaml {
-template <> struct ScalarEnumerationTraits<PointerToMemberRepresentation> {
-  static void enumeration(IO &IO, PointerToMemberRepresentation &Value) {
-    IO.enumCase(Value, "Unknown", PointerToMemberRepresentation::Unknown);
-    IO.enumCase(Value, "SingleInheritanceData",
-                PointerToMemberRepresentation::SingleInheritanceData);
-    IO.enumCase(Value, "MultipleInheritanceData",
-                PointerToMemberRepresentation::MultipleInheritanceData);
-    IO.enumCase(Value, "VirtualInheritanceData",
-                PointerToMemberRepresentation::VirtualInheritanceData);
-    IO.enumCase(Value, "GeneralData",
-                PointerToMemberRepresentation::GeneralData);
-    IO.enumCase(Value, "SingleInheritanceFunction",
-                PointerToMemberRepresentation::SingleInheritanceFunction);
-    IO.enumCase(Value, "MultipleInheritanceFunction",
-                PointerToMemberRepresentation::MultipleInheritanceFunction);
-    IO.enumCase(Value, "VirtualInheritanceFunction",
-                PointerToMemberRepresentation::VirtualInheritanceFunction);
-    IO.enumCase(Value, "GeneralFunction",
-                PointerToMemberRepresentation::GeneralFunction);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<VFTableSlotKind> {
-  static void enumeration(IO &IO, VFTableSlotKind &Kind) {
-    IO.enumCase(Kind, "Near16", VFTableSlotKind::Near16);
-    IO.enumCase(Kind, "Far16", VFTableSlotKind::Far16);
-    IO.enumCase(Kind, "This", VFTableSlotKind::This);
-    IO.enumCase(Kind, "Outer", VFTableSlotKind::Outer);
-    IO.enumCase(Kind, "Meta", VFTableSlotKind::Meta);
-    IO.enumCase(Kind, "Near", VFTableSlotKind::Near);
-    IO.enumCase(Kind, "Far", VFTableSlotKind::Far);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<CallingConvention> {
-  static void enumeration(IO &IO, CallingConvention &Value) {
-    IO.enumCase(Value, "NearC", CallingConvention::NearC);
-    IO.enumCase(Value, "FarC", CallingConvention::FarC);
-    IO.enumCase(Value, "NearPascal", CallingConvention::NearPascal);
-    IO.enumCase(Value, "FarPascal", CallingConvention::FarPascal);
-    IO.enumCase(Value, "NearFast", CallingConvention::NearFast);
-    IO.enumCase(Value, "FarFast", CallingConvention::FarFast);
-    IO.enumCase(Value, "NearStdCall", CallingConvention::NearStdCall);
-    IO.enumCase(Value, "FarStdCall", CallingConvention::FarStdCall);
-    IO.enumCase(Value, "NearSysCall", CallingConvention::NearSysCall);
-    IO.enumCase(Value, "FarSysCall", CallingConvention::FarSysCall);
-    IO.enumCase(Value, "ThisCall", CallingConvention::ThisCall);
-    IO.enumCase(Value, "MipsCall", CallingConvention::MipsCall);
-    IO.enumCase(Value, "Generic", CallingConvention::Generic);
-    IO.enumCase(Value, "AlphaCall", CallingConvention::AlphaCall);
-    IO.enumCase(Value, "PpcCall", CallingConvention::PpcCall);
-    IO.enumCase(Value, "SHCall", CallingConvention::SHCall);
-    IO.enumCase(Value, "ArmCall", CallingConvention::ArmCall);
-    IO.enumCase(Value, "AM33Call", CallingConvention::AM33Call);
-    IO.enumCase(Value, "TriCall", CallingConvention::TriCall);
-    IO.enumCase(Value, "SH5Call", CallingConvention::SH5Call);
-    IO.enumCase(Value, "M32RCall", CallingConvention::M32RCall);
-    IO.enumCase(Value, "ClrCall", CallingConvention::ClrCall);
-    IO.enumCase(Value, "Inline", CallingConvention::Inline);
-    IO.enumCase(Value, "NearVector", CallingConvention::NearVector);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<PointerKind> {
-  static void enumeration(IO &IO, PointerKind &Kind) {
-    IO.enumCase(Kind, "Near16", PointerKind::Near16);
-    IO.enumCase(Kind, "Far16", PointerKind::Far16);
-    IO.enumCase(Kind, "Huge16", PointerKind::Huge16);
-    IO.enumCase(Kind, "BasedOnSegment", PointerKind::BasedOnSegment);
-    IO.enumCase(Kind, "BasedOnValue", PointerKind::BasedOnValue);
-    IO.enumCase(Kind, "BasedOnSegmentValue", PointerKind::BasedOnSegmentValue);
-    IO.enumCase(Kind, "BasedOnAddress", PointerKind::BasedOnAddress);
-    IO.enumCase(Kind, "BasedOnSegmentAddress",
-                PointerKind::BasedOnSegmentAddress);
-    IO.enumCase(Kind, "BasedOnType", PointerKind::BasedOnType);
-    IO.enumCase(Kind, "BasedOnSelf", PointerKind::BasedOnSelf);
-    IO.enumCase(Kind, "Near32", PointerKind::Near32);
-    IO.enumCase(Kind, "Far32", PointerKind::Far32);
-    IO.enumCase(Kind, "Near64", PointerKind::Near64);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<PointerMode> {
-  static void enumeration(IO &IO, PointerMode &Mode) {
-    IO.enumCase(Mode, "Pointer", PointerMode::Pointer);
-    IO.enumCase(Mode, "LValueReference", PointerMode::LValueReference);
-    IO.enumCase(Mode, "PointerToDataMember", PointerMode::PointerToDataMember);
-    IO.enumCase(Mode, "PointerToMemberFunction",
-                PointerMode::PointerToMemberFunction);
-    IO.enumCase(Mode, "RValueReference", PointerMode::RValueReference);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<HfaKind> {
-  static void enumeration(IO &IO, HfaKind &Value) {
-    IO.enumCase(Value, "None", HfaKind::None);
-    IO.enumCase(Value, "Float", HfaKind::Float);
-    IO.enumCase(Value, "Double", HfaKind::Double);
-    IO.enumCase(Value, "Other", HfaKind::Other);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<MemberAccess> {
-  static void enumeration(IO &IO, MemberAccess &Access) {
-    IO.enumCase(Access, "None", MemberAccess::None);
-    IO.enumCase(Access, "Private", MemberAccess::Private);
-    IO.enumCase(Access, "Protected", MemberAccess::Protected);
-    IO.enumCase(Access, "Public", MemberAccess::Public);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<MethodKind> {
-  static void enumeration(IO &IO, MethodKind &Kind) {
-    IO.enumCase(Kind, "Vanilla", MethodKind::Vanilla);
-    IO.enumCase(Kind, "Virtual", MethodKind::Virtual);
-    IO.enumCase(Kind, "Static", MethodKind::Static);
-    IO.enumCase(Kind, "Friend", MethodKind::Friend);
-    IO.enumCase(Kind, "IntroducingVirtual", MethodKind::IntroducingVirtual);
-    IO.enumCase(Kind, "PureVirtual", MethodKind::PureVirtual);
-    IO.enumCase(Kind, "PureIntroducingVirtual",
-                MethodKind::PureIntroducingVirtual);
-  }
-};
-
-template <> struct ScalarEnumerationTraits<WindowsRTClassKind> {
-  static void enumeration(IO &IO, WindowsRTClassKind &Value) {
-    IO.enumCase(Value, "None", WindowsRTClassKind::None);
-    IO.enumCase(Value, "Ref", WindowsRTClassKind::RefClass);
-    IO.enumCase(Value, "Value", WindowsRTClassKind::ValueClass);
-    IO.enumCase(Value, "Interface", WindowsRTClassKind::Interface);
-  }
-};
-
-template <> struct ScalarBitSetTraits<PointerOptions> {
-  static void bitset(IO &IO, PointerOptions &Options) {
-    IO.bitSetCase(Options, "None", PointerOptions::None);
-    IO.bitSetCase(Options, "Flat32", PointerOptions::Flat32);
-    IO.bitSetCase(Options, "Volatile", PointerOptions::Volatile);
-    IO.bitSetCase(Options, "Const", PointerOptions::Const);
-    IO.bitSetCase(Options, "Unaligned", PointerOptions::Unaligned);
-    IO.bitSetCase(Options, "Restrict", PointerOptions::Restrict);
-    IO.bitSetCase(Options, "WinRTSmartPointer",
-                  PointerOptions::WinRTSmartPointer);
-  }
-};
-
-template <> struct ScalarBitSetTraits<ModifierOptions> {
-  static void bitset(IO &IO, ModifierOptions &Options) {
-    IO.bitSetCase(Options, "None", ModifierOptions::None);
-    IO.bitSetCase(Options, "Const", ModifierOptions::Const);
-    IO.bitSetCase(Options, "Volatile", ModifierOptions::Volatile);
-    IO.bitSetCase(Options, "Unaligned", ModifierOptions::Unaligned);
-  }
-};
-
-template <> struct ScalarBitSetTraits<FunctionOptions> {
-  static void bitset(IO &IO, FunctionOptions &Options) {
-    IO.bitSetCase(Options, "None", FunctionOptions::None);
-    IO.bitSetCase(Options, "CxxReturnUdt", FunctionOptions::CxxReturnUdt);
-    IO.bitSetCase(Options, "Constructor", FunctionOptions::Constructor);
-    IO.bitSetCase(Options, "ConstructorWithVirtualBases",
-                  FunctionOptions::ConstructorWithVirtualBases);
-  }
-};
-
-template <> struct ScalarBitSetTraits<ClassOptions> {
-  static void bitset(IO &IO, ClassOptions &Options) {
-    IO.bitSetCase(Options, "None", ClassOptions::None);
-    IO.bitSetCase(Options, "HasConstructorOrDestructor",
-                  ClassOptions::HasConstructorOrDestructor);
-    IO.bitSetCase(Options, "HasOverloadedOperator",
-                  ClassOptions::HasOverloadedOperator);
-    IO.bitSetCase(Options, "Nested", ClassOptions::Nested);
-    IO.bitSetCase(Options, "ContainsNestedClass",
-                  ClassOptions::ContainsNestedClass);
-    IO.bitSetCase(Options, "HasOverloadedAssignmentOperator",
-                  ClassOptions::HasOverloadedAssignmentOperator);
-    IO.bitSetCase(Options, "HasConversionOperator",
-                  ClassOptions::HasConversionOperator);
-    IO.bitSetCase(Options, "ForwardReference", ClassOptions::ForwardReference);
-    IO.bitSetCase(Options, "Scoped", ClassOptions::Scoped);
-    IO.bitSetCase(Options, "HasUniqueName", ClassOptions::HasUniqueName);
-    IO.bitSetCase(Options, "Sealed", ClassOptions::Sealed);
-    IO.bitSetCase(Options, "Intrinsic", ClassOptions::Intrinsic);
-  }
-};
-
-template <> struct ScalarBitSetTraits<MethodOptions> {
-  static void bitset(IO &IO, MethodOptions &Options) {
-    IO.bitSetCase(Options, "None", MethodOptions::None);
-    IO.bitSetCase(Options, "Pseudo", MethodOptions::Pseudo);
-    IO.bitSetCase(Options, "NoInherit", MethodOptions::NoInherit);
-    IO.bitSetCase(Options, "NoConstruct", MethodOptions::NoConstruct);
-    IO.bitSetCase(Options, "CompilerGenerated",
-                  MethodOptions::CompilerGenerated);
-    IO.bitSetCase(Options, "Sealed", MethodOptions::Sealed);
-  }
-};
-
-template <> struct ScalarTraits<APSInt> {
-  static void output(const APSInt &S, void *, llvm::raw_ostream &OS) {
-    S.print(OS, true);
-  }
-  static StringRef input(StringRef Scalar, void *Ctx, APSInt &S) {
-    S = APSInt(Scalar);
-    return "";
-  }
-
-  static bool mustQuote(StringRef Scalar) { return false; }
-};
-
-void MappingContextTraits<CVType, pdb::yaml::SerializationContext>::mapping(
-    IO &IO, CVType &Record, pdb::yaml::SerializationContext &Context) {
-  if (IO.outputting()) {
-    codeview::TypeDeserializer Deserializer;
-
-    codeview::TypeVisitorCallbackPipeline Pipeline;
-    Pipeline.addCallbackToPipeline(Deserializer);
-    Pipeline.addCallbackToPipeline(Context.Dumper);
-
-    codeview::CVTypeVisitor Visitor(Pipeline);
-    consumeError(Visitor.visitTypeRecord(Record));
-  }
-}
-
-void MappingTraits<StringIdRecord>::mapping(IO &IO, StringIdRecord &String) {
-  IO.mapRequired("Id", String.Id);
-  IO.mapRequired("String", String.String);
-}
-
-void MappingTraits<ArgListRecord>::mapping(IO &IO, ArgListRecord &Args) {
-  IO.mapRequired("ArgIndices", Args.StringIndices);
-}
-
-void MappingTraits<ClassRecord>::mapping(IO &IO, ClassRecord &Class) {
-  IO.mapRequired("MemberCount", Class.MemberCount);
-  IO.mapRequired("Options", Class.Options);
-  IO.mapRequired("FieldList", Class.FieldList);
-  IO.mapRequired("Name", Class.Name);
-  IO.mapRequired("UniqueName", Class.UniqueName);
-  IO.mapRequired("Hfa", Class.Hfa);
-  IO.mapRequired("WinRTKind", Class.WinRTKind);
-  IO.mapRequired("DerivationList", Class.DerivationList);
-  IO.mapRequired("VTableShape", Class.VTableShape);
-  IO.mapRequired("Size", Class.Size);
-}
-
-void MappingTraits<UnionRecord>::mapping(IO &IO, UnionRecord &Union) {
-  IO.mapRequired("MemberCount", Union.MemberCount);
-  IO.mapRequired("Options", Union.Options);
-  IO.mapRequired("FieldList", Union.FieldList);
-  IO.mapRequired("Name", Union.Name);
-  IO.mapRequired("UniqueName", Union.UniqueName);
-  IO.mapRequired("Hfa", Union.Hfa);
-  IO.mapRequired("Size", Union.Size);
-}
-
-void MappingTraits<EnumRecord>::mapping(IO &IO, EnumRecord &Enum) {
-  IO.mapRequired("NumEnumerators", Enum.MemberCount);
-  IO.mapRequired("Options", Enum.Options);
-  IO.mapRequired("FieldList", Enum.FieldList);
-  IO.mapRequired("Name", Enum.Name);
-  IO.mapRequired("UniqueName", Enum.UniqueName);
-  IO.mapRequired("UnderlyingType", Enum.UnderlyingType);
-}
-
-void MappingTraits<ArrayRecord>::mapping(IO &IO, ArrayRecord &AT) {
-  IO.mapRequired("ElementType", AT.ElementType);
-  IO.mapRequired("IndexType", AT.IndexType);
-  IO.mapRequired("Size", AT.Size);
-  IO.mapRequired("Name", AT.Name);
-}
-
-void MappingTraits<VFTableRecord>::mapping(IO &IO, VFTableRecord &VFT) {
-  IO.mapRequired("CompleteClass", VFT.CompleteClass);
-  IO.mapRequired("OverriddenVFTable", VFT.OverriddenVFTable);
-  IO.mapRequired("VFPtrOffset", VFT.VFPtrOffset);
-  IO.mapRequired("Name", VFT.Name);
-  IO.mapRequired("MethodNames", VFT.MethodNames);
-}
-
-void MappingTraits<MemberFuncIdRecord>::mapping(IO &IO,
-                                                MemberFuncIdRecord &Id) {
-  IO.mapRequired("ClassType", Id.ClassType);
-  IO.mapRequired("FunctionType", Id.FunctionType);
-  IO.mapRequired("Name", Id.Name);
-}
-
-void MappingTraits<ProcedureRecord>::mapping(IO &IO, ProcedureRecord &Proc) {
-  IO.mapRequired("ReturnType", Proc.ReturnType);
-  IO.mapRequired("CallConv", Proc.CallConv);
-  IO.mapRequired("Options", Proc.Options);
-  IO.mapRequired("ParameterCount", Proc.ParameterCount);
-  IO.mapRequired("ArgumentList", Proc.ArgumentList);
-}
-
-void MappingTraits<MemberFunctionRecord>::mapping(IO &IO,
-                                                  MemberFunctionRecord &MF) {
-  IO.mapRequired("ReturnType", MF.ReturnType);
-  IO.mapRequired("ClassType", MF.ClassType);
-  IO.mapRequired("ThisType", MF.ThisType);
-  IO.mapRequired("CallConv", MF.CallConv);
-  IO.mapRequired("Options", MF.Options);
-  IO.mapRequired("ParameterCount", MF.ParameterCount);
-  IO.mapRequired("ArgumentList", MF.ArgumentList);
-  IO.mapRequired("ThisPointerAdjustment", MF.ThisPointerAdjustment);
-}
-
-void MappingTraits<MethodOverloadListRecord>::mapping(
-    IO &IO, MethodOverloadListRecord &MethodList) {
-  IO.mapRequired("Methods", MethodList.Methods);
-}
-
-void MappingTraits<FuncIdRecord>::mapping(IO &IO, FuncIdRecord &Func) {
-  IO.mapRequired("ParentScope", Func.ParentScope);
-  IO.mapRequired("FunctionType", Func.FunctionType);
-  IO.mapRequired("Name", Func.Name);
-}
-
-void MappingTraits<TypeServer2Record>::mapping(IO &IO, TypeServer2Record &TS) {
-  IO.mapRequired("Guid", TS.Guid);
-  IO.mapRequired("Age", TS.Age);
-  IO.mapRequired("Name", TS.Name);
-}
-
-void MappingTraits<PointerRecord>::mapping(IO &IO, PointerRecord &Ptr) {
-  IO.mapRequired("ReferentType", Ptr.ReferentType);
-  IO.mapRequired("PtrKind", Ptr.PtrKind);
-  IO.mapRequired("Mode", Ptr.Mode);
-  IO.mapRequired("Options", Ptr.Options);
-  IO.mapRequired("Size", Ptr.Size);
-  IO.mapOptional("MemberInfo", Ptr.MemberInfo);
-}
-
-void MappingTraits<MemberPointerInfo>::mapping(IO &IO, MemberPointerInfo &MPI) {
-  IO.mapRequired("ContainingType", MPI.ContainingType);
-  IO.mapRequired("Representation", MPI.Representation);
-}
-
-void MappingTraits<ModifierRecord>::mapping(IO &IO, ModifierRecord &Mod) {
-  IO.mapRequired("ModifiedType", Mod.ModifiedType);
-  IO.mapRequired("Modifiers", Mod.Modifiers);
-}
-
-void MappingTraits<BitFieldRecord>::mapping(IO &IO, BitFieldRecord &BitField) {
-  IO.mapRequired("Type", BitField.Type);
-  IO.mapRequired("BitSize", BitField.BitSize);
-  IO.mapRequired("BitOffset", BitField.BitOffset);
-}
-
-void MappingTraits<VFTableShapeRecord>::mapping(IO &IO,
-                                                VFTableShapeRecord &Shape) {
-  IO.mapRequired("Slots", Shape.Slots);
-}
-
-void MappingTraits<UdtSourceLineRecord>::mapping(IO &IO,
-                                                 UdtSourceLineRecord &Line) {
-  IO.mapRequired("UDT", Line.UDT);
-  IO.mapRequired("SourceFile", Line.SourceFile);
-  IO.mapRequired("LineNumber", Line.LineNumber);
-}
-
-void MappingTraits<UdtModSourceLineRecord>::mapping(
-    IO &IO, UdtModSourceLineRecord &Line) {
-  IO.mapRequired("UDT", Line.UDT);
-  IO.mapRequired("SourceFile", Line.SourceFile);
-  IO.mapRequired("LineNumber", Line.LineNumber);
-  IO.mapRequired("Module", Line.Module);
-}
-
-void MappingTraits<BuildInfoRecord>::mapping(IO &IO, BuildInfoRecord &Args) {
-  IO.mapRequired("ArgIndices", Args.ArgIndices);
-}
-
-void MappingTraits<NestedTypeRecord>::mapping(IO &IO,
-                                              NestedTypeRecord &Nested) {
-  IO.mapRequired("Type", Nested.Type);
-  IO.mapRequired("Name", Nested.Name);
-}
-
-void MappingTraits<OneMethodRecord>::mapping(IO &IO, OneMethodRecord &Method) {
-  IO.mapRequired("Type", Method.Type);
-  IO.mapRequired("Kind", Method.Kind);
-  IO.mapRequired("Options", Method.Options);
-  IO.mapRequired("Access", Method.Access);
-  IO.mapRequired("VFTableOffset", Method.VFTableOffset);
-  IO.mapRequired("Name", Method.Name);
-}
-
-void MappingTraits<OverloadedMethodRecord>::mapping(
-    IO &IO, OverloadedMethodRecord &Method) {
-  IO.mapRequired("NumOverloads", Method.NumOverloads);
-  IO.mapRequired("MethodList", Method.MethodList);
-  IO.mapRequired("Name", Method.Name);
-}
-
-void MappingTraits<DataMemberRecord>::mapping(IO &IO, DataMemberRecord &Field) {
-  IO.mapRequired("Access", Field.Access);
-  IO.mapRequired("Type", Field.Type);
-  IO.mapRequired("FieldOffset", Field.FieldOffset);
-  IO.mapRequired("Name", Field.Name);
-}
-
-void MappingTraits<StaticDataMemberRecord>::mapping(
-    IO &IO, StaticDataMemberRecord &Field) {
-  IO.mapRequired("Access", Field.Access);
-  IO.mapRequired("Type", Field.Type);
-  IO.mapRequired("Name", Field.Name);
-}
-
-void MappingTraits<VFPtrRecord>::mapping(IO &IO, VFPtrRecord &VFTable) {
-  IO.mapRequired("Type", VFTable.Type);
-}
-
-void MappingTraits<EnumeratorRecord>::mapping(IO &IO, EnumeratorRecord &Enum) {
-  IO.mapRequired("Access", Enum.Access);
-  IO.mapRequired("Value", Enum.Value);
-  IO.mapRequired("Name", Enum.Name);
-}
-
-void MappingTraits<BaseClassRecord>::mapping(IO &IO, BaseClassRecord &Base) {
-  IO.mapRequired("Access", Base.Access);
-  IO.mapRequired("Type", Base.Type);
-  IO.mapRequired("Offset", Base.Offset);
-}
-
-void MappingTraits<VirtualBaseClassRecord>::mapping(
-    IO &IO, VirtualBaseClassRecord &Base) {
-  IO.mapRequired("Access", Base.Access);
-  IO.mapRequired("BaseType", Base.BaseType);
-  IO.mapRequired("VBPtrType", Base.VBPtrType);
-  IO.mapRequired("VBPtrOffset", Base.VBPtrOffset);
-  IO.mapRequired("VTableIndex", Base.VTableIndex);
-}
-
-void MappingTraits<ListContinuationRecord>::mapping(
-    IO &IO, ListContinuationRecord &Cont) {
-  IO.mapRequired("ContinuationIndex", Cont.ContinuationIndex);
-}
-
-template <> struct ScalarTraits<codeview::TypeIndex> {
-  static void output(const codeview::TypeIndex &S, void *,
-                     llvm::raw_ostream &OS) {
-    OS << S.getIndex();
-  }
-  static StringRef input(StringRef Scalar, void *Ctx, codeview::TypeIndex &S) {
-    uint32_t I;
-    StringRef Result = ScalarTraits<uint32_t>::input(Scalar, Ctx, I);
-    if (!Result.empty())
-      return Result;
-    S = TypeIndex(I);
-    return "";
-  }
-  static bool mustQuote(StringRef Scalar) { return false; }
-};
-
-void ScalarEnumerationTraits<TypeLeafKind>::enumeration(IO &io,
-                                                        TypeLeafKind &Value) {
-  auto TypeLeafNames = getTypeLeafNames();
-  for (const auto &E : TypeLeafNames)
-    io.enumCase(Value, E.Name.str().c_str(), E.Value);
-}
-}
-}
-
-Error llvm::codeview::yaml::YamlTypeDumperCallbacks::visitTypeBegin(
-    CVType &CVR) {
-  YamlIO.mapRequired("Kind", CVR.Type);
-  return Error::success();
-}
-
-Error llvm::codeview::yaml::YamlTypeDumperCallbacks::visitMemberBegin(
-    CVMemberRecord &Record) {
-  YamlIO.mapRequired("Kind", Record.Kind);
-  return Error::success();
-}
-
-void llvm::codeview::yaml::YamlTypeDumperCallbacks::visitKnownRecordImpl(
-    const char *Name, CVType &CVR, FieldListRecord &FieldList) {
-  std::vector<llvm::pdb::yaml::PdbTpiFieldListRecord> FieldListRecords;
-  if (YamlIO.outputting()) {
-    // If we are outputting, then `FieldList.Data` contains a huge chunk of data
-    // representing the serialized list of members.  We need to split it up into
-    // individual CVType records where each record represents an individual
-    // member.  This way, we can simply map the entire thing as a Yaml sequence,
-    // which will recurse back to the standard handler for top-level fields
-    // (top-level and member fields all have the exact same Yaml syntax so use
-    // the same parser).
-    //
-    // If we are not outputting, then the array contains no data starting out,
-    // and is instead populated from the sequence represented by the yaml --
-    // again, using the same logic that we use for top-level records.
-    FieldListRecordSplitter Splitter(FieldListRecords);
-    CVTypeVisitor V(Splitter);
-    consumeError(V.visitFieldListMemberStream(FieldList.Data));
-  }
-  YamlIO.mapRequired("FieldList", FieldListRecords, Context);
-}
-
-namespace llvm {
-namespace yaml {
-template <>
-struct MappingContextTraits<pdb::yaml::PdbTpiFieldListRecord,
-                            pdb::yaml::SerializationContext> {
-  static void mapping(IO &IO, pdb::yaml::PdbTpiFieldListRecord &Obj,
-                      pdb::yaml::SerializationContext &Context) {
-    codeview::TypeVisitorCallbackPipeline Pipeline;
-    codeview::TypeDeserializer Deserializer;
-    codeview::TypeSerializationVisitor Serializer(Context.FieldListBuilder,
-                                                  Context.TypeTableBuilder);
-    pdb::TpiHashUpdater Hasher;
-
-    if (IO.outputting()) {
-      // For PDB to Yaml, deserialize into a high level record type, then dump
-      // it.
-      Pipeline.addCallbackToPipeline(Deserializer);
-      Pipeline.addCallbackToPipeline(Context.Dumper);
-    } else {
-      // For Yaml to PDB, extract from the high level record type, then write it
-      // to bytes.
-      Pipeline.addCallbackToPipeline(Context.Dumper);
-      Pipeline.addCallbackToPipeline(Serializer);
-      Pipeline.addCallbackToPipeline(Hasher);
-    }
-
-    codeview::CVTypeVisitor Visitor(Pipeline);
-    consumeError(Visitor.visitMemberRecord(Obj.Record));
-  }
-};
-}
-}

Removed: llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h?rev=283640&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h (removed)
@@ -1,103 +0,0 @@
-//===- PdbYAML.h ---------------------------------------------- *- C++ --*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_CODEVIEWYAML_H
-#define LLVM_TOOLS_LLVMPDBDUMP_CODEVIEWYAML_H
-
-#include "llvm/DebugInfo/CodeView/CodeView.h"
-#include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-#include "llvm/Support/YAMLTraits.h"
-
-namespace llvm {
-namespace pdb {
-namespace yaml {
-struct SerializationContext;
-}
-}
-namespace codeview {
-namespace yaml {
-class YamlTypeDumperCallbacks : public TypeVisitorCallbacks {
-public:
-  YamlTypeDumperCallbacks(llvm::yaml::IO &IO,
-                          llvm::pdb::yaml::SerializationContext &Context)
-      : YamlIO(IO), Context(Context) {}
-
-  virtual Error visitTypeBegin(CVType &Record) override;
-  virtual Error visitMemberBegin(CVMemberRecord &Record) override;
-
-#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
-  Error visitKnownRecord(CVRecord<TypeLeafKind> &CVR, Name##Record &Record)    \
-      override {                                                               \
-    visitKnownRecordImpl(#Name, CVR, Record);                                  \
-    return Error::success();                                                   \
-  }
-#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
-  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
-    visitKnownMemberImpl(#Name, Record);                                       \
-    return Error::success();                                                   \
-  }
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-
-private:
-  template <typename T> void visitKnownMemberImpl(const char *Name, T &Record) {
-    YamlIO.mapRequired(Name, Record);
-  }
-
-  template <typename T>
-  void visitKnownRecordImpl(const char *Name, CVType &Type, T &Record) {
-    YamlIO.mapRequired(Name, Record);
-  }
-
-  void visitKnownRecordImpl(const char *Name, CVType &CVR,
-                            FieldListRecord &FieldList);
-
-  llvm::yaml::IO &YamlIO;
-  llvm::pdb::yaml::SerializationContext &Context;
-};
-}
-}
-namespace pdb {
-namespace yaml {
-struct SerializationContext;
-}
-}
-}
-
-namespace llvm {
-namespace yaml {
-template <> struct MappingTraits<codeview::MemberPointerInfo> {
-  static void mapping(IO &IO, codeview::MemberPointerInfo &Obj);
-};
-
-template <>
-struct MappingContextTraits<codeview::CVType, pdb::yaml::SerializationContext> {
-  static void mapping(IO &IO, codeview::CVType &Obj,
-                      pdb::yaml::SerializationContext &Context);
-};
-
-template <> struct ScalarEnumerationTraits<codeview::TypeLeafKind> {
-  static void enumeration(IO &io, codeview::TypeLeafKind &Value);
-};
-
-#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
-  template <> struct MappingTraits<codeview::Name##Record> {                   \
-    static void mapping(IO &IO, codeview::Name##Record &Obj);                  \
-  };
-#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
-  TYPE_RECORD(EnumName, EnumVal, Name)
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
-}
-}
-
-#endif

Modified: llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp Fri Oct  7 20:12:01 2016
@@ -9,10 +9,14 @@
 
 #include "PdbYaml.h"
 
-#include "CodeViewYaml.h"
 #include "YamlSerializationContext.h"
+#include "YamlSymbolDumper.h"
+#include "YamlTypeDumper.h"
 
+#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
 #include "llvm/DebugInfo/CodeView/TypeSerializationVisitor.h"
 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
@@ -30,6 +34,7 @@ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::NamedStreamMapping)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbDbiModuleInfo)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbSymbolRecord)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbTpiRecord)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::StreamBlockList)
 
@@ -205,10 +210,33 @@ void MappingTraits<NamedStreamMapping>::
   IO.mapRequired("StreamNum", Obj.StreamNumber);
 }
 
+void MappingTraits<PdbSymbolRecord>::mapping(IO &IO, PdbSymbolRecord &Obj) {
+  codeview::SymbolVisitorCallbackPipeline Pipeline;
+  codeview::SymbolDeserializer Deserializer(nullptr);
+  codeview::yaml::YamlSymbolDumper Dumper(IO);
+
+  if (IO.outputting()) {
+    // For PDB to Yaml, deserialize into a high level record type, then dump it.
+    Pipeline.addCallbackToPipeline(Deserializer);
+    Pipeline.addCallbackToPipeline(Dumper);
+  } else {
+    return;
+  }
+
+  codeview::CVSymbolVisitor Visitor(Pipeline);
+  consumeError(Visitor.visitSymbolRecord(Obj.Record));
+}
+
+void MappingTraits<PdbModiStream>::mapping(IO &IO, PdbModiStream &Obj) {
+  IO.mapRequired("Signature", Obj.Signature);
+  IO.mapRequired("Records", Obj.Symbols);
+}
+
 void MappingTraits<PdbDbiModuleInfo>::mapping(IO &IO, PdbDbiModuleInfo &Obj) {
   IO.mapRequired("Module", Obj.Mod);
   IO.mapRequired("ObjFile", Obj.Obj);
   IO.mapOptional("SourceFiles", Obj.SourceFiles);
+  IO.mapOptional("Modi", Obj.Modi);
 }
 
 void MappingContextTraits<PdbTpiRecord, pdb::yaml::SerializationContext>::

Modified: llvm/trunk/tools/llvm-pdbdump/PdbYaml.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/PdbYaml.h?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/PdbYaml.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/PdbYaml.h Fri Oct  7 20:12:01 2016
@@ -13,6 +13,8 @@
 #include "OutputStyle.h"
 
 #include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/MSF/MSFCommon.h"
 #include "llvm/DebugInfo/PDB/PDBTypes.h"
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
@@ -53,10 +55,20 @@ struct PdbInfoStream {
   std::vector<NamedStreamMapping> NamedStreams;
 };
 
+struct PdbSymbolRecord {
+  codeview::CVSymbol Record;
+};
+
+struct PdbModiStream {
+  uint32_t Signature;
+  std::vector<PdbSymbolRecord> Symbols;
+};
+
 struct PdbDbiModuleInfo {
   StringRef Obj;
   StringRef Mod;
   std::vector<StringRef> SourceFiles;
+  Optional<PdbModiStream> Modi;
 };
 
 struct PdbDbiStream {
@@ -138,6 +150,14 @@ template <> struct MappingTraits<pdb::ya
   static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
 };
 
+template <> struct MappingTraits<pdb::yaml::PdbSymbolRecord> {
+  static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj);
+};
+
+template <> struct MappingTraits<pdb::yaml::PdbModiStream> {
+  static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj);
+};
+
 template <> struct MappingTraits<pdb::yaml::PdbDbiModuleInfo> {
   static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj);
 };

Modified: llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/YAMLOutputStyle.cpp Fri Oct  7 20:12:01 2016
@@ -12,8 +12,10 @@
 #include "PdbYaml.h"
 #include "llvm-pdbdump.h"
 
+#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
 #include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
 #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
+#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
 #include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
@@ -27,6 +29,8 @@ YAMLOutputStyle::YAMLOutputStyle(PDBFile
 Error YAMLOutputStyle::dump() {
   if (opts::pdb2yaml::StreamDirectory)
     opts::pdb2yaml::StreamMetadata = true;
+  if (opts::pdb2yaml::DbiModuleSyms)
+    opts::pdb2yaml::DbiModuleInfo = true;
   if (opts::pdb2yaml::DbiModuleSourceFileInfo)
     opts::pdb2yaml::DbiModuleInfo = true;
   if (opts::pdb2yaml::DbiModuleInfo)
@@ -152,6 +156,25 @@ Error YAMLOutputStyle::dumpDbiStream() {
       DMI.Obj = MI.Info.getObjFileName();
       if (opts::pdb2yaml::DbiModuleSourceFileInfo)
         DMI.SourceFiles = MI.SourceFiles;
+
+      if (opts::pdb2yaml::DbiModuleSyms &&
+          MI.Info.getModuleStreamIndex() != kInvalidStreamIndex) {
+        DMI.Modi.emplace();
+        auto ModStreamData = msf::MappedBlockStream::createIndexedStream(
+            File.getMsfLayout(), File.getMsfBuffer(),
+            MI.Info.getModuleStreamIndex());
+
+        pdb::ModStream ModS(MI.Info, std::move(ModStreamData));
+        if (auto EC = ModS.reload())
+          return EC;
+
+        DMI.Modi->Signature = ModS.signature();
+        bool HadError = false;
+        for (auto &Sym : ModS.symbols(&HadError)) {
+          pdb::yaml::PdbSymbolRecord Record{Sym};
+          DMI.Modi->Symbols.push_back(Record);
+        }
+      }
       Obj.DbiStream->ModInfos.push_back(DMI);
     }
   }

Modified: llvm/trunk/tools/llvm-pdbdump/YamlSerializationContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlSerializationContext.h?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YamlSerializationContext.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/YamlSerializationContext.h Fri Oct  7 20:12:01 2016
@@ -10,8 +10,8 @@
 #ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLSERIALIZATIONCONTEXT_H
 #define LLVM_TOOLS_LLVMPDBDUMP_YAMLSERIALIZATIONCONTEXT_H
 
-#include "CodeViewYaml.h"
 #include "PdbYaml.h"
+#include "YamlTypeDumper.h"
 #include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h"
 #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"
 

Added: llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp?rev=283641&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp (added)
+++ llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp Fri Oct  7 20:12:01 2016
@@ -0,0 +1,322 @@
+//===- YamlSymbolDumper.cpp ----------------------------------- *- C++ --*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "YamlSymbolDumper.h"
+#include "PdbYaml.h"
+#include "YamlTypeDumper.h"
+
+#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
+#include "llvm/DebugInfo/CodeView/EnumTables.h"
+#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+using namespace llvm::codeview::yaml;
+
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(TypeIndex)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint64_t)
+LLVM_YAML_IS_SEQUENCE_VECTOR(OneMethodRecord)
+LLVM_YAML_IS_SEQUENCE_VECTOR(VFTableSlotKind)
+LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
+LLVM_YAML_IS_SEQUENCE_VECTOR(CVType)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbTpiFieldListRecord)
+
+namespace llvm {
+namespace yaml {
+void ScalarEnumerationTraits<SymbolKind>::enumeration(IO &io,
+                                                      SymbolKind &Value) {
+  auto SymbolNames = getSymbolTypeNames();
+  for (const auto &E : SymbolNames)
+    io.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+template <> struct ScalarEnumerationTraits<ThunkOrdinal> {
+  void enumeration(IO &io, ThunkOrdinal Ord) {}
+};
+
+void MappingTraits<ScopeEndSym>::mapping(IO &IO, ScopeEndSym &Obj) {}
+
+void MappingTraits<Thunk32Sym>::mapping(IO &IO, Thunk32Sym &Thunk) {
+  IO.mapRequired("Parent", Thunk.Header.Parent);
+  IO.mapRequired("End", Thunk.Header.End);
+  IO.mapRequired("Next", Thunk.Header.Next);
+  IO.mapRequired("Off", Thunk.Header.Off);
+  IO.mapRequired("Seg", Thunk.Header.Seg);
+  IO.mapRequired("Len", Thunk.Header.Len);
+  IO.mapRequired("Ordinal", Thunk.Header.Ord);
+}
+
+void MappingTraits<TrampolineSym>::mapping(IO &IO, TrampolineSym &Tramp) {
+  IO.mapRequired("Type", Tramp.Header.Type);
+  IO.mapRequired("Size", Tramp.Header.Size);
+  IO.mapRequired("ThunkOff", Tramp.Header.ThunkOff);
+  IO.mapRequired("TargetOff", Tramp.Header.TargetOff);
+  IO.mapRequired("ThunkSection", Tramp.Header.ThunkSection);
+  IO.mapRequired("TargetSection", Tramp.Header.TargetSection);
+}
+
+void MappingTraits<SectionSym>::mapping(IO &IO, SectionSym &Section) {
+  IO.mapRequired("SectionNumber", Section.Header.SectionNumber);
+  IO.mapRequired("Alignment", Section.Header.Alignment);
+  IO.mapRequired("Reserved", Section.Header.Reserved);
+  IO.mapRequired("Rva", Section.Header.Rva);
+  IO.mapRequired("Length", Section.Header.Length);
+  IO.mapRequired("Characteristics", Section.Header.Characteristics);
+  IO.mapRequired("Name", Section.Name);
+}
+
+void MappingTraits<CoffGroupSym>::mapping(IO &IO, CoffGroupSym &CoffGroup) {
+  IO.mapRequired("Size", CoffGroup.Header.Size);
+  IO.mapRequired("Characteristics", CoffGroup.Header.Characteristics);
+  IO.mapRequired("Offset", CoffGroup.Header.Offset);
+  IO.mapRequired("Segment", CoffGroup.Header.Segment);
+  IO.mapRequired("Name", CoffGroup.Name);
+}
+
+void MappingTraits<ExportSym>::mapping(IO &IO, ExportSym &Export) {
+  IO.mapRequired("Ordinal", Export.Header.Ordinal);
+  IO.mapRequired("Flags", Export.Header.Flags);
+  IO.mapRequired("Name", Export.Name);
+}
+
+void MappingTraits<ProcSym>::mapping(IO &IO, ProcSym &Proc) {
+  // TODO: Print the linkage name
+
+  IO.mapRequired("PtrParent", Proc.Header.PtrParent);
+  IO.mapRequired("PtrEnd", Proc.Header.PtrEnd);
+  IO.mapRequired("PtrNext", Proc.Header.PtrNext);
+  IO.mapRequired("CodeSize", Proc.Header.CodeSize);
+  IO.mapRequired("DbgStart", Proc.Header.DbgStart);
+  IO.mapRequired("DbgEnd", Proc.Header.DbgEnd);
+  IO.mapRequired("FunctionType", Proc.Header.FunctionType);
+  IO.mapRequired("Segment", Proc.Header.Segment);
+  IO.mapRequired("Flags", Proc.Header.Flags);
+  IO.mapRequired("DisplayName", Proc.Name);
+}
+
+void MappingTraits<RegisterSym>::mapping(IO &IO, RegisterSym &Register) {
+  IO.mapRequired("Type", Register.Header.Index);
+  IO.mapRequired("Seg", Register.Header.Register);
+  IO.mapRequired("Name", Register.Name);
+}
+
+void MappingTraits<PublicSym32>::mapping(IO &IO, PublicSym32 &Public) {
+  IO.mapRequired("Type", Public.Header.Index);
+  IO.mapRequired("Seg", Public.Header.Seg);
+  IO.mapRequired("Off", Public.Header.Off);
+  IO.mapRequired("Name", Public.Name);
+}
+
+void MappingTraits<ProcRefSym>::mapping(IO &IO, ProcRefSym &ProcRef) {
+  IO.mapRequired("SumName", ProcRef.Header.SumName);
+  IO.mapRequired("SymOffset", ProcRef.Header.SymOffset);
+  IO.mapRequired("Mod", ProcRef.Header.Mod);
+  IO.mapRequired("Name", ProcRef.Name);
+}
+
+void MappingTraits<EnvBlockSym>::mapping(IO &IO, EnvBlockSym &EnvBlock) {
+  IO.mapRequired("Reserved", EnvBlock.Header.Reserved);
+  IO.mapRequired("Entries", EnvBlock.Fields);
+}
+
+void MappingTraits<InlineSiteSym>::mapping(IO &IO, InlineSiteSym &InlineSite) {
+  IO.mapRequired("PtrParent", InlineSite.Header.PtrParent);
+  IO.mapRequired("PtrEnd", InlineSite.Header.PtrEnd);
+  IO.mapRequired("Inlinee", InlineSite.Header.Inlinee);
+  // TODO: The binary annotations
+}
+
+void MappingTraits<LocalSym>::mapping(IO &IO, LocalSym &Local) {
+  IO.mapRequired("Type", Local.Header.Type);
+  IO.mapRequired("Flags", Local.Header.Flags);
+  IO.mapRequired("VarName", Local.Name);
+}
+
+void MappingTraits<DefRangeSym>::mapping(IO &IO, DefRangeSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeSubfieldSym>::mapping(IO &IO,
+                                                 DefRangeSubfieldSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeRegisterSym>::mapping(IO &IO,
+                                                 DefRangeRegisterSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeFramePointerRelSym>::mapping(
+    IO &IO, DefRangeFramePointerRelSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeSubfieldRegisterSym>::mapping(
+    IO &IO, DefRangeSubfieldRegisterSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeFramePointerRelFullScopeSym>::mapping(
+    IO &IO, DefRangeFramePointerRelFullScopeSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<DefRangeRegisterRelSym>::mapping(
+    IO &IO, DefRangeRegisterRelSym &Obj) {
+  // TODO: Print the subfields
+}
+
+void MappingTraits<BlockSym>::mapping(IO &IO, BlockSym &Block) {
+  // TODO: Print the linkage name
+  IO.mapRequired("PtrParent", Block.Header.PtrParent);
+  IO.mapRequired("PtrEnd", Block.Header.PtrEnd);
+  IO.mapRequired("CodeSize", Block.Header.CodeSize);
+  IO.mapRequired("Segment", Block.Header.Segment);
+  IO.mapRequired("BlockName", Block.Name);
+}
+
+void MappingTraits<LabelSym>::mapping(IO &IO, LabelSym &Label) {
+  // TODO: Print the linkage name
+  IO.mapRequired("Segment", Label.Header.Segment);
+  IO.mapRequired("Flags", Label.Header.Flags);
+  IO.mapRequired("Flags", Label.Header.Flags);
+  IO.mapRequired("DisplayName", Label.Name);
+}
+
+void MappingTraits<ObjNameSym>::mapping(IO &IO, ObjNameSym &ObjName) {
+  IO.mapRequired("Signature", ObjName.Header.Signature);
+  IO.mapRequired("ObjectName", ObjName.Name);
+}
+
+void MappingTraits<Compile2Sym>::mapping(IO &IO, Compile2Sym &Compile2) {
+  IO.mapRequired("Flags", Compile2.Header.flags);
+  IO.mapRequired("Machine", Compile2.Header.Machine);
+  IO.mapRequired("FrontendMajor", Compile2.Header.VersionFrontendMajor);
+  IO.mapRequired("FrontendMinor", Compile2.Header.VersionFrontendMinor);
+  IO.mapRequired("FrontendBuild", Compile2.Header.VersionFrontendBuild);
+  IO.mapRequired("BackendMajor", Compile2.Header.VersionBackendMajor);
+  IO.mapRequired("BackendMinor", Compile2.Header.VersionBackendMinor);
+  IO.mapRequired("BackendBuild", Compile2.Header.VersionBackendBuild);
+  IO.mapRequired("Version", Compile2.Version);
+}
+
+void MappingTraits<Compile3Sym>::mapping(IO &IO, Compile3Sym &Compile3) {
+  IO.mapRequired("Flags", Compile3.Header.flags);
+  IO.mapRequired("Machine", Compile3.Header.Machine);
+  IO.mapRequired("FrontendMajor", Compile3.Header.VersionFrontendMajor);
+  IO.mapRequired("FrontendMinor", Compile3.Header.VersionFrontendMinor);
+  IO.mapRequired("FrontendBuild", Compile3.Header.VersionFrontendBuild);
+  IO.mapRequired("FrontendQFE", Compile3.Header.VersionFrontendQFE);
+  IO.mapRequired("BackendMajor", Compile3.Header.VersionBackendMajor);
+  IO.mapRequired("BackendMinor", Compile3.Header.VersionBackendMinor);
+  IO.mapRequired("BackendBuild", Compile3.Header.VersionBackendBuild);
+  IO.mapRequired("BackendQFE", Compile3.Header.VersionBackendQFE);
+  IO.mapRequired("Version", Compile3.Version);
+}
+
+void MappingTraits<FrameProcSym>::mapping(IO &IO, FrameProcSym &FrameProc) {
+  IO.mapRequired("TotalFrameBytes", FrameProc.Header.TotalFrameBytes);
+  IO.mapRequired("PaddingFrameBytes", FrameProc.Header.PaddingFrameBytes);
+  IO.mapRequired("OffsetToPadding", FrameProc.Header.OffsetToPadding);
+  IO.mapRequired("BytesOfCalleeSavedRegisters",
+                 FrameProc.Header.BytesOfCalleeSavedRegisters);
+  IO.mapRequired("OffsetOfExceptionHandler",
+                 FrameProc.Header.OffsetOfExceptionHandler);
+  IO.mapRequired("SectionIdOfExceptionHandler",
+                 FrameProc.Header.SectionIdOfExceptionHandler);
+  IO.mapRequired("Flags", FrameProc.Header.Flags);
+}
+
+void MappingTraits<CallSiteInfoSym>::mapping(IO &IO,
+                                             CallSiteInfoSym &CallSiteInfo) {
+  // TODO: Map Linkage Name
+  IO.mapRequired("Segment", CallSiteInfo.Header.Segment);
+  IO.mapRequired("Reserved", CallSiteInfo.Header.Reserved);
+  IO.mapRequired("Type", CallSiteInfo.Header.Type);
+}
+
+void MappingTraits<FileStaticSym>::mapping(IO &IO, FileStaticSym &FileStatic) {
+  IO.mapRequired("Index", FileStatic.Header.Index);
+  IO.mapRequired("ModFilenameOffset", FileStatic.Header.ModFilenameOffset);
+  IO.mapRequired("Flags", FileStatic.Header.Flags);
+  IO.mapRequired("Name", FileStatic.Name);
+}
+
+void MappingTraits<HeapAllocationSiteSym>::mapping(
+    IO &IO, HeapAllocationSiteSym &HeapAllocSite) {
+  // TODO: Map Linkage Name
+  IO.mapRequired("Segment", HeapAllocSite.Header.Segment);
+  IO.mapRequired("CallInstructionSize",
+                 HeapAllocSite.Header.CallInstructionSize);
+  IO.mapRequired("Type", HeapAllocSite.Header.Type);
+}
+
+void MappingTraits<FrameCookieSym>::mapping(IO &IO,
+                                            FrameCookieSym &FrameCookie) {
+  // TODO: Map Linkage Name
+  IO.mapRequired("Register", FrameCookie.Header.Register);
+  IO.mapRequired("CookieKind", FrameCookie.Header.CookieKind);
+  IO.mapRequired("Flags", FrameCookie.Header.Flags);
+}
+
+void MappingTraits<CallerSym>::mapping(IO &IO, CallerSym &Caller) {
+  // TODO: Correctly handle the ArrayRef in here.
+  std::vector<TypeIndex> Indices(Caller.Indices);
+  IO.mapRequired("FuncID", Indices);
+}
+
+void MappingTraits<UDTSym>::mapping(IO &IO, UDTSym &UDT) {
+  IO.mapRequired("Type", UDT.Header.Type);
+  IO.mapRequired("UDTName", UDT.Name);
+}
+
+void MappingTraits<BuildInfoSym>::mapping(IO &IO, BuildInfoSym &BuildInfo) {
+  IO.mapRequired("BuildId", BuildInfo.Header.BuildId);
+}
+
+void MappingTraits<BPRelativeSym>::mapping(IO &IO, BPRelativeSym &BPRel) {
+  IO.mapRequired("Offset", BPRel.Header.Offset);
+  IO.mapRequired("Type", BPRel.Header.Type);
+  IO.mapRequired("VarName", BPRel.Name);
+}
+
+void MappingTraits<RegRelativeSym>::mapping(IO &IO, RegRelativeSym &RegRel) {
+  IO.mapRequired("Offset", RegRel.Header.Offset);
+  IO.mapRequired("Type", RegRel.Header.Type);
+  IO.mapRequired("Register", RegRel.Header.Register);
+  IO.mapRequired("VarName", RegRel.Name);
+}
+
+void MappingTraits<ConstantSym>::mapping(IO &IO, ConstantSym &Constant) {
+  IO.mapRequired("Type", Constant.Header.Type);
+  IO.mapRequired("Value", Constant.Value);
+  IO.mapRequired("Name", Constant.Name);
+}
+
+void MappingTraits<DataSym>::mapping(IO &IO, DataSym &Data) {
+  // TODO: Map linkage name
+  IO.mapRequired("Type", Data.Header.Type);
+  IO.mapRequired("DisplayName", Data.Name);
+}
+
+void MappingTraits<ThreadLocalDataSym>::mapping(IO &IO,
+                                                ThreadLocalDataSym &Data) {
+  // TODO: Map linkage name
+  IO.mapRequired("Type", Data.Header.Type);
+  IO.mapRequired("DisplayName", Data.Name);
+}
+}
+}
+
+Error llvm::codeview::yaml::YamlSymbolDumper::visitSymbolBegin(CVSymbol &CVR) {
+  YamlIO.mapRequired("Kind", CVR.Type);
+  return Error::success();
+}

Added: llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.h?rev=283641&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.h (added)
+++ llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.h Fri Oct  7 20:12:01 2016
@@ -0,0 +1,66 @@
+//===- YamlSymbolDumper.h ------------------------------------- *- C++ --*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_YAMLSYMBOLDUMPER_H
+
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
+#include "llvm/Support/YAMLTraits.h"
+
+namespace llvm {
+namespace pdb {
+namespace yaml {
+struct SerializationContext;
+}
+}
+namespace codeview {
+namespace yaml {
+class YamlSymbolDumper : public SymbolVisitorCallbacks {
+public:
+  YamlSymbolDumper(llvm::yaml::IO &IO) : YamlIO(IO) {}
+
+  virtual Error visitSymbolBegin(CVSymbol &Record) override;
+
+#define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
+  Error visitKnownRecord(CVSymbol &CVR, Name &Record) override {               \
+    visitKnownRecordImpl(#Name, CVR, Record);                                  \
+    return Error::success();                                                   \
+  }
+#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
+
+private:
+  template <typename T>
+  void visitKnownRecordImpl(const char *Name, CVSymbol &Type, T &Record) {
+    YamlIO.mapRequired(Name, Record);
+  }
+
+  llvm::yaml::IO &YamlIO;
+};
+}
+}
+}
+
+namespace llvm {
+namespace yaml {
+template <> struct ScalarEnumerationTraits<codeview::SymbolKind> {
+  static void enumeration(IO &io, codeview::SymbolKind &Value);
+};
+
+#define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
+  template <> struct MappingTraits<codeview::Name> {                           \
+    static void mapping(IO &IO, codeview::Name &Obj);                          \
+  };
+#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
+}
+}
+
+#endif

Copied: llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp (from r283639, llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp?p2=llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp&p1=llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp&r1=283639&r2=283641&rev=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp Fri Oct  7 20:12:01 2016
@@ -1,4 +1,4 @@
-//===- PdbYAML.cpp -------------------------------------------- *- C++ --*-===//
+//===- YamlTypeDumper.cpp ------------------------------------- *- C++ --*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "CodeViewYaml.h"
+#include "YamlTypeDumper.h"
 #include "PdbYaml.h"
 #include "YamlSerializationContext.h"
 
@@ -260,17 +260,16 @@ template <> struct ScalarBitSetTraits<Me
   }
 };
 
-template <> struct ScalarTraits<APSInt> {
-  static void output(const APSInt &S, void *, llvm::raw_ostream &OS) {
-    S.print(OS, true);
-  }
-  static StringRef input(StringRef Scalar, void *Ctx, APSInt &S) {
-    S = APSInt(Scalar);
-    return "";
-  }
+void ScalarTraits<APSInt>::output(const APSInt &S, void *,
+                                  llvm::raw_ostream &OS) {
+  S.print(OS, true);
+}
+StringRef ScalarTraits<APSInt>::input(StringRef Scalar, void *Ctx, APSInt &S) {
+  S = APSInt(Scalar);
+  return "";
+}
 
-  static bool mustQuote(StringRef Scalar) { return false; }
-};
+bool ScalarTraits<APSInt>::mustQuote(StringRef Scalar) { return false; }
 
 void MappingContextTraits<CVType, pdb::yaml::SerializationContext>::mapping(
     IO &IO, CVType &Record, pdb::yaml::SerializationContext &Context) {
@@ -501,21 +500,22 @@ void MappingTraits<ListContinuationRecor
   IO.mapRequired("ContinuationIndex", Cont.ContinuationIndex);
 }
 
-template <> struct ScalarTraits<codeview::TypeIndex> {
-  static void output(const codeview::TypeIndex &S, void *,
-                     llvm::raw_ostream &OS) {
-    OS << S.getIndex();
-  }
-  static StringRef input(StringRef Scalar, void *Ctx, codeview::TypeIndex &S) {
-    uint32_t I;
-    StringRef Result = ScalarTraits<uint32_t>::input(Scalar, Ctx, I);
-    if (!Result.empty())
-      return Result;
-    S = TypeIndex(I);
-    return "";
-  }
-  static bool mustQuote(StringRef Scalar) { return false; }
-};
+void ScalarTraits<codeview::TypeIndex>::output(const codeview::TypeIndex &S,
+                                               void *, llvm::raw_ostream &OS) {
+  OS << S.getIndex();
+}
+StringRef ScalarTraits<codeview::TypeIndex>::input(StringRef Scalar, void *Ctx,
+                                                   codeview::TypeIndex &S) {
+  uint32_t I;
+  StringRef Result = ScalarTraits<uint32_t>::input(Scalar, Ctx, I);
+  if (!Result.empty())
+    return Result;
+  S = TypeIndex(I);
+  return "";
+}
+bool ScalarTraits<codeview::TypeIndex>::mustQuote(StringRef Scalar) {
+  return false;
+}
 
 void ScalarEnumerationTraits<TypeLeafKind>::enumeration(IO &io,
                                                         TypeLeafKind &Value) {

Copied: llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.h (from r283639, llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.h?p2=llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.h&p1=llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h&r1=283639&r2=283641&rev=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/CodeViewYaml.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.h Fri Oct  7 20:12:01 2016
@@ -1,4 +1,4 @@
-//===- PdbYAML.h ---------------------------------------------- *- C++ --*-===//
+//===- YamlTypeDumper.h --------------------------------------- *- C++ --*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_CODEVIEWYAML_H
-#define LLVM_TOOLS_LLVMPDBDUMP_CODEVIEWYAML_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLTYPEDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_YAMLTYPEDUMPER_H
 
 #include "llvm/DebugInfo/CodeView/CodeView.h"
 #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"
@@ -74,6 +74,20 @@ struct SerializationContext;
 
 namespace llvm {
 namespace yaml {
+
+template <> struct ScalarTraits<APSInt> {
+  static void output(const APSInt &S, void *, llvm::raw_ostream &OS);
+  static StringRef input(StringRef Scalar, void *Ctx, APSInt &S);
+  static bool mustQuote(StringRef Scalar);
+};
+
+template <> struct ScalarTraits<codeview::TypeIndex> {
+  static void output(const codeview::TypeIndex &S, void *,
+                     llvm::raw_ostream &OS);
+  static StringRef input(StringRef Scalar, void *Ctx, codeview::TypeIndex &S);
+  static bool mustQuote(StringRef Scalar);
+};
+
 template <> struct MappingTraits<codeview::MemberPointerInfo> {
   static void mapping(IO &IO, codeview::MemberPointerInfo &Obj);
 };

Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Fri Oct  7 20:12:01 2016
@@ -280,6 +280,11 @@ cl::opt<bool>
                   cl::desc("Dump DBI Module Information (implies -dbi-stream)"),
                   cl::sub(PdbToYamlSubcommand), cl::init(false));
 
+cl::opt<bool> DbiModuleSyms(
+    "dbi-module-syms",
+    cl::desc("Dump DBI Module Information (implies -dbi-module-info)"),
+    cl::sub(PdbToYamlSubcommand), cl::init(false));
+
 cl::opt<bool> DbiModuleSourceFileInfo(
     "dbi-module-source-info",
     cl::desc(

Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h?rev=283641&r1=283640&r2=283641&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h Fri Oct  7 20:12:01 2016
@@ -71,6 +71,7 @@ extern llvm::cl::opt<bool> StreamDirecto
 extern llvm::cl::opt<bool> PdbStream;
 extern llvm::cl::opt<bool> DbiStream;
 extern llvm::cl::opt<bool> DbiModuleInfo;
+extern llvm::cl::opt<bool> DbiModuleSyms;
 extern llvm::cl::opt<bool> DbiModuleSourceFileInfo;
 extern llvm::cl::opt<bool> TpiStream;
 extern llvm::cl::opt<bool> IpiStream;




More information about the llvm-commits mailing list