mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
Previously parsing of these were all grouped together into a single master class that could parse any type of debug info fragment. With writing forthcoming, the complexity of each individual fragment is enough to warrant them having their own classes so that reading and writing of each fragment type can be grouped together, but isolated from the code for reading and writing other fragment types. In doing so, I found a place where parsing code was duplicated for the FileChecksums fragment, across llvm-readobj and the CodeView library, and one of the implementations had a bug. Now that the codepaths are merged, the bug is resolved. Differential Revision: https://reviews.llvm.org/D32547 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301557 91177308-0d34-0410-b5e6-96231b3b80d8
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
//===- ModuleDebugFragment.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_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
|
|
#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
|
|
|
|
#include "llvm/DebugInfo/CodeView/CodeView.h"
|
|
#include "llvm/Support/BinaryStreamArray.h"
|
|
#include "llvm/Support/BinaryStreamRef.h"
|
|
#include "llvm/Support/Endian.h"
|
|
#include "llvm/Support/Error.h"
|
|
|
|
namespace llvm {
|
|
namespace codeview {
|
|
|
|
// Corresponds to the `CV_DebugSSubsectionHeader_t` structure.
|
|
struct ModuleDebugFragmentHeader {
|
|
support::ulittle32_t Kind; // codeview::ModuleDebugFragmentKind enum
|
|
support::ulittle32_t Length; // number of bytes occupied by this record.
|
|
};
|
|
|
|
class ModuleDebugFragmentRecord {
|
|
public:
|
|
ModuleDebugFragmentRecord();
|
|
ModuleDebugFragmentRecord(ModuleDebugFragmentKind Kind, BinaryStreamRef Data);
|
|
|
|
static Error initialize(BinaryStreamRef Stream,
|
|
ModuleDebugFragmentRecord &Info);
|
|
uint32_t getRecordLength() const;
|
|
ModuleDebugFragmentKind kind() const;
|
|
BinaryStreamRef getRecordData() const;
|
|
|
|
private:
|
|
ModuleDebugFragmentKind Kind;
|
|
BinaryStreamRef Data;
|
|
};
|
|
|
|
typedef VarStreamArray<ModuleDebugFragmentRecord> ModuleDebugFragmentArray;
|
|
|
|
} // namespace codeview
|
|
|
|
template <>
|
|
struct VarStreamArrayExtractor<codeview::ModuleDebugFragmentRecord> {
|
|
typedef void ContextType;
|
|
|
|
static Error extract(BinaryStreamRef Stream, uint32_t &Length,
|
|
codeview::ModuleDebugFragmentRecord &Info, void *Ctx) {
|
|
if (auto EC = codeview::ModuleDebugFragmentRecord::initialize(Stream, Info))
|
|
return EC;
|
|
Length = Info.getRecordLength();
|
|
return Error::success();
|
|
}
|
|
};
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H
|