#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
#include "llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
#include <tuple>
#include <vector>
usingnamespacellvm;
usingnamespacellvm::codeview;
usingnamespacellvm::CodeViewYAML;
usingnamespacellvm::CodeViewYAML::detail;
usingnamespacellvm::yaml;
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceFileChecksumEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceLineEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceColumnEntry)
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceLineBlock)
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceLineInfo)
LLVM_YAML_IS_SEQUENCE_VECTOR(InlineeSite)
LLVM_YAML_IS_SEQUENCE_VECTOR(InlineeInfo)
LLVM_YAML_IS_SEQUENCE_VECTOR(CrossModuleExport)
LLVM_YAML_IS_SEQUENCE_VECTOR(YAMLCrossModuleImport)
LLVM_YAML_IS_SEQUENCE_VECTOR(YAMLFrameData)
LLVM_YAML_DECLARE_SCALAR_TRAITS(…)
LLVM_YAML_DECLARE_ENUM_TRAITS(DebugSubsectionKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(FileChecksumKind)
LLVM_YAML_DECLARE_BITSET_TRAITS(LineFlags)
LLVM_YAML_DECLARE_MAPPING_TRAITS(CrossModuleExport)
LLVM_YAML_DECLARE_MAPPING_TRAITS(YAMLFrameData)
LLVM_YAML_DECLARE_MAPPING_TRAITS(YAMLCrossModuleImport)
LLVM_YAML_DECLARE_MAPPING_TRAITS(CrossModuleImportItem)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceLineEntry)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceColumnEntry)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceFileChecksumEntry)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceLineBlock)
LLVM_YAML_DECLARE_MAPPING_TRAITS(InlineeSite)
namespace llvm {
namespace CodeViewYAML {
namespace detail {
struct YAMLSubsectionBase { … };
}
}
}
namespace {
struct YAMLChecksumsSubsection : public YAMLSubsectionBase { … };
struct YAMLLinesSubsection : public YAMLSubsectionBase { … };
struct YAMLInlineeLinesSubsection : public YAMLSubsectionBase { … };
struct YAMLCrossModuleExportsSubsection : public YAMLSubsectionBase { … };
struct YAMLCrossModuleImportsSubsection : public YAMLSubsectionBase { … };
struct YAMLSymbolsSubsection : public YAMLSubsectionBase { … };
struct YAMLStringTableSubsection : public YAMLSubsectionBase { … };
struct YAMLFrameDataSubsection : public YAMLSubsectionBase { … };
struct YAMLCoffSymbolRVASubsection : public YAMLSubsectionBase { … };
}
void ScalarBitSetTraits<LineFlags>::bitset(IO &io, LineFlags &Flags) { … }
void ScalarEnumerationTraits<FileChecksumKind>::enumeration(
IO &io, FileChecksumKind &Kind) { … }
void ScalarTraits<HexFormattedString>::output(const HexFormattedString &Value,
void *ctx, raw_ostream &Out) { … }
StringRef ScalarTraits<HexFormattedString>::input(StringRef Scalar, void *ctxt,
HexFormattedString &Value) { … }
void MappingTraits<SourceLineEntry>::mapping(IO &IO, SourceLineEntry &Obj) { … }
void MappingTraits<SourceColumnEntry>::mapping(IO &IO, SourceColumnEntry &Obj) { … }
void MappingTraits<SourceLineBlock>::mapping(IO &IO, SourceLineBlock &Obj) { … }
void MappingTraits<CrossModuleExport>::mapping(IO &IO, CrossModuleExport &Obj) { … }
void MappingTraits<YAMLCrossModuleImport>::mapping(IO &IO,
YAMLCrossModuleImport &Obj) { … }
void MappingTraits<SourceFileChecksumEntry>::mapping(
IO &IO, SourceFileChecksumEntry &Obj) { … }
void MappingTraits<InlineeSite>::mapping(IO &IO, InlineeSite &Obj) { … }
void MappingTraits<YAMLFrameData>::mapping(IO &IO, YAMLFrameData &Obj) { … }
void YAMLChecksumsSubsection::map(IO &IO) { … }
void YAMLLinesSubsection::map(IO &IO) { … }
void YAMLInlineeLinesSubsection::map(IO &IO) { … }
void YAMLCrossModuleExportsSubsection::map(IO &IO) { … }
void YAMLCrossModuleImportsSubsection::map(IO &IO) { … }
void YAMLSymbolsSubsection::map(IO &IO) { … }
void YAMLStringTableSubsection::map(IO &IO) { … }
void YAMLFrameDataSubsection::map(IO &IO) { … }
void YAMLCoffSymbolRVASubsection::map(IO &IO) { … }
void MappingTraits<YAMLDebugSubsection>::mapping(
IO &IO, YAMLDebugSubsection &Subsection) { … }
std::shared_ptr<DebugSubsection> YAMLChecksumsSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection> YAMLLinesSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection>
YAMLInlineeLinesSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection>
YAMLCrossModuleExportsSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection>
YAMLCrossModuleImportsSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection> YAMLSymbolsSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection>
YAMLStringTableSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection> YAMLFrameDataSubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
std::shared_ptr<DebugSubsection>
YAMLCoffSymbolRVASubsection::toCodeViewSubsection(
BumpPtrAllocator &Allocator,
const codeview::StringsAndChecksums &SC) const { … }
static Expected<SourceFileChecksumEntry>
convertOneChecksum(const DebugStringTableSubsectionRef &Strings,
const FileChecksumEntry &CS) { … }
static Expected<StringRef>
getFileName(const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID) { … }
Expected<std::shared_ptr<YAMLChecksumsSubsection>>
YAMLChecksumsSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &FC) { … }
Expected<std::shared_ptr<YAMLLinesSubsection>>
YAMLLinesSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums,
const DebugLinesSubsectionRef &Lines) { … }
Expected<std::shared_ptr<YAMLInlineeLinesSubsection>>
YAMLInlineeLinesSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums,
const DebugInlineeLinesSubsectionRef &Lines) { … }
Expected<std::shared_ptr<YAMLCrossModuleExportsSubsection>>
YAMLCrossModuleExportsSubsection::fromCodeViewSubsection(
const DebugCrossModuleExportsSubsectionRef &Exports) { … }
Expected<std::shared_ptr<YAMLCrossModuleImportsSubsection>>
YAMLCrossModuleImportsSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings,
const DebugCrossModuleImportsSubsectionRef &Imports) { … }
Expected<std::shared_ptr<YAMLSymbolsSubsection>>
YAMLSymbolsSubsection::fromCodeViewSubsection(
const DebugSymbolsSubsectionRef &Symbols) { … }
Expected<std::shared_ptr<YAMLStringTableSubsection>>
YAMLStringTableSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings) { … }
Expected<std::shared_ptr<YAMLFrameDataSubsection>>
YAMLFrameDataSubsection::fromCodeViewSubsection(
const DebugStringTableSubsectionRef &Strings,
const DebugFrameDataSubsectionRef &Frames) { … }
Expected<std::shared_ptr<YAMLCoffSymbolRVASubsection>>
YAMLCoffSymbolRVASubsection::fromCodeViewSubsection(
const DebugSymbolRVASubsectionRef &Section) { … }
Expected<std::vector<std::shared_ptr<DebugSubsection>>>
llvm::CodeViewYAML::toCodeViewSubsectionList(
BumpPtrAllocator &Allocator, ArrayRef<YAMLDebugSubsection> Subsections,
const codeview::StringsAndChecksums &SC) { … }
namespace {
struct SubsectionConversionVisitor : public DebugSubsectionVisitor { … };
}
Error SubsectionConversionVisitor::visitUnknown(
DebugUnknownSubsectionRef &Unknown) { … }
Error SubsectionConversionVisitor::visitLines(
DebugLinesSubsectionRef &Lines, const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitFileChecksums(
DebugChecksumsSubsectionRef &Checksums,
const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitInlineeLines(
DebugInlineeLinesSubsectionRef &Inlinees,
const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitCrossModuleExports(
DebugCrossModuleExportsSubsectionRef &Exports,
const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitCrossModuleImports(
DebugCrossModuleImportsSubsectionRef &Imports,
const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitStringTable(
DebugStringTableSubsectionRef &Strings,
const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitSymbols(
DebugSymbolsSubsectionRef &Symbols, const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitFrameData(
DebugFrameDataSubsectionRef &Frames, const StringsAndChecksumsRef &State) { … }
Error SubsectionConversionVisitor::visitCOFFSymbolRVAs(
DebugSymbolRVASubsectionRef &RVAs, const StringsAndChecksumsRef &State) { … }
Expected<YAMLDebugSubsection>
YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC,
const DebugSubsectionRecord &SS) { … }
std::vector<YAMLDebugSubsection>
llvm::CodeViewYAML::fromDebugS(ArrayRef<uint8_t> Data,
const StringsAndChecksumsRef &SC) { … }
void llvm::CodeViewYAML::initializeStringsAndChecksums(
ArrayRef<YAMLDebugSubsection> Sections, codeview::StringsAndChecksums &SC) { … }