diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:23:40 +0000 |
| commit | bdbe302c3396ceb4dd89d1214485439598f05368 (patch) | |
| tree | ccf66c6349b23061ed5e9645c21f15fbe718da8b /contrib/llvm-project/llvm/lib/DebugInfo/CodeView | |
| parent | e7a1904fe1ced461b2a31f03b6592ae6564a243a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/DebugInfo/CodeView')
10 files changed, 72 insertions, 13 deletions
diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp index 689c643a7006..3cafa3a93a0d 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp @@ -185,7 +185,7 @@ Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader &Reader) { struct FieldListVisitHelper { FieldListVisitHelper(TypeVisitorCallbacks &Callbacks, ArrayRef<uint8_t> Data, VisitorDataSource Source) - : Stream(Data, llvm::support::little), Reader(Stream), + : Stream(Data, llvm::endianness::little), Reader(Stream), Deserializer(Reader), Visitor((Source == VDS_BytesPresent) ? Pipeline : Callbacks) { if (Source == VDS_BytesPresent) { diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/EnumTables.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/EnumTables.cpp index b2f0099bd01c..7e3087373bfa 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/EnumTables.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/EnumTables.cpp @@ -434,6 +434,20 @@ static const EnumEntry<uint16_t> LabelTypeEnum[] = { CV_ENUM_CLASS_ENT(LabelType, Far), }; +static const EnumEntry<uint16_t> JumpTableEntrySizeNames[] = { + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Int8), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, UInt8), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Int16), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, UInt16), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Int32), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, UInt32), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Pointer), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, UInt8ShiftLeft), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, UInt16ShiftLeft), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Int8ShiftLeft), + CV_ENUM_CLASS_ENT(JumpTableEntrySize, Int16ShiftLeft), +}; + namespace llvm { namespace codeview { @@ -559,5 +573,9 @@ ArrayRef<EnumEntry<uint16_t>> getLabelTypeEnum() { return ArrayRef(LabelTypeEnum); } +ArrayRef<EnumEntry<uint16_t>> getJumpTableEntrySizeNames() { + return ArrayRef(JumpTableEntrySizeNames); +} + } // end namespace codeview } // end namespace llvm diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp index 460f95d96a29..e59a0197d650 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp @@ -15,7 +15,6 @@ #include "llvm/DebugInfo/CodeView/RecordName.h" #include "llvm/DebugInfo/CodeView/RecordSerialization.h" #include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include <algorithm> #include <cassert> @@ -69,13 +68,13 @@ void LazyRandomTypeCollection::reset(BinaryStreamReader &Reader, } void LazyRandomTypeCollection::reset(StringRef Data, uint32_t RecordCountHint) { - BinaryStreamReader Reader(Data, support::little); + BinaryStreamReader Reader(Data, llvm::endianness::little); reset(Reader, RecordCountHint); } void LazyRandomTypeCollection::reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint) { - BinaryStreamReader Reader(Data, support::little); + BinaryStreamReader Reader(Data, llvm::endianness::little); reset(Reader, RecordCountHint); } diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordName.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordName.cpp index 5fbbc4a5d497..e06b036ede63 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordName.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordName.cpp @@ -324,7 +324,7 @@ StringRef llvm::codeview::getSymbolName(CVSymbol Sym) { if (Sym.kind() == SymbolKind::S_CONSTANT) { // S_CONSTANT is preceded by an APSInt, which has a variable length. So we // have to do a full deserialization. - BinaryStreamReader Reader(Sym.content(), llvm::support::little); + BinaryStreamReader Reader(Sym.content(), llvm::endianness::little); // The container doesn't matter for single records. SymbolRecordMapping Mapping(Reader, CodeViewContainer::ObjectFile); ConstantSym Const(SymbolKind::S_CONSTANT); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp index d76905df8681..032704478ffe 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/RecordSerialization.cpp @@ -103,7 +103,7 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, APSInt &Num) { Error llvm::codeview::consume(StringRef &Data, APSInt &Num) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes, llvm::support::little); + BinaryByteStream S(Bytes, llvm::endianness::little); BinaryStreamReader SR(S); auto EC = consume(SR, Num); Data = Data.take_back(SR.bytesRemaining()); @@ -129,7 +129,7 @@ Error llvm::codeview::consume(BinaryStreamReader &Reader, uint32_t &Item) { Error llvm::codeview::consume(StringRef &Data, uint32_t &Item) { ArrayRef<uint8_t> Bytes(Data.bytes_begin(), Data.bytes_end()); - BinaryByteStream S(Bytes, llvm::support::little); + BinaryByteStream S(Bytes, llvm::endianness::little); BinaryStreamReader SR(S); auto EC = consume(SR, Item); Data = Data.take_back(SR.bytesRemaining()); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp index cf0c877fdbf8..25725853fb39 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp @@ -34,7 +34,7 @@ SimpleTypeSerializer::~SimpleTypeSerializer() = default; template <typename T> ArrayRef<uint8_t> SimpleTypeSerializer::serialize(T &Record) { - BinaryStreamWriter Writer(ScratchBuffer, support::little); + BinaryStreamWriter Writer(ScratchBuffer, llvm::endianness::little); TypeRecordMapping Mapping(Writer); // Write the record prefix first with a dummy length but real kind. diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp index cfb12dbae845..f56739db7c75 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -589,7 +589,22 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { - ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers"); + llvm::StringRef ScopeName; + switch (CVR.kind()) { + case S_CALLEES: + ScopeName = "Callees"; + break; + case S_CALLERS: + ScopeName = "Callers"; + break; + case S_INLINEES: + ScopeName = "Inlinees"; + break; + default: + return llvm::make_error<CodeViewError>( + "Unknown CV Record type for a CallerSym object!"); + } + ListScope S(W, ScopeName); for (auto FuncID : Caller.Indices) printTypeIndex("FuncID", FuncID); return Error::success(); @@ -643,6 +658,20 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, return Error::success(); } +Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, + JumpTableSym &JumpTable) { + W.printHex("BaseOffset", JumpTable.BaseOffset); + W.printNumber("BaseSegment", JumpTable.BaseSegment); + W.printEnum("SwitchType", static_cast<uint16_t>(JumpTable.SwitchType), + getJumpTableEntrySizeNames()); + W.printHex("BranchOffset", JumpTable.BranchOffset); + W.printHex("TableOffset", JumpTable.TableOffset); + W.printNumber("BranchSegment", JumpTable.BranchSegment); + W.printNumber("TableSegment", JumpTable.TableSegment); + W.printNumber("EntriesCount", JumpTable.EntriesCount); + return Error::success(); +} + Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) { W.printNumber("Length", CVR.length()); return Error::success(); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp index 3b627930e271..b5e366b965a9 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp @@ -483,6 +483,19 @@ Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, return Error::success(); } +Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, + JumpTableSym &JumpTable) { + error(IO.mapInteger(JumpTable.BaseOffset)); + error(IO.mapInteger(JumpTable.BaseSegment)); + error(IO.mapEnum(JumpTable.SwitchType)); + error(IO.mapInteger(JumpTable.BranchOffset)); + error(IO.mapInteger(JumpTable.TableOffset)); + error(IO.mapInteger(JumpTable.BranchSegment)); + error(IO.mapInteger(JumpTable.TableSegment)); + error(IO.mapInteger(JumpTable.EntriesCount)); + return Error::success(); +} + RegisterId codeview::decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU) { assert(unsigned(EncodedReg) < 4); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp index 5fb8d497b957..eadc50f2da80 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -8,7 +8,6 @@ #include "llvm/DebugInfo/CodeView/SymbolSerializer.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include <cassert> @@ -20,8 +19,8 @@ using namespace llvm::codeview; SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator, CodeViewContainer Container) - : Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream), - Mapping(Writer, Container) {} + : Storage(Allocator), Stream(RecordBuffer, llvm::endianness::little), + Writer(Stream), Mapping(Writer, Container) {} Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) { assert(!CurrentSymbol && "Already in a symbol mapping!"); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp index 682747a2b81f..59e2a85c4d4c 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -442,6 +442,7 @@ static bool discoverTypeIndices(ArrayRef<uint8_t> Content, SymbolKind Kind, case SymbolKind::S_THUNK32: case SymbolKind::S_FRAMECOOKIE: case SymbolKind::S_UNAMESPACE: + case SymbolKind::S_ARMSWITCHTABLE: break; // Scope ending symbols. case SymbolKind::S_END: @@ -469,7 +470,7 @@ static void resolveTypeIndexReferences(ArrayRef<uint8_t> RecordData, RecordData = RecordData.drop_front(sizeof(RecordPrefix)); - BinaryStreamReader Reader(RecordData, support::little); + BinaryStreamReader Reader(RecordData, llvm::endianness::little); for (const auto &Ref : Refs) { Reader.setOffset(Ref.Offset); FixedStreamArray<TypeIndex> Run; |
