1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[DebugInfo] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 306169
This commit is contained in:
Eugene Zelenko 2017-06-23 21:57:40 +00:00
parent 531daa9d45
commit 403aa6c77c
25 changed files with 165 additions and 123 deletions

View File

@ -57,7 +57,7 @@ struct DILineInfo {
} }
}; };
typedef SmallVector<std::pair<uint64_t, DILineInfo>, 16> DILineInfoTable; using DILineInfoTable = SmallVector<std::pair<uint64_t, DILineInfo>, 16>;
/// DIInliningInfo - a format-neutral container for inlined code description. /// DIInliningInfo - a format-neutral container for inlined code description.
class DIInliningInfo { class DIInliningInfo {
@ -102,7 +102,7 @@ enum class DINameKind { None, ShortName, LinkageName };
/// should be filled with data. /// should be filled with data.
struct DILineInfoSpecifier { struct DILineInfoSpecifier {
enum class FileLineInfoKind { None, Default, AbsoluteFilePath }; enum class FileLineInfoKind { None, Default, AbsoluteFilePath };
typedef DINameKind FunctionNameKind; using FunctionNameKind = DINameKind;
FileLineInfoKind FLIKind; FileLineInfoKind FLIKind;
FunctionNameKind FNKind; FunctionNameKind FNKind;
@ -174,6 +174,7 @@ public:
// No verifier? Just say things went well. // No verifier? Just say things went well.
return true; return true;
} }
virtual DILineInfo getLineInfoForAddress(uint64_t Address, virtual DILineInfo getLineInfoForAddress(uint64_t Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address, virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,

View File

@ -33,6 +33,7 @@ public:
dwarf::Attribute Attr; dwarf::Attribute Attr;
dwarf::Form Form; dwarf::Form Form;
/// The following field is used for ByteSize for non-implicit_const /// The following field is used for ByteSize for non-implicit_const
/// attributes and as value for implicit_const ones, indicated by /// attributes and as value for implicit_const ones, indicated by
/// Form == DW_FORM_implicit_const. /// Form == DW_FORM_implicit_const.
@ -58,7 +59,7 @@ public:
/// the ByteSize member. /// the ByteSize member.
Optional<int64_t> getByteSize(const DWARFUnit &U) const; Optional<int64_t> getByteSize(const DWARFUnit &U) const;
}; };
typedef SmallVector<AttributeSpec, 8> AttributeSpecVector; using AttributeSpecVector = SmallVector<AttributeSpec, 8>;
DWARFAbbreviationDeclaration(); DWARFAbbreviationDeclaration();
@ -67,8 +68,8 @@ public:
dwarf::Tag getTag() const { return Tag; } dwarf::Tag getTag() const { return Tag; }
bool hasChildren() const { return HasChildren; } bool hasChildren() const { return HasChildren; }
typedef iterator_range<AttributeSpecVector::const_iterator> using attr_iterator_range =
attr_iterator_range; iterator_range<AttributeSpecVector::const_iterator>;
attr_iterator_range attributes() const { attr_iterator_range attributes() const {
return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());

View File

@ -32,8 +32,9 @@ class DWARFAcceleratorTable {
}; };
struct HeaderData { struct HeaderData {
typedef uint16_t AtomType; using AtomType = uint16_t;
typedef dwarf::Form Form; using Form = dwarf::Form;
uint32_t DIEOffsetBase; uint32_t DIEOffsetBase;
SmallVector<std::pair<AtomType, Form>, 3> Atoms; SmallVector<std::pair<AtomType, Form>, 3> Atoms;
}; };

View File

@ -10,7 +10,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H #ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H #define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h" #include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
@ -25,21 +24,24 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" #include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h" #include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Host.h" #include "llvm/Support/Host.h"
#include <cstdint> #include <cstdint>
#include <deque> #include <deque>
#include <map> #include <map>
#include <memory> #include <memory>
#include <utility>
namespace llvm { namespace llvm {
class DataExtractor;
class MemoryBuffer; class MemoryBuffer;
class raw_ostream; class raw_ostream;
@ -73,7 +75,7 @@ class DWARFContext : public DIContext {
std::unique_ptr<DWARFDebugLocDWO> LocDWO; std::unique_ptr<DWARFDebugLocDWO> LocDWO;
/// The maximum DWARF version of all units. /// The maximum DWARF version of all units.
unsigned MaxVersion; unsigned MaxVersion = 0;
struct DWOFile { struct DWOFile {
object::OwningBinary<object::ObjectFile> File; object::OwningBinary<object::ObjectFile> File;
@ -100,7 +102,7 @@ class DWARFContext : public DIContext {
void parseDWOTypeUnits(); void parseDWOTypeUnits();
public: public:
DWARFContext() : DIContext(CK_DWARF), MaxVersion(0) {} DWARFContext() : DIContext(CK_DWARF) {}
DWARFContext(DWARFContext &) = delete; DWARFContext(DWARFContext &) = delete;
DWARFContext &operator=(DWARFContext &) = delete; DWARFContext &operator=(DWARFContext &) = delete;
@ -112,9 +114,9 @@ public:
bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override; bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override;
typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range; using cu_iterator_range = DWARFUnitSection<DWARFCompileUnit>::iterator_range;
typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range; using tu_iterator_range = DWARFUnitSection<DWARFTypeUnit>::iterator_range;
typedef iterator_range<decltype(TUs)::iterator> tu_section_iterator_range; using tu_section_iterator_range = iterator_range<decltype(TUs)::iterator>;
/// Get compile units in this context. /// Get compile units in this context.
cu_iterator_range compile_units() { cu_iterator_range compile_units() {
@ -230,8 +232,10 @@ public:
virtual bool isLittleEndian() const = 0; virtual bool isLittleEndian() const = 0;
virtual uint8_t getAddressSize() const = 0; virtual uint8_t getAddressSize() const = 0;
virtual const DWARFSection &getInfoSection() = 0; virtual const DWARFSection &getInfoSection() = 0;
typedef MapVector<object::SectionRef, DWARFSection,
std::map<object::SectionRef, unsigned>> TypeSectionMap; using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
std::map<object::SectionRef, unsigned>>;
virtual const TypeSectionMap &getTypesSections() = 0; virtual const TypeSectionMap &getTypesSections() = 0;
virtual StringRef getAbbrevSection() = 0; virtual StringRef getAbbrevSection() = 0;
virtual const DWARFSection &getLocSection() = 0; virtual const DWARFSection &getLocSection() = 0;

View File

@ -18,6 +18,8 @@
namespace llvm { namespace llvm {
class raw_ostream;
class DWARFAbbreviationDeclarationSet { class DWARFAbbreviationDeclarationSet {
uint32_t Offset; uint32_t Offset;
/// Code of the first abbreviation, if all abbreviations in the set have /// Code of the first abbreviation, if all abbreviations in the set have
@ -25,8 +27,8 @@ class DWARFAbbreviationDeclarationSet {
uint32_t FirstAbbrCode; uint32_t FirstAbbrCode;
std::vector<DWARFAbbreviationDeclaration> Decls; std::vector<DWARFAbbreviationDeclaration> Decls;
typedef std::vector<DWARFAbbreviationDeclaration>::const_iterator using const_iterator =
const_iterator; std::vector<DWARFAbbreviationDeclaration>::const_iterator;
public: public:
DWARFAbbreviationDeclarationSet(); DWARFAbbreviationDeclarationSet();
@ -51,8 +53,8 @@ private:
}; };
class DWARFDebugAbbrev { class DWARFDebugAbbrev {
typedef std::map<uint64_t, DWARFAbbreviationDeclarationSet> using DWARFAbbreviationDeclarationSetMap =
DWARFAbbreviationDeclarationSetMap; std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
DWARFAbbreviationDeclarationSetMap AbbrDeclSets; DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;

View File

@ -46,8 +46,8 @@ public:
}; };
private: private:
typedef std::vector<Descriptor> DescriptorColl; using DescriptorColl = std::vector<Descriptor>;
typedef iterator_range<DescriptorColl::const_iterator> desc_iterator_range; using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
uint32_t Offset; uint32_t Offset;
Header HeaderData; Header HeaderData;

View File

@ -76,8 +76,8 @@ private:
} }
}; };
typedef std::vector<Range> RangeColl; using RangeColl = std::vector<Range>;
typedef RangeColl::const_iterator RangeCollIterator; using RangeCollIterator = RangeColl::const_iterator;
std::vector<RangeEndpoint> Endpoints; std::vector<RangeEndpoint> Endpoints;
RangeColl Aranges; RangeColl Aranges;

View File

@ -10,6 +10,7 @@
#ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H #ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H
#define LLVM_DEBUGINFO_DWARFDEBUGLINE_H #define LLVM_DEBUGINFO_DWARFDEBUGLINE_H
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/DataExtractor.h" #include "llvm/Support/DataExtractor.h"
@ -104,7 +105,9 @@ public:
void postAppend(); void postAppend();
void reset(bool DefaultIsStmt); void reset(bool DefaultIsStmt);
void dump(raw_ostream &OS) const; void dump(raw_ostream &OS) const;
static void dumpTableHeader(raw_ostream &OS); static void dumpTableHeader(raw_ostream &OS);
static bool orderByAddress(const Row &LHS, const Row &RHS) { static bool orderByAddress(const Row &LHS, const Row &RHS) {
return LHS.Address < RHS.Address; return LHS.Address < RHS.Address;
} }
@ -216,11 +219,12 @@ public:
bool parse(DataExtractor DebugLineData, const RelocAddrMap *RMap, bool parse(DataExtractor DebugLineData, const RelocAddrMap *RMap,
uint32_t *OffsetPtr); uint32_t *OffsetPtr);
using RowVector = std::vector<Row>;
using RowIter = RowVector::const_iterator;
using SequenceVector = std::vector<Sequence>;
using SequenceIter = SequenceVector::const_iterator;
struct Prologue Prologue; struct Prologue Prologue;
typedef std::vector<Row> RowVector;
typedef RowVector::const_iterator RowIter;
typedef std::vector<Sequence> SequenceVector;
typedef SequenceVector::const_iterator SequenceIter;
RowVector Rows; RowVector Rows;
SequenceVector Sequences; SequenceVector Sequences;
@ -244,14 +248,14 @@ private:
struct LineTable *LineTable; struct LineTable *LineTable;
/// The row number that starts at zero for the prologue, and increases for /// The row number that starts at zero for the prologue, and increases for
/// each row added to the matrix. /// each row added to the matrix.
unsigned RowNumber; unsigned RowNumber = 0;
struct Row Row; struct Row Row;
struct Sequence Sequence; struct Sequence Sequence;
}; };
typedef std::map<uint32_t, LineTable> LineTableMapTy; using LineTableMapTy = std::map<uint32_t, LineTable>;
typedef LineTableMapTy::iterator LineTableIter; using LineTableIter = LineTableMapTy::iterator;
typedef LineTableMapTy::const_iterator LineTableConstIter; using LineTableConstIter = LineTableMapTy::const_iterator;
const RelocAddrMap *RelocMap; const RelocAddrMap *RelocMap;
LineTableMapTy LineTableMap; LineTableMapTy LineTableMap;

View File

@ -39,7 +39,7 @@ class DWARFDebugLoc {
SmallVector<Entry, 2> Entries; SmallVector<Entry, 2> Entries;
}; };
typedef SmallVector<LocationList, 4> LocationLists; using LocationLists = SmallVector<LocationList, 4>;
/// A list of all the variables in the debug_loc section, each one describing /// A list of all the variables in the debug_loc section, each one describing
/// the locations in which the variable is stored. /// the locations in which the variable is stored.
@ -71,7 +71,7 @@ class DWARFDebugLocDWO {
SmallVector<Entry, 2> Entries; SmallVector<Entry, 2> Entries;
}; };
typedef SmallVector<LocationList, 4> LocationLists; using LocationLists = SmallVector<LocationList, 4>;
LocationLists Locations; LocationLists Locations;

View File

@ -40,7 +40,7 @@ class DWARFDebugMacro {
}; };
}; };
typedef SmallVector<Entry, 4> MacroList; using MacroList = SmallVector<Entry, 4>;
/// A list of all the macro entries in the debug_macinfo section. /// A list of all the macro entries in the debug_macinfo section.
MacroList Macros; MacroList Macros;

View File

@ -12,10 +12,8 @@
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/DataExtractor.h" #include "llvm/Support/DataExtractor.h"
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
@ -29,7 +27,7 @@ struct DWARFAddressRange {
}; };
/// DWARFAddressRangesVector - represents a set of absolute address ranges. /// DWARFAddressRangesVector - represents a set of absolute address ranges.
typedef std::vector<DWARFAddressRange> DWARFAddressRangesVector; using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
class DWARFDebugRangeList { class DWARFDebugRangeList {
public: public:

View File

@ -12,7 +12,6 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include <cstdint> #include <cstdint>
#include <utility>
namespace llvm { namespace llvm {
@ -28,7 +27,7 @@ struct RelocAddrEntry {
/// dwarf where we expect relocated values. This adds a bit of complexity to the /// dwarf where we expect relocated values. This adds a bit of complexity to the
/// dwarf parsing/extraction at the benefit of not allocating memory for the /// dwarf parsing/extraction at the benefit of not allocating memory for the
/// entire size of the debug info sections. /// entire size of the debug info sections.
typedef DenseMap<uint64_t, RelocAddrEntry> RelocAddrMap; using RelocAddrMap = DenseMap<uint64_t, RelocAddrEntry>;
} // end namespace llvm } // end namespace llvm

View File

@ -22,8 +22,6 @@
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h" #include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/DataExtractor.h" #include "llvm/Support/DataExtractor.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -31,6 +29,7 @@
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <memory> #include <memory>
#include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
@ -72,9 +71,9 @@ class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
bool Parsed = false; bool Parsed = false;
public: public:
typedef SmallVectorImpl<std::unique_ptr<UnitType>> UnitVector; using UnitVector = SmallVectorImpl<std::unique_ptr<UnitType>>;
typedef typename UnitVector::iterator iterator; using iterator = typename UnitVector::iterator;
typedef llvm::iterator_range<typename UnitVector::iterator> iterator_range; using iterator_range = llvm::iterator_range<typename UnitVector::iterator>;
UnitType *getUnitForOffset(uint32_t Offset) const override { UnitType *getUnitForOffset(uint32_t Offset) const override {
auto *CU = std::upper_bound( auto *CU = std::upper_bound(
@ -142,8 +141,9 @@ class DWARFUnit {
/// IntervalMap does not support range removal, as a result, we use the /// IntervalMap does not support range removal, as a result, we use the
/// std::map::upper_bound for address range lookup. /// std::map::upper_bound for address range lookup.
std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap; std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
typedef iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>
die_iterator_range; using die_iterator_range =
iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
std::shared_ptr<DWARFUnit> DWO; std::shared_ptr<DWARFUnit> DWO;

View File

@ -12,18 +12,16 @@
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MSFCommon.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include <cstdint>
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
namespace msf { namespace msf {
class MSFBuilder { class MSFBuilder {
public: public:
/// \brief Create a new `MSFBuilder`. /// \brief Create a new `MSFBuilder`.
@ -122,7 +120,7 @@ private:
Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks); Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks);
uint32_t computeDirectoryByteSize() const; uint32_t computeDirectoryByteSize() const;
typedef std::vector<uint32_t> BlockList; using BlockList = std::vector<uint32_t>;
BumpPtrAllocator &Allocator; BumpPtrAllocator &Allocator;
@ -136,7 +134,8 @@ private:
std::vector<uint32_t> DirectoryBlocks; std::vector<uint32_t> DirectoryBlocks;
std::vector<std::pair<uint32_t, BlockList>> StreamData; std::vector<std::pair<uint32_t, BlockList>> StreamData;
}; };
} // namespace msf
} // namespace llvm } // end namespace msf
} // end namespace llvm
#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H #endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H

View File

@ -12,15 +12,15 @@
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include <cstdint>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
namespace msf { namespace msf {
static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
't', ' ', 'C', '/', 'C', '+', '+', ' ', 't', ' ', 'C', '/', 'C', '+', '+', ' ',
'M', 'S', 'F', ' ', '7', '.', '0', '0', 'M', 'S', 'F', ' ', '7', '.', '0', '0',
@ -50,8 +50,9 @@ struct SuperBlock {
}; };
struct MSFLayout { struct MSFLayout {
MSFLayout() : SB(nullptr) {} MSFLayout() = default;
const SuperBlock *SB;
const SuperBlock *SB = nullptr;
BitVector FreePageMap; BitVector FreePageMap;
ArrayRef<support::ulittle32_t> DirectoryBlocks; ArrayRef<support::ulittle32_t> DirectoryBlocks;
ArrayRef<support::ulittle32_t> StreamSizes; ArrayRef<support::ulittle32_t> StreamSizes;
@ -90,15 +91,16 @@ inline uint32_t getFpmIntervalLength(const MSFLayout &L) {
inline uint32_t getNumFpmIntervals(const MSFLayout &L) { inline uint32_t getNumFpmIntervals(const MSFLayout &L) {
uint32_t Length = getFpmIntervalLength(L); uint32_t Length = getFpmIntervalLength(L);
return llvm::alignTo(L.SB->NumBlocks, Length) / Length; return alignTo(L.SB->NumBlocks, Length) / Length;
} }
inline uint32_t getFullFpmByteSize(const MSFLayout &L) { inline uint32_t getFullFpmByteSize(const MSFLayout &L) {
return llvm::alignTo(L.SB->NumBlocks, 8) / 8; return alignTo(L.SB->NumBlocks, 8) / 8;
} }
Error validateSuperBlock(const SuperBlock &SB); Error validateSuperBlock(const SuperBlock &SB);
} // namespace msf
} // namespace llvm } // end namespace msf
} // end namespace llvm
#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H #endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H

View File

@ -1,5 +1,4 @@
//===- MappedBlockStream.h - Discontiguous stream data in an MSF -*- C++ //==- MappedBlockStream.h - Discontiguous stream data in an MSF --*- C++ -*-==//
//-*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -13,7 +12,6 @@
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/MSF/MSFStreamLayout.h" #include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStream.h" #include "llvm/Support/BinaryStream.h"
@ -21,6 +19,7 @@
#include "llvm/Support/Endian.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include <cstdint> #include <cstdint>
#include <memory>
#include <vector> #include <vector>
namespace llvm { namespace llvm {
@ -40,6 +39,7 @@ struct MSFLayout;
/// of bytes. /// of bytes.
class MappedBlockStream : public BinaryStream { class MappedBlockStream : public BinaryStream {
friend class WritableMappedBlockStream; friend class WritableMappedBlockStream;
public: public:
static std::unique_ptr<MappedBlockStream> static std::unique_ptr<MappedBlockStream>
createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, createStream(uint32_t BlockSize, const MSFStreamLayout &Layout,
@ -57,8 +57,8 @@ public:
createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData,
BumpPtrAllocator &Allocator); BumpPtrAllocator &Allocator);
llvm::support::endianness getEndian() const override { support::endianness getEndian() const override {
return llvm::support::little; return support::little;
} }
Error readBytes(uint32_t Offset, uint32_t Size, Error readBytes(uint32_t Offset, uint32_t Size,
@ -68,7 +68,7 @@ public:
uint32_t getLength() override; uint32_t getLength() override;
llvm::BumpPtrAllocator &getAllocator() { return Allocator; } BumpPtrAllocator &getAllocator() { return Allocator; }
void invalidateCache(); void invalidateCache();
@ -92,7 +92,7 @@ private:
const MSFStreamLayout StreamLayout; const MSFStreamLayout StreamLayout;
BinaryStreamRef MsfData; BinaryStreamRef MsfData;
typedef MutableArrayRef<uint8_t> CacheEntry; using CacheEntry = MutableArrayRef<uint8_t>;
// We just store the allocator by reference. We use this to allocate // We just store the allocator by reference. We use this to allocate
// contiguous memory for things like arrays or strings that cross a block // contiguous memory for things like arrays or strings that cross a block
@ -124,8 +124,8 @@ public:
createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData,
BumpPtrAllocator &Allocator); BumpPtrAllocator &Allocator);
llvm::support::endianness getEndian() const override { support::endianness getEndian() const override {
return llvm::support::little; return support::little;
} }
Error readBytes(uint32_t Offset, uint32_t Size, Error readBytes(uint32_t Offset, uint32_t Size,
@ -141,6 +141,7 @@ public:
const MSFStreamLayout &getStreamLayout() const { const MSFStreamLayout &getStreamLayout() const {
return ReadInterface.getStreamLayout(); return ReadInterface.getStreamLayout();
} }
uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); } uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); }
uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); } uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); }
uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); } uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); }
@ -153,7 +154,6 @@ protected:
private: private:
MappedBlockStream ReadInterface; MappedBlockStream ReadInterface;
WritableBinaryStreamRef WriteInterface; WritableBinaryStreamRef WriteInterface;
}; };

