llvm/tools/llvm-pdbdump/YamlSymbolDumper.h
Zachary Turner 2ce5ded6d2 [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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283641 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 01:12:01 +00:00

67 lines
2.0 KiB
C++

//===- 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