1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
Zachary Turner 8ef979bdc8 [PDB] Teach libpdb to write DBI Stream ECNames.
Based strictly on the name, this seems to have something to do
width edit & continue.  The goal of this patch has nothing to do
with supporting edit and continue though.  msvc link.exe writes
very basic information into this area even when *not* compiling
with support for E&C, and so the goal here is to bring lld-link
to parity.  Since we cannot know what assumptions standard tools
make about the content of PDB files, we need to be as close as
possible.

This ECNames data structure is a standard PDB string hash table.
link.exe puts a single string into this hash table, which is the
full path to the PDB file on disk.  It then references this string
from the module descriptor for the compiler generated `* Linker *`
module.

With this patch, lld-link will generate the exact same sequence of
bytes as MSVC link for this subsection for a given object file
input (as reported by `llvm-pdbutil bytes -ec`).

llvm-svn: 307356
2017-07-07 05:04:36 +00:00

106 lines
3.0 KiB
C++

//===- DbiModuleDescriptorBuilder.h - PDB module information ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <string>
#include <vector>
namespace llvm {
class BinaryStreamWriter;
namespace codeview {
class DebugSubsectionRecordBuilder;
}
namespace msf {
class MSFBuilder;
struct MSFLayout;
}
namespace pdb {
class DbiModuleDescriptorBuilder {
friend class DbiStreamBuilder;
public:
DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex,
msf::MSFBuilder &Msf);
~DbiModuleDescriptorBuilder();
DbiModuleDescriptorBuilder(const DbiModuleDescriptorBuilder &) = delete;
DbiModuleDescriptorBuilder &
operator=(const DbiModuleDescriptorBuilder &) = delete;
void setPdbFilePathNI(uint32_t NI);
void setObjFileName(StringRef Name);
void addSymbol(codeview::CVSymbol Symbol);
void
addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
void
addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
uint16_t getStreamIndex() const;
StringRef getModuleName() const { return ModuleName; }
StringRef getObjFileName() const { return ObjFileName; }
unsigned getModuleIndex() const { return Layout.Mod; }
ArrayRef<std::string> source_files() const {
return makeArrayRef(SourceFiles);
}
uint32_t calculateSerializedLength() const;
/// Return the offset within the module symbol stream of the next symbol
/// record passed to addSymbol. Add four to account for the signature.
uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; }
void finalize();
Error finalizeMsfLayout();
Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout,
WritableBinaryStreamRef MsfBuffer);
private:
uint32_t calculateC13DebugInfoSize() const;
void addSourceFile(StringRef Path);
msf::MSFBuilder &MSF;
uint32_t SymbolByteSize = 0;
uint32_t PdbFilePathNI = 0;
std::string ModuleName;
std::string ObjFileName;
std::vector<std::string> SourceFiles;
std::vector<codeview::CVSymbol> Symbols;
std::vector<std::unique_ptr<codeview::DebugSubsectionRecordBuilder>>
C13Builders;
ModuleInfoHeader Layout;
};
} // end namespace pdb
} // end namespace llvm
#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H