View File

@ -1,4 +1,4 @@
//===-- SymbolizableModule.h ------------------------------------ C++ -----===// //===- SymbolizableModule.h -------------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -14,12 +14,7 @@
#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H #define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H
#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DIContext.h"
#include <cstdint>
namespace llvm {
namespace object {
class ObjectFile;
}
}
namespace llvm { namespace llvm {
namespace symbolize { namespace symbolize {
@ -28,7 +23,8 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
class SymbolizableModule { class SymbolizableModule {
public: public:
virtual ~SymbolizableModule() {} virtual ~SymbolizableModule() = default;
virtual DILineInfo symbolizeCode(uint64_t ModuleOffset, virtual DILineInfo symbolizeCode(uint64_t ModuleOffset,
FunctionNameKind FNKind, FunctionNameKind FNKind,
bool UseSymbolTable) const = 0; bool UseSymbolTable) const = 0;
@ -45,7 +41,7 @@ public:
virtual uint64_t getModulePreferredBase() const = 0; virtual uint64_t getModulePreferredBase() const = 0;
}; };
} // namespace symbolize } // end namespace symbolize
} // namespace llvm } // end namespace llvm
#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H #endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H

View File

@ -1,4 +1,4 @@
//===-- Symbolize.h --------------------------------------------- C++ -----===// //===- Symbolize.h ----------------------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -10,21 +10,27 @@
// Header for LLVM symbolization library. // Header for LLVM symbolization library.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H #ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H
#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H #define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
#include "llvm/Support/ErrorOr.h" #include "llvm/Support/Error.h"
#include <algorithm>
#include <cstdint>
#include <map> #include <map>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
namespace llvm { namespace llvm {
namespace symbolize { namespace symbolize {
using namespace object; using namespace object;
using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
class LLVMSymbolizer { class LLVMSymbolizer {
@ -36,6 +42,7 @@ public:
bool RelativeAddresses : 1; bool RelativeAddresses : 1;
std::string DefaultArch; std::string DefaultArch;
std::vector<std::string> DsymHints; std::vector<std::string> DsymHints;
Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName, Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,
bool UseSymbolTable = true, bool Demangle = true, bool UseSymbolTable = true, bool Demangle = true,
bool RelativeAddresses = false, std::string DefaultArch = "") bool RelativeAddresses = false, std::string DefaultArch = "")
@ -45,6 +52,7 @@ public:
}; };
LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {} LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}
~LLVMSymbolizer() { ~LLVMSymbolizer() {
flush(); flush();
} }
@ -56,6 +64,7 @@ public:
Expected<DIGlobal> symbolizeData(const std::string &ModuleName, Expected<DIGlobal> symbolizeData(const std::string &ModuleName,
uint64_t ModuleOffset); uint64_t ModuleOffset);
void flush(); void flush();
static std::string static std::string
DemangleName(const std::string &Name, DemangleName(const std::string &Name,
const SymbolizableModule *DbiModuleDescriptor); const SymbolizableModule *DbiModuleDescriptor);
@ -63,7 +72,7 @@ public:
private: private:
// Bundles together object file with code/data and object file with // Bundles together object file with code/data and object file with
// corresponding debug info. These objects can be the same. // corresponding debug info. These objects can be the same.
typedef std::pair<ObjectFile*, ObjectFile*> ObjectPair; using ObjectPair = std::pair<ObjectFile *, ObjectFile *>;
/// Returns a SymbolizableModule or an error if loading debug info failed. /// Returns a SymbolizableModule or an error if loading debug info failed.
/// Only one attempt is made to load a module, and errors during loading are /// Only one attempt is made to load a module, and errors during loading are
@ -106,7 +115,7 @@ private:
Options Opts; Options Opts;
}; };
} // namespace symbolize } // end namespace symbolize
} // namespace llvm } // end namespace llvm
#endif #endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H

