-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeView] Isolate Debug Info Fragments into standalone classes.
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 llvm-svn: 301557
- Loading branch information
Zachary Turner
committed
Apr 27, 2017
1 parent
e509447
commit c37cb0c
Showing
19 changed files
with
511 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//===- ModuleDebugLineFragment.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_MODULEDEBUGFILECHECKSUMFRAGMENT_H | ||
#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H | ||
|
||
#include "llvm/ADT/ArrayRef.h" | ||
#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h" | ||
#include "llvm/Support/BinaryStreamArray.h" | ||
#include "llvm/Support/BinaryStreamReader.h" | ||
#include "llvm/Support/Endian.h" | ||
|
||
namespace llvm { | ||
namespace codeview { | ||
|
||
struct FileChecksumEntry { | ||
uint32_t FileNameOffset; // Byte offset of filename in global stringtable. | ||
FileChecksumKind Kind; // The type of checksum. | ||
ArrayRef<uint8_t> Checksum; // The bytes of the checksum. | ||
}; | ||
} | ||
} | ||
|
||
namespace llvm { | ||
template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> { | ||
public: | ||
typedef void ContextType; | ||
|
||
static Error extract(BinaryStreamRef Stream, uint32_t &Len, | ||
codeview::FileChecksumEntry &Item, void *Ctx); | ||
}; | ||
} | ||
|
||
namespace llvm { | ||
namespace codeview { | ||
class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment { | ||
typedef VarStreamArray<FileChecksumEntry> FileChecksumArray; | ||
typedef FileChecksumArray::Iterator Iterator; | ||
|
||
public: | ||
ModuleDebugFileChecksumFragment() | ||
: ModuleDebugFragment(ModuleDebugFragmentKind::FileChecksums) {} | ||
|
||
static bool classof(const ModuleDebugFragment *S) { | ||
return S->kind() == ModuleDebugFragmentKind::FileChecksums; | ||
} | ||
|
||
Error initialize(BinaryStreamReader Reader); | ||
|
||
Iterator begin() const { return Checksums.begin(); } | ||
Iterator end() const { return Checksums.end(); } | ||
|
||
private: | ||
FileChecksumArray Checksums; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
llvm/include/llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//===- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.