brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 8746675 Raw
150 lines · c
1//===- PdbYAML.h ---------------------------------------------- *- C++ --*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H10#define LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H11 12#include "OutputStyle.h"13 14#include "llvm/BinaryFormat/COFF.h"15#include "llvm/DebugInfo/CodeView/SymbolRecord.h"16#include "llvm/DebugInfo/CodeView/TypeRecord.h"17#include "llvm/DebugInfo/MSF/MSFCommon.h"18#include "llvm/DebugInfo/PDB/Native/PDBFile.h"19#include "llvm/DebugInfo/PDB/Native/RawConstants.h"20#include "llvm/DebugInfo/PDB/PDBTypes.h"21#include "llvm/Object/COFF.h"22#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"23#include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"24#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"25#include "llvm/Support/Endian.h"26#include "llvm/Support/YAMLTraits.h"27 28#include <optional>29#include <vector>30 31namespace llvm {32namespace pdb {33 34namespace yaml {35 36struct MSFHeaders {37  msf::SuperBlock SuperBlock;38  uint32_t NumDirectoryBlocks = 0;39  std::vector<uint32_t> DirectoryBlocks;40  uint32_t NumStreams = 0;41  uint64_t FileSize = 0;42};43 44struct CoffSectionHeader {45  CoffSectionHeader();46  CoffSectionHeader(const object::coff_section &Section);47 48  object::coff_section toCoffSection() const;49 50  StringRef Name;51  uint32_t VirtualSize = 0;52  uint32_t VirtualAddress = 0;53  uint32_t SizeOfRawData = 0;54  uint32_t PointerToRawData = 0;55  uint32_t PointerToRelocations = 0;56  uint32_t PointerToLinenumbers = 0;57  uint16_t NumberOfRelocations = 0;58  uint16_t NumberOfLinenumbers = 0;59  uint32_t Characteristics = 0;60};61 62struct StreamBlockList {63  std::vector<uint32_t> Blocks;64};65 66struct NamedStreamMapping {67  StringRef StreamName;68  uint32_t StreamNumber;69};70 71struct PdbInfoStream {72  PdbRaw_ImplVer Version = PdbImplVC70;73  uint32_t Signature = 0;74  uint32_t Age = 1;75  codeview::GUID Guid;76  std::vector<PdbRaw_FeatureSig> Features;77  std::vector<NamedStreamMapping> NamedStreams;78};79 80struct PdbModiStream {81  uint32_t Signature;82  std::vector<CodeViewYAML::SymbolRecord> Symbols;83};84 85struct PdbDbiModuleInfo {86  StringRef Obj;87  StringRef Mod;88  std::vector<StringRef> SourceFiles;89  std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections;90  std::optional<PdbModiStream> Modi;91};92 93struct PdbDbiStream {94  PdbRaw_DbiVer VerHeader = PdbDbiV70;95  uint32_t Age = 1;96  uint16_t BuildNumber = 0;97  uint32_t PdbDllVersion = 0;98  uint16_t PdbDllRbld = 0;99  uint16_t Flags = 1;100  PDB_Machine MachineType = PDB_Machine::x86;101 102  std::vector<PdbDbiModuleInfo> ModInfos;103  COFF::header FakeHeader;104  std::vector<CoffSectionHeader> SectionHeaders;105};106 107struct PdbTpiStream {108  PdbRaw_TpiVer Version = PdbTpiV80;109  std::vector<CodeViewYAML::LeafRecord> Records;110};111 112struct PdbPublicsStream {113  std::vector<CodeViewYAML::SymbolRecord> PubSyms;114};115 116struct PdbObject {117  explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}118 119  std::optional<MSFHeaders> Headers;120  std::optional<std::vector<uint32_t>> StreamSizes;121  std::optional<std::vector<StreamBlockList>> StreamMap;122  std::optional<PdbInfoStream> PdbStream;123  std::optional<PdbDbiStream> DbiStream;124  std::optional<PdbTpiStream> TpiStream;125  std::optional<PdbTpiStream> IpiStream;126  std::optional<PdbPublicsStream> PublicsStream;127 128  std::optional<std::vector<StringRef>> StringTable;129 130  BumpPtrAllocator &Allocator;131};132}133}134}135 136LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::CoffSectionHeader)137LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbObject)138LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::MSFHeaders)139LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(msf::SuperBlock)140LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::StreamBlockList)141LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbInfoStream)142LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiStream)143LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbTpiStream)144LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbPublicsStream)145LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::NamedStreamMapping)146LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbModiStream)147LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiModuleInfo)148 149#endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H150