View File

@ -13,6 +13,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
@ -36,7 +37,6 @@
#include "llvm/Object/RelocVisitor.h" #include "llvm/Object/RelocVisitor.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "llvm/Support/DataExtractor.h" #include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
@ -44,8 +44,8 @@
#include <algorithm> #include <algorithm>
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <set>
#include <string> #include <string>
#include <tuple>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -55,9 +55,9 @@ using namespace object;
#define DEBUG_TYPE "dwarf" #define DEBUG_TYPE "dwarf"
typedef DWARFDebugLine::LineTable DWARFLineTable; using DWARFLineTable = DWARFDebugLine::LineTable;
typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind; using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind;
typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind; using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
uint64_t llvm::getRelocatedValue(const DataExtractor &Data, uint32_t Size, uint64_t llvm::getRelocatedValue(const DataExtractor &Data, uint32_t Size,
uint32_t *Off, const RelocAddrMap *Relocs, uint32_t *Off, const RelocAddrMap *Relocs,
@ -201,8 +201,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
} }
} }
void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts){ void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
DIDumpType DumpType = DumpOpts.DumpType; DIDumpType DumpType = DumpOpts.DumpType;
bool DumpEH = DumpOpts.DumpEH; bool DumpEH = DumpOpts.DumpEH;
bool SummarizeTypes = DumpOpts.SummarizeTypes; bool SummarizeTypes = DumpOpts.SummarizeTypes;
@ -1068,7 +1067,7 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
errs() << "error: failed to compute relocation: " << Name << "\n"; errs() << "error: failed to compute relocation: " << Name << "\n";
continue; continue;
} }
llvm::RelocAddrEntry Rel = {SymInfoOrErr->SectionIndex, Val}; RelocAddrEntry Rel = {SymInfoOrErr->SectionIndex, Val};
Map->insert({Reloc.getOffset(), Rel}); Map->insert({Reloc.getOffset(), Rel});
} }
} }

