25 using namespace llvm::codeview;
26 using namespace llvm::msf;
27 using namespace llvm::pdb;
42 Size +=
alignTo(SymbolByteSize, 4);
50 DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(
StringRef ModuleName,
53 : MSF(Msf), ModuleName(ModuleName) {
54 ::memset(&Layout, 0,
sizeof(Layout));
55 Layout.
Mod = ModIndex;
73 Symbols.push_back(Symbol);
77 "Invalid Symbol alignment!");
78 SymbolByteSize += Symbol.
length();
81 void DbiModuleDescriptorBuilder::addSourceFile(
StringRef Path) {
82 SourceFiles.push_back(Path);
85 uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize()
const {
87 for (
const auto &Builder : C13Builders) {
88 assert(Builder &&
"Empty C13 Fragment Builder!");
89 Result += Builder->calculateSerializedLength();
101 template <
typename T>
struct Foo {
102 explicit Foo(
T &&Answer) : Answer(Answer) {}
114 Layout.
C13Bytes = calculateC13DebugInfoSize();
117 Layout.
NumFiles = SourceFiles.size();
128 uint32_t C13Size = calculateC13DebugInfoSize();
132 return ExpectedSN.takeError();
152 auto NS = WritableMappedBlockStream::createIndexedStream(
169 "Invalid debug section alignment!");
170 for (
const auto &Builder : C13Builders) {
171 assert(Builder &&
"Empty C13 Fragment Builder!");
172 if (
auto EC = Builder->commit(SymbolWriter))
186 std::shared_ptr<DebugSubsection> Subsection) {
188 C13Builders.push_back(llvm::make_unique<DebugSubsectionRecordBuilder>(
189 std::move(Subsection), CodeViewContainer::Pdb));
194 C13Builders.push_back(llvm::make_unique<DebugSubsectionRecordBuilder>(
195 SubsectionContents, CodeViewContainer::Pdb));
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer)
uint16_t getStreamIndex() const
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
~DbiModuleDescriptorBuilder()
uint32_t getOffset() const
Error finalizeMsfLayout()
uint32_t alignOf(CodeViewContainer Container)
support::ulittle16_t ModuleIndex
size_t size() const
size - Get the array size.
void setObjFileName(StringRef Name)
const uint16_t kInvalidStreamIndex
Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
static size_t length(const CVSymbol &Item)
Error writeCString(StringRef Str)
Write the the string Str to the underlying stream followed by a null terminator.
static ErrorSuccess success()
Create a success value.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Expected< uint32_t > addStream(uint32_t Size, ArrayRef< uint32_t > Blocks)
Add a stream to the MSF file with the given size, occupying the given list of blocks.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize, uint32_t C13Size)
ArrayRef< uint8_t > RecordData
uint32_t bytesRemaining() const
void addSymbol(codeview::CVSymbol Symbol)
Error padToAlignment(uint32_t Align)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
BinaryItemStream represents a sequence of objects stored in some kind of external container but for w...
static ArrayRef< uint8_t > bytes(const CVSymbol &Item)
Lightweight error class with error context and mandatory checking.
void setItems(ArrayRef< T > ItemArray)
StringRef - Represent a constant reference to a string, i.e.
void setPdbFilePathNI(uint32_t NI)
uint32_t calculateSerializedLength() const
BumpPtrAllocator & getAllocator()
void addDebugSubsection(std::shared_ptr< codeview::DebugSubsection > Subsection)