View File

@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
@ -71,7 +70,7 @@ protected:
/// An entry may contain CFI instructions. An instruction consists of an /// An entry may contain CFI instructions. An instruction consists of an
/// opcode and an optional sequence of operands. /// opcode and an optional sequence of operands.
typedef std::vector<uint64_t> Operands; using Operands = std::vector<uint64_t>;
struct Instruction { struct Instruction {
Instruction(uint8_t Opcode) Instruction(uint8_t Opcode)
: Opcode(Opcode) : Opcode(Opcode)

View File

@ -9,6 +9,8 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
@ -26,13 +28,17 @@
using namespace llvm; using namespace llvm;
using namespace dwarf; using namespace dwarf;
typedef DILineInfoSpecifier::FileLineInfoKind FileLineInfoKind; using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind;
namespace { namespace {
struct ContentDescriptor { struct ContentDescriptor {
dwarf::LineNumberEntryFormat Type; dwarf::LineNumberEntryFormat Type;
dwarf::Form Form; dwarf::Form Form;
}; };
typedef SmallVector<ContentDescriptor, 4> ContentDescriptors;
using ContentDescriptors = SmallVector<ContentDescriptor, 4>;
} // end anonmyous namespace } // end anonmyous namespace
DWARFDebugLine::Prologue::Prologue() { clear(); } DWARFDebugLine::Prologue::Prologue() { clear(); }
@ -333,7 +339,7 @@ void DWARFDebugLine::LineTable::clear() {
} }
DWARFDebugLine::ParsingState::ParsingState(struct LineTable *LT) DWARFDebugLine::ParsingState::ParsingState(struct LineTable *LT)
: LineTable(LT), RowNumber(0) { : LineTable(LT) {
resetRowAndSequence(); resetRowAndSequence();
} }

View File

@ -1,4 +1,4 @@
//===-- DWARFUnit.cpp -----------------------------------------------------===// //===- DWARFUnit.cpp ------------------------------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
@ -17,8 +16,6 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataExtractor.h" #include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include <algorithm> #include <algorithm>
@ -26,6 +23,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstdio> #include <cstdio>
#include <utility>
#include <vector> #include <vector>
using namespace llvm; using namespace llvm;
@ -55,8 +53,8 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
const DWARFUnitIndex::Entry *IndexEntry) const DWARFUnitIndex::Entry *IndexEntry)
: Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS), : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
LineSection(LS), StringSection(SS), StringOffsetSection(SOS), LineSection(LS), StringSection(SS), StringOffsetSection(SOS),
StringOffsetSectionBase(0), AddrOffsetSection(AOS), isLittleEndian(LE), AddrOffsetSection(AOS), isLittleEndian(LE), isDWO(IsDWO),
isDWO(IsDWO), UnitSection(UnitSection), IndexEntry(IndexEntry) { UnitSection(UnitSection), IndexEntry(IndexEntry) {
clear(); clear();
} }

View File

@ -1,3 +1,4 @@
//===- MSFBuilder.cpp -----------------------------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -6,22 +7,30 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MSFError.h" #include "llvm/DebugInfo/MSF/MSFError.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <memory>
#include <utility>
#include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
using namespace llvm::support; using namespace llvm::support;
namespace { static const uint32_t kSuperBlockBlock = 0;
const uint32_t kSuperBlockBlock = 0; static const uint32_t kFreePageMap0Block = 1;
const uint32_t kFreePageMap0Block = 1; static const uint32_t kFreePageMap1Block = 2;
const uint32_t kFreePageMap1Block = 2; static const uint32_t kNumReservedPages = 3;
const uint32_t kNumReservedPages = 3;
const uint32_t kDefaultFreePageMap = kFreePageMap0Block; static const uint32_t kDefaultFreePageMap = kFreePageMap0Block;
const uint32_t kDefaultBlockMapAddr = kNumReservedPages; static const uint32_t kDefaultBlockMapAddr = kNumReservedPages;
}
MSFBuilder::MSFBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, MSFBuilder::MSFBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow,
BumpPtrAllocator &Allocator) BumpPtrAllocator &Allocator)
@ -263,7 +272,7 @@ Expected<MSFLayout> MSFBuilder::build() {
// The stream sizes should be re-allocated as a stable pointer and the stream // The stream sizes should be re-allocated as a stable pointer and the stream
// map should have each of its entries allocated as a separate stable pointer. // map should have each of its entries allocated as a separate stable pointer.
if (StreamData.size() > 0) { if (!StreamData.empty()) {
ulittle32_t *Sizes = Allocator.Allocate<ulittle32_t>(StreamData.size()); ulittle32_t *Sizes = Allocator.Allocate<ulittle32_t>(StreamData.size());
L.StreamSizes = ArrayRef<ulittle32_t>(Sizes, StreamData.size()); L.StreamSizes = ArrayRef<ulittle32_t>(Sizes, StreamData.size());
L.StreamMap.resize(StreamData.size()); L.StreamMap.resize(StreamData.size());

View File

@ -1,4 +1,4 @@
//===- MSFCommon.cpp - Common types and functions for MSF files -*- C++ -*-===// //===- MSFCommon.cpp - Common types and functions for MSF files -----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -9,6 +9,10 @@
#include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MSFCommon.h"
#include "llvm/DebugInfo/MSF/MSFError.h" #include "llvm/DebugInfo/MSF/MSFError.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <cstring>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;

View File

@ -8,23 +8,33 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/MSF/IMSFFile.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MSFCommon.h"
#include "llvm/DebugInfo/MSF/MSFStreamLayout.h" #include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
#include "llvm/Support/BinaryStreamError.h" #include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <utility>
#include <vector>
using namespace llvm; using namespace llvm;
using namespace llvm::msf; using namespace llvm::msf;
namespace { namespace {
template <typename Base> class MappedBlockStreamImpl : public Base { template <typename Base> class MappedBlockStreamImpl : public Base {
public: public:
template <typename... Args> template <typename... Args>
MappedBlockStreamImpl(Args &&... Params) MappedBlockStreamImpl(Args &&... Params)
: Base(std::forward<Args>(Params)...) {} : Base(std::forward<Args>(Params)...) {}
}; };
}
} // end anonymous namespace
static void initializeFpmStreamLayout(const MSFLayout &Layout, static void initializeFpmStreamLayout(const MSFLayout &Layout,
MSFStreamLayout &FpmLayout) { MSFStreamLayout &FpmLayout) {
@ -39,7 +49,8 @@ static void initializeFpmStreamLayout(const MSFLayout &Layout,
FpmLayout.Length = msf::getFullFpmByteSize(Layout); FpmLayout.Length = msf::getFullFpmByteSize(Layout);
} }
typedef std::pair<uint32_t, uint32_t> Interval; using Interval = std::pair<uint32_t, uint32_t>;
static Interval intersect(const Interval &I1, const Interval &I2) { static Interval intersect(const Interval &I1, const Interval &I2) {
return std::make_pair(std::max(I1.first, I2.first), return std::make_pair(std::max(I1.first, I2.first),
std::min(I1.second, I2.second)); std::min(I1.second, I2.second));
@ -214,7 +225,7 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size,
uint32_t OffsetInBlock = Offset % BlockSize; uint32_t OffsetInBlock = Offset % BlockSize;
uint32_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock); uint32_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock);
uint32_t NumAdditionalBlocks = uint32_t NumAdditionalBlocks =
llvm::alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize; alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize;
uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1; uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1;
uint32_t E = StreamLayout.Blocks[BlockNum]; uint32_t E = StreamLayout.Blocks[BlockNum];