diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/llvm12/include/llvm/DebugInfo | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/DebugInfo')
236 files changed, 28428 insertions, 28428 deletions
diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h index 043adf2390..9e7af58440 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h @@ -1,81 +1,81 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- AppendingTypeTableBuilder.h -------------------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H -#define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Allocator.h" -#include <cassert> -#include <cstdint> -#include <memory> -#include <vector> - -namespace llvm { -namespace codeview { - -class ContinuationRecordBuilder; - -class AppendingTypeTableBuilder : public TypeCollection { - - BumpPtrAllocator &RecordStorage; - SimpleTypeSerializer SimpleSerializer; - - /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). - SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; - -public: - explicit AppendingTypeTableBuilder(BumpPtrAllocator &Storage); - ~AppendingTypeTableBuilder(); - - // TypeCollection overrides - Optional<TypeIndex> getFirst() override; - Optional<TypeIndex> getNext(TypeIndex Prev) override; - CVType getType(TypeIndex Index) override; - StringRef getTypeName(TypeIndex Index) override; - bool contains(TypeIndex Index) override; - uint32_t size() override; - uint32_t capacity() override; - bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; - - // public interface - void reset(); - TypeIndex nextTypeIndex() const; - - BumpPtrAllocator &getAllocator() { return RecordStorage; } - - ArrayRef<ArrayRef<uint8_t>> records() const; - TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record); - TypeIndex insertRecord(ContinuationRecordBuilder &Builder); - - template <typename T> TypeIndex writeLeafType(T &Record) { - ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); - return insertRecordBytes(Data); - } -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- AppendingTypeTableBuilder.h -------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H +#define LLVM_DEBUGINFO_CODEVIEW_APPENDINGTYPETABLEBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/Allocator.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { +namespace codeview { + +class ContinuationRecordBuilder; + +class AppendingTypeTableBuilder : public TypeCollection { + + BumpPtrAllocator &RecordStorage; + SimpleTypeSerializer SimpleSerializer; + + /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). + SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; + +public: + explicit AppendingTypeTableBuilder(BumpPtrAllocator &Storage); + ~AppendingTypeTableBuilder(); + + // TypeCollection overrides + Optional<TypeIndex> getFirst() override; + Optional<TypeIndex> getNext(TypeIndex Prev) override; + CVType getType(TypeIndex Index) override; + StringRef getTypeName(TypeIndex Index) override; + bool contains(TypeIndex Index) override; + uint32_t size() override; + uint32_t capacity() override; + bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; + + // public interface + void reset(); + TypeIndex nextTypeIndex() const; + + BumpPtrAllocator &getAllocator() { return RecordStorage; } + + ArrayRef<ArrayRef<uint8_t>> records() const; + TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record); + TypeIndex insertRecord(ContinuationRecordBuilder &Builder); + + template <typename T> TypeIndex writeLeafType(T &Record) { + ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); + return insertRecordBytes(Data); + } +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVRecord.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVRecord.h index a24b5e7da5..37e2e918e0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVRecord.h @@ -1,145 +1,145 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CVRecord.h -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H -#define LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CVRecord.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H +#define LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> - -namespace llvm { - -namespace codeview { - -/// CVRecord is a fat pointer (base + size pair) to a symbol or type record. -/// Carrying the size separately instead of trusting the size stored in the -/// record prefix provides some extra safety and flexibility. -template <typename Kind> class CVRecord { -public: - CVRecord() = default; - - CVRecord(ArrayRef<uint8_t> Data) : RecordData(Data) {} - - CVRecord(const RecordPrefix *P, size_t Size) - : RecordData(reinterpret_cast<const uint8_t *>(P), Size) {} - - bool valid() const { return kind() != Kind(0); } - - uint32_t length() const { return RecordData.size(); } - - Kind kind() const { - if (RecordData.size() < sizeof(RecordPrefix)) - return Kind(0); - return static_cast<Kind>(static_cast<uint16_t>( - reinterpret_cast<const RecordPrefix *>(RecordData.data())->RecordKind)); - } - - ArrayRef<uint8_t> data() const { return RecordData; } - - StringRef str_data() const { - return StringRef(reinterpret_cast<const char *>(RecordData.data()), - RecordData.size()); - } - - ArrayRef<uint8_t> content() const { - return RecordData.drop_front(sizeof(RecordPrefix)); - } - - ArrayRef<uint8_t> RecordData; -}; - +#include "llvm/DebugInfo/CodeView/CodeViewError.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> + +namespace llvm { + +namespace codeview { + +/// CVRecord is a fat pointer (base + size pair) to a symbol or type record. +/// Carrying the size separately instead of trusting the size stored in the +/// record prefix provides some extra safety and flexibility. +template <typename Kind> class CVRecord { +public: + CVRecord() = default; + + CVRecord(ArrayRef<uint8_t> Data) : RecordData(Data) {} + + CVRecord(const RecordPrefix *P, size_t Size) + : RecordData(reinterpret_cast<const uint8_t *>(P), Size) {} + + bool valid() const { return kind() != Kind(0); } + + uint32_t length() const { return RecordData.size(); } + + Kind kind() const { + if (RecordData.size() < sizeof(RecordPrefix)) + return Kind(0); + return static_cast<Kind>(static_cast<uint16_t>( + reinterpret_cast<const RecordPrefix *>(RecordData.data())->RecordKind)); + } + + ArrayRef<uint8_t> data() const { return RecordData; } + + StringRef str_data() const { + return StringRef(reinterpret_cast<const char *>(RecordData.data()), + RecordData.size()); + } + + ArrayRef<uint8_t> content() const { + return RecordData.drop_front(sizeof(RecordPrefix)); + } + + ArrayRef<uint8_t> RecordData; +}; + // There are two kinds of codeview records: type and symbol records. using CVType = CVRecord<TypeLeafKind>; using CVSymbol = CVRecord<SymbolKind>; - -template <typename Record, typename Func> -Error forEachCodeViewRecord(ArrayRef<uint8_t> StreamBuffer, Func F) { - while (!StreamBuffer.empty()) { - if (StreamBuffer.size() < sizeof(RecordPrefix)) - return make_error<CodeViewError>(cv_error_code::corrupt_record); - - const RecordPrefix *Prefix = - reinterpret_cast<const RecordPrefix *>(StreamBuffer.data()); - - size_t RealLen = Prefix->RecordLen + 2; - if (StreamBuffer.size() < RealLen) - return make_error<CodeViewError>(cv_error_code::corrupt_record); - - ArrayRef<uint8_t> Data = StreamBuffer.take_front(RealLen); - StreamBuffer = StreamBuffer.drop_front(RealLen); - - Record R(Data); - if (auto EC = F(R)) - return EC; - } - return Error::success(); -} - -/// Read a complete record from a stream at a random offset. -template <typename Kind> -inline Expected<CVRecord<Kind>> readCVRecordFromStream(BinaryStreamRef Stream, - uint32_t Offset) { - const RecordPrefix *Prefix = nullptr; - BinaryStreamReader Reader(Stream); - Reader.setOffset(Offset); - - if (auto EC = Reader.readObject(Prefix)) - return std::move(EC); - if (Prefix->RecordLen < 2) - return make_error<CodeViewError>(cv_error_code::corrupt_record); - - Reader.setOffset(Offset); - ArrayRef<uint8_t> RawData; - if (auto EC = Reader.readBytes(RawData, Prefix->RecordLen + sizeof(uint16_t))) - return std::move(EC); - return codeview::CVRecord<Kind>(RawData); -} - -} // end namespace codeview - -template <typename Kind> -struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> { - Error operator()(BinaryStreamRef Stream, uint32_t &Len, - codeview::CVRecord<Kind> &Item) { - auto ExpectedRec = codeview::readCVRecordFromStream<Kind>(Stream, 0); - if (!ExpectedRec) - return ExpectedRec.takeError(); - Item = *ExpectedRec; - Len = ExpectedRec->length(); - return Error::success(); - } -}; - + +template <typename Record, typename Func> +Error forEachCodeViewRecord(ArrayRef<uint8_t> StreamBuffer, Func F) { + while (!StreamBuffer.empty()) { + if (StreamBuffer.size() < sizeof(RecordPrefix)) + return make_error<CodeViewError>(cv_error_code::corrupt_record); + + const RecordPrefix *Prefix = + reinterpret_cast<const RecordPrefix *>(StreamBuffer.data()); + + size_t RealLen = Prefix->RecordLen + 2; + if (StreamBuffer.size() < RealLen) + return make_error<CodeViewError>(cv_error_code::corrupt_record); + + ArrayRef<uint8_t> Data = StreamBuffer.take_front(RealLen); + StreamBuffer = StreamBuffer.drop_front(RealLen); + + Record R(Data); + if (auto EC = F(R)) + return EC; + } + return Error::success(); +} + +/// Read a complete record from a stream at a random offset. +template <typename Kind> +inline Expected<CVRecord<Kind>> readCVRecordFromStream(BinaryStreamRef Stream, + uint32_t Offset) { + const RecordPrefix *Prefix = nullptr; + BinaryStreamReader Reader(Stream); + Reader.setOffset(Offset); + + if (auto EC = Reader.readObject(Prefix)) + return std::move(EC); + if (Prefix->RecordLen < 2) + return make_error<CodeViewError>(cv_error_code::corrupt_record); + + Reader.setOffset(Offset); + ArrayRef<uint8_t> RawData; + if (auto EC = Reader.readBytes(RawData, Prefix->RecordLen + sizeof(uint16_t))) + return std::move(EC); + return codeview::CVRecord<Kind>(RawData); +} + +} // end namespace codeview + +template <typename Kind> +struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> { + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + codeview::CVRecord<Kind> &Item) { + auto ExpectedRec = codeview::readCVRecordFromStream<Kind>(Stream, 0); + if (!ExpectedRec) + return ExpectedRec.takeError(); + Item = *ExpectedRec; + Len = ExpectedRec->length(); + return Error::success(); + } +}; + namespace codeview { using CVSymbolArray = VarStreamArray<CVSymbol>; using CVTypeArray = VarStreamArray<CVType>; using CVTypeRange = iterator_range<CVTypeArray::Iterator>; } // namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h index 854f6f35eb..7f85014919 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CVSymbolVisitor.h ----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H -#define LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H - -#include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/Support/ErrorOr.h" - -namespace llvm { -namespace codeview { -class SymbolVisitorCallbacks; - -class CVSymbolVisitor { -public: - CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks); - - Error visitSymbolRecord(CVSymbol &Record); - Error visitSymbolRecord(CVSymbol &Record, uint32_t Offset); - Error visitSymbolStream(const CVSymbolArray &Symbols); - Error visitSymbolStream(const CVSymbolArray &Symbols, uint32_t InitialOffset); - -private: - SymbolVisitorCallbacks &Callbacks; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CVSymbolVisitor.h ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H +#define LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H + +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/Support/ErrorOr.h" + +namespace llvm { +namespace codeview { +class SymbolVisitorCallbacks; + +class CVSymbolVisitor { +public: + CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks); + + Error visitSymbolRecord(CVSymbol &Record); + Error visitSymbolRecord(CVSymbol &Record, uint32_t Offset); + Error visitSymbolStream(const CVSymbolArray &Symbols); + Error visitSymbolStream(const CVSymbolArray &Symbols, uint32_t InitialOffset); + +private: + SymbolVisitorCallbacks &Callbacks; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h index 205e9cc7e8..dc379fde94 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CVTypeVisitor.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H -#define LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H - -#include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -class TypeCollection; -class TypeVisitorCallbacks; - -enum VisitorDataSource { - VDS_BytesPresent, // The record bytes are passed into the visitation - // function. The algorithm should first deserialize them - // before passing them on through the pipeline. - VDS_BytesExternal // The record bytes are not present, and it is the - // responsibility of the visitor callback interface to - // supply the bytes. -}; - -Error visitTypeRecord(CVType &Record, TypeIndex Index, - TypeVisitorCallbacks &Callbacks, - VisitorDataSource Source = VDS_BytesPresent); -Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks, - VisitorDataSource Source = VDS_BytesPresent); - -Error visitMemberRecord(CVMemberRecord Record, TypeVisitorCallbacks &Callbacks, - VisitorDataSource Source = VDS_BytesPresent); -Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record, - TypeVisitorCallbacks &Callbacks); - -Error visitMemberRecordStream(ArrayRef<uint8_t> FieldList, - TypeVisitorCallbacks &Callbacks); - -Error visitTypeStream(const CVTypeArray &Types, TypeVisitorCallbacks &Callbacks, - VisitorDataSource Source = VDS_BytesPresent); -Error visitTypeStream(CVTypeRange Types, TypeVisitorCallbacks &Callbacks); -Error visitTypeStream(TypeCollection &Types, TypeVisitorCallbacks &Callbacks); - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CVTypeVisitor.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H +#define LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H + +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class TypeCollection; +class TypeVisitorCallbacks; + +enum VisitorDataSource { + VDS_BytesPresent, // The record bytes are passed into the visitation + // function. The algorithm should first deserialize them + // before passing them on through the pipeline. + VDS_BytesExternal // The record bytes are not present, and it is the + // responsibility of the visitor callback interface to + // supply the bytes. +}; + +Error visitTypeRecord(CVType &Record, TypeIndex Index, + TypeVisitorCallbacks &Callbacks, + VisitorDataSource Source = VDS_BytesPresent); +Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks, + VisitorDataSource Source = VDS_BytesPresent); + +Error visitMemberRecord(CVMemberRecord Record, TypeVisitorCallbacks &Callbacks, + VisitorDataSource Source = VDS_BytesPresent); +Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record, + TypeVisitorCallbacks &Callbacks); + +Error visitMemberRecordStream(ArrayRef<uint8_t> FieldList, + TypeVisitorCallbacks &Callbacks); + +Error visitTypeStream(const CVTypeArray &Types, TypeVisitorCallbacks &Callbacks, + VisitorDataSource Source = VDS_BytesPresent); +Error visitTypeStream(CVTypeRange Types, TypeVisitorCallbacks &Callbacks); +Error visitTypeStream(TypeCollection &Types, TypeVisitorCallbacks &Callbacks); + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeView.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeView.h index 935fca6906..c82a9dc401 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeView.h @@ -1,625 +1,625 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CodeView.h -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Defines constants and basic types describing CodeView debug information. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H -#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H - -#include <cinttypes> -#include <type_traits> - -#include "llvm/Support/Endian.h" - -namespace llvm { -namespace codeview { - -/// Distinguishes individual records in .debug$T or .debug$P section or PDB type -/// stream. The documentation and headers talk about this as the "leaf" type. -enum class TypeRecordKind : uint16_t { -#define TYPE_RECORD(lf_ename, value, name) name = value, -#include "CodeViewTypes.def" -}; - -/// Duplicate copy of the above enum, but using the official CV names. Useful -/// for reference purposes and when dealing with unknown record types. -enum TypeLeafKind : uint16_t { -#define CV_TYPE(name, val) name = val, -#include "CodeViewTypes.def" -}; - -/// Distinguishes individual records in the Symbols subsection of a .debug$S -/// section. Equivalent to SYM_ENUM_e in cvinfo.h. -enum class SymbolRecordKind : uint16_t { -#define SYMBOL_RECORD(lf_ename, value, name) name = value, -#include "CodeViewSymbols.def" -}; - -/// Duplicate copy of the above enum, but using the official CV names. Useful -/// for reference purposes and when dealing with unknown record types. -enum SymbolKind : uint16_t { -#define CV_SYMBOL(name, val) name = val, -#include "CodeViewSymbols.def" -}; - -#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \ - inline Class operator|(Class a, Class b) { \ - return static_cast<Class>( \ - static_cast<std::underlying_type<Class>::type>(a) | \ - static_cast<std::underlying_type<Class>::type>(b)); \ - } \ - inline Class operator&(Class a, Class b) { \ - return static_cast<Class>( \ - static_cast<std::underlying_type<Class>::type>(a) & \ - static_cast<std::underlying_type<Class>::type>(b)); \ - } \ - inline Class operator~(Class a) { \ - return static_cast<Class>( \ - ~static_cast<std::underlying_type<Class>::type>(a)); \ - } \ - inline Class &operator|=(Class &a, Class b) { \ - a = a | b; \ - return a; \ - } \ - inline Class &operator&=(Class &a, Class b) { \ - a = a & b; \ - return a; \ - } - -/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx -enum class CPUType : uint16_t { - Intel8080 = 0x0, - Intel8086 = 0x1, - Intel80286 = 0x2, - Intel80386 = 0x3, - Intel80486 = 0x4, - Pentium = 0x5, - PentiumPro = 0x6, - Pentium3 = 0x7, - MIPS = 0x10, - MIPS16 = 0x11, - MIPS32 = 0x12, - MIPS64 = 0x13, - MIPSI = 0x14, - MIPSII = 0x15, - MIPSIII = 0x16, - MIPSIV = 0x17, - MIPSV = 0x18, - M68000 = 0x20, - M68010 = 0x21, - M68020 = 0x22, - M68030 = 0x23, - M68040 = 0x24, - Alpha = 0x30, - Alpha21164 = 0x31, - Alpha21164A = 0x32, - Alpha21264 = 0x33, - Alpha21364 = 0x34, - PPC601 = 0x40, - PPC603 = 0x41, - PPC604 = 0x42, - PPC620 = 0x43, - PPCFP = 0x44, - PPCBE = 0x45, - SH3 = 0x50, - SH3E = 0x51, - SH3DSP = 0x52, - SH4 = 0x53, - SHMedia = 0x54, - ARM3 = 0x60, - ARM4 = 0x61, - ARM4T = 0x62, - ARM5 = 0x63, - ARM5T = 0x64, - ARM6 = 0x65, - ARM_XMAC = 0x66, - ARM_WMMX = 0x67, - ARM7 = 0x68, - ARM64 = 0x69, - Omni = 0x70, - Ia64 = 0x80, - Ia64_2 = 0x81, - CEE = 0x90, - AM33 = 0xa0, - M32R = 0xb0, - TriCore = 0xc0, - X64 = 0xd0, - EBC = 0xe0, - Thumb = 0xf0, - ARMNT = 0xf4, - D3D11_Shader = 0x100, -}; - -/// These values correspond to the CV_CFL_LANG enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx -enum SourceLanguage : uint8_t { - C = 0x00, - Cpp = 0x01, - Fortran = 0x02, - Masm = 0x03, - Pascal = 0x04, - Basic = 0x05, - Cobol = 0x06, - Link = 0x07, - Cvtres = 0x08, - Cvtpgd = 0x09, - CSharp = 0x0a, - VB = 0x0b, - ILAsm = 0x0c, - Java = 0x0d, - JScript = 0x0e, - MSIL = 0x0f, - HLSL = 0x10, - - /// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV - /// source language. Microsoft does not have enumerators for them yet. - D = 'D', - Swift = 'S', -}; - -/// These values correspond to the CV_call_e enumeration, and are documented -/// at the following locations: -/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx -/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx -/// -enum class CallingConvention : uint8_t { - NearC = 0x00, // near right to left push, caller pops stack - FarC = 0x01, // far right to left push, caller pops stack - NearPascal = 0x02, // near left to right push, callee pops stack - FarPascal = 0x03, // far left to right push, callee pops stack - NearFast = 0x04, // near left to right push with regs, callee pops stack - FarFast = 0x05, // far left to right push with regs, callee pops stack - NearStdCall = 0x07, // near standard call - FarStdCall = 0x08, // far standard call - NearSysCall = 0x09, // near sys call - FarSysCall = 0x0a, // far sys call - ThisCall = 0x0b, // this call (this passed in register) - MipsCall = 0x0c, // Mips call - Generic = 0x0d, // Generic call sequence - AlphaCall = 0x0e, // Alpha call - PpcCall = 0x0f, // PPC call - SHCall = 0x10, // Hitachi SuperH call - ArmCall = 0x11, // ARM call - AM33Call = 0x12, // AM33 call - TriCall = 0x13, // TriCore Call - SH5Call = 0x14, // Hitachi SuperH-5 call - M32RCall = 0x15, // M32R Call - ClrCall = 0x16, // clr call - Inline = - 0x17, // Marker for routines always inlined and thus lacking a convention - NearVector = 0x18 // near left to right push with regs, callee pops stack -}; - -enum class ClassOptions : uint16_t { - None = 0x0000, - Packed = 0x0001, - HasConstructorOrDestructor = 0x0002, - HasOverloadedOperator = 0x0004, - Nested = 0x0008, - ContainsNestedClass = 0x0010, - HasOverloadedAssignmentOperator = 0x0020, - HasConversionOperator = 0x0040, - ForwardReference = 0x0080, - Scoped = 0x0100, - HasUniqueName = 0x0200, - Sealed = 0x0400, - Intrinsic = 0x2000 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions) - -enum class FrameProcedureOptions : uint32_t { - None = 0x00000000, - HasAlloca = 0x00000001, - HasSetJmp = 0x00000002, - HasLongJmp = 0x00000004, - HasInlineAssembly = 0x00000008, - HasExceptionHandling = 0x00000010, - MarkedInline = 0x00000020, - HasStructuredExceptionHandling = 0x00000040, - Naked = 0x00000080, - SecurityChecks = 0x00000100, - AsynchronousExceptionHandling = 0x00000200, - NoStackOrderingForSecurityChecks = 0x00000400, - Inlined = 0x00000800, - StrictSecurityChecks = 0x00001000, - SafeBuffers = 0x00002000, - EncodedLocalBasePointerMask = 0x0000C000, - EncodedParamBasePointerMask = 0x00030000, - ProfileGuidedOptimization = 0x00040000, - ValidProfileCounts = 0x00080000, - OptimizedForSpeed = 0x00100000, - GuardCfg = 0x00200000, - GuardCfw = 0x00400000 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions) - -enum class FunctionOptions : uint8_t { - None = 0x00, - CxxReturnUdt = 0x01, - Constructor = 0x02, - ConstructorWithVirtualBases = 0x04 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions) - -enum class HfaKind : uint8_t { - None = 0x00, - Float = 0x01, - Double = 0x02, - Other = 0x03 -}; - -/// Source-level access specifier. (CV_access_e) -enum class MemberAccess : uint8_t { - None = 0, - Private = 1, - Protected = 2, - Public = 3 -}; - -/// Part of member attribute flags. (CV_methodprop_e) -enum class MethodKind : uint8_t { - Vanilla = 0x00, - Virtual = 0x01, - Static = 0x02, - Friend = 0x03, - IntroducingVirtual = 0x04, - PureVirtual = 0x05, - PureIntroducingVirtual = 0x06 -}; - -/// Equivalent to CV_fldattr_t bitfield. -enum class MethodOptions : uint16_t { - None = 0x0000, - AccessMask = 0x0003, - MethodKindMask = 0x001c, - Pseudo = 0x0020, - NoInherit = 0x0040, - NoConstruct = 0x0080, - CompilerGenerated = 0x0100, - Sealed = 0x0200 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions) - -/// Equivalent to CV_LABEL_TYPE_e. -enum class LabelType : uint16_t { - Near = 0x0, - Far = 0x4, -}; - -/// Equivalent to CV_modifier_t. -/// TODO: Add flag for _Atomic modifier -enum class ModifierOptions : uint16_t { - None = 0x0000, - Const = 0x0001, - Volatile = 0x0002, - Unaligned = 0x0004 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions) - -// If the subsection kind has this bit set, then the linker should ignore it. -enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 }; - -enum class DebugSubsectionKind : uint32_t { - None = 0, - Symbols = 0xf1, - Lines = 0xf2, - StringTable = 0xf3, - FileChecksums = 0xf4, - FrameData = 0xf5, - InlineeLines = 0xf6, - CrossScopeImports = 0xf7, - CrossScopeExports = 0xf8, - - // These appear to relate to .Net assembly info. - ILLines = 0xf9, - FuncMDTokenMap = 0xfa, - TypeMDTokenMap = 0xfb, - MergedAssemblyInput = 0xfc, - - CoffSymbolRVA = 0xfd, -}; - -/// Equivalent to CV_ptrtype_e. -enum class PointerKind : uint8_t { - Near16 = 0x00, // 16 bit pointer - Far16 = 0x01, // 16:16 far pointer - Huge16 = 0x02, // 16:16 huge pointer - BasedOnSegment = 0x03, // based on segment - BasedOnValue = 0x04, // based on value of base - BasedOnSegmentValue = 0x05, // based on segment value of base - BasedOnAddress = 0x06, // based on address of base - BasedOnSegmentAddress = 0x07, // based on segment address of base - BasedOnType = 0x08, // based on type - BasedOnSelf = 0x09, // based on self - Near32 = 0x0a, // 32 bit pointer - Far32 = 0x0b, // 16:32 pointer - Near64 = 0x0c // 64 bit pointer -}; - -/// Equivalent to CV_ptrmode_e. -enum class PointerMode : uint8_t { - Pointer = 0x00, // "normal" pointer - LValueReference = 0x01, // "old" reference - PointerToDataMember = 0x02, // pointer to data member - PointerToMemberFunction = 0x03, // pointer to member function - RValueReference = 0x04 // r-value reference -}; - -/// Equivalent to misc lfPointerAttr bitfields. -enum class PointerOptions : uint32_t { - None = 0x00000000, - Flat32 = 0x00000100, - Volatile = 0x00000200, - Const = 0x00000400, - Unaligned = 0x00000800, - Restrict = 0x00001000, - WinRTSmartPointer = 0x00080000, - LValueRefThisPointer = 0x00100000, - RValueRefThisPointer = 0x00200000 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions) - -/// Equivalent to CV_pmtype_e. -enum class PointerToMemberRepresentation : uint16_t { - Unknown = 0x00, // not specified (pre VC8) - SingleInheritanceData = 0x01, // member data, single inheritance - MultipleInheritanceData = 0x02, // member data, multiple inheritance - VirtualInheritanceData = 0x03, // member data, virtual inheritance - GeneralData = 0x04, // member data, most general - SingleInheritanceFunction = 0x05, // member function, single inheritance - MultipleInheritanceFunction = 0x06, // member function, multiple inheritance - VirtualInheritanceFunction = 0x07, // member function, virtual inheritance - GeneralFunction = 0x08 // member function, most general -}; - -enum class VFTableSlotKind : uint8_t { - Near16 = 0x00, - Far16 = 0x01, - This = 0x02, - Outer = 0x03, - Meta = 0x04, - Near = 0x05, - Far = 0x06 -}; - -enum class WindowsRTClassKind : uint8_t { - None = 0x00, - RefClass = 0x01, - ValueClass = 0x02, - Interface = 0x03 -}; - -/// Corresponds to CV_LVARFLAGS bitfield. -enum class LocalSymFlags : uint16_t { - None = 0, - IsParameter = 1 << 0, - IsAddressTaken = 1 << 1, - IsCompilerGenerated = 1 << 2, - IsAggregate = 1 << 3, - IsAggregated = 1 << 4, - IsAliased = 1 << 5, - IsAlias = 1 << 6, - IsReturnValue = 1 << 7, - IsOptimizedOut = 1 << 8, - IsEnregisteredGlobal = 1 << 9, - IsEnregisteredStatic = 1 << 10, -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags) - -/// Corresponds to the CV_PUBSYMFLAGS bitfield. -enum class PublicSymFlags : uint32_t { - None = 0, - Code = 1 << 0, - Function = 1 << 1, - Managed = 1 << 2, - MSIL = 1 << 3, -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags) - -/// Corresponds to the CV_PROCFLAGS bitfield. -enum class ProcSymFlags : uint8_t { - None = 0, - HasFP = 1 << 0, - HasIRET = 1 << 1, - HasFRET = 1 << 2, - IsNoReturn = 1 << 3, - IsUnreachable = 1 << 4, - HasCustomCallingConv = 1 << 5, - IsNoInline = 1 << 6, - HasOptimizedDebugInfo = 1 << 7, -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags) - -/// Corresponds to COMPILESYM2::Flags bitfield. -enum class CompileSym2Flags : uint32_t { - None = 0, - SourceLanguageMask = 0xFF, - EC = 1 << 8, - NoDbgInfo = 1 << 9, - LTCG = 1 << 10, - NoDataAlign = 1 << 11, - ManagedPresent = 1 << 12, - SecurityChecks = 1 << 13, - HotPatch = 1 << 14, - CVTCIL = 1 << 15, - MSILModule = 1 << 16, -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags) - -/// Corresponds to COMPILESYM3::Flags bitfield. -enum class CompileSym3Flags : uint32_t { - None = 0, - SourceLanguageMask = 0xFF, - EC = 1 << 8, - NoDbgInfo = 1 << 9, - LTCG = 1 << 10, - NoDataAlign = 1 << 11, - ManagedPresent = 1 << 12, - SecurityChecks = 1 << 13, - HotPatch = 1 << 14, - CVTCIL = 1 << 15, - MSILModule = 1 << 16, - Sdl = 1 << 17, - PGO = 1 << 18, - Exp = 1 << 19, -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags) - -enum class ExportFlags : uint16_t { - None = 0, - IsConstant = 1 << 0, - IsData = 1 << 1, - IsPrivate = 1 << 2, - HasNoName = 1 << 3, - HasExplicitOrdinal = 1 << 4, - IsForwarder = 1 << 5 -}; -CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags) - -// Corresponds to BinaryAnnotationOpcode enum. -enum class BinaryAnnotationsOpCode : uint32_t { - Invalid, - CodeOffset, - ChangeCodeOffsetBase, - ChangeCodeOffset, - ChangeCodeLength, - ChangeFile, - ChangeLineOffset, - ChangeLineEndDelta, - ChangeRangeKind, - ChangeColumnStart, - ChangeColumnEndDelta, - ChangeCodeOffsetAndLineOffset, - ChangeCodeLengthAndCodeOffset, - ChangeColumnEnd, -}; - -// Corresponds to CV_cookietype_e enum. -enum class FrameCookieKind : uint8_t { - Copy, - XorStackPointer, - XorFramePointer, - XorR13, -}; - -// Corresponds to CV_HREG_e enum. -enum class RegisterId : uint16_t { -#define CV_REGISTERS_ALL -#define CV_REGISTER(name, value) name = value, -#include "CodeViewRegisters.def" -#undef CV_REGISTER -#undef CV_REGISTERS_ALL -}; - -// Register Ids are shared between architectures in CodeView. CPUType is needed -// to map register Id to name. -struct CPURegister { - CPURegister() = delete; - CPURegister(CPUType Cpu, codeview::RegisterId Reg) { - this->Cpu = Cpu; - this->Reg = Reg; - } - CPUType Cpu; - RegisterId Reg; -}; - -/// Two-bit value indicating which register is the designated frame pointer -/// register. Appears in the S_FRAMEPROC record flags. -enum class EncodedFramePtrReg : uint8_t { - None = 0, - StackPtr = 1, - FramePtr = 2, - BasePtr = 3, -}; - -RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU); - -EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU); - -/// These values correspond to the THUNK_ORDINAL enumeration. -enum class ThunkOrdinal : uint8_t { - Standard, - ThisAdjustor, - Vcall, - Pcode, - UnknownLoad, - TrampIncremental, - BranchIsland -}; - -enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland }; - -// These values correspond to the CV_SourceChksum_t enumeration. -enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 }; - -enum LineFlags : uint16_t { - LF_None = 0, - LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS -}; - -/// Data in the SUBSEC_FRAMEDATA subection. -struct FrameData { - support::ulittle32_t RvaStart; - support::ulittle32_t CodeSize; - support::ulittle32_t LocalSize; - support::ulittle32_t ParamsSize; - support::ulittle32_t MaxStackSize; - support::ulittle32_t FrameFunc; - support::ulittle16_t PrologSize; - support::ulittle16_t SavedRegsSize; - support::ulittle32_t Flags; - enum : uint32_t { - HasSEH = 1 << 0, - HasEH = 1 << 1, - IsFunctionStart = 1 << 2, - }; -}; - -// Corresponds to LocalIdAndGlobalIdPair structure. -// This structure information allows cross-referencing between PDBs. For -// example, when a PDB is being built during compilation it is not yet known -// what other modules may end up in the PDB at link time. So certain types of -// IDs may clash between the various compile time PDBs. For each affected -// module, a subsection would be put into the PDB containing a mapping from its -// local IDs to a single ID namespace for all items in the PDB file. -struct CrossModuleExport { - support::ulittle32_t Local; - support::ulittle32_t Global; -}; - -struct CrossModuleImport { - support::ulittle32_t ModuleNameOffset; - support::ulittle32_t Count; // Number of elements - // support::ulittle32_t ids[Count]; // id from referenced module -}; - -enum class CodeViewContainer { ObjectFile, Pdb }; - -inline uint32_t alignOf(CodeViewContainer Container) { - if (Container == CodeViewContainer::ObjectFile) - return 1; - return 4; -} -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CodeView.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Defines constants and basic types describing CodeView debug information. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H +#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H + +#include <cinttypes> +#include <type_traits> + +#include "llvm/Support/Endian.h" + +namespace llvm { +namespace codeview { + +/// Distinguishes individual records in .debug$T or .debug$P section or PDB type +/// stream. The documentation and headers talk about this as the "leaf" type. +enum class TypeRecordKind : uint16_t { +#define TYPE_RECORD(lf_ename, value, name) name = value, +#include "CodeViewTypes.def" +}; + +/// Duplicate copy of the above enum, but using the official CV names. Useful +/// for reference purposes and when dealing with unknown record types. +enum TypeLeafKind : uint16_t { +#define CV_TYPE(name, val) name = val, +#include "CodeViewTypes.def" +}; + +/// Distinguishes individual records in the Symbols subsection of a .debug$S +/// section. Equivalent to SYM_ENUM_e in cvinfo.h. +enum class SymbolRecordKind : uint16_t { +#define SYMBOL_RECORD(lf_ename, value, name) name = value, +#include "CodeViewSymbols.def" +}; + +/// Duplicate copy of the above enum, but using the official CV names. Useful +/// for reference purposes and when dealing with unknown record types. +enum SymbolKind : uint16_t { +#define CV_SYMBOL(name, val) name = val, +#include "CodeViewSymbols.def" +}; + +#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \ + inline Class operator|(Class a, Class b) { \ + return static_cast<Class>( \ + static_cast<std::underlying_type<Class>::type>(a) | \ + static_cast<std::underlying_type<Class>::type>(b)); \ + } \ + inline Class operator&(Class a, Class b) { \ + return static_cast<Class>( \ + static_cast<std::underlying_type<Class>::type>(a) & \ + static_cast<std::underlying_type<Class>::type>(b)); \ + } \ + inline Class operator~(Class a) { \ + return static_cast<Class>( \ + ~static_cast<std::underlying_type<Class>::type>(a)); \ + } \ + inline Class &operator|=(Class &a, Class b) { \ + a = a | b; \ + return a; \ + } \ + inline Class &operator&=(Class &a, Class b) { \ + a = a & b; \ + return a; \ + } + +/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +enum class CPUType : uint16_t { + Intel8080 = 0x0, + Intel8086 = 0x1, + Intel80286 = 0x2, + Intel80386 = 0x3, + Intel80486 = 0x4, + Pentium = 0x5, + PentiumPro = 0x6, + Pentium3 = 0x7, + MIPS = 0x10, + MIPS16 = 0x11, + MIPS32 = 0x12, + MIPS64 = 0x13, + MIPSI = 0x14, + MIPSII = 0x15, + MIPSIII = 0x16, + MIPSIV = 0x17, + MIPSV = 0x18, + M68000 = 0x20, + M68010 = 0x21, + M68020 = 0x22, + M68030 = 0x23, + M68040 = 0x24, + Alpha = 0x30, + Alpha21164 = 0x31, + Alpha21164A = 0x32, + Alpha21264 = 0x33, + Alpha21364 = 0x34, + PPC601 = 0x40, + PPC603 = 0x41, + PPC604 = 0x42, + PPC620 = 0x43, + PPCFP = 0x44, + PPCBE = 0x45, + SH3 = 0x50, + SH3E = 0x51, + SH3DSP = 0x52, + SH4 = 0x53, + SHMedia = 0x54, + ARM3 = 0x60, + ARM4 = 0x61, + ARM4T = 0x62, + ARM5 = 0x63, + ARM5T = 0x64, + ARM6 = 0x65, + ARM_XMAC = 0x66, + ARM_WMMX = 0x67, + ARM7 = 0x68, + ARM64 = 0x69, + Omni = 0x70, + Ia64 = 0x80, + Ia64_2 = 0x81, + CEE = 0x90, + AM33 = 0xa0, + M32R = 0xb0, + TriCore = 0xc0, + X64 = 0xd0, + EBC = 0xe0, + Thumb = 0xf0, + ARMNT = 0xf4, + D3D11_Shader = 0x100, +}; + +/// These values correspond to the CV_CFL_LANG enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx +enum SourceLanguage : uint8_t { + C = 0x00, + Cpp = 0x01, + Fortran = 0x02, + Masm = 0x03, + Pascal = 0x04, + Basic = 0x05, + Cobol = 0x06, + Link = 0x07, + Cvtres = 0x08, + Cvtpgd = 0x09, + CSharp = 0x0a, + VB = 0x0b, + ILAsm = 0x0c, + Java = 0x0d, + JScript = 0x0e, + MSIL = 0x0f, + HLSL = 0x10, + + /// The DMD & Swift compilers emit 'D' and 'S', respectively, for the CV + /// source language. Microsoft does not have enumerators for them yet. + D = 'D', + Swift = 'S', +}; + +/// These values correspond to the CV_call_e enumeration, and are documented +/// at the following locations: +/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx +/// +enum class CallingConvention : uint8_t { + NearC = 0x00, // near right to left push, caller pops stack + FarC = 0x01, // far right to left push, caller pops stack + NearPascal = 0x02, // near left to right push, callee pops stack + FarPascal = 0x03, // far left to right push, callee pops stack + NearFast = 0x04, // near left to right push with regs, callee pops stack + FarFast = 0x05, // far left to right push with regs, callee pops stack + NearStdCall = 0x07, // near standard call + FarStdCall = 0x08, // far standard call + NearSysCall = 0x09, // near sys call + FarSysCall = 0x0a, // far sys call + ThisCall = 0x0b, // this call (this passed in register) + MipsCall = 0x0c, // Mips call + Generic = 0x0d, // Generic call sequence + AlphaCall = 0x0e, // Alpha call + PpcCall = 0x0f, // PPC call + SHCall = 0x10, // Hitachi SuperH call + ArmCall = 0x11, // ARM call + AM33Call = 0x12, // AM33 call + TriCall = 0x13, // TriCore Call + SH5Call = 0x14, // Hitachi SuperH-5 call + M32RCall = 0x15, // M32R Call + ClrCall = 0x16, // clr call + Inline = + 0x17, // Marker for routines always inlined and thus lacking a convention + NearVector = 0x18 // near left to right push with regs, callee pops stack +}; + +enum class ClassOptions : uint16_t { + None = 0x0000, + Packed = 0x0001, + HasConstructorOrDestructor = 0x0002, + HasOverloadedOperator = 0x0004, + Nested = 0x0008, + ContainsNestedClass = 0x0010, + HasOverloadedAssignmentOperator = 0x0020, + HasConversionOperator = 0x0040, + ForwardReference = 0x0080, + Scoped = 0x0100, + HasUniqueName = 0x0200, + Sealed = 0x0400, + Intrinsic = 0x2000 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions) + +enum class FrameProcedureOptions : uint32_t { + None = 0x00000000, + HasAlloca = 0x00000001, + HasSetJmp = 0x00000002, + HasLongJmp = 0x00000004, + HasInlineAssembly = 0x00000008, + HasExceptionHandling = 0x00000010, + MarkedInline = 0x00000020, + HasStructuredExceptionHandling = 0x00000040, + Naked = 0x00000080, + SecurityChecks = 0x00000100, + AsynchronousExceptionHandling = 0x00000200, + NoStackOrderingForSecurityChecks = 0x00000400, + Inlined = 0x00000800, + StrictSecurityChecks = 0x00001000, + SafeBuffers = 0x00002000, + EncodedLocalBasePointerMask = 0x0000C000, + EncodedParamBasePointerMask = 0x00030000, + ProfileGuidedOptimization = 0x00040000, + ValidProfileCounts = 0x00080000, + OptimizedForSpeed = 0x00100000, + GuardCfg = 0x00200000, + GuardCfw = 0x00400000 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions) + +enum class FunctionOptions : uint8_t { + None = 0x00, + CxxReturnUdt = 0x01, + Constructor = 0x02, + ConstructorWithVirtualBases = 0x04 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions) + +enum class HfaKind : uint8_t { + None = 0x00, + Float = 0x01, + Double = 0x02, + Other = 0x03 +}; + +/// Source-level access specifier. (CV_access_e) +enum class MemberAccess : uint8_t { + None = 0, + Private = 1, + Protected = 2, + Public = 3 +}; + +/// Part of member attribute flags. (CV_methodprop_e) +enum class MethodKind : uint8_t { + Vanilla = 0x00, + Virtual = 0x01, + Static = 0x02, + Friend = 0x03, + IntroducingVirtual = 0x04, + PureVirtual = 0x05, + PureIntroducingVirtual = 0x06 +}; + +/// Equivalent to CV_fldattr_t bitfield. +enum class MethodOptions : uint16_t { + None = 0x0000, + AccessMask = 0x0003, + MethodKindMask = 0x001c, + Pseudo = 0x0020, + NoInherit = 0x0040, + NoConstruct = 0x0080, + CompilerGenerated = 0x0100, + Sealed = 0x0200 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions) + +/// Equivalent to CV_LABEL_TYPE_e. +enum class LabelType : uint16_t { + Near = 0x0, + Far = 0x4, +}; + +/// Equivalent to CV_modifier_t. +/// TODO: Add flag for _Atomic modifier +enum class ModifierOptions : uint16_t { + None = 0x0000, + Const = 0x0001, + Volatile = 0x0002, + Unaligned = 0x0004 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions) + +// If the subsection kind has this bit set, then the linker should ignore it. +enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 }; + +enum class DebugSubsectionKind : uint32_t { + None = 0, + Symbols = 0xf1, + Lines = 0xf2, + StringTable = 0xf3, + FileChecksums = 0xf4, + FrameData = 0xf5, + InlineeLines = 0xf6, + CrossScopeImports = 0xf7, + CrossScopeExports = 0xf8, + + // These appear to relate to .Net assembly info. + ILLines = 0xf9, + FuncMDTokenMap = 0xfa, + TypeMDTokenMap = 0xfb, + MergedAssemblyInput = 0xfc, + + CoffSymbolRVA = 0xfd, +}; + +/// Equivalent to CV_ptrtype_e. +enum class PointerKind : uint8_t { + Near16 = 0x00, // 16 bit pointer + Far16 = 0x01, // 16:16 far pointer + Huge16 = 0x02, // 16:16 huge pointer + BasedOnSegment = 0x03, // based on segment + BasedOnValue = 0x04, // based on value of base + BasedOnSegmentValue = 0x05, // based on segment value of base + BasedOnAddress = 0x06, // based on address of base + BasedOnSegmentAddress = 0x07, // based on segment address of base + BasedOnType = 0x08, // based on type + BasedOnSelf = 0x09, // based on self + Near32 = 0x0a, // 32 bit pointer + Far32 = 0x0b, // 16:32 pointer + Near64 = 0x0c // 64 bit pointer +}; + +/// Equivalent to CV_ptrmode_e. +enum class PointerMode : uint8_t { + Pointer = 0x00, // "normal" pointer + LValueReference = 0x01, // "old" reference + PointerToDataMember = 0x02, // pointer to data member + PointerToMemberFunction = 0x03, // pointer to member function + RValueReference = 0x04 // r-value reference +}; + +/// Equivalent to misc lfPointerAttr bitfields. +enum class PointerOptions : uint32_t { + None = 0x00000000, + Flat32 = 0x00000100, + Volatile = 0x00000200, + Const = 0x00000400, + Unaligned = 0x00000800, + Restrict = 0x00001000, + WinRTSmartPointer = 0x00080000, + LValueRefThisPointer = 0x00100000, + RValueRefThisPointer = 0x00200000 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions) + +/// Equivalent to CV_pmtype_e. +enum class PointerToMemberRepresentation : uint16_t { + Unknown = 0x00, // not specified (pre VC8) + SingleInheritanceData = 0x01, // member data, single inheritance + MultipleInheritanceData = 0x02, // member data, multiple inheritance + VirtualInheritanceData = 0x03, // member data, virtual inheritance + GeneralData = 0x04, // member data, most general + SingleInheritanceFunction = 0x05, // member function, single inheritance + MultipleInheritanceFunction = 0x06, // member function, multiple inheritance + VirtualInheritanceFunction = 0x07, // member function, virtual inheritance + GeneralFunction = 0x08 // member function, most general +}; + +enum class VFTableSlotKind : uint8_t { + Near16 = 0x00, + Far16 = 0x01, + This = 0x02, + Outer = 0x03, + Meta = 0x04, + Near = 0x05, + Far = 0x06 +}; + +enum class WindowsRTClassKind : uint8_t { + None = 0x00, + RefClass = 0x01, + ValueClass = 0x02, + Interface = 0x03 +}; + +/// Corresponds to CV_LVARFLAGS bitfield. +enum class LocalSymFlags : uint16_t { + None = 0, + IsParameter = 1 << 0, + IsAddressTaken = 1 << 1, + IsCompilerGenerated = 1 << 2, + IsAggregate = 1 << 3, + IsAggregated = 1 << 4, + IsAliased = 1 << 5, + IsAlias = 1 << 6, + IsReturnValue = 1 << 7, + IsOptimizedOut = 1 << 8, + IsEnregisteredGlobal = 1 << 9, + IsEnregisteredStatic = 1 << 10, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags) + +/// Corresponds to the CV_PUBSYMFLAGS bitfield. +enum class PublicSymFlags : uint32_t { + None = 0, + Code = 1 << 0, + Function = 1 << 1, + Managed = 1 << 2, + MSIL = 1 << 3, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags) + +/// Corresponds to the CV_PROCFLAGS bitfield. +enum class ProcSymFlags : uint8_t { + None = 0, + HasFP = 1 << 0, + HasIRET = 1 << 1, + HasFRET = 1 << 2, + IsNoReturn = 1 << 3, + IsUnreachable = 1 << 4, + HasCustomCallingConv = 1 << 5, + IsNoInline = 1 << 6, + HasOptimizedDebugInfo = 1 << 7, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags) + +/// Corresponds to COMPILESYM2::Flags bitfield. +enum class CompileSym2Flags : uint32_t { + None = 0, + SourceLanguageMask = 0xFF, + EC = 1 << 8, + NoDbgInfo = 1 << 9, + LTCG = 1 << 10, + NoDataAlign = 1 << 11, + ManagedPresent = 1 << 12, + SecurityChecks = 1 << 13, + HotPatch = 1 << 14, + CVTCIL = 1 << 15, + MSILModule = 1 << 16, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags) + +/// Corresponds to COMPILESYM3::Flags bitfield. +enum class CompileSym3Flags : uint32_t { + None = 0, + SourceLanguageMask = 0xFF, + EC = 1 << 8, + NoDbgInfo = 1 << 9, + LTCG = 1 << 10, + NoDataAlign = 1 << 11, + ManagedPresent = 1 << 12, + SecurityChecks = 1 << 13, + HotPatch = 1 << 14, + CVTCIL = 1 << 15, + MSILModule = 1 << 16, + Sdl = 1 << 17, + PGO = 1 << 18, + Exp = 1 << 19, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags) + +enum class ExportFlags : uint16_t { + None = 0, + IsConstant = 1 << 0, + IsData = 1 << 1, + IsPrivate = 1 << 2, + HasNoName = 1 << 3, + HasExplicitOrdinal = 1 << 4, + IsForwarder = 1 << 5 +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags) + +// Corresponds to BinaryAnnotationOpcode enum. +enum class BinaryAnnotationsOpCode : uint32_t { + Invalid, + CodeOffset, + ChangeCodeOffsetBase, + ChangeCodeOffset, + ChangeCodeLength, + ChangeFile, + ChangeLineOffset, + ChangeLineEndDelta, + ChangeRangeKind, + ChangeColumnStart, + ChangeColumnEndDelta, + ChangeCodeOffsetAndLineOffset, + ChangeCodeLengthAndCodeOffset, + ChangeColumnEnd, +}; + +// Corresponds to CV_cookietype_e enum. +enum class FrameCookieKind : uint8_t { + Copy, + XorStackPointer, + XorFramePointer, + XorR13, +}; + +// Corresponds to CV_HREG_e enum. +enum class RegisterId : uint16_t { +#define CV_REGISTERS_ALL +#define CV_REGISTER(name, value) name = value, +#include "CodeViewRegisters.def" +#undef CV_REGISTER +#undef CV_REGISTERS_ALL +}; + +// Register Ids are shared between architectures in CodeView. CPUType is needed +// to map register Id to name. +struct CPURegister { + CPURegister() = delete; + CPURegister(CPUType Cpu, codeview::RegisterId Reg) { + this->Cpu = Cpu; + this->Reg = Reg; + } + CPUType Cpu; + RegisterId Reg; +}; + +/// Two-bit value indicating which register is the designated frame pointer +/// register. Appears in the S_FRAMEPROC record flags. +enum class EncodedFramePtrReg : uint8_t { + None = 0, + StackPtr = 1, + FramePtr = 2, + BasePtr = 3, +}; + +RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU); + +EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU); + +/// These values correspond to the THUNK_ORDINAL enumeration. +enum class ThunkOrdinal : uint8_t { + Standard, + ThisAdjustor, + Vcall, + Pcode, + UnknownLoad, + TrampIncremental, + BranchIsland +}; + +enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland }; + +// These values correspond to the CV_SourceChksum_t enumeration. +enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 }; + +enum LineFlags : uint16_t { + LF_None = 0, + LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS +}; + +/// Data in the SUBSEC_FRAMEDATA subection. +struct FrameData { + support::ulittle32_t RvaStart; + support::ulittle32_t CodeSize; + support::ulittle32_t LocalSize; + support::ulittle32_t ParamsSize; + support::ulittle32_t MaxStackSize; + support::ulittle32_t FrameFunc; + support::ulittle16_t PrologSize; + support::ulittle16_t SavedRegsSize; + support::ulittle32_t Flags; + enum : uint32_t { + HasSEH = 1 << 0, + HasEH = 1 << 1, + IsFunctionStart = 1 << 2, + }; +}; + +// Corresponds to LocalIdAndGlobalIdPair structure. +// This structure information allows cross-referencing between PDBs. For +// example, when a PDB is being built during compilation it is not yet known +// what other modules may end up in the PDB at link time. So certain types of +// IDs may clash between the various compile time PDBs. For each affected +// module, a subsection would be put into the PDB containing a mapping from its +// local IDs to a single ID namespace for all items in the PDB file. +struct CrossModuleExport { + support::ulittle32_t Local; + support::ulittle32_t Global; +}; + +struct CrossModuleImport { + support::ulittle32_t ModuleNameOffset; + support::ulittle32_t Count; // Number of elements + // support::ulittle32_t ids[Count]; // id from referenced module +}; + +enum class CodeViewContainer { ObjectFile, Pdb }; + +inline uint32_t alignOf(CodeViewContainer Container) { + if (Container == CodeViewContainer::ObjectFile) + return 1; + return 4; +} +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewError.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewError.h index 8fc845cb1c..f9d7bf2e96 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewError.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewError.h @@ -1,65 +1,65 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CodeViewError.h - Error extensions for CodeView ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H -#define LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H - -#include "llvm/Support/Error.h" - -#include <string> - -namespace llvm { -namespace codeview { -enum class cv_error_code { - unspecified = 1, - insufficient_buffer, - operation_unsupported, - corrupt_record, - no_records, - unknown_member_record, -}; -} // namespace codeview -} // namespace llvm - -namespace std { -template <> -struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {}; -} // namespace std - -namespace llvm { -namespace codeview { -const std::error_category &CVErrorCategory(); - -inline std::error_code make_error_code(cv_error_code E) { - return std::error_code(static_cast<int>(E), CVErrorCategory()); -} - -/// Base class for errors originating when parsing raw PDB files -class CodeViewError : public ErrorInfo<CodeViewError, StringError> { -public: - using ErrorInfo<CodeViewError, - StringError>::ErrorInfo; // inherit constructors - CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {} - static char ID; -}; - -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CodeViewError.h - Error extensions for CodeView ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H +#define LLVM_DEBUGINFO_PDB_CODEVIEW_CODEVIEWERROR_H + +#include "llvm/Support/Error.h" + +#include <string> + +namespace llvm { +namespace codeview { +enum class cv_error_code { + unspecified = 1, + insufficient_buffer, + operation_unsupported, + corrupt_record, + no_records, + unknown_member_record, +}; +} // namespace codeview +} // namespace llvm + +namespace std { +template <> +struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {}; +} // namespace std + +namespace llvm { +namespace codeview { +const std::error_category &CVErrorCategory(); + +inline std::error_code make_error_code(cv_error_code E) { + return std::error_code(static_cast<int>(E), CVErrorCategory()); +} + +/// Base class for errors originating when parsing raw PDB files +class CodeViewError : public ErrorInfo<CodeViewError, StringError> { +public: + using ErrorInfo<CodeViewError, + StringError>::ErrorInfo; // inherit constructors + CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {} + static char ID; +}; + +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h index d755a702e4..f21d24d0ba 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h @@ -1,282 +1,282 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- CodeViewRecordIO.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H -#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H - -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- CodeViewRecordIO.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H +#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H + +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeViewError.h" #include "llvm/DebugInfo/CodeView/GUID.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Error.h" -#include <cassert> -#include <cstdint> -#include <type_traits> - -namespace llvm { - -namespace codeview { - -class CodeViewRecordStreamer { -public: - virtual void emitBytes(StringRef Data) = 0; - virtual void emitIntValue(uint64_t Value, unsigned Size) = 0; - virtual void emitBinaryData(StringRef Data) = 0; - virtual void AddComment(const Twine &T) = 0; - virtual void AddRawComment(const Twine &T) = 0; - virtual bool isVerboseAsm() = 0; - virtual std::string getTypeName(TypeIndex TI) = 0; - virtual ~CodeViewRecordStreamer() = default; -}; - -class CodeViewRecordIO { - uint32_t getCurrentOffset() const { - if (isWriting()) - return Writer->getOffset(); - else if (isReading()) - return Reader->getOffset(); - else - return 0; - } - -public: - // deserializes records to structures - explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {} - - // serializes records to buffer - explicit CodeViewRecordIO(BinaryStreamWriter &Writer) : Writer(&Writer) {} - - // writes records to assembly file using MC library interface - explicit CodeViewRecordIO(CodeViewRecordStreamer &Streamer) - : Streamer(&Streamer) {} - - Error beginRecord(Optional<uint32_t> MaxLength); - Error endRecord(); - - Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = ""); - - bool isStreaming() const { - return (Streamer != nullptr) && (Reader == nullptr) && (Writer == nullptr); - } - bool isReading() const { - return (Reader != nullptr) && (Streamer == nullptr) && (Writer == nullptr); - } - bool isWriting() const { - return (Writer != nullptr) && (Streamer == nullptr) && (Reader == nullptr); - } - - uint32_t maxFieldLength() const; - - template <typename T> Error mapObject(T &Value) { - if (isStreaming()) { - StringRef BytesSR = - StringRef((reinterpret_cast<const char *>(&Value)), sizeof(Value)); - Streamer->emitBytes(BytesSR); - incrStreamedLen(sizeof(T)); - return Error::success(); - } - - if (isWriting()) - return Writer->writeObject(Value); - - const T *ValuePtr; - if (auto EC = Reader->readObject(ValuePtr)) - return EC; - Value = *ValuePtr; - return Error::success(); - } - - template <typename T> Error mapInteger(T &Value, const Twine &Comment = "") { - if (isStreaming()) { - emitComment(Comment); - Streamer->emitIntValue((int)Value, sizeof(T)); - incrStreamedLen(sizeof(T)); - return Error::success(); - } - - if (isWriting()) - return Writer->writeInteger(Value); - - return Reader->readInteger(Value); - } - - template <typename T> Error mapEnum(T &Value, const Twine &Comment = "") { - if (!isStreaming() && sizeof(Value) > maxFieldLength()) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); - - using U = std::underlying_type_t<T>; - U X; - - if (isWriting() || isStreaming()) - X = static_cast<U>(Value); - - if (auto EC = mapInteger(X, Comment)) - return EC; - - if (isReading()) - Value = static_cast<T>(X); - - return Error::success(); - } - - Error mapEncodedInteger(int64_t &Value, const Twine &Comment = ""); - Error mapEncodedInteger(uint64_t &Value, const Twine &Comment = ""); - Error mapEncodedInteger(APSInt &Value, const Twine &Comment = ""); - Error mapStringZ(StringRef &Value, const Twine &Comment = ""); - Error mapGuid(GUID &Guid, const Twine &Comment = ""); - - Error mapStringZVectorZ(std::vector<StringRef> &Value, - const Twine &Comment = ""); - - template <typename SizeType, typename T, typename ElementMapper> - Error mapVectorN(T &Items, const ElementMapper &Mapper, - const Twine &Comment = "") { - SizeType Size; - if (isStreaming()) { - Size = static_cast<SizeType>(Items.size()); - emitComment(Comment); - Streamer->emitIntValue(Size, sizeof(Size)); - incrStreamedLen(sizeof(Size)); // add 1 for the delimiter - - for (auto &X : Items) { - if (auto EC = Mapper(*this, X)) - return EC; - } - } else if (isWriting()) { - Size = static_cast<SizeType>(Items.size()); - if (auto EC = Writer->writeInteger(Size)) - return EC; - - for (auto &X : Items) { - if (auto EC = Mapper(*this, X)) - return EC; - } - } else { - if (auto EC = Reader->readInteger(Size)) - return EC; - for (SizeType I = 0; I < Size; ++I) { - typename T::value_type Item; - if (auto EC = Mapper(*this, Item)) - return EC; - Items.push_back(Item); - } - } - - return Error::success(); - } - - template <typename T, typename ElementMapper> - Error mapVectorTail(T &Items, const ElementMapper &Mapper, - const Twine &Comment = "") { - emitComment(Comment); - if (isStreaming() || isWriting()) { - for (auto &Item : Items) { - if (auto EC = Mapper(*this, Item)) - return EC; - } - } else { - typename T::value_type Field; - // Stop when we run out of bytes or we hit record padding bytes. - while (!Reader->empty() && Reader->peek() < 0xf0 /* LF_PAD0 */) { - if (auto EC = Mapper(*this, Field)) - return EC; - Items.push_back(Field); - } - } - return Error::success(); - } - - Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes, const Twine &Comment = ""); - Error mapByteVectorTail(std::vector<uint8_t> &Bytes, - const Twine &Comment = ""); - - Error padToAlignment(uint32_t Align); - Error skipPadding(); - - uint64_t getStreamedLen() { - if (isStreaming()) - return StreamedLen; - return 0; - } - - void emitRawComment(const Twine &T) { - if (isStreaming() && Streamer->isVerboseAsm()) - Streamer->AddRawComment(T); - } - -private: - void emitEncodedSignedInteger(const int64_t &Value, - const Twine &Comment = ""); - void emitEncodedUnsignedInteger(const uint64_t &Value, - const Twine &Comment = ""); - Error writeEncodedSignedInteger(const int64_t &Value); - Error writeEncodedUnsignedInteger(const uint64_t &Value); - - void incrStreamedLen(const uint64_t &Len) { - if (isStreaming()) - StreamedLen += Len; - } - - void resetStreamedLen() { - if (isStreaming()) - StreamedLen = 4; // The record prefix is 4 bytes long - } - - void emitComment(const Twine &Comment) { - if (isStreaming() && Streamer->isVerboseAsm()) { - Twine TComment(Comment); - if (!TComment.isTriviallyEmpty()) - Streamer->AddComment(TComment); - } - } - - struct RecordLimit { - uint32_t BeginOffset; - Optional<uint32_t> MaxLength; - - Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const { - if (!MaxLength.hasValue()) - return None; - assert(CurrentOffset >= BeginOffset); - - uint32_t BytesUsed = CurrentOffset - BeginOffset; - if (BytesUsed >= *MaxLength) - return 0; - return *MaxLength - BytesUsed; - } - }; - - SmallVector<RecordLimit, 2> Limits; - - BinaryStreamReader *Reader = nullptr; - BinaryStreamWriter *Writer = nullptr; - CodeViewRecordStreamer *Streamer = nullptr; - uint64_t StreamedLen = 0; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Error.h" +#include <cassert> +#include <cstdint> +#include <type_traits> + +namespace llvm { + +namespace codeview { + +class CodeViewRecordStreamer { +public: + virtual void emitBytes(StringRef Data) = 0; + virtual void emitIntValue(uint64_t Value, unsigned Size) = 0; + virtual void emitBinaryData(StringRef Data) = 0; + virtual void AddComment(const Twine &T) = 0; + virtual void AddRawComment(const Twine &T) = 0; + virtual bool isVerboseAsm() = 0; + virtual std::string getTypeName(TypeIndex TI) = 0; + virtual ~CodeViewRecordStreamer() = default; +}; + +class CodeViewRecordIO { + uint32_t getCurrentOffset() const { + if (isWriting()) + return Writer->getOffset(); + else if (isReading()) + return Reader->getOffset(); + else + return 0; + } + +public: + // deserializes records to structures + explicit CodeViewRecordIO(BinaryStreamReader &Reader) : Reader(&Reader) {} + + // serializes records to buffer + explicit CodeViewRecordIO(BinaryStreamWriter &Writer) : Writer(&Writer) {} + + // writes records to assembly file using MC library interface + explicit CodeViewRecordIO(CodeViewRecordStreamer &Streamer) + : Streamer(&Streamer) {} + + Error beginRecord(Optional<uint32_t> MaxLength); + Error endRecord(); + + Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = ""); + + bool isStreaming() const { + return (Streamer != nullptr) && (Reader == nullptr) && (Writer == nullptr); + } + bool isReading() const { + return (Reader != nullptr) && (Streamer == nullptr) && (Writer == nullptr); + } + bool isWriting() const { + return (Writer != nullptr) && (Streamer == nullptr) && (Reader == nullptr); + } + + uint32_t maxFieldLength() const; + + template <typename T> Error mapObject(T &Value) { + if (isStreaming()) { + StringRef BytesSR = + StringRef((reinterpret_cast<const char *>(&Value)), sizeof(Value)); + Streamer->emitBytes(BytesSR); + incrStreamedLen(sizeof(T)); + return Error::success(); + } + + if (isWriting()) + return Writer->writeObject(Value); + + const T *ValuePtr; + if (auto EC = Reader->readObject(ValuePtr)) + return EC; + Value = *ValuePtr; + return Error::success(); + } + + template <typename T> Error mapInteger(T &Value, const Twine &Comment = "") { + if (isStreaming()) { + emitComment(Comment); + Streamer->emitIntValue((int)Value, sizeof(T)); + incrStreamedLen(sizeof(T)); + return Error::success(); + } + + if (isWriting()) + return Writer->writeInteger(Value); + + return Reader->readInteger(Value); + } + + template <typename T> Error mapEnum(T &Value, const Twine &Comment = "") { + if (!isStreaming() && sizeof(Value) > maxFieldLength()) + return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + + using U = std::underlying_type_t<T>; + U X; + + if (isWriting() || isStreaming()) + X = static_cast<U>(Value); + + if (auto EC = mapInteger(X, Comment)) + return EC; + + if (isReading()) + Value = static_cast<T>(X); + + return Error::success(); + } + + Error mapEncodedInteger(int64_t &Value, const Twine &Comment = ""); + Error mapEncodedInteger(uint64_t &Value, const Twine &Comment = ""); + Error mapEncodedInteger(APSInt &Value, const Twine &Comment = ""); + Error mapStringZ(StringRef &Value, const Twine &Comment = ""); + Error mapGuid(GUID &Guid, const Twine &Comment = ""); + + Error mapStringZVectorZ(std::vector<StringRef> &Value, + const Twine &Comment = ""); + + template <typename SizeType, typename T, typename ElementMapper> + Error mapVectorN(T &Items, const ElementMapper &Mapper, + const Twine &Comment = "") { + SizeType Size; + if (isStreaming()) { + Size = static_cast<SizeType>(Items.size()); + emitComment(Comment); + Streamer->emitIntValue(Size, sizeof(Size)); + incrStreamedLen(sizeof(Size)); // add 1 for the delimiter + + for (auto &X : Items) { + if (auto EC = Mapper(*this, X)) + return EC; + } + } else if (isWriting()) { + Size = static_cast<SizeType>(Items.size()); + if (auto EC = Writer->writeInteger(Size)) + return EC; + + for (auto &X : Items) { + if (auto EC = Mapper(*this, X)) + return EC; + } + } else { + if (auto EC = Reader->readInteger(Size)) + return EC; + for (SizeType I = 0; I < Size; ++I) { + typename T::value_type Item; + if (auto EC = Mapper(*this, Item)) + return EC; + Items.push_back(Item); + } + } + + return Error::success(); + } + + template <typename T, typename ElementMapper> + Error mapVectorTail(T &Items, const ElementMapper &Mapper, + const Twine &Comment = "") { + emitComment(Comment); + if (isStreaming() || isWriting()) { + for (auto &Item : Items) { + if (auto EC = Mapper(*this, Item)) + return EC; + } + } else { + typename T::value_type Field; + // Stop when we run out of bytes or we hit record padding bytes. + while (!Reader->empty() && Reader->peek() < 0xf0 /* LF_PAD0 */) { + if (auto EC = Mapper(*this, Field)) + return EC; + Items.push_back(Field); + } + } + return Error::success(); + } + + Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes, const Twine &Comment = ""); + Error mapByteVectorTail(std::vector<uint8_t> &Bytes, + const Twine &Comment = ""); + + Error padToAlignment(uint32_t Align); + Error skipPadding(); + + uint64_t getStreamedLen() { + if (isStreaming()) + return StreamedLen; + return 0; + } + + void emitRawComment(const Twine &T) { + if (isStreaming() && Streamer->isVerboseAsm()) + Streamer->AddRawComment(T); + } + +private: + void emitEncodedSignedInteger(const int64_t &Value, + const Twine &Comment = ""); + void emitEncodedUnsignedInteger(const uint64_t &Value, + const Twine &Comment = ""); + Error writeEncodedSignedInteger(const int64_t &Value); + Error writeEncodedUnsignedInteger(const uint64_t &Value); + + void incrStreamedLen(const uint64_t &Len) { + if (isStreaming()) + StreamedLen += Len; + } + + void resetStreamedLen() { + if (isStreaming()) + StreamedLen = 4; // The record prefix is 4 bytes long + } + + void emitComment(const Twine &Comment) { + if (isStreaming() && Streamer->isVerboseAsm()) { + Twine TComment(Comment); + if (!TComment.isTriviallyEmpty()) + Streamer->AddComment(TComment); + } + } + + struct RecordLimit { + uint32_t BeginOffset; + Optional<uint32_t> MaxLength; + + Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const { + if (!MaxLength.hasValue()) + return None; + assert(CurrentOffset >= BeginOffset); + + uint32_t BytesUsed = CurrentOffset - BeginOffset; + if (BytesUsed >= *MaxLength) + return 0; + return *MaxLength - BytesUsed; + } + }; + + SmallVector<RecordLimit, 2> Limits; + + BinaryStreamReader *Reader = nullptr; + BinaryStreamWriter *Writer = nullptr; + CodeViewRecordStreamer *Streamer = nullptr; + uint64_t StreamedLen = 0; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_CODEVIEWRECORDIO_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def index 8e49a3aadf..48ea7e52c1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def @@ -1,406 +1,406 @@ -//===-- CodeViewRegisters.def - CodeView registers --------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// See CV_HREG_e in cvconst.h. This should match the constants there. -// -//===----------------------------------------------------------------------===// - -#ifndef CV_REGISTER -#define CV_REGISTER(name, value) -#endif - -#if !defined(CV_REGISTERS_ALL) && !defined(CV_REGISTERS_X86) && \ +//===-- CodeViewRegisters.def - CodeView registers --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// See CV_HREG_e in cvconst.h. This should match the constants there. +// +//===----------------------------------------------------------------------===// + +#ifndef CV_REGISTER +#define CV_REGISTER(name, value) +#endif + +#if !defined(CV_REGISTERS_ALL) && !defined(CV_REGISTERS_X86) && \ !defined(CV_REGISTERS_ARM) && \ - !defined(CV_REGISTERS_ARM64) -#error Need include at least one register set. -#endif - -// This currently only contains the "register subset shared by all processor -// types" (ERR etc.) and the x86/arm64 registers. - -#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_X86) - -// Some system headers define macros that conflict with our enums. Every -// compiler supported by LLVM has the push_macro and pop_macro pragmas, so use -// them to avoid the conflict. -#pragma push_macro("CR0") -#pragma push_macro("CR1") -#pragma push_macro("CR2") -#pragma push_macro("CR3") -#pragma push_macro("CR4") - -CV_REGISTER(ERR, 30000) -CV_REGISTER(TEB, 30001) -CV_REGISTER(TIMER, 30002) -CV_REGISTER(EFAD1, 30003) -CV_REGISTER(EFAD2, 30004) -CV_REGISTER(EFAD3, 30005) -CV_REGISTER(VFRAME, 30006) -CV_REGISTER(HANDLE, 30007) -CV_REGISTER(PARAMS, 30008) -CV_REGISTER(LOCALS, 30009) -CV_REGISTER(TID, 30010) -CV_REGISTER(ENV, 30011) -CV_REGISTER(CMDLN, 30012) - -CV_REGISTER(NONE, 0) -CV_REGISTER(AL, 1) -CV_REGISTER(CL, 2) -CV_REGISTER(DL, 3) -CV_REGISTER(BL, 4) -CV_REGISTER(AH, 5) -CV_REGISTER(CH, 6) -CV_REGISTER(DH, 7) -CV_REGISTER(BH, 8) -CV_REGISTER(AX, 9) -CV_REGISTER(CX, 10) -CV_REGISTER(DX, 11) -CV_REGISTER(BX, 12) -CV_REGISTER(SP, 13) -CV_REGISTER(BP, 14) -CV_REGISTER(SI, 15) -CV_REGISTER(DI, 16) -CV_REGISTER(EAX, 17) -CV_REGISTER(ECX, 18) -CV_REGISTER(EDX, 19) -CV_REGISTER(EBX, 20) -CV_REGISTER(ESP, 21) -CV_REGISTER(EBP, 22) -CV_REGISTER(ESI, 23) -CV_REGISTER(EDI, 24) -CV_REGISTER(ES, 25) -CV_REGISTER(CS, 26) -CV_REGISTER(SS, 27) -CV_REGISTER(DS, 28) -CV_REGISTER(FS, 29) -CV_REGISTER(GS, 30) -CV_REGISTER(IP, 31) -CV_REGISTER(FLAGS, 32) -CV_REGISTER(EIP, 33) -CV_REGISTER(EFLAGS, 34) -CV_REGISTER(TEMP, 40) -CV_REGISTER(TEMPH, 41) -CV_REGISTER(QUOTE, 42) -CV_REGISTER(PCDR3, 43) -CV_REGISTER(PCDR4, 44) -CV_REGISTER(PCDR5, 45) -CV_REGISTER(PCDR6, 46) -CV_REGISTER(PCDR7, 47) -CV_REGISTER(CR0, 80) -CV_REGISTER(CR1, 81) -CV_REGISTER(CR2, 82) -CV_REGISTER(CR3, 83) -CV_REGISTER(CR4, 84) -CV_REGISTER(DR0, 90) -CV_REGISTER(DR1, 91) -CV_REGISTER(DR2, 92) -CV_REGISTER(DR3, 93) -CV_REGISTER(DR4, 94) -CV_REGISTER(DR5, 95) -CV_REGISTER(DR6, 96) -CV_REGISTER(DR7, 97) -CV_REGISTER(GDTR, 110) -CV_REGISTER(GDTL, 111) -CV_REGISTER(IDTR, 112) -CV_REGISTER(IDTL, 113) -CV_REGISTER(LDTR, 114) -CV_REGISTER(TR, 115) - -CV_REGISTER(PSEUDO1, 116) -CV_REGISTER(PSEUDO2, 117) -CV_REGISTER(PSEUDO3, 118) -CV_REGISTER(PSEUDO4, 119) -CV_REGISTER(PSEUDO5, 120) -CV_REGISTER(PSEUDO6, 121) -CV_REGISTER(PSEUDO7, 122) -CV_REGISTER(PSEUDO8, 123) -CV_REGISTER(PSEUDO9, 124) - -CV_REGISTER(ST0, 128) -CV_REGISTER(ST1, 129) -CV_REGISTER(ST2, 130) -CV_REGISTER(ST3, 131) -CV_REGISTER(ST4, 132) -CV_REGISTER(ST5, 133) -CV_REGISTER(ST6, 134) -CV_REGISTER(ST7, 135) -CV_REGISTER(CTRL, 136) -CV_REGISTER(STAT, 137) -CV_REGISTER(TAG, 138) -CV_REGISTER(FPIP, 139) -CV_REGISTER(FPCS, 140) -CV_REGISTER(FPDO, 141) -CV_REGISTER(FPDS, 142) -CV_REGISTER(ISEM, 143) -CV_REGISTER(FPEIP, 144) -CV_REGISTER(FPEDO, 145) - -CV_REGISTER(MM0, 146) -CV_REGISTER(MM1, 147) -CV_REGISTER(MM2, 148) -CV_REGISTER(MM3, 149) -CV_REGISTER(MM4, 150) -CV_REGISTER(MM5, 151) -CV_REGISTER(MM6, 152) -CV_REGISTER(MM7, 153) - -CV_REGISTER(XMM0, 154) -CV_REGISTER(XMM1, 155) -CV_REGISTER(XMM2, 156) -CV_REGISTER(XMM3, 157) -CV_REGISTER(XMM4, 158) -CV_REGISTER(XMM5, 159) -CV_REGISTER(XMM6, 160) -CV_REGISTER(XMM7, 161) - -CV_REGISTER(MXCSR, 211) - -CV_REGISTER(EDXEAX, 212) - -CV_REGISTER(EMM0L, 220) -CV_REGISTER(EMM1L, 221) -CV_REGISTER(EMM2L, 222) -CV_REGISTER(EMM3L, 223) -CV_REGISTER(EMM4L, 224) -CV_REGISTER(EMM5L, 225) -CV_REGISTER(EMM6L, 226) -CV_REGISTER(EMM7L, 227) - -CV_REGISTER(EMM0H, 228) -CV_REGISTER(EMM1H, 229) -CV_REGISTER(EMM2H, 230) -CV_REGISTER(EMM3H, 231) -CV_REGISTER(EMM4H, 232) -CV_REGISTER(EMM5H, 233) -CV_REGISTER(EMM6H, 234) -CV_REGISTER(EMM7H, 235) - -CV_REGISTER(MM00, 236) -CV_REGISTER(MM01, 237) -CV_REGISTER(MM10, 238) -CV_REGISTER(MM11, 239) -CV_REGISTER(MM20, 240) -CV_REGISTER(MM21, 241) -CV_REGISTER(MM30, 242) -CV_REGISTER(MM31, 243) -CV_REGISTER(MM40, 244) -CV_REGISTER(MM41, 245) -CV_REGISTER(MM50, 246) -CV_REGISTER(MM51, 247) -CV_REGISTER(MM60, 248) -CV_REGISTER(MM61, 249) -CV_REGISTER(MM70, 250) -CV_REGISTER(MM71, 251) - -CV_REGISTER(BND0, 396) -CV_REGISTER(BND1, 397) -CV_REGISTER(BND2, 398) - - -CV_REGISTER(XMM8, 252) -CV_REGISTER(XMM9, 253) -CV_REGISTER(XMM10, 254) -CV_REGISTER(XMM11, 255) -CV_REGISTER(XMM12, 256) -CV_REGISTER(XMM13, 257) -CV_REGISTER(XMM14, 258) -CV_REGISTER(XMM15, 259) - - -CV_REGISTER(SIL, 324) -CV_REGISTER(DIL, 325) -CV_REGISTER(BPL, 326) -CV_REGISTER(SPL, 327) - -CV_REGISTER(RAX, 328) -CV_REGISTER(RBX, 329) -CV_REGISTER(RCX, 330) -CV_REGISTER(RDX, 331) -CV_REGISTER(RSI, 332) -CV_REGISTER(RDI, 333) -CV_REGISTER(RBP, 334) -CV_REGISTER(RSP, 335) - -CV_REGISTER(R8, 336) -CV_REGISTER(R9, 337) -CV_REGISTER(R10, 338) -CV_REGISTER(R11, 339) -CV_REGISTER(R12, 340) -CV_REGISTER(R13, 341) -CV_REGISTER(R14, 342) -CV_REGISTER(R15, 343) - -CV_REGISTER(R8B, 344) -CV_REGISTER(R9B, 345) -CV_REGISTER(R10B, 346) -CV_REGISTER(R11B, 347) -CV_REGISTER(R12B, 348) -CV_REGISTER(R13B, 349) -CV_REGISTER(R14B, 350) -CV_REGISTER(R15B, 351) - -CV_REGISTER(R8W, 352) -CV_REGISTER(R9W, 353) -CV_REGISTER(R10W, 354) -CV_REGISTER(R11W, 355) -CV_REGISTER(R12W, 356) -CV_REGISTER(R13W, 357) -CV_REGISTER(R14W, 358) -CV_REGISTER(R15W, 359) - -CV_REGISTER(R8D, 360) -CV_REGISTER(R9D, 361) -CV_REGISTER(R10D, 362) -CV_REGISTER(R11D, 363) -CV_REGISTER(R12D, 364) -CV_REGISTER(R13D, 365) -CV_REGISTER(R14D, 366) -CV_REGISTER(R15D, 367) - - -// cvconst.h defines both CV_REG_YMM0 (252) and CV_AMD64_YMM0 (368). Keep the -// original prefix to distinguish them. - -CV_REGISTER(AMD64_YMM0, 368) -CV_REGISTER(AMD64_YMM1, 369) -CV_REGISTER(AMD64_YMM2, 370) -CV_REGISTER(AMD64_YMM3, 371) -CV_REGISTER(AMD64_YMM4, 372) -CV_REGISTER(AMD64_YMM5, 373) -CV_REGISTER(AMD64_YMM6, 374) -CV_REGISTER(AMD64_YMM7, 375) -CV_REGISTER(AMD64_YMM8, 376) -CV_REGISTER(AMD64_YMM9, 377) -CV_REGISTER(AMD64_YMM10, 378) -CV_REGISTER(AMD64_YMM11, 379) -CV_REGISTER(AMD64_YMM12, 380) -CV_REGISTER(AMD64_YMM13, 381) -CV_REGISTER(AMD64_YMM14, 382) -CV_REGISTER(AMD64_YMM15, 383) - -CV_REGISTER(AMD64_XMM16, 694) -CV_REGISTER(AMD64_XMM17, 695) -CV_REGISTER(AMD64_XMM18, 696) -CV_REGISTER(AMD64_XMM19, 697) -CV_REGISTER(AMD64_XMM20, 698) -CV_REGISTER(AMD64_XMM21, 699) -CV_REGISTER(AMD64_XMM22, 700) -CV_REGISTER(AMD64_XMM23, 701) -CV_REGISTER(AMD64_XMM24, 702) -CV_REGISTER(AMD64_XMM25, 703) -CV_REGISTER(AMD64_XMM26, 704) -CV_REGISTER(AMD64_XMM27, 705) -CV_REGISTER(AMD64_XMM28, 706) -CV_REGISTER(AMD64_XMM29, 707) -CV_REGISTER(AMD64_XMM30, 708) -CV_REGISTER(AMD64_XMM31, 709) - -CV_REGISTER(AMD64_YMM16, 710) -CV_REGISTER(AMD64_YMM17, 711) -CV_REGISTER(AMD64_YMM18, 712) -CV_REGISTER(AMD64_YMM19, 713) -CV_REGISTER(AMD64_YMM20, 714) -CV_REGISTER(AMD64_YMM21, 715) -CV_REGISTER(AMD64_YMM22, 716) -CV_REGISTER(AMD64_YMM23, 717) -CV_REGISTER(AMD64_YMM24, 718) -CV_REGISTER(AMD64_YMM25, 719) -CV_REGISTER(AMD64_YMM26, 720) -CV_REGISTER(AMD64_YMM27, 721) -CV_REGISTER(AMD64_YMM28, 722) -CV_REGISTER(AMD64_YMM29, 723) -CV_REGISTER(AMD64_YMM30, 724) -CV_REGISTER(AMD64_YMM31, 725) - -CV_REGISTER(AMD64_ZMM0, 726) -CV_REGISTER(AMD64_ZMM1, 727) -CV_REGISTER(AMD64_ZMM2, 728) -CV_REGISTER(AMD64_ZMM3, 729) -CV_REGISTER(AMD64_ZMM4, 730) -CV_REGISTER(AMD64_ZMM5, 731) -CV_REGISTER(AMD64_ZMM6, 732) -CV_REGISTER(AMD64_ZMM7, 733) -CV_REGISTER(AMD64_ZMM8, 734) -CV_REGISTER(AMD64_ZMM9, 735) -CV_REGISTER(AMD64_ZMM10, 736) -CV_REGISTER(AMD64_ZMM11, 737) -CV_REGISTER(AMD64_ZMM12, 738) -CV_REGISTER(AMD64_ZMM13, 739) -CV_REGISTER(AMD64_ZMM14, 740) -CV_REGISTER(AMD64_ZMM15, 741) -CV_REGISTER(AMD64_ZMM16, 742) -CV_REGISTER(AMD64_ZMM17, 743) -CV_REGISTER(AMD64_ZMM18, 744) -CV_REGISTER(AMD64_ZMM19, 745) -CV_REGISTER(AMD64_ZMM20, 746) -CV_REGISTER(AMD64_ZMM21, 747) -CV_REGISTER(AMD64_ZMM22, 748) -CV_REGISTER(AMD64_ZMM23, 749) -CV_REGISTER(AMD64_ZMM24, 750) -CV_REGISTER(AMD64_ZMM25, 751) -CV_REGISTER(AMD64_ZMM26, 752) -CV_REGISTER(AMD64_ZMM27, 753) -CV_REGISTER(AMD64_ZMM28, 754) -CV_REGISTER(AMD64_ZMM29, 755) -CV_REGISTER(AMD64_ZMM30, 756) -CV_REGISTER(AMD64_ZMM31, 757) - -CV_REGISTER(AMD64_K0, 758) -CV_REGISTER(AMD64_K1, 759) -CV_REGISTER(AMD64_K2, 760) -CV_REGISTER(AMD64_K3, 761) -CV_REGISTER(AMD64_K4, 762) -CV_REGISTER(AMD64_K5, 763) -CV_REGISTER(AMD64_K6, 764) -CV_REGISTER(AMD64_K7, 765) - -#pragma pop_macro("CR0") -#pragma pop_macro("CR1") -#pragma pop_macro("CR2") -#pragma pop_macro("CR3") -#pragma pop_macro("CR4") - -#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_X86) - -#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM) - -// ARM registers - -CV_REGISTER(ARM_NOREG, 0) - -// General purpose 32-bit integer regisers - -CV_REGISTER(ARM_R0, 10) -CV_REGISTER(ARM_R1, 11) -CV_REGISTER(ARM_R2, 12) -CV_REGISTER(ARM_R3, 13) -CV_REGISTER(ARM_R4, 14) -CV_REGISTER(ARM_R5, 15) -CV_REGISTER(ARM_R6, 16) -CV_REGISTER(ARM_R7, 17) -CV_REGISTER(ARM_R8, 18) -CV_REGISTER(ARM_R9, 19) -CV_REGISTER(ARM_R10, 20) -CV_REGISTER(ARM_R11, 21) -CV_REGISTER(ARM_R12, 22) -CV_REGISTER(ARM_SP, 23) -CV_REGISTER(ARM_LR, 24) -CV_REGISTER(ARM_PC, 25) - -// Status register - + !defined(CV_REGISTERS_ARM64) +#error Need include at least one register set. +#endif + +// This currently only contains the "register subset shared by all processor +// types" (ERR etc.) and the x86/arm64 registers. + +#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_X86) + +// Some system headers define macros that conflict with our enums. Every +// compiler supported by LLVM has the push_macro and pop_macro pragmas, so use +// them to avoid the conflict. +#pragma push_macro("CR0") +#pragma push_macro("CR1") +#pragma push_macro("CR2") +#pragma push_macro("CR3") +#pragma push_macro("CR4") + +CV_REGISTER(ERR, 30000) +CV_REGISTER(TEB, 30001) +CV_REGISTER(TIMER, 30002) +CV_REGISTER(EFAD1, 30003) +CV_REGISTER(EFAD2, 30004) +CV_REGISTER(EFAD3, 30005) +CV_REGISTER(VFRAME, 30006) +CV_REGISTER(HANDLE, 30007) +CV_REGISTER(PARAMS, 30008) +CV_REGISTER(LOCALS, 30009) +CV_REGISTER(TID, 30010) +CV_REGISTER(ENV, 30011) +CV_REGISTER(CMDLN, 30012) + +CV_REGISTER(NONE, 0) +CV_REGISTER(AL, 1) +CV_REGISTER(CL, 2) +CV_REGISTER(DL, 3) +CV_REGISTER(BL, 4) +CV_REGISTER(AH, 5) +CV_REGISTER(CH, 6) +CV_REGISTER(DH, 7) +CV_REGISTER(BH, 8) +CV_REGISTER(AX, 9) +CV_REGISTER(CX, 10) +CV_REGISTER(DX, 11) +CV_REGISTER(BX, 12) +CV_REGISTER(SP, 13) +CV_REGISTER(BP, 14) +CV_REGISTER(SI, 15) +CV_REGISTER(DI, 16) +CV_REGISTER(EAX, 17) +CV_REGISTER(ECX, 18) +CV_REGISTER(EDX, 19) +CV_REGISTER(EBX, 20) +CV_REGISTER(ESP, 21) +CV_REGISTER(EBP, 22) +CV_REGISTER(ESI, 23) +CV_REGISTER(EDI, 24) +CV_REGISTER(ES, 25) +CV_REGISTER(CS, 26) +CV_REGISTER(SS, 27) +CV_REGISTER(DS, 28) +CV_REGISTER(FS, 29) +CV_REGISTER(GS, 30) +CV_REGISTER(IP, 31) +CV_REGISTER(FLAGS, 32) +CV_REGISTER(EIP, 33) +CV_REGISTER(EFLAGS, 34) +CV_REGISTER(TEMP, 40) +CV_REGISTER(TEMPH, 41) +CV_REGISTER(QUOTE, 42) +CV_REGISTER(PCDR3, 43) +CV_REGISTER(PCDR4, 44) +CV_REGISTER(PCDR5, 45) +CV_REGISTER(PCDR6, 46) +CV_REGISTER(PCDR7, 47) +CV_REGISTER(CR0, 80) +CV_REGISTER(CR1, 81) +CV_REGISTER(CR2, 82) +CV_REGISTER(CR3, 83) +CV_REGISTER(CR4, 84) +CV_REGISTER(DR0, 90) +CV_REGISTER(DR1, 91) +CV_REGISTER(DR2, 92) +CV_REGISTER(DR3, 93) +CV_REGISTER(DR4, 94) +CV_REGISTER(DR5, 95) +CV_REGISTER(DR6, 96) +CV_REGISTER(DR7, 97) +CV_REGISTER(GDTR, 110) +CV_REGISTER(GDTL, 111) +CV_REGISTER(IDTR, 112) +CV_REGISTER(IDTL, 113) +CV_REGISTER(LDTR, 114) +CV_REGISTER(TR, 115) + +CV_REGISTER(PSEUDO1, 116) +CV_REGISTER(PSEUDO2, 117) +CV_REGISTER(PSEUDO3, 118) +CV_REGISTER(PSEUDO4, 119) +CV_REGISTER(PSEUDO5, 120) +CV_REGISTER(PSEUDO6, 121) +CV_REGISTER(PSEUDO7, 122) +CV_REGISTER(PSEUDO8, 123) +CV_REGISTER(PSEUDO9, 124) + +CV_REGISTER(ST0, 128) +CV_REGISTER(ST1, 129) +CV_REGISTER(ST2, 130) +CV_REGISTER(ST3, 131) +CV_REGISTER(ST4, 132) +CV_REGISTER(ST5, 133) +CV_REGISTER(ST6, 134) +CV_REGISTER(ST7, 135) +CV_REGISTER(CTRL, 136) +CV_REGISTER(STAT, 137) +CV_REGISTER(TAG, 138) +CV_REGISTER(FPIP, 139) +CV_REGISTER(FPCS, 140) +CV_REGISTER(FPDO, 141) +CV_REGISTER(FPDS, 142) +CV_REGISTER(ISEM, 143) +CV_REGISTER(FPEIP, 144) +CV_REGISTER(FPEDO, 145) + +CV_REGISTER(MM0, 146) +CV_REGISTER(MM1, 147) +CV_REGISTER(MM2, 148) +CV_REGISTER(MM3, 149) +CV_REGISTER(MM4, 150) +CV_REGISTER(MM5, 151) +CV_REGISTER(MM6, 152) +CV_REGISTER(MM7, 153) + +CV_REGISTER(XMM0, 154) +CV_REGISTER(XMM1, 155) +CV_REGISTER(XMM2, 156) +CV_REGISTER(XMM3, 157) +CV_REGISTER(XMM4, 158) +CV_REGISTER(XMM5, 159) +CV_REGISTER(XMM6, 160) +CV_REGISTER(XMM7, 161) + +CV_REGISTER(MXCSR, 211) + +CV_REGISTER(EDXEAX, 212) + +CV_REGISTER(EMM0L, 220) +CV_REGISTER(EMM1L, 221) +CV_REGISTER(EMM2L, 222) +CV_REGISTER(EMM3L, 223) +CV_REGISTER(EMM4L, 224) +CV_REGISTER(EMM5L, 225) +CV_REGISTER(EMM6L, 226) +CV_REGISTER(EMM7L, 227) + +CV_REGISTER(EMM0H, 228) +CV_REGISTER(EMM1H, 229) +CV_REGISTER(EMM2H, 230) +CV_REGISTER(EMM3H, 231) +CV_REGISTER(EMM4H, 232) +CV_REGISTER(EMM5H, 233) +CV_REGISTER(EMM6H, 234) +CV_REGISTER(EMM7H, 235) + +CV_REGISTER(MM00, 236) +CV_REGISTER(MM01, 237) +CV_REGISTER(MM10, 238) +CV_REGISTER(MM11, 239) +CV_REGISTER(MM20, 240) +CV_REGISTER(MM21, 241) +CV_REGISTER(MM30, 242) +CV_REGISTER(MM31, 243) +CV_REGISTER(MM40, 244) +CV_REGISTER(MM41, 245) +CV_REGISTER(MM50, 246) +CV_REGISTER(MM51, 247) +CV_REGISTER(MM60, 248) +CV_REGISTER(MM61, 249) +CV_REGISTER(MM70, 250) +CV_REGISTER(MM71, 251) + +CV_REGISTER(BND0, 396) +CV_REGISTER(BND1, 397) +CV_REGISTER(BND2, 398) + + +CV_REGISTER(XMM8, 252) +CV_REGISTER(XMM9, 253) +CV_REGISTER(XMM10, 254) +CV_REGISTER(XMM11, 255) +CV_REGISTER(XMM12, 256) +CV_REGISTER(XMM13, 257) +CV_REGISTER(XMM14, 258) +CV_REGISTER(XMM15, 259) + + +CV_REGISTER(SIL, 324) +CV_REGISTER(DIL, 325) +CV_REGISTER(BPL, 326) +CV_REGISTER(SPL, 327) + +CV_REGISTER(RAX, 328) +CV_REGISTER(RBX, 329) +CV_REGISTER(RCX, 330) +CV_REGISTER(RDX, 331) +CV_REGISTER(RSI, 332) +CV_REGISTER(RDI, 333) +CV_REGISTER(RBP, 334) +CV_REGISTER(RSP, 335) + +CV_REGISTER(R8, 336) +CV_REGISTER(R9, 337) +CV_REGISTER(R10, 338) +CV_REGISTER(R11, 339) +CV_REGISTER(R12, 340) +CV_REGISTER(R13, 341) +CV_REGISTER(R14, 342) +CV_REGISTER(R15, 343) + +CV_REGISTER(R8B, 344) +CV_REGISTER(R9B, 345) +CV_REGISTER(R10B, 346) +CV_REGISTER(R11B, 347) +CV_REGISTER(R12B, 348) +CV_REGISTER(R13B, 349) +CV_REGISTER(R14B, 350) +CV_REGISTER(R15B, 351) + +CV_REGISTER(R8W, 352) +CV_REGISTER(R9W, 353) +CV_REGISTER(R10W, 354) +CV_REGISTER(R11W, 355) +CV_REGISTER(R12W, 356) +CV_REGISTER(R13W, 357) +CV_REGISTER(R14W, 358) +CV_REGISTER(R15W, 359) + +CV_REGISTER(R8D, 360) +CV_REGISTER(R9D, 361) +CV_REGISTER(R10D, 362) +CV_REGISTER(R11D, 363) +CV_REGISTER(R12D, 364) +CV_REGISTER(R13D, 365) +CV_REGISTER(R14D, 366) +CV_REGISTER(R15D, 367) + + +// cvconst.h defines both CV_REG_YMM0 (252) and CV_AMD64_YMM0 (368). Keep the +// original prefix to distinguish them. + +CV_REGISTER(AMD64_YMM0, 368) +CV_REGISTER(AMD64_YMM1, 369) +CV_REGISTER(AMD64_YMM2, 370) +CV_REGISTER(AMD64_YMM3, 371) +CV_REGISTER(AMD64_YMM4, 372) +CV_REGISTER(AMD64_YMM5, 373) +CV_REGISTER(AMD64_YMM6, 374) +CV_REGISTER(AMD64_YMM7, 375) +CV_REGISTER(AMD64_YMM8, 376) +CV_REGISTER(AMD64_YMM9, 377) +CV_REGISTER(AMD64_YMM10, 378) +CV_REGISTER(AMD64_YMM11, 379) +CV_REGISTER(AMD64_YMM12, 380) +CV_REGISTER(AMD64_YMM13, 381) +CV_REGISTER(AMD64_YMM14, 382) +CV_REGISTER(AMD64_YMM15, 383) + +CV_REGISTER(AMD64_XMM16, 694) +CV_REGISTER(AMD64_XMM17, 695) +CV_REGISTER(AMD64_XMM18, 696) +CV_REGISTER(AMD64_XMM19, 697) +CV_REGISTER(AMD64_XMM20, 698) +CV_REGISTER(AMD64_XMM21, 699) +CV_REGISTER(AMD64_XMM22, 700) +CV_REGISTER(AMD64_XMM23, 701) +CV_REGISTER(AMD64_XMM24, 702) +CV_REGISTER(AMD64_XMM25, 703) +CV_REGISTER(AMD64_XMM26, 704) +CV_REGISTER(AMD64_XMM27, 705) +CV_REGISTER(AMD64_XMM28, 706) +CV_REGISTER(AMD64_XMM29, 707) +CV_REGISTER(AMD64_XMM30, 708) +CV_REGISTER(AMD64_XMM31, 709) + +CV_REGISTER(AMD64_YMM16, 710) +CV_REGISTER(AMD64_YMM17, 711) +CV_REGISTER(AMD64_YMM18, 712) +CV_REGISTER(AMD64_YMM19, 713) +CV_REGISTER(AMD64_YMM20, 714) +CV_REGISTER(AMD64_YMM21, 715) +CV_REGISTER(AMD64_YMM22, 716) +CV_REGISTER(AMD64_YMM23, 717) +CV_REGISTER(AMD64_YMM24, 718) +CV_REGISTER(AMD64_YMM25, 719) +CV_REGISTER(AMD64_YMM26, 720) +CV_REGISTER(AMD64_YMM27, 721) +CV_REGISTER(AMD64_YMM28, 722) +CV_REGISTER(AMD64_YMM29, 723) +CV_REGISTER(AMD64_YMM30, 724) +CV_REGISTER(AMD64_YMM31, 725) + +CV_REGISTER(AMD64_ZMM0, 726) +CV_REGISTER(AMD64_ZMM1, 727) +CV_REGISTER(AMD64_ZMM2, 728) +CV_REGISTER(AMD64_ZMM3, 729) +CV_REGISTER(AMD64_ZMM4, 730) +CV_REGISTER(AMD64_ZMM5, 731) +CV_REGISTER(AMD64_ZMM6, 732) +CV_REGISTER(AMD64_ZMM7, 733) +CV_REGISTER(AMD64_ZMM8, 734) +CV_REGISTER(AMD64_ZMM9, 735) +CV_REGISTER(AMD64_ZMM10, 736) +CV_REGISTER(AMD64_ZMM11, 737) +CV_REGISTER(AMD64_ZMM12, 738) +CV_REGISTER(AMD64_ZMM13, 739) +CV_REGISTER(AMD64_ZMM14, 740) +CV_REGISTER(AMD64_ZMM15, 741) +CV_REGISTER(AMD64_ZMM16, 742) +CV_REGISTER(AMD64_ZMM17, 743) +CV_REGISTER(AMD64_ZMM18, 744) +CV_REGISTER(AMD64_ZMM19, 745) +CV_REGISTER(AMD64_ZMM20, 746) +CV_REGISTER(AMD64_ZMM21, 747) +CV_REGISTER(AMD64_ZMM22, 748) +CV_REGISTER(AMD64_ZMM23, 749) +CV_REGISTER(AMD64_ZMM24, 750) +CV_REGISTER(AMD64_ZMM25, 751) +CV_REGISTER(AMD64_ZMM26, 752) +CV_REGISTER(AMD64_ZMM27, 753) +CV_REGISTER(AMD64_ZMM28, 754) +CV_REGISTER(AMD64_ZMM29, 755) +CV_REGISTER(AMD64_ZMM30, 756) +CV_REGISTER(AMD64_ZMM31, 757) + +CV_REGISTER(AMD64_K0, 758) +CV_REGISTER(AMD64_K1, 759) +CV_REGISTER(AMD64_K2, 760) +CV_REGISTER(AMD64_K3, 761) +CV_REGISTER(AMD64_K4, 762) +CV_REGISTER(AMD64_K5, 763) +CV_REGISTER(AMD64_K6, 764) +CV_REGISTER(AMD64_K7, 765) + +#pragma pop_macro("CR0") +#pragma pop_macro("CR1") +#pragma pop_macro("CR2") +#pragma pop_macro("CR3") +#pragma pop_macro("CR4") + +#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_X86) + +#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM) + +// ARM registers + +CV_REGISTER(ARM_NOREG, 0) + +// General purpose 32-bit integer regisers + +CV_REGISTER(ARM_R0, 10) +CV_REGISTER(ARM_R1, 11) +CV_REGISTER(ARM_R2, 12) +CV_REGISTER(ARM_R3, 13) +CV_REGISTER(ARM_R4, 14) +CV_REGISTER(ARM_R5, 15) +CV_REGISTER(ARM_R6, 16) +CV_REGISTER(ARM_R7, 17) +CV_REGISTER(ARM_R8, 18) +CV_REGISTER(ARM_R9, 19) +CV_REGISTER(ARM_R10, 20) +CV_REGISTER(ARM_R11, 21) +CV_REGISTER(ARM_R12, 22) +CV_REGISTER(ARM_SP, 23) +CV_REGISTER(ARM_LR, 24) +CV_REGISTER(ARM_PC, 25) + +// Status register + CV_REGISTER(ARM_CPSR, 26) - -// ARM VFPv1 registers - -CV_REGISTER(ARM_FPSCR, 40) -CV_REGISTER(ARM_FPEXC, 41) - + +// ARM VFPv1 registers + +CV_REGISTER(ARM_FPSCR, 40) +CV_REGISTER(ARM_FPEXC, 41) + CV_REGISTER(ARM_FS0, 50) CV_REGISTER(ARM_FS1, 51) CV_REGISTER(ARM_FS2, 52) @@ -434,288 +434,288 @@ CV_REGISTER(ARM_FS29, 79) CV_REGISTER(ARM_FS30, 80) CV_REGISTER(ARM_FS31, 81) -// ARM VFPv3/NEON registers - -CV_REGISTER(ARM_FS32, 200) -CV_REGISTER(ARM_FS33, 201) -CV_REGISTER(ARM_FS34, 202) -CV_REGISTER(ARM_FS35, 203) -CV_REGISTER(ARM_FS36, 204) -CV_REGISTER(ARM_FS37, 205) -CV_REGISTER(ARM_FS38, 206) -CV_REGISTER(ARM_FS39, 207) -CV_REGISTER(ARM_FS40, 208) -CV_REGISTER(ARM_FS41, 209) -CV_REGISTER(ARM_FS42, 210) -CV_REGISTER(ARM_FS43, 211) -CV_REGISTER(ARM_FS44, 212) -CV_REGISTER(ARM_FS45, 213) -CV_REGISTER(ARM_FS46, 214) -CV_REGISTER(ARM_FS47, 215) -CV_REGISTER(ARM_FS48, 216) -CV_REGISTER(ARM_FS49, 217) -CV_REGISTER(ARM_FS50, 218) -CV_REGISTER(ARM_FS51, 219) -CV_REGISTER(ARM_FS52, 220) -CV_REGISTER(ARM_FS53, 221) -CV_REGISTER(ARM_FS54, 222) -CV_REGISTER(ARM_FS55, 223) -CV_REGISTER(ARM_FS56, 224) -CV_REGISTER(ARM_FS57, 225) -CV_REGISTER(ARM_FS58, 226) -CV_REGISTER(ARM_FS59, 227) -CV_REGISTER(ARM_FS60, 228) -CV_REGISTER(ARM_FS61, 229) -CV_REGISTER(ARM_FS62, 230) -CV_REGISTER(ARM_FS63, 231) - -CV_REGISTER(ARM_ND0, 300) -CV_REGISTER(ARM_ND1, 301) -CV_REGISTER(ARM_ND2, 302) -CV_REGISTER(ARM_ND3, 303) -CV_REGISTER(ARM_ND4, 304) -CV_REGISTER(ARM_ND5, 305) -CV_REGISTER(ARM_ND6, 306) -CV_REGISTER(ARM_ND7, 307) -CV_REGISTER(ARM_ND8, 308) -CV_REGISTER(ARM_ND9, 309) -CV_REGISTER(ARM_ND10, 310) -CV_REGISTER(ARM_ND11, 311) -CV_REGISTER(ARM_ND12, 312) -CV_REGISTER(ARM_ND13, 313) -CV_REGISTER(ARM_ND14, 314) -CV_REGISTER(ARM_ND15, 315) -CV_REGISTER(ARM_ND16, 316) -CV_REGISTER(ARM_ND17, 317) -CV_REGISTER(ARM_ND18, 318) -CV_REGISTER(ARM_ND19, 319) -CV_REGISTER(ARM_ND20, 320) -CV_REGISTER(ARM_ND21, 321) -CV_REGISTER(ARM_ND22, 322) -CV_REGISTER(ARM_ND23, 323) -CV_REGISTER(ARM_ND24, 324) -CV_REGISTER(ARM_ND25, 325) -CV_REGISTER(ARM_ND26, 326) -CV_REGISTER(ARM_ND27, 327) -CV_REGISTER(ARM_ND28, 328) -CV_REGISTER(ARM_ND29, 329) -CV_REGISTER(ARM_ND30, 330) -CV_REGISTER(ARM_ND31, 331) - -CV_REGISTER(ARM_NQ0, 400) -CV_REGISTER(ARM_NQ1, 401) -CV_REGISTER(ARM_NQ2, 402) -CV_REGISTER(ARM_NQ3, 403) -CV_REGISTER(ARM_NQ4, 404) -CV_REGISTER(ARM_NQ5, 405) -CV_REGISTER(ARM_NQ6, 406) -CV_REGISTER(ARM_NQ7, 407) -CV_REGISTER(ARM_NQ8, 408) -CV_REGISTER(ARM_NQ9, 409) -CV_REGISTER(ARM_NQ10, 410) -CV_REGISTER(ARM_NQ11, 411) -CV_REGISTER(ARM_NQ12, 412) -CV_REGISTER(ARM_NQ13, 413) -CV_REGISTER(ARM_NQ14, 414) -CV_REGISTER(ARM_NQ15, 415) - -#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM) - -#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64) - -// arm64intr.h from MSVC defines ARM64_FPSR, which conflicts with -// these declarations. -#pragma push_macro("ARM64_FPSR") -#undef ARM64_FPSR - -// ARM64 registers - -CV_REGISTER(ARM64_NOREG, 0) - -// General purpose 32-bit integer registers - -CV_REGISTER(ARM64_W0, 10) -CV_REGISTER(ARM64_W1, 11) -CV_REGISTER(ARM64_W2, 12) -CV_REGISTER(ARM64_W3, 13) -CV_REGISTER(ARM64_W4, 14) -CV_REGISTER(ARM64_W5, 15) -CV_REGISTER(ARM64_W6, 16) -CV_REGISTER(ARM64_W7, 17) -CV_REGISTER(ARM64_W8, 18) -CV_REGISTER(ARM64_W9, 19) -CV_REGISTER(ARM64_W10, 20) -CV_REGISTER(ARM64_W11, 21) -CV_REGISTER(ARM64_W12, 22) -CV_REGISTER(ARM64_W13, 23) -CV_REGISTER(ARM64_W14, 24) -CV_REGISTER(ARM64_W15, 25) -CV_REGISTER(ARM64_W16, 26) -CV_REGISTER(ARM64_W17, 27) -CV_REGISTER(ARM64_W18, 28) -CV_REGISTER(ARM64_W19, 29) -CV_REGISTER(ARM64_W20, 30) -CV_REGISTER(ARM64_W21, 31) -CV_REGISTER(ARM64_W22, 32) -CV_REGISTER(ARM64_W23, 33) -CV_REGISTER(ARM64_W24, 34) -CV_REGISTER(ARM64_W25, 35) -CV_REGISTER(ARM64_W26, 36) -CV_REGISTER(ARM64_W27, 37) -CV_REGISTER(ARM64_W28, 38) -CV_REGISTER(ARM64_W29, 39) -CV_REGISTER(ARM64_W30, 40) -CV_REGISTER(ARM64_WZR, 41) - -// General purpose 64-bit integer registers - -CV_REGISTER(ARM64_X0, 50) -CV_REGISTER(ARM64_X1, 51) -CV_REGISTER(ARM64_X2, 52) -CV_REGISTER(ARM64_X3, 53) -CV_REGISTER(ARM64_X4, 54) -CV_REGISTER(ARM64_X5, 55) -CV_REGISTER(ARM64_X6, 56) -CV_REGISTER(ARM64_X7, 57) -CV_REGISTER(ARM64_X8, 58) -CV_REGISTER(ARM64_X9, 59) -CV_REGISTER(ARM64_X10, 60) -CV_REGISTER(ARM64_X11, 61) -CV_REGISTER(ARM64_X12, 62) -CV_REGISTER(ARM64_X13, 63) -CV_REGISTER(ARM64_X14, 64) -CV_REGISTER(ARM64_X15, 65) -CV_REGISTER(ARM64_X16, 66) -CV_REGISTER(ARM64_X17, 67) -CV_REGISTER(ARM64_X18, 68) -CV_REGISTER(ARM64_X19, 69) -CV_REGISTER(ARM64_X20, 70) -CV_REGISTER(ARM64_X21, 71) -CV_REGISTER(ARM64_X22, 72) -CV_REGISTER(ARM64_X23, 73) -CV_REGISTER(ARM64_X24, 74) -CV_REGISTER(ARM64_X25, 75) -CV_REGISTER(ARM64_X26, 76) -CV_REGISTER(ARM64_X27, 77) -CV_REGISTER(ARM64_X28, 78) -CV_REGISTER(ARM64_FP, 79) -CV_REGISTER(ARM64_LR, 80) -CV_REGISTER(ARM64_SP, 81) -CV_REGISTER(ARM64_ZR, 82) - -// status register - -CV_REGISTER(ARM64_NZCV, 90) - -// 32-bit floating point registers - -CV_REGISTER(ARM64_S0, 100) -CV_REGISTER(ARM64_S1, 101) -CV_REGISTER(ARM64_S2, 102) -CV_REGISTER(ARM64_S3, 103) -CV_REGISTER(ARM64_S4, 104) -CV_REGISTER(ARM64_S5, 105) -CV_REGISTER(ARM64_S6, 106) -CV_REGISTER(ARM64_S7, 107) -CV_REGISTER(ARM64_S8, 108) -CV_REGISTER(ARM64_S9, 109) -CV_REGISTER(ARM64_S10, 110) -CV_REGISTER(ARM64_S11, 111) -CV_REGISTER(ARM64_S12, 112) -CV_REGISTER(ARM64_S13, 113) -CV_REGISTER(ARM64_S14, 114) -CV_REGISTER(ARM64_S15, 115) -CV_REGISTER(ARM64_S16, 116) -CV_REGISTER(ARM64_S17, 117) -CV_REGISTER(ARM64_S18, 118) -CV_REGISTER(ARM64_S19, 119) -CV_REGISTER(ARM64_S20, 120) -CV_REGISTER(ARM64_S21, 121) -CV_REGISTER(ARM64_S22, 122) -CV_REGISTER(ARM64_S23, 123) -CV_REGISTER(ARM64_S24, 124) -CV_REGISTER(ARM64_S25, 125) -CV_REGISTER(ARM64_S26, 126) -CV_REGISTER(ARM64_S27, 127) -CV_REGISTER(ARM64_S28, 128) -CV_REGISTER(ARM64_S29, 129) -CV_REGISTER(ARM64_S30, 130) -CV_REGISTER(ARM64_S31, 131) - -// 64-bit floating point registers - -CV_REGISTER(ARM64_D0, 140) -CV_REGISTER(ARM64_D1, 141) -CV_REGISTER(ARM64_D2, 142) -CV_REGISTER(ARM64_D3, 143) -CV_REGISTER(ARM64_D4, 144) -CV_REGISTER(ARM64_D5, 145) -CV_REGISTER(ARM64_D6, 146) -CV_REGISTER(ARM64_D7, 147) -CV_REGISTER(ARM64_D8, 148) -CV_REGISTER(ARM64_D9, 149) -CV_REGISTER(ARM64_D10, 150) -CV_REGISTER(ARM64_D11, 151) -CV_REGISTER(ARM64_D12, 152) -CV_REGISTER(ARM64_D13, 153) -CV_REGISTER(ARM64_D14, 154) -CV_REGISTER(ARM64_D15, 155) -CV_REGISTER(ARM64_D16, 156) -CV_REGISTER(ARM64_D17, 157) -CV_REGISTER(ARM64_D18, 158) -CV_REGISTER(ARM64_D19, 159) -CV_REGISTER(ARM64_D20, 160) -CV_REGISTER(ARM64_D21, 161) -CV_REGISTER(ARM64_D22, 162) -CV_REGISTER(ARM64_D23, 163) -CV_REGISTER(ARM64_D24, 164) -CV_REGISTER(ARM64_D25, 165) -CV_REGISTER(ARM64_D26, 166) -CV_REGISTER(ARM64_D27, 167) -CV_REGISTER(ARM64_D28, 168) -CV_REGISTER(ARM64_D29, 169) -CV_REGISTER(ARM64_D30, 170) -CV_REGISTER(ARM64_D31, 171) - -// 128-bit SIMD registers - -CV_REGISTER(ARM64_Q0, 180) -CV_REGISTER(ARM64_Q1, 181) -CV_REGISTER(ARM64_Q2, 182) -CV_REGISTER(ARM64_Q3, 183) -CV_REGISTER(ARM64_Q4, 184) -CV_REGISTER(ARM64_Q5, 185) -CV_REGISTER(ARM64_Q6, 186) -CV_REGISTER(ARM64_Q7, 187) -CV_REGISTER(ARM64_Q8, 188) -CV_REGISTER(ARM64_Q9, 189) -CV_REGISTER(ARM64_Q10, 190) -CV_REGISTER(ARM64_Q11, 191) -CV_REGISTER(ARM64_Q12, 192) -CV_REGISTER(ARM64_Q13, 193) -CV_REGISTER(ARM64_Q14, 194) -CV_REGISTER(ARM64_Q15, 195) -CV_REGISTER(ARM64_Q16, 196) -CV_REGISTER(ARM64_Q17, 197) -CV_REGISTER(ARM64_Q18, 198) -CV_REGISTER(ARM64_Q19, 199) -CV_REGISTER(ARM64_Q20, 200) -CV_REGISTER(ARM64_Q21, 201) -CV_REGISTER(ARM64_Q22, 202) -CV_REGISTER(ARM64_Q23, 203) -CV_REGISTER(ARM64_Q24, 204) -CV_REGISTER(ARM64_Q25, 205) -CV_REGISTER(ARM64_Q26, 206) -CV_REGISTER(ARM64_Q27, 207) -CV_REGISTER(ARM64_Q28, 208) -CV_REGISTER(ARM64_Q29, 209) -CV_REGISTER(ARM64_Q30, 210) -CV_REGISTER(ARM64_Q31, 211) - -// Floating point status register - -CV_REGISTER(ARM64_FPSR, 220) - -#pragma pop_macro("ARM64_FPSR") - -#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64) +// ARM VFPv3/NEON registers + +CV_REGISTER(ARM_FS32, 200) +CV_REGISTER(ARM_FS33, 201) +CV_REGISTER(ARM_FS34, 202) +CV_REGISTER(ARM_FS35, 203) +CV_REGISTER(ARM_FS36, 204) +CV_REGISTER(ARM_FS37, 205) +CV_REGISTER(ARM_FS38, 206) +CV_REGISTER(ARM_FS39, 207) +CV_REGISTER(ARM_FS40, 208) +CV_REGISTER(ARM_FS41, 209) +CV_REGISTER(ARM_FS42, 210) +CV_REGISTER(ARM_FS43, 211) +CV_REGISTER(ARM_FS44, 212) +CV_REGISTER(ARM_FS45, 213) +CV_REGISTER(ARM_FS46, 214) +CV_REGISTER(ARM_FS47, 215) +CV_REGISTER(ARM_FS48, 216) +CV_REGISTER(ARM_FS49, 217) +CV_REGISTER(ARM_FS50, 218) +CV_REGISTER(ARM_FS51, 219) +CV_REGISTER(ARM_FS52, 220) +CV_REGISTER(ARM_FS53, 221) +CV_REGISTER(ARM_FS54, 222) +CV_REGISTER(ARM_FS55, 223) +CV_REGISTER(ARM_FS56, 224) +CV_REGISTER(ARM_FS57, 225) +CV_REGISTER(ARM_FS58, 226) +CV_REGISTER(ARM_FS59, 227) +CV_REGISTER(ARM_FS60, 228) +CV_REGISTER(ARM_FS61, 229) +CV_REGISTER(ARM_FS62, 230) +CV_REGISTER(ARM_FS63, 231) + +CV_REGISTER(ARM_ND0, 300) +CV_REGISTER(ARM_ND1, 301) +CV_REGISTER(ARM_ND2, 302) +CV_REGISTER(ARM_ND3, 303) +CV_REGISTER(ARM_ND4, 304) +CV_REGISTER(ARM_ND5, 305) +CV_REGISTER(ARM_ND6, 306) +CV_REGISTER(ARM_ND7, 307) +CV_REGISTER(ARM_ND8, 308) +CV_REGISTER(ARM_ND9, 309) +CV_REGISTER(ARM_ND10, 310) +CV_REGISTER(ARM_ND11, 311) +CV_REGISTER(ARM_ND12, 312) +CV_REGISTER(ARM_ND13, 313) +CV_REGISTER(ARM_ND14, 314) +CV_REGISTER(ARM_ND15, 315) +CV_REGISTER(ARM_ND16, 316) +CV_REGISTER(ARM_ND17, 317) +CV_REGISTER(ARM_ND18, 318) +CV_REGISTER(ARM_ND19, 319) +CV_REGISTER(ARM_ND20, 320) +CV_REGISTER(ARM_ND21, 321) +CV_REGISTER(ARM_ND22, 322) +CV_REGISTER(ARM_ND23, 323) +CV_REGISTER(ARM_ND24, 324) +CV_REGISTER(ARM_ND25, 325) +CV_REGISTER(ARM_ND26, 326) +CV_REGISTER(ARM_ND27, 327) +CV_REGISTER(ARM_ND28, 328) +CV_REGISTER(ARM_ND29, 329) +CV_REGISTER(ARM_ND30, 330) +CV_REGISTER(ARM_ND31, 331) + +CV_REGISTER(ARM_NQ0, 400) +CV_REGISTER(ARM_NQ1, 401) +CV_REGISTER(ARM_NQ2, 402) +CV_REGISTER(ARM_NQ3, 403) +CV_REGISTER(ARM_NQ4, 404) +CV_REGISTER(ARM_NQ5, 405) +CV_REGISTER(ARM_NQ6, 406) +CV_REGISTER(ARM_NQ7, 407) +CV_REGISTER(ARM_NQ8, 408) +CV_REGISTER(ARM_NQ9, 409) +CV_REGISTER(ARM_NQ10, 410) +CV_REGISTER(ARM_NQ11, 411) +CV_REGISTER(ARM_NQ12, 412) +CV_REGISTER(ARM_NQ13, 413) +CV_REGISTER(ARM_NQ14, 414) +CV_REGISTER(ARM_NQ15, 415) + +#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM) + +#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64) + +// arm64intr.h from MSVC defines ARM64_FPSR, which conflicts with +// these declarations. +#pragma push_macro("ARM64_FPSR") +#undef ARM64_FPSR + +// ARM64 registers + +CV_REGISTER(ARM64_NOREG, 0) + +// General purpose 32-bit integer registers + +CV_REGISTER(ARM64_W0, 10) +CV_REGISTER(ARM64_W1, 11) +CV_REGISTER(ARM64_W2, 12) +CV_REGISTER(ARM64_W3, 13) +CV_REGISTER(ARM64_W4, 14) +CV_REGISTER(ARM64_W5, 15) +CV_REGISTER(ARM64_W6, 16) +CV_REGISTER(ARM64_W7, 17) +CV_REGISTER(ARM64_W8, 18) +CV_REGISTER(ARM64_W9, 19) +CV_REGISTER(ARM64_W10, 20) +CV_REGISTER(ARM64_W11, 21) +CV_REGISTER(ARM64_W12, 22) +CV_REGISTER(ARM64_W13, 23) +CV_REGISTER(ARM64_W14, 24) +CV_REGISTER(ARM64_W15, 25) +CV_REGISTER(ARM64_W16, 26) +CV_REGISTER(ARM64_W17, 27) +CV_REGISTER(ARM64_W18, 28) +CV_REGISTER(ARM64_W19, 29) +CV_REGISTER(ARM64_W20, 30) +CV_REGISTER(ARM64_W21, 31) +CV_REGISTER(ARM64_W22, 32) +CV_REGISTER(ARM64_W23, 33) +CV_REGISTER(ARM64_W24, 34) +CV_REGISTER(ARM64_W25, 35) +CV_REGISTER(ARM64_W26, 36) +CV_REGISTER(ARM64_W27, 37) +CV_REGISTER(ARM64_W28, 38) +CV_REGISTER(ARM64_W29, 39) +CV_REGISTER(ARM64_W30, 40) +CV_REGISTER(ARM64_WZR, 41) + +// General purpose 64-bit integer registers + +CV_REGISTER(ARM64_X0, 50) +CV_REGISTER(ARM64_X1, 51) +CV_REGISTER(ARM64_X2, 52) +CV_REGISTER(ARM64_X3, 53) +CV_REGISTER(ARM64_X4, 54) +CV_REGISTER(ARM64_X5, 55) +CV_REGISTER(ARM64_X6, 56) +CV_REGISTER(ARM64_X7, 57) +CV_REGISTER(ARM64_X8, 58) +CV_REGISTER(ARM64_X9, 59) +CV_REGISTER(ARM64_X10, 60) +CV_REGISTER(ARM64_X11, 61) +CV_REGISTER(ARM64_X12, 62) +CV_REGISTER(ARM64_X13, 63) +CV_REGISTER(ARM64_X14, 64) +CV_REGISTER(ARM64_X15, 65) +CV_REGISTER(ARM64_X16, 66) +CV_REGISTER(ARM64_X17, 67) +CV_REGISTER(ARM64_X18, 68) +CV_REGISTER(ARM64_X19, 69) +CV_REGISTER(ARM64_X20, 70) +CV_REGISTER(ARM64_X21, 71) +CV_REGISTER(ARM64_X22, 72) +CV_REGISTER(ARM64_X23, 73) +CV_REGISTER(ARM64_X24, 74) +CV_REGISTER(ARM64_X25, 75) +CV_REGISTER(ARM64_X26, 76) +CV_REGISTER(ARM64_X27, 77) +CV_REGISTER(ARM64_X28, 78) +CV_REGISTER(ARM64_FP, 79) +CV_REGISTER(ARM64_LR, 80) +CV_REGISTER(ARM64_SP, 81) +CV_REGISTER(ARM64_ZR, 82) + +// status register + +CV_REGISTER(ARM64_NZCV, 90) + +// 32-bit floating point registers + +CV_REGISTER(ARM64_S0, 100) +CV_REGISTER(ARM64_S1, 101) +CV_REGISTER(ARM64_S2, 102) +CV_REGISTER(ARM64_S3, 103) +CV_REGISTER(ARM64_S4, 104) +CV_REGISTER(ARM64_S5, 105) +CV_REGISTER(ARM64_S6, 106) +CV_REGISTER(ARM64_S7, 107) +CV_REGISTER(ARM64_S8, 108) +CV_REGISTER(ARM64_S9, 109) +CV_REGISTER(ARM64_S10, 110) +CV_REGISTER(ARM64_S11, 111) +CV_REGISTER(ARM64_S12, 112) +CV_REGISTER(ARM64_S13, 113) +CV_REGISTER(ARM64_S14, 114) +CV_REGISTER(ARM64_S15, 115) +CV_REGISTER(ARM64_S16, 116) +CV_REGISTER(ARM64_S17, 117) +CV_REGISTER(ARM64_S18, 118) +CV_REGISTER(ARM64_S19, 119) +CV_REGISTER(ARM64_S20, 120) +CV_REGISTER(ARM64_S21, 121) +CV_REGISTER(ARM64_S22, 122) +CV_REGISTER(ARM64_S23, 123) +CV_REGISTER(ARM64_S24, 124) +CV_REGISTER(ARM64_S25, 125) +CV_REGISTER(ARM64_S26, 126) +CV_REGISTER(ARM64_S27, 127) +CV_REGISTER(ARM64_S28, 128) +CV_REGISTER(ARM64_S29, 129) +CV_REGISTER(ARM64_S30, 130) +CV_REGISTER(ARM64_S31, 131) + +// 64-bit floating point registers + +CV_REGISTER(ARM64_D0, 140) +CV_REGISTER(ARM64_D1, 141) +CV_REGISTER(ARM64_D2, 142) +CV_REGISTER(ARM64_D3, 143) +CV_REGISTER(ARM64_D4, 144) +CV_REGISTER(ARM64_D5, 145) +CV_REGISTER(ARM64_D6, 146) +CV_REGISTER(ARM64_D7, 147) +CV_REGISTER(ARM64_D8, 148) +CV_REGISTER(ARM64_D9, 149) +CV_REGISTER(ARM64_D10, 150) +CV_REGISTER(ARM64_D11, 151) +CV_REGISTER(ARM64_D12, 152) +CV_REGISTER(ARM64_D13, 153) +CV_REGISTER(ARM64_D14, 154) +CV_REGISTER(ARM64_D15, 155) +CV_REGISTER(ARM64_D16, 156) +CV_REGISTER(ARM64_D17, 157) +CV_REGISTER(ARM64_D18, 158) +CV_REGISTER(ARM64_D19, 159) +CV_REGISTER(ARM64_D20, 160) +CV_REGISTER(ARM64_D21, 161) +CV_REGISTER(ARM64_D22, 162) +CV_REGISTER(ARM64_D23, 163) +CV_REGISTER(ARM64_D24, 164) +CV_REGISTER(ARM64_D25, 165) +CV_REGISTER(ARM64_D26, 166) +CV_REGISTER(ARM64_D27, 167) +CV_REGISTER(ARM64_D28, 168) +CV_REGISTER(ARM64_D29, 169) +CV_REGISTER(ARM64_D30, 170) +CV_REGISTER(ARM64_D31, 171) + +// 128-bit SIMD registers + +CV_REGISTER(ARM64_Q0, 180) +CV_REGISTER(ARM64_Q1, 181) +CV_REGISTER(ARM64_Q2, 182) +CV_REGISTER(ARM64_Q3, 183) +CV_REGISTER(ARM64_Q4, 184) +CV_REGISTER(ARM64_Q5, 185) +CV_REGISTER(ARM64_Q6, 186) +CV_REGISTER(ARM64_Q7, 187) +CV_REGISTER(ARM64_Q8, 188) +CV_REGISTER(ARM64_Q9, 189) +CV_REGISTER(ARM64_Q10, 190) +CV_REGISTER(ARM64_Q11, 191) +CV_REGISTER(ARM64_Q12, 192) +CV_REGISTER(ARM64_Q13, 193) +CV_REGISTER(ARM64_Q14, 194) +CV_REGISTER(ARM64_Q15, 195) +CV_REGISTER(ARM64_Q16, 196) +CV_REGISTER(ARM64_Q17, 197) +CV_REGISTER(ARM64_Q18, 198) +CV_REGISTER(ARM64_Q19, 199) +CV_REGISTER(ARM64_Q20, 200) +CV_REGISTER(ARM64_Q21, 201) +CV_REGISTER(ARM64_Q22, 202) +CV_REGISTER(ARM64_Q23, 203) +CV_REGISTER(ARM64_Q24, 204) +CV_REGISTER(ARM64_Q25, 205) +CV_REGISTER(ARM64_Q26, 206) +CV_REGISTER(ARM64_Q27, 207) +CV_REGISTER(ARM64_Q28, 208) +CV_REGISTER(ARM64_Q29, 209) +CV_REGISTER(ARM64_Q30, 210) +CV_REGISTER(ARM64_Q31, 211) + +// Floating point status register + +CV_REGISTER(ARM64_FPSR, 220) + +#pragma pop_macro("ARM64_FPSR") + +#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64) diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def index d20ca6486d..4f8ccfdd16 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewSymbols.def @@ -1,260 +1,260 @@ -//===-- CodeViewSymbols.def - All CodeView leaf types -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// See LEAF_ENUM_e in cvinfo.h. This should match the constants there. -// -//===----------------------------------------------------------------------===// - -#ifndef CV_SYMBOL -#define CV_SYMBOL(ename, value) -#endif - -#ifndef SYMBOL_RECORD -#define SYMBOL_RECORD(lf_ename, value, name) CV_SYMBOL(lf_ename, value) -#endif - -#ifndef SYMBOL_RECORD_ALIAS -#define SYMBOL_RECORD_ALIAS(lf_ename, value, name, alias_name) \ - SYMBOL_RECORD(lf_ename, value, name) -#endif - -// 16 bit symbol types. Not very useful, provided only for reference. -CV_SYMBOL(S_COMPILE , 0x0001) -CV_SYMBOL(S_REGISTER_16t , 0x0002) -CV_SYMBOL(S_CONSTANT_16t , 0x0003) -CV_SYMBOL(S_UDT_16t , 0x0004) -CV_SYMBOL(S_SSEARCH , 0x0005) -CV_SYMBOL(S_SKIP , 0x0007) -CV_SYMBOL(S_CVRESERVE , 0x0008) -CV_SYMBOL(S_OBJNAME_ST , 0x0009) -CV_SYMBOL(S_ENDARG , 0x000a) -CV_SYMBOL(S_COBOLUDT_16t , 0x000b) -CV_SYMBOL(S_MANYREG_16t , 0x000c) -CV_SYMBOL(S_RETURN , 0x000d) -CV_SYMBOL(S_ENTRYTHIS , 0x000e) -CV_SYMBOL(S_BPREL16 , 0x0100) -CV_SYMBOL(S_LDATA16 , 0x0101) -CV_SYMBOL(S_GDATA16 , 0x0102) -CV_SYMBOL(S_PUB16 , 0x0103) -CV_SYMBOL(S_LPROC16 , 0x0104) -CV_SYMBOL(S_GPROC16 , 0x0105) -CV_SYMBOL(S_THUNK16 , 0x0106) -CV_SYMBOL(S_BLOCK16 , 0x0107) -CV_SYMBOL(S_WITH16 , 0x0108) -CV_SYMBOL(S_LABEL16 , 0x0109) -CV_SYMBOL(S_CEXMODEL16 , 0x010a) -CV_SYMBOL(S_VFTABLE16 , 0x010b) -CV_SYMBOL(S_REGREL16 , 0x010c) -CV_SYMBOL(S_BPREL32_16t , 0x0200) -CV_SYMBOL(S_LDATA32_16t , 0x0201) -CV_SYMBOL(S_GDATA32_16t , 0x0202) -CV_SYMBOL(S_PUB32_16t , 0x0203) -CV_SYMBOL(S_LPROC32_16t , 0x0204) -CV_SYMBOL(S_GPROC32_16t , 0x0205) -CV_SYMBOL(S_THUNK32_ST , 0x0206) -CV_SYMBOL(S_BLOCK32_ST , 0x0207) -CV_SYMBOL(S_WITH32_ST , 0x0208) -CV_SYMBOL(S_LABEL32_ST , 0x0209) -CV_SYMBOL(S_CEXMODEL32 , 0x020a) -CV_SYMBOL(S_VFTABLE32_16t , 0x020b) -CV_SYMBOL(S_REGREL32_16t , 0x020c) -CV_SYMBOL(S_LTHREAD32_16t , 0x020d) -CV_SYMBOL(S_GTHREAD32_16t , 0x020e) -CV_SYMBOL(S_SLINK32 , 0x020f) -CV_SYMBOL(S_LPROCMIPS_16t , 0x0300) -CV_SYMBOL(S_GPROCMIPS_16t , 0x0301) -CV_SYMBOL(S_PROCREF_ST , 0x0400) -CV_SYMBOL(S_DATAREF_ST , 0x0401) -CV_SYMBOL(S_ALIGN , 0x0402) -CV_SYMBOL(S_LPROCREF_ST , 0x0403) -CV_SYMBOL(S_OEM , 0x0404) - -// All post 16 bit symbol types have the 0x1000 bit set. -CV_SYMBOL(S_TI16_MAX , 0x1000) - -// Mostly unused "start" symbol types. -CV_SYMBOL(S_REGISTER_ST , 0x1001) -CV_SYMBOL(S_CONSTANT_ST , 0x1002) -CV_SYMBOL(S_UDT_ST , 0x1003) -CV_SYMBOL(S_COBOLUDT_ST , 0x1004) -CV_SYMBOL(S_MANYREG_ST , 0x1005) -CV_SYMBOL(S_BPREL32_ST , 0x1006) -CV_SYMBOL(S_LDATA32_ST , 0x1007) -CV_SYMBOL(S_GDATA32_ST , 0x1008) -CV_SYMBOL(S_PUB32_ST , 0x1009) -CV_SYMBOL(S_LPROC32_ST , 0x100a) -CV_SYMBOL(S_GPROC32_ST , 0x100b) -CV_SYMBOL(S_VFTABLE32 , 0x100c) -CV_SYMBOL(S_REGREL32_ST , 0x100d) -CV_SYMBOL(S_LTHREAD32_ST , 0x100e) -CV_SYMBOL(S_GTHREAD32_ST , 0x100f) -CV_SYMBOL(S_LPROCMIPS_ST , 0x1010) -CV_SYMBOL(S_GPROCMIPS_ST , 0x1011) - -CV_SYMBOL(S_COMPILE2_ST , 0x1013) -CV_SYMBOL(S_MANYREG2_ST , 0x1014) -CV_SYMBOL(S_LPROCIA64_ST , 0x1015) -CV_SYMBOL(S_GPROCIA64_ST , 0x1016) -CV_SYMBOL(S_LOCALSLOT_ST , 0x1017) -CV_SYMBOL(S_PARAMSLOT_ST , 0x1018) -CV_SYMBOL(S_GMANPROC_ST , 0x101a) -CV_SYMBOL(S_LMANPROC_ST , 0x101b) -CV_SYMBOL(S_RESERVED1 , 0x101c) -CV_SYMBOL(S_RESERVED2 , 0x101d) -CV_SYMBOL(S_RESERVED3 , 0x101e) -CV_SYMBOL(S_RESERVED4 , 0x101f) -CV_SYMBOL(S_LMANDATA_ST , 0x1020) -CV_SYMBOL(S_GMANDATA_ST , 0x1021) -CV_SYMBOL(S_MANFRAMEREL_ST, 0x1022) -CV_SYMBOL(S_MANREGISTER_ST, 0x1023) -CV_SYMBOL(S_MANSLOT_ST , 0x1024) -CV_SYMBOL(S_MANMANYREG_ST , 0x1025) -CV_SYMBOL(S_MANREGREL_ST , 0x1026) -CV_SYMBOL(S_MANMANYREG2_ST, 0x1027) -CV_SYMBOL(S_MANTYPREF , 0x1028) -CV_SYMBOL(S_UNAMESPACE_ST , 0x1029) - -// End of S_*_ST symbols, which do not appear to be generated by modern -// compilers. -CV_SYMBOL(S_ST_MAX , 0x1100) - - -CV_SYMBOL(S_WITH32 , 0x1104) -CV_SYMBOL(S_MANYREG , 0x110a) -CV_SYMBOL(S_LPROCMIPS , 0x1114) -CV_SYMBOL(S_GPROCMIPS , 0x1115) -CV_SYMBOL(S_MANYREG2 , 0x1117) -CV_SYMBOL(S_LPROCIA64 , 0x1118) -CV_SYMBOL(S_GPROCIA64 , 0x1119) -CV_SYMBOL(S_LOCALSLOT , 0x111a) -CV_SYMBOL(S_PARAMSLOT , 0x111b) - -// Managed code symbols. -CV_SYMBOL(S_MANFRAMEREL , 0x111e) -CV_SYMBOL(S_MANREGISTER , 0x111f) -CV_SYMBOL(S_MANSLOT , 0x1120) -CV_SYMBOL(S_MANMANYREG , 0x1121) -CV_SYMBOL(S_MANREGREL , 0x1122) -CV_SYMBOL(S_MANMANYREG2 , 0x1123) -CV_SYMBOL(S_DATAREF , 0x1126) -CV_SYMBOL(S_ANNOTATIONREF , 0x1128) -CV_SYMBOL(S_TOKENREF , 0x1129) -CV_SYMBOL(S_GMANPROC , 0x112a) -CV_SYMBOL(S_LMANPROC , 0x112b) -CV_SYMBOL(S_ATTR_FRAMEREL , 0x112e) -CV_SYMBOL(S_ATTR_REGISTER , 0x112f) -CV_SYMBOL(S_ATTR_REGREL , 0x1130) -CV_SYMBOL(S_ATTR_MANYREG , 0x1131) - - -CV_SYMBOL(S_SEPCODE , 0x1132) -CV_SYMBOL(S_LOCAL_2005 , 0x1133) -CV_SYMBOL(S_DEFRANGE_2005 , 0x1134) -CV_SYMBOL(S_DEFRANGE2_2005, 0x1135) -CV_SYMBOL(S_DISCARDED , 0x113b) - -// Current symbol types for most procedures as of this writing. -CV_SYMBOL(S_LPROCMIPS_ID , 0x1148) -CV_SYMBOL(S_GPROCMIPS_ID , 0x1149) -CV_SYMBOL(S_LPROCIA64_ID , 0x114a) -CV_SYMBOL(S_GPROCIA64_ID , 0x114b) - -CV_SYMBOL(S_DEFRANGE_HLSL , 0x1150) -CV_SYMBOL(S_GDATA_HLSL , 0x1151) -CV_SYMBOL(S_LDATA_HLSL , 0x1152) -CV_SYMBOL(S_LOCAL_DPC_GROUPSHARED, 0x1154) -CV_SYMBOL(S_DEFRANGE_DPC_PTR_TAG, 0x1157) -CV_SYMBOL(S_DPC_SYM_TAG_MAP, 0x1158) -CV_SYMBOL(S_ARMSWITCHTABLE , 0x1159) -CV_SYMBOL(S_POGODATA , 0x115c) -CV_SYMBOL(S_INLINESITE2 , 0x115d) -CV_SYMBOL(S_MOD_TYPEREF , 0x115f) -CV_SYMBOL(S_REF_MINIPDB , 0x1160) -CV_SYMBOL(S_PDBMAP , 0x1161) -CV_SYMBOL(S_GDATA_HLSL32 , 0x1162) -CV_SYMBOL(S_LDATA_HLSL32 , 0x1163) -CV_SYMBOL(S_GDATA_HLSL32_EX, 0x1164) -CV_SYMBOL(S_LDATA_HLSL32_EX, 0x1165) - -CV_SYMBOL(S_FASTLINK, 0x1167) // Undocumented -SYMBOL_RECORD_ALIAS(S_INLINEES, 0x1168, InlineesSym, CallerSym) // Undocumented - -// Known symbol types -SYMBOL_RECORD(S_END , 0x0006, ScopeEndSym) -SYMBOL_RECORD_ALIAS(S_INLINESITE_END , 0x114e, InlineSiteEnd, ScopeEndSym) -SYMBOL_RECORD_ALIAS(S_PROC_ID_END , 0x114f, ProcEnd, ScopeEndSym) - -SYMBOL_RECORD(S_THUNK32 , 0x1102, Thunk32Sym) -SYMBOL_RECORD(S_TRAMPOLINE , 0x112c, TrampolineSym) -SYMBOL_RECORD(S_SECTION , 0x1136, SectionSym) -SYMBOL_RECORD(S_COFFGROUP , 0x1137, CoffGroupSym) -SYMBOL_RECORD(S_EXPORT , 0x1138, ExportSym) - -SYMBOL_RECORD(S_LPROC32 , 0x110f, ProcSym) -SYMBOL_RECORD_ALIAS(S_GPROC32 , 0x1110, GlobalProcSym, ProcSym) -SYMBOL_RECORD_ALIAS(S_LPROC32_ID , 0x1146, ProcIdSym, ProcSym) -SYMBOL_RECORD_ALIAS(S_GPROC32_ID , 0x1147, GlobalProcIdSym, ProcSym) -SYMBOL_RECORD_ALIAS(S_LPROC32_DPC , 0x1155, DPCProcSym, ProcSym) -SYMBOL_RECORD_ALIAS(S_LPROC32_DPC_ID , 0x1156, DPCProcIdSym, ProcSym) - -SYMBOL_RECORD(S_REGISTER , 0x1106, RegisterSym) -SYMBOL_RECORD(S_PUB32 , 0x110e, PublicSym32) - -SYMBOL_RECORD(S_PROCREF , 0x1125, ProcRefSym) -SYMBOL_RECORD_ALIAS(S_LPROCREF, 0x1127, LocalProcRef, ProcRefSym) - - -SYMBOL_RECORD(S_ENVBLOCK , 0x113d, EnvBlockSym) - -SYMBOL_RECORD(S_INLINESITE , 0x114d, InlineSiteSym) -SYMBOL_RECORD(S_LOCAL , 0x113e, LocalSym) -SYMBOL_RECORD(S_DEFRANGE , 0x113f, DefRangeSym) -SYMBOL_RECORD(S_DEFRANGE_SUBFIELD, 0x1140, DefRangeSubfieldSym) -SYMBOL_RECORD(S_DEFRANGE_REGISTER, 0x1141, DefRangeRegisterSym) -SYMBOL_RECORD(S_DEFRANGE_FRAMEPOINTER_REL, 0x1142, DefRangeFramePointerRelSym) -SYMBOL_RECORD(S_DEFRANGE_SUBFIELD_REGISTER, 0x1143, DefRangeSubfieldRegisterSym) -SYMBOL_RECORD(S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE, 0x1144, DefRangeFramePointerRelFullScopeSym) -SYMBOL_RECORD(S_DEFRANGE_REGISTER_REL, 0x1145, DefRangeRegisterRelSym) -SYMBOL_RECORD(S_BLOCK32 , 0x1103, BlockSym) -SYMBOL_RECORD(S_LABEL32 , 0x1105, LabelSym) -SYMBOL_RECORD(S_OBJNAME , 0x1101, ObjNameSym) -SYMBOL_RECORD(S_COMPILE2 , 0x1116, Compile2Sym) -SYMBOL_RECORD(S_COMPILE3 , 0x113c, Compile3Sym) -SYMBOL_RECORD(S_FRAMEPROC , 0x1012, FrameProcSym) -SYMBOL_RECORD(S_CALLSITEINFO , 0x1139, CallSiteInfoSym) -SYMBOL_RECORD(S_FILESTATIC , 0x1153, FileStaticSym) -SYMBOL_RECORD(S_HEAPALLOCSITE , 0x115e, HeapAllocationSiteSym) -SYMBOL_RECORD(S_FRAMECOOKIE , 0x113a, FrameCookieSym) - -SYMBOL_RECORD(S_CALLEES , 0x115a, CallerSym) -SYMBOL_RECORD_ALIAS(S_CALLERS, 0x115b, CalleeSym, CallerSym) - -SYMBOL_RECORD(S_UDT , 0x1108, UDTSym) -SYMBOL_RECORD_ALIAS(S_COBOLUDT , 0x1109, CobolUDT, UDTSym) - -SYMBOL_RECORD(S_BUILDINFO , 0x114c, BuildInfoSym) -SYMBOL_RECORD(S_BPREL32 , 0x110b, BPRelativeSym) -SYMBOL_RECORD(S_REGREL32 , 0x1111, RegRelativeSym) - -SYMBOL_RECORD(S_CONSTANT , 0x1107, ConstantSym) -SYMBOL_RECORD_ALIAS(S_MANCONSTANT , 0x112d, ManagedConstant, ConstantSym) - -SYMBOL_RECORD(S_LDATA32 , 0x110c, DataSym) -SYMBOL_RECORD_ALIAS(S_GDATA32 , 0x110d, GlobalData, DataSym) -SYMBOL_RECORD_ALIAS(S_LMANDATA , 0x111c, ManagedLocalData, DataSym) -SYMBOL_RECORD_ALIAS(S_GMANDATA , 0x111d, ManagedGlobalData, DataSym) - -SYMBOL_RECORD(S_LTHREAD32 , 0x1112, ThreadLocalDataSym) -SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym) - -SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym) -SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym) - -#undef CV_SYMBOL -#undef SYMBOL_RECORD -#undef SYMBOL_RECORD_ALIAS +//===-- CodeViewSymbols.def - All CodeView leaf types -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// See LEAF_ENUM_e in cvinfo.h. This should match the constants there. +// +//===----------------------------------------------------------------------===// + +#ifndef CV_SYMBOL +#define CV_SYMBOL(ename, value) +#endif + +#ifndef SYMBOL_RECORD +#define SYMBOL_RECORD(lf_ename, value, name) CV_SYMBOL(lf_ename, value) +#endif + +#ifndef SYMBOL_RECORD_ALIAS +#define SYMBOL_RECORD_ALIAS(lf_ename, value, name, alias_name) \ + SYMBOL_RECORD(lf_ename, value, name) +#endif + +// 16 bit symbol types. Not very useful, provided only for reference. +CV_SYMBOL(S_COMPILE , 0x0001) +CV_SYMBOL(S_REGISTER_16t , 0x0002) +CV_SYMBOL(S_CONSTANT_16t , 0x0003) +CV_SYMBOL(S_UDT_16t , 0x0004) +CV_SYMBOL(S_SSEARCH , 0x0005) +CV_SYMBOL(S_SKIP , 0x0007) +CV_SYMBOL(S_CVRESERVE , 0x0008) +CV_SYMBOL(S_OBJNAME_ST , 0x0009) +CV_SYMBOL(S_ENDARG , 0x000a) +CV_SYMBOL(S_COBOLUDT_16t , 0x000b) +CV_SYMBOL(S_MANYREG_16t , 0x000c) +CV_SYMBOL(S_RETURN , 0x000d) +CV_SYMBOL(S_ENTRYTHIS , 0x000e) +CV_SYMBOL(S_BPREL16 , 0x0100) +CV_SYMBOL(S_LDATA16 , 0x0101) +CV_SYMBOL(S_GDATA16 , 0x0102) +CV_SYMBOL(S_PUB16 , 0x0103) +CV_SYMBOL(S_LPROC16 , 0x0104) +CV_SYMBOL(S_GPROC16 , 0x0105) +CV_SYMBOL(S_THUNK16 , 0x0106) +CV_SYMBOL(S_BLOCK16 , 0x0107) +CV_SYMBOL(S_WITH16 , 0x0108) +CV_SYMBOL(S_LABEL16 , 0x0109) +CV_SYMBOL(S_CEXMODEL16 , 0x010a) +CV_SYMBOL(S_VFTABLE16 , 0x010b) +CV_SYMBOL(S_REGREL16 , 0x010c) +CV_SYMBOL(S_BPREL32_16t , 0x0200) +CV_SYMBOL(S_LDATA32_16t , 0x0201) +CV_SYMBOL(S_GDATA32_16t , 0x0202) +CV_SYMBOL(S_PUB32_16t , 0x0203) +CV_SYMBOL(S_LPROC32_16t , 0x0204) +CV_SYMBOL(S_GPROC32_16t , 0x0205) +CV_SYMBOL(S_THUNK32_ST , 0x0206) +CV_SYMBOL(S_BLOCK32_ST , 0x0207) +CV_SYMBOL(S_WITH32_ST , 0x0208) +CV_SYMBOL(S_LABEL32_ST , 0x0209) +CV_SYMBOL(S_CEXMODEL32 , 0x020a) +CV_SYMBOL(S_VFTABLE32_16t , 0x020b) +CV_SYMBOL(S_REGREL32_16t , 0x020c) +CV_SYMBOL(S_LTHREAD32_16t , 0x020d) +CV_SYMBOL(S_GTHREAD32_16t , 0x020e) +CV_SYMBOL(S_SLINK32 , 0x020f) +CV_SYMBOL(S_LPROCMIPS_16t , 0x0300) +CV_SYMBOL(S_GPROCMIPS_16t , 0x0301) +CV_SYMBOL(S_PROCREF_ST , 0x0400) +CV_SYMBOL(S_DATAREF_ST , 0x0401) +CV_SYMBOL(S_ALIGN , 0x0402) +CV_SYMBOL(S_LPROCREF_ST , 0x0403) +CV_SYMBOL(S_OEM , 0x0404) + +// All post 16 bit symbol types have the 0x1000 bit set. +CV_SYMBOL(S_TI16_MAX , 0x1000) + +// Mostly unused "start" symbol types. +CV_SYMBOL(S_REGISTER_ST , 0x1001) +CV_SYMBOL(S_CONSTANT_ST , 0x1002) +CV_SYMBOL(S_UDT_ST , 0x1003) +CV_SYMBOL(S_COBOLUDT_ST , 0x1004) +CV_SYMBOL(S_MANYREG_ST , 0x1005) +CV_SYMBOL(S_BPREL32_ST , 0x1006) +CV_SYMBOL(S_LDATA32_ST , 0x1007) +CV_SYMBOL(S_GDATA32_ST , 0x1008) +CV_SYMBOL(S_PUB32_ST , 0x1009) +CV_SYMBOL(S_LPROC32_ST , 0x100a) +CV_SYMBOL(S_GPROC32_ST , 0x100b) +CV_SYMBOL(S_VFTABLE32 , 0x100c) +CV_SYMBOL(S_REGREL32_ST , 0x100d) +CV_SYMBOL(S_LTHREAD32_ST , 0x100e) +CV_SYMBOL(S_GTHREAD32_ST , 0x100f) +CV_SYMBOL(S_LPROCMIPS_ST , 0x1010) +CV_SYMBOL(S_GPROCMIPS_ST , 0x1011) + +CV_SYMBOL(S_COMPILE2_ST , 0x1013) +CV_SYMBOL(S_MANYREG2_ST , 0x1014) +CV_SYMBOL(S_LPROCIA64_ST , 0x1015) +CV_SYMBOL(S_GPROCIA64_ST , 0x1016) +CV_SYMBOL(S_LOCALSLOT_ST , 0x1017) +CV_SYMBOL(S_PARAMSLOT_ST , 0x1018) +CV_SYMBOL(S_GMANPROC_ST , 0x101a) +CV_SYMBOL(S_LMANPROC_ST , 0x101b) +CV_SYMBOL(S_RESERVED1 , 0x101c) +CV_SYMBOL(S_RESERVED2 , 0x101d) +CV_SYMBOL(S_RESERVED3 , 0x101e) +CV_SYMBOL(S_RESERVED4 , 0x101f) +CV_SYMBOL(S_LMANDATA_ST , 0x1020) +CV_SYMBOL(S_GMANDATA_ST , 0x1021) +CV_SYMBOL(S_MANFRAMEREL_ST, 0x1022) +CV_SYMBOL(S_MANREGISTER_ST, 0x1023) +CV_SYMBOL(S_MANSLOT_ST , 0x1024) +CV_SYMBOL(S_MANMANYREG_ST , 0x1025) +CV_SYMBOL(S_MANREGREL_ST , 0x1026) +CV_SYMBOL(S_MANMANYREG2_ST, 0x1027) +CV_SYMBOL(S_MANTYPREF , 0x1028) +CV_SYMBOL(S_UNAMESPACE_ST , 0x1029) + +// End of S_*_ST symbols, which do not appear to be generated by modern +// compilers. +CV_SYMBOL(S_ST_MAX , 0x1100) + + +CV_SYMBOL(S_WITH32 , 0x1104) +CV_SYMBOL(S_MANYREG , 0x110a) +CV_SYMBOL(S_LPROCMIPS , 0x1114) +CV_SYMBOL(S_GPROCMIPS , 0x1115) +CV_SYMBOL(S_MANYREG2 , 0x1117) +CV_SYMBOL(S_LPROCIA64 , 0x1118) +CV_SYMBOL(S_GPROCIA64 , 0x1119) +CV_SYMBOL(S_LOCALSLOT , 0x111a) +CV_SYMBOL(S_PARAMSLOT , 0x111b) + +// Managed code symbols. +CV_SYMBOL(S_MANFRAMEREL , 0x111e) +CV_SYMBOL(S_MANREGISTER , 0x111f) +CV_SYMBOL(S_MANSLOT , 0x1120) +CV_SYMBOL(S_MANMANYREG , 0x1121) +CV_SYMBOL(S_MANREGREL , 0x1122) +CV_SYMBOL(S_MANMANYREG2 , 0x1123) +CV_SYMBOL(S_DATAREF , 0x1126) +CV_SYMBOL(S_ANNOTATIONREF , 0x1128) +CV_SYMBOL(S_TOKENREF , 0x1129) +CV_SYMBOL(S_GMANPROC , 0x112a) +CV_SYMBOL(S_LMANPROC , 0x112b) +CV_SYMBOL(S_ATTR_FRAMEREL , 0x112e) +CV_SYMBOL(S_ATTR_REGISTER , 0x112f) +CV_SYMBOL(S_ATTR_REGREL , 0x1130) +CV_SYMBOL(S_ATTR_MANYREG , 0x1131) + + +CV_SYMBOL(S_SEPCODE , 0x1132) +CV_SYMBOL(S_LOCAL_2005 , 0x1133) +CV_SYMBOL(S_DEFRANGE_2005 , 0x1134) +CV_SYMBOL(S_DEFRANGE2_2005, 0x1135) +CV_SYMBOL(S_DISCARDED , 0x113b) + +// Current symbol types for most procedures as of this writing. +CV_SYMBOL(S_LPROCMIPS_ID , 0x1148) +CV_SYMBOL(S_GPROCMIPS_ID , 0x1149) +CV_SYMBOL(S_LPROCIA64_ID , 0x114a) +CV_SYMBOL(S_GPROCIA64_ID , 0x114b) + +CV_SYMBOL(S_DEFRANGE_HLSL , 0x1150) +CV_SYMBOL(S_GDATA_HLSL , 0x1151) +CV_SYMBOL(S_LDATA_HLSL , 0x1152) +CV_SYMBOL(S_LOCAL_DPC_GROUPSHARED, 0x1154) +CV_SYMBOL(S_DEFRANGE_DPC_PTR_TAG, 0x1157) +CV_SYMBOL(S_DPC_SYM_TAG_MAP, 0x1158) +CV_SYMBOL(S_ARMSWITCHTABLE , 0x1159) +CV_SYMBOL(S_POGODATA , 0x115c) +CV_SYMBOL(S_INLINESITE2 , 0x115d) +CV_SYMBOL(S_MOD_TYPEREF , 0x115f) +CV_SYMBOL(S_REF_MINIPDB , 0x1160) +CV_SYMBOL(S_PDBMAP , 0x1161) +CV_SYMBOL(S_GDATA_HLSL32 , 0x1162) +CV_SYMBOL(S_LDATA_HLSL32 , 0x1163) +CV_SYMBOL(S_GDATA_HLSL32_EX, 0x1164) +CV_SYMBOL(S_LDATA_HLSL32_EX, 0x1165) + +CV_SYMBOL(S_FASTLINK, 0x1167) // Undocumented +SYMBOL_RECORD_ALIAS(S_INLINEES, 0x1168, InlineesSym, CallerSym) // Undocumented + +// Known symbol types +SYMBOL_RECORD(S_END , 0x0006, ScopeEndSym) +SYMBOL_RECORD_ALIAS(S_INLINESITE_END , 0x114e, InlineSiteEnd, ScopeEndSym) +SYMBOL_RECORD_ALIAS(S_PROC_ID_END , 0x114f, ProcEnd, ScopeEndSym) + +SYMBOL_RECORD(S_THUNK32 , 0x1102, Thunk32Sym) +SYMBOL_RECORD(S_TRAMPOLINE , 0x112c, TrampolineSym) +SYMBOL_RECORD(S_SECTION , 0x1136, SectionSym) +SYMBOL_RECORD(S_COFFGROUP , 0x1137, CoffGroupSym) +SYMBOL_RECORD(S_EXPORT , 0x1138, ExportSym) + +SYMBOL_RECORD(S_LPROC32 , 0x110f, ProcSym) +SYMBOL_RECORD_ALIAS(S_GPROC32 , 0x1110, GlobalProcSym, ProcSym) +SYMBOL_RECORD_ALIAS(S_LPROC32_ID , 0x1146, ProcIdSym, ProcSym) +SYMBOL_RECORD_ALIAS(S_GPROC32_ID , 0x1147, GlobalProcIdSym, ProcSym) +SYMBOL_RECORD_ALIAS(S_LPROC32_DPC , 0x1155, DPCProcSym, ProcSym) +SYMBOL_RECORD_ALIAS(S_LPROC32_DPC_ID , 0x1156, DPCProcIdSym, ProcSym) + +SYMBOL_RECORD(S_REGISTER , 0x1106, RegisterSym) +SYMBOL_RECORD(S_PUB32 , 0x110e, PublicSym32) + +SYMBOL_RECORD(S_PROCREF , 0x1125, ProcRefSym) +SYMBOL_RECORD_ALIAS(S_LPROCREF, 0x1127, LocalProcRef, ProcRefSym) + + +SYMBOL_RECORD(S_ENVBLOCK , 0x113d, EnvBlockSym) + +SYMBOL_RECORD(S_INLINESITE , 0x114d, InlineSiteSym) +SYMBOL_RECORD(S_LOCAL , 0x113e, LocalSym) +SYMBOL_RECORD(S_DEFRANGE , 0x113f, DefRangeSym) +SYMBOL_RECORD(S_DEFRANGE_SUBFIELD, 0x1140, DefRangeSubfieldSym) +SYMBOL_RECORD(S_DEFRANGE_REGISTER, 0x1141, DefRangeRegisterSym) +SYMBOL_RECORD(S_DEFRANGE_FRAMEPOINTER_REL, 0x1142, DefRangeFramePointerRelSym) +SYMBOL_RECORD(S_DEFRANGE_SUBFIELD_REGISTER, 0x1143, DefRangeSubfieldRegisterSym) +SYMBOL_RECORD(S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE, 0x1144, DefRangeFramePointerRelFullScopeSym) +SYMBOL_RECORD(S_DEFRANGE_REGISTER_REL, 0x1145, DefRangeRegisterRelSym) +SYMBOL_RECORD(S_BLOCK32 , 0x1103, BlockSym) +SYMBOL_RECORD(S_LABEL32 , 0x1105, LabelSym) +SYMBOL_RECORD(S_OBJNAME , 0x1101, ObjNameSym) +SYMBOL_RECORD(S_COMPILE2 , 0x1116, Compile2Sym) +SYMBOL_RECORD(S_COMPILE3 , 0x113c, Compile3Sym) +SYMBOL_RECORD(S_FRAMEPROC , 0x1012, FrameProcSym) +SYMBOL_RECORD(S_CALLSITEINFO , 0x1139, CallSiteInfoSym) +SYMBOL_RECORD(S_FILESTATIC , 0x1153, FileStaticSym) +SYMBOL_RECORD(S_HEAPALLOCSITE , 0x115e, HeapAllocationSiteSym) +SYMBOL_RECORD(S_FRAMECOOKIE , 0x113a, FrameCookieSym) + +SYMBOL_RECORD(S_CALLEES , 0x115a, CallerSym) +SYMBOL_RECORD_ALIAS(S_CALLERS, 0x115b, CalleeSym, CallerSym) + +SYMBOL_RECORD(S_UDT , 0x1108, UDTSym) +SYMBOL_RECORD_ALIAS(S_COBOLUDT , 0x1109, CobolUDT, UDTSym) + +SYMBOL_RECORD(S_BUILDINFO , 0x114c, BuildInfoSym) +SYMBOL_RECORD(S_BPREL32 , 0x110b, BPRelativeSym) +SYMBOL_RECORD(S_REGREL32 , 0x1111, RegRelativeSym) + +SYMBOL_RECORD(S_CONSTANT , 0x1107, ConstantSym) +SYMBOL_RECORD_ALIAS(S_MANCONSTANT , 0x112d, ManagedConstant, ConstantSym) + +SYMBOL_RECORD(S_LDATA32 , 0x110c, DataSym) +SYMBOL_RECORD_ALIAS(S_GDATA32 , 0x110d, GlobalData, DataSym) +SYMBOL_RECORD_ALIAS(S_LMANDATA , 0x111c, ManagedLocalData, DataSym) +SYMBOL_RECORD_ALIAS(S_GMANDATA , 0x111d, ManagedGlobalData, DataSym) + +SYMBOL_RECORD(S_LTHREAD32 , 0x1112, ThreadLocalDataSym) +SYMBOL_RECORD_ALIAS(S_GTHREAD32 , 0x1113, GlobalTLS, ThreadLocalDataSym) + +SYMBOL_RECORD(S_UNAMESPACE , 0x1124, UsingNamespaceSym) +SYMBOL_RECORD(S_ANNOTATION , 0x1019, AnnotationSym) + +#undef CV_SYMBOL +#undef SYMBOL_RECORD +#undef SYMBOL_RECORD_ALIAS diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewTypes.def b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewTypes.def index 103d3eb242..a31111eb80 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewTypes.def +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/CodeViewTypes.def @@ -1,249 +1,249 @@ -//===-- CodeViewTypes.def - All CodeView leaf types -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// See LEAF_ENUM_e in cvinfo.h. This should match the constants there. -// -//===----------------------------------------------------------------------===// - -// If the type is known, then we have a record describing it in TypeRecord.h. - -#ifndef CV_TYPE -#define CV_TYPE(lf_ename, value) -#endif - -// If the type is known, then we have a record describing it in TypeRecord.h. -#ifndef TYPE_RECORD -#define TYPE_RECORD(lf_ename, value, name) CV_TYPE(lf_ename, value) -#endif - -#ifndef TYPE_RECORD_ALIAS -#define TYPE_RECORD_ALIAS(lf_ename, value, name, alias_name) \ - TYPE_RECORD(lf_ename, value, name) -#endif - -#ifndef MEMBER_RECORD -#define MEMBER_RECORD(lf_ename, value, name) TYPE_RECORD(lf_ename, value, name) -#endif - -#ifndef MEMBER_RECORD_ALIAS -#define MEMBER_RECORD_ALIAS(lf_ename, value, name, alias_name) \ - MEMBER_RECORD(lf_ename, value, name) -#endif - -TYPE_RECORD(LF_POINTER, 0x1002, Pointer) -TYPE_RECORD(LF_MODIFIER, 0x1001, Modifier) -TYPE_RECORD(LF_PROCEDURE, 0x1008, Procedure) -TYPE_RECORD(LF_MFUNCTION, 0x1009, MemberFunction) -TYPE_RECORD(LF_LABEL, 0x000e, Label) -TYPE_RECORD(LF_ARGLIST, 0x1201, ArgList) - -TYPE_RECORD(LF_FIELDLIST, 0x1203, FieldList) - -TYPE_RECORD(LF_ARRAY, 0x1503, Array) -TYPE_RECORD(LF_CLASS, 0x1504, Class) -TYPE_RECORD_ALIAS(LF_STRUCTURE, 0x1505, Struct, Class) -TYPE_RECORD_ALIAS(LF_INTERFACE, 0x1519, Interface, Class) -TYPE_RECORD(LF_UNION, 0x1506, Union) -TYPE_RECORD(LF_ENUM, 0x1507, Enum) -TYPE_RECORD(LF_TYPESERVER2, 0x1515, TypeServer2) -TYPE_RECORD(LF_VFTABLE, 0x151d, VFTable) -TYPE_RECORD(LF_VTSHAPE, 0x000a, VFTableShape) - -TYPE_RECORD(LF_BITFIELD, 0x1205, BitField) - -// Member type records. These are generally not length prefixed, and appear -// inside of a field list record. -MEMBER_RECORD(LF_BCLASS, 0x1400, BaseClass) -MEMBER_RECORD_ALIAS(LF_BINTERFACE, 0x151a, BaseInterface, BaseClass) - -MEMBER_RECORD(LF_VBCLASS, 0x1401, VirtualBaseClass) -MEMBER_RECORD_ALIAS(LF_IVBCLASS, 0x1402, IndirectVirtualBaseClass, - VirtualBaseClass) - -MEMBER_RECORD(LF_VFUNCTAB, 0x1409, VFPtr) -MEMBER_RECORD(LF_STMEMBER, 0x150e, StaticDataMember) -MEMBER_RECORD(LF_METHOD, 0x150f, OverloadedMethod) -MEMBER_RECORD(LF_MEMBER, 0x150d, DataMember) -MEMBER_RECORD(LF_NESTTYPE, 0x1510, NestedType) -MEMBER_RECORD(LF_ONEMETHOD, 0x1511, OneMethod) -MEMBER_RECORD(LF_ENUMERATE, 0x1502, Enumerator) -MEMBER_RECORD(LF_INDEX, 0x1404, ListContinuation) - -// ID leaf records. Subsequent leaf types may be referenced from .debug$S. -TYPE_RECORD(LF_FUNC_ID, 0x1601, FuncId) -TYPE_RECORD(LF_MFUNC_ID, 0x1602, MemberFuncId) -TYPE_RECORD(LF_BUILDINFO, 0x1603, BuildInfo) -TYPE_RECORD(LF_SUBSTR_LIST, 0x1604, StringList) -TYPE_RECORD(LF_STRING_ID, 0x1605, StringId) -TYPE_RECORD(LF_UDT_SRC_LINE, 0x1606, UdtSourceLine) -TYPE_RECORD(LF_UDT_MOD_SRC_LINE, 0x1607, UdtModSourceLine) - - -TYPE_RECORD(LF_METHODLIST, 0x1206, MethodOverloadList) - -TYPE_RECORD(LF_PRECOMP, 0x1509, Precomp) -TYPE_RECORD(LF_ENDPRECOMP, 0x0014, EndPrecomp) - -// 16 bit type records. -CV_TYPE(LF_MODIFIER_16t, 0x0001) -CV_TYPE(LF_POINTER_16t, 0x0002) -CV_TYPE(LF_ARRAY_16t, 0x0003) -CV_TYPE(LF_CLASS_16t, 0x0004) -CV_TYPE(LF_STRUCTURE_16t, 0x0005) -CV_TYPE(LF_UNION_16t, 0x0006) -CV_TYPE(LF_ENUM_16t, 0x0007) -CV_TYPE(LF_PROCEDURE_16t, 0x0008) -CV_TYPE(LF_MFUNCTION_16t, 0x0009) -CV_TYPE(LF_COBOL0_16t, 0x000b) -CV_TYPE(LF_COBOL1, 0x000c) -CV_TYPE(LF_BARRAY_16t, 0x000d) -CV_TYPE(LF_NULLLEAF, 0x000f) // LF_NULL -CV_TYPE(LF_NOTTRAN, 0x0010) -CV_TYPE(LF_DIMARRAY_16t, 0x0011) -CV_TYPE(LF_VFTPATH_16t, 0x0012) -CV_TYPE(LF_PRECOMP_16t, 0x0013) -CV_TYPE(LF_OEM_16t, 0x0015) -CV_TYPE(LF_TYPESERVER_ST, 0x0016) - -CV_TYPE(LF_SKIP_16t, 0x0200) -CV_TYPE(LF_ARGLIST_16t, 0x0201) -CV_TYPE(LF_DEFARG_16t, 0x0202) -CV_TYPE(LF_LIST, 0x0203) -CV_TYPE(LF_FIELDLIST_16t, 0x0204) -CV_TYPE(LF_DERIVED_16t, 0x0205) -CV_TYPE(LF_BITFIELD_16t, 0x0206) -CV_TYPE(LF_METHODLIST_16t, 0x0207) -CV_TYPE(LF_DIMCONU_16t, 0x0208) -CV_TYPE(LF_DIMCONLU_16t, 0x0209) -CV_TYPE(LF_DIMVARU_16t, 0x020a) -CV_TYPE(LF_DIMVARLU_16t, 0x020b) -CV_TYPE(LF_REFSYM, 0x020c) - -// 16 bit member types. Generally not length prefixed. -CV_TYPE(LF_BCLASS_16t, 0x0400) -CV_TYPE(LF_VBCLASS_16t, 0x0401) -CV_TYPE(LF_IVBCLASS_16t, 0x0402) -CV_TYPE(LF_ENUMERATE_ST, 0x0403) -CV_TYPE(LF_FRIENDFCN_16t, 0x0404) -CV_TYPE(LF_INDEX_16t, 0x0405) -CV_TYPE(LF_MEMBER_16t, 0x0406) -CV_TYPE(LF_STMEMBER_16t, 0x0407) -CV_TYPE(LF_METHOD_16t, 0x0408) -CV_TYPE(LF_NESTTYPE_16t, 0x0409) -CV_TYPE(LF_VFUNCTAB_16t, 0x040a) -CV_TYPE(LF_FRIENDCLS_16t, 0x040b) -CV_TYPE(LF_ONEMETHOD_16t, 0x040c) -CV_TYPE(LF_VFUNCOFF_16t, 0x040d) - -CV_TYPE(LF_TI16_MAX, 0x1000) - -CV_TYPE(LF_ARRAY_ST, 0x1003) -CV_TYPE(LF_CLASS_ST, 0x1004) -CV_TYPE(LF_STRUCTURE_ST, 0x1005) -CV_TYPE(LF_UNION_ST, 0x1006) -CV_TYPE(LF_ENUM_ST, 0x1007) -CV_TYPE(LF_COBOL0, 0x100a) -CV_TYPE(LF_BARRAY, 0x100b) -CV_TYPE(LF_DIMARRAY_ST, 0x100c) -CV_TYPE(LF_VFTPATH, 0x100d) -CV_TYPE(LF_PRECOMP_ST, 0x100e) -CV_TYPE(LF_OEM, 0x100f) -CV_TYPE(LF_ALIAS_ST, 0x1010) -CV_TYPE(LF_OEM2, 0x1011) - -CV_TYPE(LF_SKIP, 0x1200) -CV_TYPE(LF_DEFARG_ST, 0x1202) -CV_TYPE(LF_DERIVED, 0x1204) -CV_TYPE(LF_DIMCONU, 0x1207) -CV_TYPE(LF_DIMCONLU, 0x1208) -CV_TYPE(LF_DIMVARU, 0x1209) -CV_TYPE(LF_DIMVARLU, 0x120a) - -// Member type records. These are generally not length prefixed, and appear -// inside of a field list record. -CV_TYPE(LF_FRIENDFCN_ST, 0x1403) -CV_TYPE(LF_MEMBER_ST, 0x1405) -CV_TYPE(LF_STMEMBER_ST, 0x1406) -CV_TYPE(LF_METHOD_ST, 0x1407) -CV_TYPE(LF_NESTTYPE_ST, 0x1408) -CV_TYPE(LF_FRIENDCLS, 0x140a) -CV_TYPE(LF_ONEMETHOD_ST, 0x140b) -CV_TYPE(LF_VFUNCOFF, 0x140c) -CV_TYPE(LF_NESTTYPEEX_ST, 0x140d) -CV_TYPE(LF_MEMBERMODIFY_ST, 0x140e) -CV_TYPE(LF_MANAGED_ST, 0x140f) - -CV_TYPE(LF_ST_MAX, 0x1500) -CV_TYPE(LF_TYPESERVER, 0x1501) -CV_TYPE(LF_DIMARRAY, 0x1508) -CV_TYPE(LF_ALIAS, 0x150a) -CV_TYPE(LF_DEFARG, 0x150b) -CV_TYPE(LF_FRIENDFCN, 0x150c) -CV_TYPE(LF_NESTTYPEEX, 0x1512) -CV_TYPE(LF_MEMBERMODIFY, 0x1513) -CV_TYPE(LF_MANAGED, 0x1514) -CV_TYPE(LF_STRIDED_ARRAY, 0x1516) -CV_TYPE(LF_HLSL, 0x1517) -CV_TYPE(LF_MODIFIER_EX, 0x1518) -CV_TYPE(LF_VECTOR, 0x151b) -CV_TYPE(LF_MATRIX, 0x151c) - -// ID leaf records. Subsequent leaf types may be referenced from .debug$S. - -// Numeric leaf types. These are generally contained in other records, and not -// encountered in the main type stream. - -CV_TYPE(LF_NUMERIC, 0x8000) -CV_TYPE(LF_CHAR, 0x8000) -CV_TYPE(LF_SHORT, 0x8001) -CV_TYPE(LF_USHORT, 0x8002) -CV_TYPE(LF_LONG, 0x8003) -CV_TYPE(LF_ULONG, 0x8004) -CV_TYPE(LF_REAL32, 0x8005) -CV_TYPE(LF_REAL64, 0x8006) -CV_TYPE(LF_REAL80, 0x8007) -CV_TYPE(LF_REAL128, 0x8008) -CV_TYPE(LF_QUADWORD, 0x8009) -CV_TYPE(LF_UQUADWORD, 0x800a) -CV_TYPE(LF_REAL48, 0x800b) -CV_TYPE(LF_COMPLEX32, 0x800c) -CV_TYPE(LF_COMPLEX64, 0x800d) -CV_TYPE(LF_COMPLEX80, 0x800e) -CV_TYPE(LF_COMPLEX128, 0x800f) -CV_TYPE(LF_VARSTRING, 0x8010) -CV_TYPE(LF_OCTWORD, 0x8017) -CV_TYPE(LF_UOCTWORD, 0x8018) -CV_TYPE(LF_DECIMAL, 0x8019) -CV_TYPE(LF_DATE, 0x801a) -CV_TYPE(LF_UTF8STRING, 0x801b) -CV_TYPE(LF_REAL16, 0x801c) - -// Padding bytes. These are emitted into alignment bytes in the type stream. - -CV_TYPE(LF_PAD0, 0xf0) -CV_TYPE(LF_PAD1, 0xf1) -CV_TYPE(LF_PAD2, 0xf2) -CV_TYPE(LF_PAD3, 0xf3) -CV_TYPE(LF_PAD4, 0xf4) -CV_TYPE(LF_PAD5, 0xf5) -CV_TYPE(LF_PAD6, 0xf6) -CV_TYPE(LF_PAD7, 0xf7) -CV_TYPE(LF_PAD8, 0xf8) -CV_TYPE(LF_PAD9, 0xf9) -CV_TYPE(LF_PAD10, 0xfa) -CV_TYPE(LF_PAD11, 0xfb) -CV_TYPE(LF_PAD12, 0xfc) -CV_TYPE(LF_PAD13, 0xfd) -CV_TYPE(LF_PAD14, 0xfe) -CV_TYPE(LF_PAD15, 0xff) - -#undef CV_TYPE -#undef TYPE_RECORD -#undef TYPE_RECORD_ALIAS -#undef MEMBER_RECORD -#undef MEMBER_RECORD_ALIAS +//===-- CodeViewTypes.def - All CodeView leaf types -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// See LEAF_ENUM_e in cvinfo.h. This should match the constants there. +// +//===----------------------------------------------------------------------===// + +// If the type is known, then we have a record describing it in TypeRecord.h. + +#ifndef CV_TYPE +#define CV_TYPE(lf_ename, value) +#endif + +// If the type is known, then we have a record describing it in TypeRecord.h. +#ifndef TYPE_RECORD +#define TYPE_RECORD(lf_ename, value, name) CV_TYPE(lf_ename, value) +#endif + +#ifndef TYPE_RECORD_ALIAS +#define TYPE_RECORD_ALIAS(lf_ename, value, name, alias_name) \ + TYPE_RECORD(lf_ename, value, name) +#endif + +#ifndef MEMBER_RECORD +#define MEMBER_RECORD(lf_ename, value, name) TYPE_RECORD(lf_ename, value, name) +#endif + +#ifndef MEMBER_RECORD_ALIAS +#define MEMBER_RECORD_ALIAS(lf_ename, value, name, alias_name) \ + MEMBER_RECORD(lf_ename, value, name) +#endif + +TYPE_RECORD(LF_POINTER, 0x1002, Pointer) +TYPE_RECORD(LF_MODIFIER, 0x1001, Modifier) +TYPE_RECORD(LF_PROCEDURE, 0x1008, Procedure) +TYPE_RECORD(LF_MFUNCTION, 0x1009, MemberFunction) +TYPE_RECORD(LF_LABEL, 0x000e, Label) +TYPE_RECORD(LF_ARGLIST, 0x1201, ArgList) + +TYPE_RECORD(LF_FIELDLIST, 0x1203, FieldList) + +TYPE_RECORD(LF_ARRAY, 0x1503, Array) +TYPE_RECORD(LF_CLASS, 0x1504, Class) +TYPE_RECORD_ALIAS(LF_STRUCTURE, 0x1505, Struct, Class) +TYPE_RECORD_ALIAS(LF_INTERFACE, 0x1519, Interface, Class) +TYPE_RECORD(LF_UNION, 0x1506, Union) +TYPE_RECORD(LF_ENUM, 0x1507, Enum) +TYPE_RECORD(LF_TYPESERVER2, 0x1515, TypeServer2) +TYPE_RECORD(LF_VFTABLE, 0x151d, VFTable) +TYPE_RECORD(LF_VTSHAPE, 0x000a, VFTableShape) + +TYPE_RECORD(LF_BITFIELD, 0x1205, BitField) + +// Member type records. These are generally not length prefixed, and appear +// inside of a field list record. +MEMBER_RECORD(LF_BCLASS, 0x1400, BaseClass) +MEMBER_RECORD_ALIAS(LF_BINTERFACE, 0x151a, BaseInterface, BaseClass) + +MEMBER_RECORD(LF_VBCLASS, 0x1401, VirtualBaseClass) +MEMBER_RECORD_ALIAS(LF_IVBCLASS, 0x1402, IndirectVirtualBaseClass, + VirtualBaseClass) + +MEMBER_RECORD(LF_VFUNCTAB, 0x1409, VFPtr) +MEMBER_RECORD(LF_STMEMBER, 0x150e, StaticDataMember) +MEMBER_RECORD(LF_METHOD, 0x150f, OverloadedMethod) +MEMBER_RECORD(LF_MEMBER, 0x150d, DataMember) +MEMBER_RECORD(LF_NESTTYPE, 0x1510, NestedType) +MEMBER_RECORD(LF_ONEMETHOD, 0x1511, OneMethod) +MEMBER_RECORD(LF_ENUMERATE, 0x1502, Enumerator) +MEMBER_RECORD(LF_INDEX, 0x1404, ListContinuation) + +// ID leaf records. Subsequent leaf types may be referenced from .debug$S. +TYPE_RECORD(LF_FUNC_ID, 0x1601, FuncId) +TYPE_RECORD(LF_MFUNC_ID, 0x1602, MemberFuncId) +TYPE_RECORD(LF_BUILDINFO, 0x1603, BuildInfo) +TYPE_RECORD(LF_SUBSTR_LIST, 0x1604, StringList) +TYPE_RECORD(LF_STRING_ID, 0x1605, StringId) +TYPE_RECORD(LF_UDT_SRC_LINE, 0x1606, UdtSourceLine) +TYPE_RECORD(LF_UDT_MOD_SRC_LINE, 0x1607, UdtModSourceLine) + + +TYPE_RECORD(LF_METHODLIST, 0x1206, MethodOverloadList) + +TYPE_RECORD(LF_PRECOMP, 0x1509, Precomp) +TYPE_RECORD(LF_ENDPRECOMP, 0x0014, EndPrecomp) + +// 16 bit type records. +CV_TYPE(LF_MODIFIER_16t, 0x0001) +CV_TYPE(LF_POINTER_16t, 0x0002) +CV_TYPE(LF_ARRAY_16t, 0x0003) +CV_TYPE(LF_CLASS_16t, 0x0004) +CV_TYPE(LF_STRUCTURE_16t, 0x0005) +CV_TYPE(LF_UNION_16t, 0x0006) +CV_TYPE(LF_ENUM_16t, 0x0007) +CV_TYPE(LF_PROCEDURE_16t, 0x0008) +CV_TYPE(LF_MFUNCTION_16t, 0x0009) +CV_TYPE(LF_COBOL0_16t, 0x000b) +CV_TYPE(LF_COBOL1, 0x000c) +CV_TYPE(LF_BARRAY_16t, 0x000d) +CV_TYPE(LF_NULLLEAF, 0x000f) // LF_NULL +CV_TYPE(LF_NOTTRAN, 0x0010) +CV_TYPE(LF_DIMARRAY_16t, 0x0011) +CV_TYPE(LF_VFTPATH_16t, 0x0012) +CV_TYPE(LF_PRECOMP_16t, 0x0013) +CV_TYPE(LF_OEM_16t, 0x0015) +CV_TYPE(LF_TYPESERVER_ST, 0x0016) + +CV_TYPE(LF_SKIP_16t, 0x0200) +CV_TYPE(LF_ARGLIST_16t, 0x0201) +CV_TYPE(LF_DEFARG_16t, 0x0202) +CV_TYPE(LF_LIST, 0x0203) +CV_TYPE(LF_FIELDLIST_16t, 0x0204) +CV_TYPE(LF_DERIVED_16t, 0x0205) +CV_TYPE(LF_BITFIELD_16t, 0x0206) +CV_TYPE(LF_METHODLIST_16t, 0x0207) +CV_TYPE(LF_DIMCONU_16t, 0x0208) +CV_TYPE(LF_DIMCONLU_16t, 0x0209) +CV_TYPE(LF_DIMVARU_16t, 0x020a) +CV_TYPE(LF_DIMVARLU_16t, 0x020b) +CV_TYPE(LF_REFSYM, 0x020c) + +// 16 bit member types. Generally not length prefixed. +CV_TYPE(LF_BCLASS_16t, 0x0400) +CV_TYPE(LF_VBCLASS_16t, 0x0401) +CV_TYPE(LF_IVBCLASS_16t, 0x0402) +CV_TYPE(LF_ENUMERATE_ST, 0x0403) +CV_TYPE(LF_FRIENDFCN_16t, 0x0404) +CV_TYPE(LF_INDEX_16t, 0x0405) +CV_TYPE(LF_MEMBER_16t, 0x0406) +CV_TYPE(LF_STMEMBER_16t, 0x0407) +CV_TYPE(LF_METHOD_16t, 0x0408) +CV_TYPE(LF_NESTTYPE_16t, 0x0409) +CV_TYPE(LF_VFUNCTAB_16t, 0x040a) +CV_TYPE(LF_FRIENDCLS_16t, 0x040b) +CV_TYPE(LF_ONEMETHOD_16t, 0x040c) +CV_TYPE(LF_VFUNCOFF_16t, 0x040d) + +CV_TYPE(LF_TI16_MAX, 0x1000) + +CV_TYPE(LF_ARRAY_ST, 0x1003) +CV_TYPE(LF_CLASS_ST, 0x1004) +CV_TYPE(LF_STRUCTURE_ST, 0x1005) +CV_TYPE(LF_UNION_ST, 0x1006) +CV_TYPE(LF_ENUM_ST, 0x1007) +CV_TYPE(LF_COBOL0, 0x100a) +CV_TYPE(LF_BARRAY, 0x100b) +CV_TYPE(LF_DIMARRAY_ST, 0x100c) +CV_TYPE(LF_VFTPATH, 0x100d) +CV_TYPE(LF_PRECOMP_ST, 0x100e) +CV_TYPE(LF_OEM, 0x100f) +CV_TYPE(LF_ALIAS_ST, 0x1010) +CV_TYPE(LF_OEM2, 0x1011) + +CV_TYPE(LF_SKIP, 0x1200) +CV_TYPE(LF_DEFARG_ST, 0x1202) +CV_TYPE(LF_DERIVED, 0x1204) +CV_TYPE(LF_DIMCONU, 0x1207) +CV_TYPE(LF_DIMCONLU, 0x1208) +CV_TYPE(LF_DIMVARU, 0x1209) +CV_TYPE(LF_DIMVARLU, 0x120a) + +// Member type records. These are generally not length prefixed, and appear +// inside of a field list record. +CV_TYPE(LF_FRIENDFCN_ST, 0x1403) +CV_TYPE(LF_MEMBER_ST, 0x1405) +CV_TYPE(LF_STMEMBER_ST, 0x1406) +CV_TYPE(LF_METHOD_ST, 0x1407) +CV_TYPE(LF_NESTTYPE_ST, 0x1408) +CV_TYPE(LF_FRIENDCLS, 0x140a) +CV_TYPE(LF_ONEMETHOD_ST, 0x140b) +CV_TYPE(LF_VFUNCOFF, 0x140c) +CV_TYPE(LF_NESTTYPEEX_ST, 0x140d) +CV_TYPE(LF_MEMBERMODIFY_ST, 0x140e) +CV_TYPE(LF_MANAGED_ST, 0x140f) + +CV_TYPE(LF_ST_MAX, 0x1500) +CV_TYPE(LF_TYPESERVER, 0x1501) +CV_TYPE(LF_DIMARRAY, 0x1508) +CV_TYPE(LF_ALIAS, 0x150a) +CV_TYPE(LF_DEFARG, 0x150b) +CV_TYPE(LF_FRIENDFCN, 0x150c) +CV_TYPE(LF_NESTTYPEEX, 0x1512) +CV_TYPE(LF_MEMBERMODIFY, 0x1513) +CV_TYPE(LF_MANAGED, 0x1514) +CV_TYPE(LF_STRIDED_ARRAY, 0x1516) +CV_TYPE(LF_HLSL, 0x1517) +CV_TYPE(LF_MODIFIER_EX, 0x1518) +CV_TYPE(LF_VECTOR, 0x151b) +CV_TYPE(LF_MATRIX, 0x151c) + +// ID leaf records. Subsequent leaf types may be referenced from .debug$S. + +// Numeric leaf types. These are generally contained in other records, and not +// encountered in the main type stream. + +CV_TYPE(LF_NUMERIC, 0x8000) +CV_TYPE(LF_CHAR, 0x8000) +CV_TYPE(LF_SHORT, 0x8001) +CV_TYPE(LF_USHORT, 0x8002) +CV_TYPE(LF_LONG, 0x8003) +CV_TYPE(LF_ULONG, 0x8004) +CV_TYPE(LF_REAL32, 0x8005) +CV_TYPE(LF_REAL64, 0x8006) +CV_TYPE(LF_REAL80, 0x8007) +CV_TYPE(LF_REAL128, 0x8008) +CV_TYPE(LF_QUADWORD, 0x8009) +CV_TYPE(LF_UQUADWORD, 0x800a) +CV_TYPE(LF_REAL48, 0x800b) +CV_TYPE(LF_COMPLEX32, 0x800c) +CV_TYPE(LF_COMPLEX64, 0x800d) +CV_TYPE(LF_COMPLEX80, 0x800e) +CV_TYPE(LF_COMPLEX128, 0x800f) +CV_TYPE(LF_VARSTRING, 0x8010) +CV_TYPE(LF_OCTWORD, 0x8017) +CV_TYPE(LF_UOCTWORD, 0x8018) +CV_TYPE(LF_DECIMAL, 0x8019) +CV_TYPE(LF_DATE, 0x801a) +CV_TYPE(LF_UTF8STRING, 0x801b) +CV_TYPE(LF_REAL16, 0x801c) + +// Padding bytes. These are emitted into alignment bytes in the type stream. + +CV_TYPE(LF_PAD0, 0xf0) +CV_TYPE(LF_PAD1, 0xf1) +CV_TYPE(LF_PAD2, 0xf2) +CV_TYPE(LF_PAD3, 0xf3) +CV_TYPE(LF_PAD4, 0xf4) +CV_TYPE(LF_PAD5, 0xf5) +CV_TYPE(LF_PAD6, 0xf6) +CV_TYPE(LF_PAD7, 0xf7) +CV_TYPE(LF_PAD8, 0xf8) +CV_TYPE(LF_PAD9, 0xf9) +CV_TYPE(LF_PAD10, 0xfa) +CV_TYPE(LF_PAD11, 0xfb) +CV_TYPE(LF_PAD12, 0xfc) +CV_TYPE(LF_PAD13, 0xfd) +CV_TYPE(LF_PAD14, 0xfe) +CV_TYPE(LF_PAD15, 0xff) + +#undef CV_TYPE +#undef TYPE_RECORD +#undef TYPE_RECORD_ALIAS +#undef MEMBER_RECORD +#undef MEMBER_RECORD_ALIAS diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h index 28ee7583ef..6a39181c2a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h @@ -1,74 +1,74 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- ContinuationRecordBuilder.h ------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H -#define LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Error.h" -#include <cassert> -#include <cstdint> -#include <memory> -#include <vector> - -namespace llvm { -namespace codeview { -enum class ContinuationRecordKind { FieldList, MethodOverloadList }; - -class ContinuationRecordBuilder { - SmallVector<uint32_t, 4> SegmentOffsets; - Optional<ContinuationRecordKind> Kind; - AppendingBinaryByteStream Buffer; - BinaryStreamWriter SegmentWriter; - TypeRecordMapping Mapping; - ArrayRef<uint8_t> InjectedSegmentBytes; - - uint32_t getCurrentSegmentLength() const; - - void insertSegmentEnd(uint32_t Offset); - CVType createSegmentRecord(uint32_t OffBegin, uint32_t OffEnd, - Optional<TypeIndex> RefersTo); - -public: - ContinuationRecordBuilder(); - ~ContinuationRecordBuilder(); - - void begin(ContinuationRecordKind RecordKind); - - // This template is explicitly instantiated in the implementation file for all - // supported types. The method itself is ugly, so inlining it into the header - // file clutters an otherwise straightforward interface. - template <typename RecordType> void writeMemberType(RecordType &Record); - - std::vector<CVType> end(TypeIndex Index); -}; -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- ContinuationRecordBuilder.h ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H +#define LLVM_DEBUGINFO_CODEVIEW_CONTINUATIONRECORDBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Error.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { +namespace codeview { +enum class ContinuationRecordKind { FieldList, MethodOverloadList }; + +class ContinuationRecordBuilder { + SmallVector<uint32_t, 4> SegmentOffsets; + Optional<ContinuationRecordKind> Kind; + AppendingBinaryByteStream Buffer; + BinaryStreamWriter SegmentWriter; + TypeRecordMapping Mapping; + ArrayRef<uint8_t> InjectedSegmentBytes; + + uint32_t getCurrentSegmentLength() const; + + void insertSegmentEnd(uint32_t Offset); + CVType createSegmentRecord(uint32_t OffBegin, uint32_t OffEnd, + Optional<TypeIndex> RefersTo); + +public: + ContinuationRecordBuilder(); + ~ContinuationRecordBuilder(); + + void begin(ContinuationRecordKind RecordKind); + + // This template is explicitly instantiated in the implementation file for all + // supported types. The method itself is ugly, so inlining it into the header + // file clutters an otherwise straightforward interface. + template <typename RecordType> void writeMemberType(RecordType &Record); + + std::vector<CVType> end(TypeIndex Index); +}; +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h index 5f45e7bce7..a06f298312 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h @@ -1,114 +1,114 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugChecksumsSubsection.h -------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -namespace codeview { - -class DebugStringTableSubsection; - -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. -}; - -} // end namespace codeview - -template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> { -public: - using ContextType = void; - - Error operator()(BinaryStreamRef Stream, uint32_t &Len, - codeview::FileChecksumEntry &Item); -}; - -namespace codeview { - -class DebugChecksumsSubsectionRef final : public DebugSubsectionRef { - using FileChecksumArray = VarStreamArray<codeview::FileChecksumEntry>; - using Iterator = FileChecksumArray::Iterator; - -public: - DebugChecksumsSubsectionRef() - : DebugSubsectionRef(DebugSubsectionKind::FileChecksums) {} - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::FileChecksums; - } - - bool valid() const { return Checksums.valid(); } - - Error initialize(BinaryStreamReader Reader); - Error initialize(BinaryStreamRef Stream); - - Iterator begin() const { return Checksums.begin(); } - Iterator end() const { return Checksums.end(); } - - const FileChecksumArray &getArray() const { return Checksums; } - -private: - FileChecksumArray Checksums; -}; - -class DebugChecksumsSubsection final : public DebugSubsection { -public: - explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings); - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::FileChecksums; - } - - void addChecksum(StringRef FileName, FileChecksumKind Kind, - ArrayRef<uint8_t> Bytes); - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - uint32_t mapChecksumOffset(StringRef FileName) const; - -private: - DebugStringTableSubsection &Strings; - - DenseMap<uint32_t, uint32_t> OffsetMap; - uint32_t SerializedSize = 0; - BumpPtrAllocator Storage; - std::vector<FileChecksumEntry> Checksums; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugChecksumsSubsection.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +namespace codeview { + +class DebugStringTableSubsection; + +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. +}; + +} // end namespace codeview + +template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> { +public: + using ContextType = void; + + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + codeview::FileChecksumEntry &Item); +}; + +namespace codeview { + +class DebugChecksumsSubsectionRef final : public DebugSubsectionRef { + using FileChecksumArray = VarStreamArray<codeview::FileChecksumEntry>; + using Iterator = FileChecksumArray::Iterator; + +public: + DebugChecksumsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::FileChecksums) {} + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::FileChecksums; + } + + bool valid() const { return Checksums.valid(); } + + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Stream); + + Iterator begin() const { return Checksums.begin(); } + Iterator end() const { return Checksums.end(); } + + const FileChecksumArray &getArray() const { return Checksums; } + +private: + FileChecksumArray Checksums; +}; + +class DebugChecksumsSubsection final : public DebugSubsection { +public: + explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FileChecksums; + } + + void addChecksum(StringRef FileName, FileChecksumKind Kind, + ArrayRef<uint8_t> Bytes); + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + uint32_t mapChecksumOffset(StringRef FileName) const; + +private: + DebugStringTableSubsection &Strings; + + DenseMap<uint32_t, uint32_t> OffsetMap; + uint32_t SerializedSize = 0; + BumpPtrAllocator Storage; + std::vector<FileChecksumEntry> Checksums; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h index 90a3b5687d..0ab2352a4a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h @@ -1,78 +1,78 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugCrossExSubsection.h ---------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <map> - -namespace llvm { -namespace codeview { - -class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef { - using ReferenceArray = FixedStreamArray<CrossModuleExport>; - using Iterator = ReferenceArray::Iterator; - -public: - DebugCrossModuleExportsSubsectionRef() - : DebugSubsectionRef(DebugSubsectionKind::CrossScopeExports) {} - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::CrossScopeExports; - } - - Error initialize(BinaryStreamReader Reader); - Error initialize(BinaryStreamRef Stream); - - Iterator begin() const { return References.begin(); } - Iterator end() const { return References.end(); } - -private: - FixedStreamArray<CrossModuleExport> References; -}; - -class DebugCrossModuleExportsSubsection final : public DebugSubsection { -public: - DebugCrossModuleExportsSubsection() - : DebugSubsection(DebugSubsectionKind::CrossScopeExports) {} - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::CrossScopeExports; - } - - void addMapping(uint32_t Local, uint32_t Global); - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - -private: - std::map<uint32_t, uint32_t> Mappings; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugCrossExSubsection.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <map> + +namespace llvm { +namespace codeview { + +class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef { + using ReferenceArray = FixedStreamArray<CrossModuleExport>; + using Iterator = ReferenceArray::Iterator; + +public: + DebugCrossModuleExportsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::CrossScopeExports) {} + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::CrossScopeExports; + } + + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Stream); + + Iterator begin() const { return References.begin(); } + Iterator end() const { return References.end(); } + +private: + FixedStreamArray<CrossModuleExport> References; +}; + +class DebugCrossModuleExportsSubsection final : public DebugSubsection { +public: + DebugCrossModuleExportsSubsection() + : DebugSubsection(DebugSubsectionKind::CrossScopeExports) {} + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::CrossScopeExports; + } + + void addMapping(uint32_t Local, uint32_t Global); + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + +private: + std::map<uint32_t, uint32_t> Mappings; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h index 0016db3b2a..8e26297f31 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h @@ -1,105 +1,105 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugCrossImpSubsection.h --------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H - -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -namespace codeview { - -struct CrossModuleImportItem { - const CrossModuleImport *Header = nullptr; - FixedStreamArray<support::ulittle32_t> Imports; -}; - -} // end namespace codeview - -template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> { -public: - using ContextType = void; - - Error operator()(BinaryStreamRef Stream, uint32_t &Len, - codeview::CrossModuleImportItem &Item); -}; - -namespace codeview { - -class DebugStringTableSubsection; - -class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef { - using ReferenceArray = VarStreamArray<CrossModuleImportItem>; - using Iterator = ReferenceArray::Iterator; - -public: - DebugCrossModuleImportsSubsectionRef() - : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {} - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::CrossScopeImports; - } - - Error initialize(BinaryStreamReader Reader); - Error initialize(BinaryStreamRef Stream); - - Iterator begin() const { return References.begin(); } - Iterator end() const { return References.end(); } - -private: - ReferenceArray References; -}; - -class DebugCrossModuleImportsSubsection final : public DebugSubsection { -public: - explicit DebugCrossModuleImportsSubsection( - DebugStringTableSubsection &Strings) - : DebugSubsection(DebugSubsectionKind::CrossScopeImports), - Strings(Strings) {} - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::CrossScopeImports; - } - - void addImport(StringRef Module, uint32_t ImportId); - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - -private: - DebugStringTableSubsection &Strings; - StringMap<std::vector<support::ulittle32_t>> Mappings; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugCrossImpSubsection.h --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H + +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +namespace codeview { + +struct CrossModuleImportItem { + const CrossModuleImport *Header = nullptr; + FixedStreamArray<support::ulittle32_t> Imports; +}; + +} // end namespace codeview + +template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> { +public: + using ContextType = void; + + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + codeview::CrossModuleImportItem &Item); +}; + +namespace codeview { + +class DebugStringTableSubsection; + +class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef { + using ReferenceArray = VarStreamArray<CrossModuleImportItem>; + using Iterator = ReferenceArray::Iterator; + +public: + DebugCrossModuleImportsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {} + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::CrossScopeImports; + } + + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Stream); + + Iterator begin() const { return References.begin(); } + Iterator end() const { return References.end(); } + +private: + ReferenceArray References; +}; + +class DebugCrossModuleImportsSubsection final : public DebugSubsection { +public: + explicit DebugCrossModuleImportsSubsection( + DebugStringTableSubsection &Strings) + : DebugSubsection(DebugSubsectionKind::CrossScopeImports), + Strings(Strings) {} + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::CrossScopeImports; + } + + void addImport(StringRef Module, uint32_t ImportId); + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + +private: + DebugStringTableSubsection &Strings; + StringMap<std::vector<support::ulittle32_t>> Mappings; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h index 766a3ea351..2d6f46e4fa 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h @@ -1,74 +1,74 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugFrameDataSubsection.h ------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -class DebugFrameDataSubsectionRef final : public DebugSubsectionRef { -public: - DebugFrameDataSubsectionRef() - : DebugSubsectionRef(DebugSubsectionKind::FrameData) {} - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::FrameData; - } - - Error initialize(BinaryStreamReader Reader); - Error initialize(BinaryStreamRef Stream); - - FixedStreamArray<FrameData>::Iterator begin() const { return Frames.begin(); } - FixedStreamArray<FrameData>::Iterator end() const { return Frames.end(); } - - const support::ulittle32_t *getRelocPtr() const { return RelocPtr; } - -private: - const support::ulittle32_t *RelocPtr = nullptr; - FixedStreamArray<FrameData> Frames; -}; - -class DebugFrameDataSubsection final : public DebugSubsection { -public: - DebugFrameDataSubsection(bool IncludeRelocPtr) - : DebugSubsection(DebugSubsectionKind::FrameData), - IncludeRelocPtr(IncludeRelocPtr) {} - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::FrameData; - } - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - - void addFrameData(const FrameData &Frame); - void setFrames(ArrayRef<FrameData> Frames); - -private: - bool IncludeRelocPtr = false; - std::vector<FrameData> Frames; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugFrameDataSubsection.h ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGFRAMEDATASUBSECTION_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class DebugFrameDataSubsectionRef final : public DebugSubsectionRef { +public: + DebugFrameDataSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::FrameData) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FrameData; + } + + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Stream); + + FixedStreamArray<FrameData>::Iterator begin() const { return Frames.begin(); } + FixedStreamArray<FrameData>::Iterator end() const { return Frames.end(); } + + const support::ulittle32_t *getRelocPtr() const { return RelocPtr; } + +private: + const support::ulittle32_t *RelocPtr = nullptr; + FixedStreamArray<FrameData> Frames; +}; + +class DebugFrameDataSubsection final : public DebugSubsection { +public: + DebugFrameDataSubsection(bool IncludeRelocPtr) + : DebugSubsection(DebugSubsectionKind::FrameData), + IncludeRelocPtr(IncludeRelocPtr) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::FrameData; + } + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + void addFrameData(const FrameData &Frame); + void setFrames(ArrayRef<FrameData> Frames); + +private: + bool IncludeRelocPtr = false; + std::vector<FrameData> Frames; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h index c6114c87ac..0d6ed09392 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h @@ -1,136 +1,136 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugInlineeLinesSubsection.h ----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -namespace codeview { - -class DebugChecksumsSubsection; - -enum class InlineeLinesSignature : uint32_t { - Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE - ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX -}; - -struct InlineeSourceLineHeader { - TypeIndex Inlinee; // ID of the function that was inlined. - support::ulittle32_t FileID; // Offset into FileChecksums subsection. - support::ulittle32_t SourceLineNum; // First line of inlined code. - // If extra files present: - // ulittle32_t ExtraFileCount; - // ulittle32_t Files[]; -}; - -struct InlineeSourceLine { - const InlineeSourceLineHeader *Header; - FixedStreamArray<support::ulittle32_t> ExtraFiles; -}; - -} // end namespace codeview - -template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> { - Error operator()(BinaryStreamRef Stream, uint32_t &Len, - codeview::InlineeSourceLine &Item); - - bool HasExtraFiles = false; -}; - -namespace codeview { - -class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef { - using LinesArray = VarStreamArray<InlineeSourceLine>; - using Iterator = LinesArray::Iterator; - -public: - DebugInlineeLinesSubsectionRef(); - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::InlineeLines; - } - - Error initialize(BinaryStreamReader Reader); - Error initialize(BinaryStreamRef Section) { - return initialize(BinaryStreamReader(Section)); - } - - bool valid() const { return Lines.valid(); } - bool hasExtraFiles() const; - - Iterator begin() const { return Lines.begin(); } - Iterator end() const { return Lines.end(); } - -private: - InlineeLinesSignature Signature; - LinesArray Lines; -}; - -class DebugInlineeLinesSubsection final : public DebugSubsection { -public: - struct Entry { - std::vector<support::ulittle32_t> ExtraFiles; - InlineeSourceLineHeader Header; - }; - - DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums, - bool HasExtraFiles = false); - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::InlineeLines; - } - - Error commit(BinaryStreamWriter &Writer) const override; - uint32_t calculateSerializedSize() const override; - - void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine); - void addExtraFile(StringRef FileName); - - bool hasExtraFiles() const { return HasExtraFiles; } - void setHasExtraFiles(bool Has) { HasExtraFiles = Has; } - - std::vector<Entry>::const_iterator begin() const { return Entries.begin(); } - std::vector<Entry>::const_iterator end() const { return Entries.end(); } - -private: - DebugChecksumsSubsection &Checksums; - bool HasExtraFiles = false; - uint32_t ExtraFileCount = 0; - std::vector<Entry> Entries; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugInlineeLinesSubsection.h ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +namespace codeview { + +class DebugChecksumsSubsection; + +enum class InlineeLinesSignature : uint32_t { + Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE + ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX +}; + +struct InlineeSourceLineHeader { + TypeIndex Inlinee; // ID of the function that was inlined. + support::ulittle32_t FileID; // Offset into FileChecksums subsection. + support::ulittle32_t SourceLineNum; // First line of inlined code. + // If extra files present: + // ulittle32_t ExtraFileCount; + // ulittle32_t Files[]; +}; + +struct InlineeSourceLine { + const InlineeSourceLineHeader *Header; + FixedStreamArray<support::ulittle32_t> ExtraFiles; +}; + +} // end namespace codeview + +template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> { + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + codeview::InlineeSourceLine &Item); + + bool HasExtraFiles = false; +}; + +namespace codeview { + +class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef { + using LinesArray = VarStreamArray<InlineeSourceLine>; + using Iterator = LinesArray::Iterator; + +public: + DebugInlineeLinesSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::InlineeLines; + } + + Error initialize(BinaryStreamReader Reader); + Error initialize(BinaryStreamRef Section) { + return initialize(BinaryStreamReader(Section)); + } + + bool valid() const { return Lines.valid(); } + bool hasExtraFiles() const; + + Iterator begin() const { return Lines.begin(); } + Iterator end() const { return Lines.end(); } + +private: + InlineeLinesSignature Signature; + LinesArray Lines; +}; + +class DebugInlineeLinesSubsection final : public DebugSubsection { +public: + struct Entry { + std::vector<support::ulittle32_t> ExtraFiles; + InlineeSourceLineHeader Header; + }; + + DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums, + bool HasExtraFiles = false); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::InlineeLines; + } + + Error commit(BinaryStreamWriter &Writer) const override; + uint32_t calculateSerializedSize() const override; + + void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine); + void addExtraFile(StringRef FileName); + + bool hasExtraFiles() const { return HasExtraFiles; } + void setHasExtraFiles(bool Has) { HasExtraFiles = Has; } + + std::vector<Entry>::const_iterator begin() const { return Entries.begin(); } + std::vector<Entry>::const_iterator end() const { return Entries.end(); } + +private: + DebugChecksumsSubsection &Checksums; + bool HasExtraFiles = false; + uint32_t ExtraFileCount = 0; + std::vector<Entry> Entries; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h index 068231c2f6..738aeb391e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h @@ -1,160 +1,160 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugLinesSubsection.h -----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace codeview { - -class DebugChecksumsSubsection; -class DebugStringTableSubsection; - -// Corresponds to the `CV_DebugSLinesHeader_t` structure. -struct LineFragmentHeader { - support::ulittle32_t RelocOffset; // Code offset of line contribution. - support::ulittle16_t RelocSegment; // Code segment of line contribution. - support::ulittle16_t Flags; // See LineFlags enumeration. - support::ulittle32_t CodeSize; // Code size of this line contribution. -}; - -// Corresponds to the `CV_DebugSLinesFileBlockHeader_t` structure. -struct LineBlockFragmentHeader { - support::ulittle32_t NameIndex; // Offset of FileChecksum entry in File - // checksums buffer. The checksum entry then - // contains another offset into the string - // table of the actual name. - support::ulittle32_t NumLines; // Number of lines - support::ulittle32_t BlockSize; // Code size of block, in bytes. - // The following two variable length arrays appear immediately after the - // header. The structure definitions follow. - // LineNumberEntry Lines[NumLines]; - // ColumnNumberEntry Columns[NumLines]; -}; - -// Corresponds to `CV_Line_t` structure -struct LineNumberEntry { - support::ulittle32_t Offset; // Offset to start of code bytes for line number - support::ulittle32_t Flags; // Start:24, End:7, IsStatement:1 -}; - -// Corresponds to `CV_Column_t` structure -struct ColumnNumberEntry { - support::ulittle16_t StartColumn; - support::ulittle16_t EndColumn; -}; - -struct LineColumnEntry { - support::ulittle32_t NameIndex; - FixedStreamArray<LineNumberEntry> LineNumbers; - FixedStreamArray<ColumnNumberEntry> Columns; -}; - -class LineColumnExtractor { -public: - Error operator()(BinaryStreamRef Stream, uint32_t &Len, - LineColumnEntry &Item); - - const LineFragmentHeader *Header = nullptr; -}; - -class DebugLinesSubsectionRef final : public DebugSubsectionRef { - friend class LineColumnExtractor; - - using LineInfoArray = VarStreamArray<LineColumnEntry, LineColumnExtractor>; - using Iterator = LineInfoArray::Iterator; - -public: - DebugLinesSubsectionRef(); - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::Lines; - } - - Error initialize(BinaryStreamReader Reader); - - Iterator begin() const { return LinesAndColumns.begin(); } - Iterator end() const { return LinesAndColumns.end(); } - - const LineFragmentHeader *header() const { return Header; } - - bool hasColumnInfo() const; - -private: - const LineFragmentHeader *Header = nullptr; - LineInfoArray LinesAndColumns; -}; - -class DebugLinesSubsection final : public DebugSubsection { - struct Block { - Block(uint32_t ChecksumBufferOffset) - : ChecksumBufferOffset(ChecksumBufferOffset) {} - - uint32_t ChecksumBufferOffset; - std::vector<LineNumberEntry> Lines; - std::vector<ColumnNumberEntry> Columns; - }; - -public: - DebugLinesSubsection(DebugChecksumsSubsection &Checksums, - DebugStringTableSubsection &Strings); - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::Lines; - } - - void createBlock(StringRef FileName); - void addLineInfo(uint32_t Offset, const LineInfo &Line); - void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line, - uint32_t ColStart, uint32_t ColEnd); - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - - void setRelocationAddress(uint16_t Segment, uint32_t Offset); - void setCodeSize(uint32_t Size); - void setFlags(LineFlags Flags); - - bool hasColumnInfo() const; - -private: - DebugChecksumsSubsection &Checksums; - uint32_t RelocOffset = 0; - uint16_t RelocSegment = 0; - uint32_t CodeSize = 0; - LineFlags Flags = LF_None; - std::vector<Block> Blocks; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugLinesSubsection.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace codeview { + +class DebugChecksumsSubsection; +class DebugStringTableSubsection; + +// Corresponds to the `CV_DebugSLinesHeader_t` structure. +struct LineFragmentHeader { + support::ulittle32_t RelocOffset; // Code offset of line contribution. + support::ulittle16_t RelocSegment; // Code segment of line contribution. + support::ulittle16_t Flags; // See LineFlags enumeration. + support::ulittle32_t CodeSize; // Code size of this line contribution. +}; + +// Corresponds to the `CV_DebugSLinesFileBlockHeader_t` structure. +struct LineBlockFragmentHeader { + support::ulittle32_t NameIndex; // Offset of FileChecksum entry in File + // checksums buffer. The checksum entry then + // contains another offset into the string + // table of the actual name. + support::ulittle32_t NumLines; // Number of lines + support::ulittle32_t BlockSize; // Code size of block, in bytes. + // The following two variable length arrays appear immediately after the + // header. The structure definitions follow. + // LineNumberEntry Lines[NumLines]; + // ColumnNumberEntry Columns[NumLines]; +}; + +// Corresponds to `CV_Line_t` structure +struct LineNumberEntry { + support::ulittle32_t Offset; // Offset to start of code bytes for line number + support::ulittle32_t Flags; // Start:24, End:7, IsStatement:1 +}; + +// Corresponds to `CV_Column_t` structure +struct ColumnNumberEntry { + support::ulittle16_t StartColumn; + support::ulittle16_t EndColumn; +}; + +struct LineColumnEntry { + support::ulittle32_t NameIndex; + FixedStreamArray<LineNumberEntry> LineNumbers; + FixedStreamArray<ColumnNumberEntry> Columns; +}; + +class LineColumnExtractor { +public: + Error operator()(BinaryStreamRef Stream, uint32_t &Len, + LineColumnEntry &Item); + + const LineFragmentHeader *Header = nullptr; +}; + +class DebugLinesSubsectionRef final : public DebugSubsectionRef { + friend class LineColumnExtractor; + + using LineInfoArray = VarStreamArray<LineColumnEntry, LineColumnExtractor>; + using Iterator = LineInfoArray::Iterator; + +public: + DebugLinesSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::Lines; + } + + Error initialize(BinaryStreamReader Reader); + + Iterator begin() const { return LinesAndColumns.begin(); } + Iterator end() const { return LinesAndColumns.end(); } + + const LineFragmentHeader *header() const { return Header; } + + bool hasColumnInfo() const; + +private: + const LineFragmentHeader *Header = nullptr; + LineInfoArray LinesAndColumns; +}; + +class DebugLinesSubsection final : public DebugSubsection { + struct Block { + Block(uint32_t ChecksumBufferOffset) + : ChecksumBufferOffset(ChecksumBufferOffset) {} + + uint32_t ChecksumBufferOffset; + std::vector<LineNumberEntry> Lines; + std::vector<ColumnNumberEntry> Columns; + }; + +public: + DebugLinesSubsection(DebugChecksumsSubsection &Checksums, + DebugStringTableSubsection &Strings); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::Lines; + } + + void createBlock(StringRef FileName); + void addLineInfo(uint32_t Offset, const LineInfo &Line); + void addLineAndColumnInfo(uint32_t Offset, const LineInfo &Line, + uint32_t ColStart, uint32_t ColEnd); + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + void setRelocationAddress(uint16_t Segment, uint32_t Offset); + void setCodeSize(uint32_t Size); + void setFlags(LineFlags Flags); + + bool hasColumnInfo() const; + +private: + DebugChecksumsSubsection &Checksums; + uint32_t RelocOffset = 0; + uint16_t RelocSegment = 0; + uint32_t CodeSize = 0; + LineFlags Flags = LF_None; + std::vector<Block> Blocks; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h index f7c068f64f..067149c40d 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h @@ -1,107 +1,107 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugStringTableSubsection.h - CodeView String Table -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" -#include <cstdint> - -namespace llvm { - -class BinaryStreamReader; - -namespace codeview { - -/// Represents a read-only view of a CodeView string table. This is a very -/// simple flat buffer consisting of null-terminated strings, where strings -/// are retrieved by their offset in the buffer. DebugStringTableSubsectionRef -/// does not own the underlying storage for the buffer. -class DebugStringTableSubsectionRef : public DebugSubsectionRef { -public: - DebugStringTableSubsectionRef(); - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::StringTable; - } - - Error initialize(BinaryStreamRef Contents); - Error initialize(BinaryStreamReader &Reader); - - Expected<StringRef> getString(uint32_t Offset) const; - - bool valid() const { return Stream.valid(); } - - BinaryStreamRef getBuffer() const { return Stream; } - -private: - BinaryStreamRef Stream; -}; - -/// Represents a read-write view of a CodeView string table. -/// DebugStringTableSubsection owns the underlying storage for the table, and is -/// capable of serializing the string table into a format understood by -/// DebugStringTableSubsectionRef. -class DebugStringTableSubsection : public DebugSubsection { -public: - DebugStringTableSubsection(); - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::StringTable; - } - - // If string S does not exist in the string table, insert it. - // Returns the ID for S. - uint32_t insert(StringRef S); - - // Return the ID for string S. Assumes S exists in the table. - uint32_t getIdForString(StringRef S) const; - - StringRef getStringForId(uint32_t Id) const; - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - - uint32_t size() const; - - StringMap<uint32_t>::const_iterator begin() const { - return StringToId.begin(); - } - - StringMap<uint32_t>::const_iterator end() const { return StringToId.end(); } - - std::vector<uint32_t> sortedIds() const; - -private: - DenseMap<uint32_t, StringRef> IdToString; - StringMap<uint32_t> StringToId; - uint32_t StringSize = 1; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugStringTableSubsection.h - CodeView String Table -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> + +namespace llvm { + +class BinaryStreamReader; + +namespace codeview { + +/// Represents a read-only view of a CodeView string table. This is a very +/// simple flat buffer consisting of null-terminated strings, where strings +/// are retrieved by their offset in the buffer. DebugStringTableSubsectionRef +/// does not own the underlying storage for the buffer. +class DebugStringTableSubsectionRef : public DebugSubsectionRef { +public: + DebugStringTableSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::StringTable; + } + + Error initialize(BinaryStreamRef Contents); + Error initialize(BinaryStreamReader &Reader); + + Expected<StringRef> getString(uint32_t Offset) const; + + bool valid() const { return Stream.valid(); } + + BinaryStreamRef getBuffer() const { return Stream; } + +private: + BinaryStreamRef Stream; +}; + +/// Represents a read-write view of a CodeView string table. +/// DebugStringTableSubsection owns the underlying storage for the table, and is +/// capable of serializing the string table into a format understood by +/// DebugStringTableSubsectionRef. +class DebugStringTableSubsection : public DebugSubsection { +public: + DebugStringTableSubsection(); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::StringTable; + } + + // If string S does not exist in the string table, insert it. + // Returns the ID for S. + uint32_t insert(StringRef S); + + // Return the ID for string S. Assumes S exists in the table. + uint32_t getIdForString(StringRef S) const; + + StringRef getStringForId(uint32_t Id) const; + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + uint32_t size() const; + + StringMap<uint32_t>::const_iterator begin() const { + return StringToId.begin(); + } + + StringMap<uint32_t>::const_iterator end() const { return StringToId.end(); } + + std::vector<uint32_t> sortedIds() const; + +private: + DenseMap<uint32_t, StringRef> IdToString; + StringMap<uint32_t> StringToId; + uint32_t StringSize = 1; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsection.h index 4e03aec61b..61518a3be2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsection.h @@ -1,62 +1,62 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugSubsection.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Casting.h" - -namespace llvm { -namespace codeview { - -class DebugSubsectionRef { -public: - explicit DebugSubsectionRef(DebugSubsectionKind Kind) : Kind(Kind) {} - virtual ~DebugSubsectionRef(); - - static bool classof(const DebugSubsectionRef *S) { return true; } - - DebugSubsectionKind kind() const { return Kind; } - -protected: - DebugSubsectionKind Kind; -}; - -class DebugSubsection { -public: - explicit DebugSubsection(DebugSubsectionKind Kind) : Kind(Kind) {} - virtual ~DebugSubsection(); - - static bool classof(const DebugSubsection *S) { return true; } - - DebugSubsectionKind kind() const { return Kind; } - - virtual Error commit(BinaryStreamWriter &Writer) const = 0; - virtual uint32_t calculateSerializedSize() const = 0; - -protected: - DebugSubsectionKind Kind; -}; - -} // namespace codeview -} // namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugSubsection.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Casting.h" + +namespace llvm { +namespace codeview { + +class DebugSubsectionRef { +public: + explicit DebugSubsectionRef(DebugSubsectionKind Kind) : Kind(Kind) {} + virtual ~DebugSubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { return true; } + + DebugSubsectionKind kind() const { return Kind; } + +protected: + DebugSubsectionKind Kind; +}; + +class DebugSubsection { +public: + explicit DebugSubsection(DebugSubsectionKind Kind) : Kind(Kind) {} + virtual ~DebugSubsection(); + + static bool classof(const DebugSubsection *S) { return true; } + + DebugSubsectionKind kind() const { return Kind; } + + virtual Error commit(BinaryStreamWriter &Writer) const = 0; + virtual uint32_t calculateSerializedSize() const = 0; + +protected: + DebugSubsectionKind Kind; +}; + +} // namespace codeview +} // namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h index 90ab4081a8..603080f200 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h @@ -1,106 +1,106 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugSubsectionRecord.h ----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_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" -#include "llvm/Support/MathExtras.h" -#include <cstdint> -#include <memory> - -namespace llvm { - -class BinaryStreamWriter; - -namespace codeview { - -class DebugSubsection; - -// Corresponds to the `CV_DebugSSubsectionHeader_t` structure. -struct DebugSubsectionHeader { - support::ulittle32_t Kind; // codeview::DebugSubsectionKind enum - support::ulittle32_t Length; // number of bytes occupied by this record. -}; - -class DebugSubsectionRecord { -public: - DebugSubsectionRecord(); - DebugSubsectionRecord(DebugSubsectionKind Kind, BinaryStreamRef Data); - - static Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info); - - uint32_t getRecordLength() const; - DebugSubsectionKind kind() const; - BinaryStreamRef getRecordData() const; - -private: - DebugSubsectionKind Kind = DebugSubsectionKind::None; - BinaryStreamRef Data; -}; - -class DebugSubsectionRecordBuilder { -public: - DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection); - - /// Use this to copy existing subsections directly from source to destination. - /// For example, line table subsections in an object file only need to be - /// relocated before being copied into the PDB. - DebugSubsectionRecordBuilder(const DebugSubsectionRecord &Contents); - - uint32_t calculateSerializedLength() const; - Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const; - -private: - /// The subsection to build. Will be null if Contents is non-empty. - std::shared_ptr<DebugSubsection> Subsection; - - /// The bytes of the subsection. Only non-empty if Subsection is null. - /// FIXME: Reduce the size of this. - DebugSubsectionRecord Contents; -}; - -} // end namespace codeview - -template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> { - Error operator()(BinaryStreamRef Stream, uint32_t &Length, - codeview::DebugSubsectionRecord &Info) { - // FIXME: We need to pass the container type through to this function. In - // practice this isn't super important since the subsection header describes - // its length and we can just skip it. It's more important when writing. - if (auto EC = codeview::DebugSubsectionRecord::initialize(Stream, Info)) - return EC; - Length = alignTo(Info.getRecordLength(), 4); - return Error::success(); - } -}; - -namespace codeview { - -using DebugSubsectionArray = VarStreamArray<DebugSubsectionRecord>; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugSubsectionRecord.h ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_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" +#include "llvm/Support/MathExtras.h" +#include <cstdint> +#include <memory> + +namespace llvm { + +class BinaryStreamWriter; + +namespace codeview { + +class DebugSubsection; + +// Corresponds to the `CV_DebugSSubsectionHeader_t` structure. +struct DebugSubsectionHeader { + support::ulittle32_t Kind; // codeview::DebugSubsectionKind enum + support::ulittle32_t Length; // number of bytes occupied by this record. +}; + +class DebugSubsectionRecord { +public: + DebugSubsectionRecord(); + DebugSubsectionRecord(DebugSubsectionKind Kind, BinaryStreamRef Data); + + static Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info); + + uint32_t getRecordLength() const; + DebugSubsectionKind kind() const; + BinaryStreamRef getRecordData() const; + +private: + DebugSubsectionKind Kind = DebugSubsectionKind::None; + BinaryStreamRef Data; +}; + +class DebugSubsectionRecordBuilder { +public: + DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection); + + /// Use this to copy existing subsections directly from source to destination. + /// For example, line table subsections in an object file only need to be + /// relocated before being copied into the PDB. + DebugSubsectionRecordBuilder(const DebugSubsectionRecord &Contents); + + uint32_t calculateSerializedLength() const; + Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const; + +private: + /// The subsection to build. Will be null if Contents is non-empty. + std::shared_ptr<DebugSubsection> Subsection; + + /// The bytes of the subsection. Only non-empty if Subsection is null. + /// FIXME: Reduce the size of this. + DebugSubsectionRecord Contents; +}; + +} // end namespace codeview + +template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> { + Error operator()(BinaryStreamRef Stream, uint32_t &Length, + codeview::DebugSubsectionRecord &Info) { + // FIXME: We need to pass the container type through to this function. In + // practice this isn't super important since the subsection header describes + // its length and we can just skip it. It's more important when writing. + if (auto EC = codeview::DebugSubsectionRecord::initialize(Stream, Info)) + return EC; + Length = alignTo(Info.getRecordLength(), 4); + return Error::success(); + } +}; + +namespace codeview { + +using DebugSubsectionArray = VarStreamArray<DebugSubsectionRecord>; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h index ba8dcdd4a1..46180b052a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h @@ -1,121 +1,121 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" -#include "llvm/Support/Error.h" - -namespace llvm { - -namespace codeview { - -class DebugChecksumsSubsectionRef; -class DebugSubsectionRecord; -class DebugInlineeLinesSubsectionRef; -class DebugCrossModuleExportsSubsectionRef; -class DebugCrossModuleImportsSubsectionRef; -class DebugFrameDataSubsectionRef; -class DebugLinesSubsectionRef; -class DebugStringTableSubsectionRef; -class DebugSymbolRVASubsectionRef; -class DebugSymbolsSubsectionRef; -class DebugUnknownSubsectionRef; - -class DebugSubsectionVisitor { -public: - virtual ~DebugSubsectionVisitor() = default; - - virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) { - return Error::success(); - } - virtual Error visitLines(DebugLinesSubsectionRef &Lines, - const StringsAndChecksumsRef &State) = 0; - virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums, - const StringsAndChecksumsRef &State) = 0; - virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees, - const StringsAndChecksumsRef &State) = 0; - virtual Error - visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE, - const StringsAndChecksumsRef &State) = 0; - virtual Error - visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE, - const StringsAndChecksumsRef &State) = 0; - - virtual Error visitStringTable(DebugStringTableSubsectionRef &ST, - const StringsAndChecksumsRef &State) = 0; - - virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE, - const StringsAndChecksumsRef &State) = 0; - - virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD, - const StringsAndChecksumsRef &State) = 0; - virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs, - const StringsAndChecksumsRef &State) = 0; -}; - -Error visitDebugSubsection(const DebugSubsectionRecord &R, - DebugSubsectionVisitor &V, - const StringsAndChecksumsRef &State); - -namespace detail { -template <typename T> -Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, - StringsAndChecksumsRef &State) { - State.initialize(std::forward<T>(FragmentRange)); - - for (const DebugSubsectionRecord &L : FragmentRange) { - if (auto EC = visitDebugSubsection(L, V, State)) - return EC; - } - return Error::success(); -} -} // namespace detail - -template <typename T> -Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) { - StringsAndChecksumsRef State; - return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, - State); -} - -template <typename T> -Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, - const DebugStringTableSubsectionRef &Strings) { - StringsAndChecksumsRef State(Strings); - return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, - State); -} - -template <typename T> -Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, - const DebugStringTableSubsectionRef &Strings, - const DebugChecksumsSubsectionRef &Checksums) { - StringsAndChecksumsRef State(Strings, Checksums); - return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, - State); -} - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugSubsectionVisitor.h -----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" +#include "llvm/Support/Error.h" + +namespace llvm { + +namespace codeview { + +class DebugChecksumsSubsectionRef; +class DebugSubsectionRecord; +class DebugInlineeLinesSubsectionRef; +class DebugCrossModuleExportsSubsectionRef; +class DebugCrossModuleImportsSubsectionRef; +class DebugFrameDataSubsectionRef; +class DebugLinesSubsectionRef; +class DebugStringTableSubsectionRef; +class DebugSymbolRVASubsectionRef; +class DebugSymbolsSubsectionRef; +class DebugUnknownSubsectionRef; + +class DebugSubsectionVisitor { +public: + virtual ~DebugSubsectionVisitor() = default; + + virtual Error visitUnknown(DebugUnknownSubsectionRef &Unknown) { + return Error::success(); + } + virtual Error visitLines(DebugLinesSubsectionRef &Lines, + const StringsAndChecksumsRef &State) = 0; + virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums, + const StringsAndChecksumsRef &State) = 0; + virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees, + const StringsAndChecksumsRef &State) = 0; + virtual Error + visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE, + const StringsAndChecksumsRef &State) = 0; + virtual Error + visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE, + const StringsAndChecksumsRef &State) = 0; + + virtual Error visitStringTable(DebugStringTableSubsectionRef &ST, + const StringsAndChecksumsRef &State) = 0; + + virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE, + const StringsAndChecksumsRef &State) = 0; + + virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD, + const StringsAndChecksumsRef &State) = 0; + virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs, + const StringsAndChecksumsRef &State) = 0; +}; + +Error visitDebugSubsection(const DebugSubsectionRecord &R, + DebugSubsectionVisitor &V, + const StringsAndChecksumsRef &State); + +namespace detail { +template <typename T> +Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, + StringsAndChecksumsRef &State) { + State.initialize(std::forward<T>(FragmentRange)); + + for (const DebugSubsectionRecord &L : FragmentRange) { + if (auto EC = visitDebugSubsection(L, V, State)) + return EC; + } + return Error::success(); +} +} // namespace detail + +template <typename T> +Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) { + StringsAndChecksumsRef State; + return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, + State); +} + +template <typename T> +Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, + const DebugStringTableSubsectionRef &Strings) { + StringsAndChecksumsRef State(Strings); + return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, + State); +} + +template <typename T> +Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, + const DebugStringTableSubsectionRef &Strings, + const DebugChecksumsSubsectionRef &Checksums) { + StringsAndChecksumsRef State(Strings, Checksums); + return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V, + State); +} + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h index e680bbd3fa..0883848ade 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h @@ -1,77 +1,77 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugSymbolRVASubsection.h -------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -class BinaryStreamReader; - -namespace codeview { - -class DebugSymbolRVASubsectionRef final : public DebugSubsectionRef { -public: - using ArrayType = FixedStreamArray<support::ulittle32_t>; - - DebugSymbolRVASubsectionRef(); - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::CoffSymbolRVA; - } - - ArrayType::Iterator begin() const { return RVAs.begin(); } - ArrayType::Iterator end() const { return RVAs.end(); } - - Error initialize(BinaryStreamReader &Reader); - -private: - ArrayType RVAs; -}; - -class DebugSymbolRVASubsection final : public DebugSubsection { -public: - DebugSymbolRVASubsection(); - - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::CoffSymbolRVA; - } - - Error commit(BinaryStreamWriter &Writer) const override; - uint32_t calculateSerializedSize() const override; - - void addRVA(uint32_t RVA) { RVAs.push_back(support::ulittle32_t(RVA)); } - -private: - std::vector<support::ulittle32_t> RVAs; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugSymbolRVASubsection.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +class BinaryStreamReader; + +namespace codeview { + +class DebugSymbolRVASubsectionRef final : public DebugSubsectionRef { +public: + using ArrayType = FixedStreamArray<support::ulittle32_t>; + + DebugSymbolRVASubsectionRef(); + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::CoffSymbolRVA; + } + + ArrayType::Iterator begin() const { return RVAs.begin(); } + ArrayType::Iterator end() const { return RVAs.end(); } + + Error initialize(BinaryStreamReader &Reader); + +private: + ArrayType RVAs; +}; + +class DebugSymbolRVASubsection final : public DebugSubsection { +public: + DebugSymbolRVASubsection(); + + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::CoffSymbolRVA; + } + + Error commit(BinaryStreamWriter &Writer) const override; + uint32_t calculateSerializedSize() const override; + + void addRVA(uint32_t RVA) { RVAs.push_back(support::ulittle32_t(RVA)); } + +private: + std::vector<support::ulittle32_t> RVAs; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h index c0f16953ea..a04b6a0f3e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h @@ -1,66 +1,66 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugSymbolsSubsection.h --------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugSymbolsSubsection.h --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H + #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -class DebugSymbolsSubsectionRef final : public DebugSubsectionRef { -public: - DebugSymbolsSubsectionRef() - : DebugSubsectionRef(DebugSubsectionKind::Symbols) {} - - static bool classof(const DebugSubsectionRef *S) { - return S->kind() == DebugSubsectionKind::Symbols; - } - - Error initialize(BinaryStreamReader Reader); - - CVSymbolArray::Iterator begin() const { return Records.begin(); } - CVSymbolArray::Iterator end() const { return Records.end(); } - -private: - CVSymbolArray Records; -}; - -class DebugSymbolsSubsection final : public DebugSubsection { -public: - DebugSymbolsSubsection() : DebugSubsection(DebugSubsectionKind::Symbols) {} - static bool classof(const DebugSubsection *S) { - return S->kind() == DebugSubsectionKind::Symbols; - } - - uint32_t calculateSerializedSize() const override; - Error commit(BinaryStreamWriter &Writer) const override; - - void addSymbol(CVSymbol Symbol); - -private: - uint32_t Length = 0; - std::vector<CVSymbol> Records; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class DebugSymbolsSubsectionRef final : public DebugSubsectionRef { +public: + DebugSymbolsSubsectionRef() + : DebugSubsectionRef(DebugSubsectionKind::Symbols) {} + + static bool classof(const DebugSubsectionRef *S) { + return S->kind() == DebugSubsectionKind::Symbols; + } + + Error initialize(BinaryStreamReader Reader); + + CVSymbolArray::Iterator begin() const { return Records.begin(); } + CVSymbolArray::Iterator end() const { return Records.end(); } + +private: + CVSymbolArray Records; +}; + +class DebugSymbolsSubsection final : public DebugSubsection { +public: + DebugSymbolsSubsection() : DebugSubsection(DebugSubsectionKind::Symbols) {} + static bool classof(const DebugSubsection *S) { + return S->kind() == DebugSubsectionKind::Symbols; + } + + uint32_t calculateSerializedSize() const override; + Error commit(BinaryStreamWriter &Writer) const override; + + void addSymbol(CVSymbol Symbol); + +private: + uint32_t Length = 0; + std::vector<CVSymbol> Records; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h index 32ebe0e400..ef2c73cca2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/DebugUnknownSubsection.h @@ -1,42 +1,42 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DebugUnknownSubsection.h -----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H - -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/Support/BinaryStreamRef.h" - -namespace llvm { -namespace codeview { - -class DebugUnknownSubsectionRef final : public DebugSubsectionRef { -public: - DebugUnknownSubsectionRef(DebugSubsectionKind Kind, BinaryStreamRef Data) - : DebugSubsectionRef(Kind), Data(Data) {} - - BinaryStreamRef getData() const { return Data; } - -private: - BinaryStreamRef Data; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DebugUnknownSubsection.h -----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H +#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGUNKNOWNFRAGMENT_H + +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/Support/BinaryStreamRef.h" + +namespace llvm { +namespace codeview { + +class DebugUnknownSubsectionRef final : public DebugSubsectionRef { +public: + DebugUnknownSubsectionRef(DebugSubsectionKind Kind, BinaryStreamRef Data) + : DebugSubsectionRef(Kind), Data(Data) {} + + BinaryStreamRef getData() const { return Data; } + +private: + BinaryStreamRef Data; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/EnumTables.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/EnumTables.h index b24cf8b7d9..1729c86a19 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/EnumTables.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/EnumTables.h @@ -1,66 +1,66 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- EnumTables.h - Enum to string conversion tables ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H -#define LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/BinaryFormat/COFF.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/Support/ScopedPrinter.h" -#include <cstdint> - -namespace llvm { -namespace codeview { - -ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames(); -ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames(); -ArrayRef<EnumEntry<uint16_t>> getRegisterNames(CPUType Cpu); -ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames(); -ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames(); -ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames(); -ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames(); -ArrayRef<EnumEntry<SourceLanguage>> getSourceLanguageNames(); -ArrayRef<EnumEntry<uint32_t>> getCompileSym2FlagNames(); -ArrayRef<EnumEntry<uint32_t>> getCompileSym3FlagNames(); -ArrayRef<EnumEntry<uint32_t>> getFileChecksumNames(); -ArrayRef<EnumEntry<unsigned>> getCPUTypeNames(); -ArrayRef<EnumEntry<uint32_t>> getFrameProcSymFlagNames(); -ArrayRef<EnumEntry<uint16_t>> getExportSymFlagNames(); -ArrayRef<EnumEntry<uint32_t>> getModuleSubstreamKindNames(); -ArrayRef<EnumEntry<uint8_t>> getThunkOrdinalNames(); -ArrayRef<EnumEntry<uint16_t>> getTrampolineNames(); -ArrayRef<EnumEntry<COFF::SectionCharacteristics>> -getImageSectionCharacteristicNames(); -ArrayRef<EnumEntry<uint16_t>> getClassOptionNames(); -ArrayRef<EnumEntry<uint8_t>> getMemberAccessNames(); -ArrayRef<EnumEntry<uint16_t>> getMethodOptionNames(); -ArrayRef<EnumEntry<uint16_t>> getMemberKindNames(); -ArrayRef<EnumEntry<uint8_t>> getPtrKindNames(); -ArrayRef<EnumEntry<uint8_t>> getPtrModeNames(); -ArrayRef<EnumEntry<uint16_t>> getPtrMemberRepNames(); -ArrayRef<EnumEntry<uint16_t>> getTypeModifierNames(); -ArrayRef<EnumEntry<uint8_t>> getCallingConventions(); -ArrayRef<EnumEntry<uint8_t>> getFunctionOptionEnum(); -ArrayRef<EnumEntry<uint16_t>> getLabelTypeEnum(); - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- EnumTables.h - Enum to string conversion tables ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H +#define LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/BinaryFormat/COFF.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/Support/ScopedPrinter.h" +#include <cstdint> + +namespace llvm { +namespace codeview { + +ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames(); +ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames(); +ArrayRef<EnumEntry<uint16_t>> getRegisterNames(CPUType Cpu); +ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames(); +ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames(); +ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames(); +ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames(); +ArrayRef<EnumEntry<SourceLanguage>> getSourceLanguageNames(); +ArrayRef<EnumEntry<uint32_t>> getCompileSym2FlagNames(); +ArrayRef<EnumEntry<uint32_t>> getCompileSym3FlagNames(); +ArrayRef<EnumEntry<uint32_t>> getFileChecksumNames(); +ArrayRef<EnumEntry<unsigned>> getCPUTypeNames(); +ArrayRef<EnumEntry<uint32_t>> getFrameProcSymFlagNames(); +ArrayRef<EnumEntry<uint16_t>> getExportSymFlagNames(); +ArrayRef<EnumEntry<uint32_t>> getModuleSubstreamKindNames(); +ArrayRef<EnumEntry<uint8_t>> getThunkOrdinalNames(); +ArrayRef<EnumEntry<uint16_t>> getTrampolineNames(); +ArrayRef<EnumEntry<COFF::SectionCharacteristics>> +getImageSectionCharacteristicNames(); +ArrayRef<EnumEntry<uint16_t>> getClassOptionNames(); +ArrayRef<EnumEntry<uint8_t>> getMemberAccessNames(); +ArrayRef<EnumEntry<uint16_t>> getMethodOptionNames(); +ArrayRef<EnumEntry<uint16_t>> getMemberKindNames(); +ArrayRef<EnumEntry<uint8_t>> getPtrKindNames(); +ArrayRef<EnumEntry<uint8_t>> getPtrModeNames(); +ArrayRef<EnumEntry<uint16_t>> getPtrMemberRepNames(); +ArrayRef<EnumEntry<uint16_t>> getTypeModifierNames(); +ArrayRef<EnumEntry<uint8_t>> getCallingConventions(); +ArrayRef<EnumEntry<uint8_t>> getFunctionOptionEnum(); +ArrayRef<EnumEntry<uint16_t>> getLabelTypeEnum(); + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Formatters.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Formatters.h index dc60e478f6..d8e4c5a7ae 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Formatters.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Formatters.h @@ -1,83 +1,83 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Formatters.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H -#define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/GUID.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/FormatAdapters.h" -#include "llvm/Support/FormatVariadic.h" -#include "llvm/Support/raw_ostream.h" -#include <cstdint> - -namespace llvm { - -namespace codeview { - -namespace detail { - -class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> { - ArrayRef<uint8_t> Guid; - -public: - explicit GuidAdapter(ArrayRef<uint8_t> Guid); - explicit GuidAdapter(StringRef Guid); - - void format(raw_ostream &Stream, StringRef Style) override; -}; - -} // end namespace detail - -inline detail::GuidAdapter fmt_guid(StringRef Item) { - return detail::GuidAdapter(Item); -} - -inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) { - return detail::GuidAdapter(Item); -} - -} // end namespace codeview - -template <> struct format_provider<codeview::TypeIndex> { -public: - static void format(const codeview::TypeIndex &V, raw_ostream &Stream, - StringRef Style) { - if (V.isNoneType()) - Stream << "<no type>"; - else { - Stream << formatv("{0:X+4}", V.getIndex()); - if (V.isSimple()) - Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")"; - } - } -}; - -template <> struct format_provider<codeview::GUID> { - static void format(const codeview::GUID &V, llvm::raw_ostream &Stream, - StringRef Style) { - Stream << V; - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Formatters.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H +#define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/GUID.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/FormatAdapters.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" +#include <cstdint> + +namespace llvm { + +namespace codeview { + +namespace detail { + +class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> { + ArrayRef<uint8_t> Guid; + +public: + explicit GuidAdapter(ArrayRef<uint8_t> Guid); + explicit GuidAdapter(StringRef Guid); + + void format(raw_ostream &Stream, StringRef Style) override; +}; + +} // end namespace detail + +inline detail::GuidAdapter fmt_guid(StringRef Item) { + return detail::GuidAdapter(Item); +} + +inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) { + return detail::GuidAdapter(Item); +} + +} // end namespace codeview + +template <> struct format_provider<codeview::TypeIndex> { +public: + static void format(const codeview::TypeIndex &V, raw_ostream &Stream, + StringRef Style) { + if (V.isNoneType()) + Stream << "<no type>"; + else { + Stream << formatv("{0:X+4}", V.getIndex()); + if (V.isSimple()) + Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")"; + } + } +}; + +template <> struct format_provider<codeview::GUID> { + static void format(const codeview::GUID &V, llvm::raw_ostream &Stream, + StringRef Style) { + Stream << V; + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/FunctionId.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/FunctionId.h index 0813671a6e..8de994911b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/FunctionId.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/FunctionId.h @@ -1,66 +1,66 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- FunctionId.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_FUNCTIONID_H -#define LLVM_DEBUGINFO_CODEVIEW_FUNCTIONID_H - -#include <cinttypes> - -namespace llvm { -namespace codeview { - -class FunctionId { -public: - FunctionId() : Index(0) {} - - explicit FunctionId(uint32_t Index) : Index(Index) {} - - uint32_t getIndex() const { return Index; } - -private: - uint32_t Index; -}; - -inline bool operator==(const FunctionId &A, const FunctionId &B) { - return A.getIndex() == B.getIndex(); -} - -inline bool operator!=(const FunctionId &A, const FunctionId &B) { - return A.getIndex() != B.getIndex(); -} - -inline bool operator<(const FunctionId &A, const FunctionId &B) { - return A.getIndex() < B.getIndex(); -} - -inline bool operator<=(const FunctionId &A, const FunctionId &B) { - return A.getIndex() <= B.getIndex(); -} - -inline bool operator>(const FunctionId &A, const FunctionId &B) { - return A.getIndex() > B.getIndex(); -} - -inline bool operator>=(const FunctionId &A, const FunctionId &B) { - return A.getIndex() >= B.getIndex(); -} -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- FunctionId.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_FUNCTIONID_H +#define LLVM_DEBUGINFO_CODEVIEW_FUNCTIONID_H + +#include <cinttypes> + +namespace llvm { +namespace codeview { + +class FunctionId { +public: + FunctionId() : Index(0) {} + + explicit FunctionId(uint32_t Index) : Index(Index) {} + + uint32_t getIndex() const { return Index; } + +private: + uint32_t Index; +}; + +inline bool operator==(const FunctionId &A, const FunctionId &B) { + return A.getIndex() == B.getIndex(); +} + +inline bool operator!=(const FunctionId &A, const FunctionId &B) { + return A.getIndex() != B.getIndex(); +} + +inline bool operator<(const FunctionId &A, const FunctionId &B) { + return A.getIndex() < B.getIndex(); +} + +inline bool operator<=(const FunctionId &A, const FunctionId &B) { + return A.getIndex() <= B.getIndex(); +} + +inline bool operator>(const FunctionId &A, const FunctionId &B) { + return A.getIndex() > B.getIndex(); +} + +inline bool operator>=(const FunctionId &A, const FunctionId &B) { + return A.getIndex() >= B.getIndex(); +} +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GUID.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GUID.h index 332c178257..71e2f370a0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GUID.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GUID.h @@ -1,65 +1,65 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GUID.h ---------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_GUID_H -#define LLVM_DEBUGINFO_CODEVIEW_GUID_H - -#include <cstdint> -#include <cstring> - -namespace llvm { -class raw_ostream; - -namespace codeview { - -/// This represents the 'GUID' type from windows.h. -struct GUID { - uint8_t Guid[16]; -}; - -inline bool operator==(const GUID &LHS, const GUID &RHS) { - return 0 == ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)); -} - -inline bool operator<(const GUID &LHS, const GUID &RHS) { - return ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)) < 0; -} - -inline bool operator<=(const GUID &LHS, const GUID &RHS) { - return ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)) <= 0; -} - -inline bool operator>(const GUID &LHS, const GUID &RHS) { - return !(LHS <= RHS); -} - -inline bool operator>=(const GUID &LHS, const GUID &RHS) { - return !(LHS < RHS); -} - -inline bool operator!=(const GUID &LHS, const GUID &RHS) { - return !(LHS == RHS); -} - -raw_ostream &operator<<(raw_ostream &OS, const GUID &Guid); - -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GUID.h ---------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_GUID_H +#define LLVM_DEBUGINFO_CODEVIEW_GUID_H + +#include <cstdint> +#include <cstring> + +namespace llvm { +class raw_ostream; + +namespace codeview { + +/// This represents the 'GUID' type from windows.h. +struct GUID { + uint8_t Guid[16]; +}; + +inline bool operator==(const GUID &LHS, const GUID &RHS) { + return 0 == ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)); +} + +inline bool operator<(const GUID &LHS, const GUID &RHS) { + return ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)) < 0; +} + +inline bool operator<=(const GUID &LHS, const GUID &RHS) { + return ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid)) <= 0; +} + +inline bool operator>(const GUID &LHS, const GUID &RHS) { + return !(LHS <= RHS); +} + +inline bool operator>=(const GUID &LHS, const GUID &RHS) { + return !(LHS < RHS); +} + +inline bool operator!=(const GUID &LHS, const GUID &RHS) { + return !(LHS == RHS); +} + +raw_ostream &operator<<(raw_ostream &OS, const GUID &Guid); + +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h index b200b78e42..a8c0745dda 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h @@ -1,132 +1,132 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GlobalTypeTableBuilder.h ----------------------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_GLOBALTYPETABLEBUILDER_H -#define LLVM_DEBUGINFO_CODEVIEW_GLOBALTYPETABLEBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeHashing.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Allocator.h" -#include <cassert> -#include <cstdint> -#include <memory> -#include <vector> - -namespace llvm { -namespace codeview { - -class ContinuationRecordBuilder; - -class GlobalTypeTableBuilder : public TypeCollection { - /// Storage for records. These need to outlive the TypeTableBuilder. - BumpPtrAllocator &RecordStorage; - - /// A serializer that can write non-continuation leaf types. Only used as - /// a convenience function so that we can provide an interface method to - /// write an unserialized record. - SimpleTypeSerializer SimpleSerializer; - - /// Hash table. - DenseMap<GloballyHashedType, TypeIndex> HashedRecords; - - /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). - SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; - - /// Contains a list of all hash values indexed by TypeIndex.toArrayIndex(). - SmallVector<GloballyHashedType, 2> SeenHashes; - -public: - explicit GlobalTypeTableBuilder(BumpPtrAllocator &Storage); - ~GlobalTypeTableBuilder(); - - // TypeCollection overrides - Optional<TypeIndex> getFirst() override; - Optional<TypeIndex> getNext(TypeIndex Prev) override; - CVType getType(TypeIndex Index) override; - StringRef getTypeName(TypeIndex Index) override; - bool contains(TypeIndex Index) override; - uint32_t size() override; - uint32_t capacity() override; - bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; - - // public interface - void reset(); - TypeIndex nextTypeIndex() const; - - BumpPtrAllocator &getAllocator() { return RecordStorage; } - - ArrayRef<ArrayRef<uint8_t>> records() const; - ArrayRef<GloballyHashedType> hashes() const; - - template <typename CreateFunc> - TypeIndex insertRecordAs(GloballyHashedType Hash, size_t RecordSize, - CreateFunc Create) { - assert(RecordSize < UINT32_MAX && "Record too big"); - assert(RecordSize % 4 == 0 && - "RecordSize is not a multiple of 4 bytes which will cause " - "misalignment in the output TPI stream!"); - - auto Result = HashedRecords.try_emplace(Hash, nextTypeIndex()); - - if (LLVM_UNLIKELY(Result.second /*inserted*/ || - Result.first->second.isSimple())) { - uint8_t *Stable = RecordStorage.Allocate<uint8_t>(RecordSize); - MutableArrayRef<uint8_t> Data(Stable, RecordSize); - ArrayRef<uint8_t> StableRecord = Create(Data); - if (StableRecord.empty()) { - // Records with forward references into the Type stream will be deferred - // for insertion at a later time, on the second pass. - Result.first->getSecond() = TypeIndex(SimpleTypeKind::NotTranslated); - return TypeIndex(SimpleTypeKind::NotTranslated); - } - if (Result.first->second.isSimple()) { - assert(Result.first->second.getIndex() == - (uint32_t)SimpleTypeKind::NotTranslated); - // On the second pass, update with index to remapped record. The - // (initially misbehaved) record will now come *after* other records - // resolved in the first pass, with proper *back* references in the - // stream. - Result.first->second = nextTypeIndex(); - } - SeenRecords.push_back(StableRecord); - SeenHashes.push_back(Hash); - } - - return Result.first->second; - } - - TypeIndex insertRecordBytes(ArrayRef<uint8_t> Data); - TypeIndex insertRecord(ContinuationRecordBuilder &Builder); - - template <typename T> TypeIndex writeLeafType(T &Record) { - ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); - return insertRecordBytes(Data); - } -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GlobalTypeTableBuilder.h ----------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_GLOBALTYPETABLEBUILDER_H +#define LLVM_DEBUGINFO_CODEVIEW_GLOBALTYPETABLEBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeHashing.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/Allocator.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { +namespace codeview { + +class ContinuationRecordBuilder; + +class GlobalTypeTableBuilder : public TypeCollection { + /// Storage for records. These need to outlive the TypeTableBuilder. + BumpPtrAllocator &RecordStorage; + + /// A serializer that can write non-continuation leaf types. Only used as + /// a convenience function so that we can provide an interface method to + /// write an unserialized record. + SimpleTypeSerializer SimpleSerializer; + + /// Hash table. + DenseMap<GloballyHashedType, TypeIndex> HashedRecords; + + /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). + SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; + + /// Contains a list of all hash values indexed by TypeIndex.toArrayIndex(). + SmallVector<GloballyHashedType, 2> SeenHashes; + +public: + explicit GlobalTypeTableBuilder(BumpPtrAllocator &Storage); + ~GlobalTypeTableBuilder(); + + // TypeCollection overrides + Optional<TypeIndex> getFirst() override; + Optional<TypeIndex> getNext(TypeIndex Prev) override; + CVType getType(TypeIndex Index) override; + StringRef getTypeName(TypeIndex Index) override; + bool contains(TypeIndex Index) override; + uint32_t size() override; + uint32_t capacity() override; + bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; + + // public interface + void reset(); + TypeIndex nextTypeIndex() const; + + BumpPtrAllocator &getAllocator() { return RecordStorage; } + + ArrayRef<ArrayRef<uint8_t>> records() const; + ArrayRef<GloballyHashedType> hashes() const; + + template <typename CreateFunc> + TypeIndex insertRecordAs(GloballyHashedType Hash, size_t RecordSize, + CreateFunc Create) { + assert(RecordSize < UINT32_MAX && "Record too big"); + assert(RecordSize % 4 == 0 && + "RecordSize is not a multiple of 4 bytes which will cause " + "misalignment in the output TPI stream!"); + + auto Result = HashedRecords.try_emplace(Hash, nextTypeIndex()); + + if (LLVM_UNLIKELY(Result.second /*inserted*/ || + Result.first->second.isSimple())) { + uint8_t *Stable = RecordStorage.Allocate<uint8_t>(RecordSize); + MutableArrayRef<uint8_t> Data(Stable, RecordSize); + ArrayRef<uint8_t> StableRecord = Create(Data); + if (StableRecord.empty()) { + // Records with forward references into the Type stream will be deferred + // for insertion at a later time, on the second pass. + Result.first->getSecond() = TypeIndex(SimpleTypeKind::NotTranslated); + return TypeIndex(SimpleTypeKind::NotTranslated); + } + if (Result.first->second.isSimple()) { + assert(Result.first->second.getIndex() == + (uint32_t)SimpleTypeKind::NotTranslated); + // On the second pass, update with index to remapped record. The + // (initially misbehaved) record will now come *after* other records + // resolved in the first pass, with proper *back* references in the + // stream. + Result.first->second = nextTypeIndex(); + } + SeenRecords.push_back(StableRecord); + SeenHashes.push_back(Hash); + } + + return Result.first->second; + } + + TypeIndex insertRecordBytes(ArrayRef<uint8_t> Data); + TypeIndex insertRecord(ContinuationRecordBuilder &Builder); + + template <typename T> TypeIndex writeLeafType(T &Record) { + ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); + return insertRecordBytes(Data); + } +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h index e8d38f787d..4cce3d919e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h @@ -1,126 +1,126 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- LazyRandomTypeCollection.h -------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/StringSaver.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace codeview { - -/// Provides amortized O(1) random access to a CodeView type stream. -/// Normally to access a type from a type stream, you must know its byte -/// offset into the type stream, because type records are variable-lengthed. -/// However, this is not the way we prefer to access them. For example, given -/// a symbol record one of the fields may be the TypeIndex of the symbol's -/// type record. Or given a type record such as an array type, there might -/// be a TypeIndex for the element type. Sequential access is perfect when -/// we're just dumping every entry, but it's very poor for real world usage. -/// -/// Type streams in PDBs contain an additional field which is a list of pairs -/// containing indices and their corresponding offsets, roughly every ~8KB of -/// record data. This general idea need not be confined to PDBs though. By -/// supplying such an array, the producer of a type stream can allow the -/// consumer much better access time, because the consumer can find the nearest -/// index in this array, and do a linear scan forward only from there. -/// -/// LazyRandomTypeCollection implements this algorithm, but additionally goes -/// one step further by caching offsets of every record that has been visited at -/// least once. This way, even repeated visits of the same record will never -/// require more than one linear scan. For a type stream of N elements divided -/// into M chunks of roughly equal size, this yields a worst case lookup time -/// of O(N/M) and an amortized time of O(1). -class LazyRandomTypeCollection : public TypeCollection { - using PartialOffsetArray = FixedStreamArray<TypeIndexOffset>; - - struct CacheEntry { - CVType Type; - uint32_t Offset; - StringRef Name; - }; - -public: - explicit LazyRandomTypeCollection(uint32_t RecordCountHint); - LazyRandomTypeCollection(StringRef Data, uint32_t RecordCountHint); - LazyRandomTypeCollection(ArrayRef<uint8_t> Data, uint32_t RecordCountHint); - LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint, - PartialOffsetArray PartialOffsets); - LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint); - - void reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint); - void reset(StringRef Data, uint32_t RecordCountHint); - void reset(BinaryStreamReader &Reader, uint32_t RecordCountHint); - - uint32_t getOffsetOfType(TypeIndex Index); - - Optional<CVType> tryGetType(TypeIndex Index); - - CVType getType(TypeIndex Index) override; - StringRef getTypeName(TypeIndex Index) override; - bool contains(TypeIndex Index) override; - uint32_t size() override; - uint32_t capacity() override; - Optional<TypeIndex> getFirst() override; - Optional<TypeIndex> getNext(TypeIndex Prev) override; - bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; - -private: - Error ensureTypeExists(TypeIndex Index); - void ensureCapacityFor(TypeIndex Index); - - Error visitRangeForType(TypeIndex TI); - Error fullScanForType(TypeIndex TI); - void visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End); - - /// Number of actual records. - uint32_t Count = 0; - - /// The largest type index which we've visited. - TypeIndex LargestTypeIndex = TypeIndex::None(); - - BumpPtrAllocator Allocator; - StringSaver NameStorage; - - /// The type array to allow random access visitation of. - CVTypeArray Types; - - std::vector<CacheEntry> Records; - - /// An array of index offsets for the given type stream, allowing log(N) - /// lookups of a type record by index. Similar to KnownOffsets but only - /// contains offsets for some type indices, some of which may not have - /// ever been visited. - PartialOffsetArray PartialOffsets; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- LazyRandomTypeCollection.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/StringSaver.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace codeview { + +/// Provides amortized O(1) random access to a CodeView type stream. +/// Normally to access a type from a type stream, you must know its byte +/// offset into the type stream, because type records are variable-lengthed. +/// However, this is not the way we prefer to access them. For example, given +/// a symbol record one of the fields may be the TypeIndex of the symbol's +/// type record. Or given a type record such as an array type, there might +/// be a TypeIndex for the element type. Sequential access is perfect when +/// we're just dumping every entry, but it's very poor for real world usage. +/// +/// Type streams in PDBs contain an additional field which is a list of pairs +/// containing indices and their corresponding offsets, roughly every ~8KB of +/// record data. This general idea need not be confined to PDBs though. By +/// supplying such an array, the producer of a type stream can allow the +/// consumer much better access time, because the consumer can find the nearest +/// index in this array, and do a linear scan forward only from there. +/// +/// LazyRandomTypeCollection implements this algorithm, but additionally goes +/// one step further by caching offsets of every record that has been visited at +/// least once. This way, even repeated visits of the same record will never +/// require more than one linear scan. For a type stream of N elements divided +/// into M chunks of roughly equal size, this yields a worst case lookup time +/// of O(N/M) and an amortized time of O(1). +class LazyRandomTypeCollection : public TypeCollection { + using PartialOffsetArray = FixedStreamArray<TypeIndexOffset>; + + struct CacheEntry { + CVType Type; + uint32_t Offset; + StringRef Name; + }; + +public: + explicit LazyRandomTypeCollection(uint32_t RecordCountHint); + LazyRandomTypeCollection(StringRef Data, uint32_t RecordCountHint); + LazyRandomTypeCollection(ArrayRef<uint8_t> Data, uint32_t RecordCountHint); + LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint, + PartialOffsetArray PartialOffsets); + LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint); + + void reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint); + void reset(StringRef Data, uint32_t RecordCountHint); + void reset(BinaryStreamReader &Reader, uint32_t RecordCountHint); + + uint32_t getOffsetOfType(TypeIndex Index); + + Optional<CVType> tryGetType(TypeIndex Index); + + CVType getType(TypeIndex Index) override; + StringRef getTypeName(TypeIndex Index) override; + bool contains(TypeIndex Index) override; + uint32_t size() override; + uint32_t capacity() override; + Optional<TypeIndex> getFirst() override; + Optional<TypeIndex> getNext(TypeIndex Prev) override; + bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; + +private: + Error ensureTypeExists(TypeIndex Index); + void ensureCapacityFor(TypeIndex Index); + + Error visitRangeForType(TypeIndex TI); + Error fullScanForType(TypeIndex TI); + void visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End); + + /// Number of actual records. + uint32_t Count = 0; + + /// The largest type index which we've visited. + TypeIndex LargestTypeIndex = TypeIndex::None(); + + BumpPtrAllocator Allocator; + StringSaver NameStorage; + + /// The type array to allow random access visitation of. + CVTypeArray Types; + + std::vector<CacheEntry> Records; + + /// An array of index offsets for the given type stream, allowing log(N) + /// lookups of a type record by index. Similar to KnownOffsets but only + /// contains offsets for some type indices, some of which may not have + /// ever been visited. + PartialOffsetArray PartialOffsets; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Line.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Line.h index d71d6ab719..4de507bfb0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Line.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/Line.h @@ -1,143 +1,143 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Line.h ---------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_LINE_H -#define LLVM_DEBUGINFO_CODEVIEW_LINE_H - -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Endian.h" -#include <cinttypes> - -namespace llvm { -namespace codeview { - -using llvm::support::ulittle32_t; - -class LineInfo { -public: - enum : uint32_t { - AlwaysStepIntoLineNumber = 0xfeefee, - NeverStepIntoLineNumber = 0xf00f00 - }; - - enum : int { EndLineDeltaShift = 24 }; - - enum : uint32_t { - StartLineMask = 0x00ffffff, - EndLineDeltaMask = 0x7f000000, - StatementFlag = 0x80000000u - }; - - LineInfo(uint32_t StartLine, uint32_t EndLine, bool IsStatement); - LineInfo(uint32_t LineData) : LineData(LineData) {} - - uint32_t getStartLine() const { return LineData & StartLineMask; } - - uint32_t getLineDelta() const { - return (LineData & EndLineDeltaMask) >> EndLineDeltaShift; - } - - uint32_t getEndLine() const { return getStartLine() + getLineDelta(); } - - bool isStatement() const { return (LineData & StatementFlag) != 0; } - - uint32_t getRawData() const { return LineData; } - - bool isAlwaysStepInto() const { - return getStartLine() == AlwaysStepIntoLineNumber; - } - - bool isNeverStepInto() const { - return getStartLine() == NeverStepIntoLineNumber; - } - -private: - uint32_t LineData; -}; - -class ColumnInfo { -private: - static const uint32_t StartColumnMask = 0x0000ffffu; - static const uint32_t EndColumnMask = 0xffff0000u; - static const int EndColumnShift = 16; - -public: - ColumnInfo(uint16_t StartColumn, uint16_t EndColumn) { - ColumnData = - (static_cast<uint32_t>(StartColumn) & StartColumnMask) | - ((static_cast<uint32_t>(EndColumn) << EndColumnShift) & EndColumnMask); - } - - uint16_t getStartColumn() const { - return static_cast<uint16_t>(ColumnData & StartColumnMask); - } - - uint16_t getEndColumn() const { - return static_cast<uint16_t>((ColumnData & EndColumnMask) >> - EndColumnShift); - } - - uint32_t getRawData() const { return ColumnData; } - -private: - uint32_t ColumnData; -}; - -class Line { -private: - int32_t CodeOffset; - LineInfo LineInf; - ColumnInfo ColumnInf; - -public: - Line(int32_t CodeOffset, uint32_t StartLine, uint32_t EndLine, - uint16_t StartColumn, uint16_t EndColumn, bool IsStatement) - : CodeOffset(CodeOffset), LineInf(StartLine, EndLine, IsStatement), - ColumnInf(StartColumn, EndColumn) {} - - Line(int32_t CodeOffset, LineInfo LineInf, ColumnInfo ColumnInf) - : CodeOffset(CodeOffset), LineInf(LineInf), ColumnInf(ColumnInf) {} - - LineInfo getLineInfo() const { return LineInf; } - - ColumnInfo getColumnInfo() const { return ColumnInf; } - - int32_t getCodeOffset() const { return CodeOffset; } - - uint32_t getStartLine() const { return LineInf.getStartLine(); } - - uint32_t getLineDelta() const { return LineInf.getLineDelta(); } - - uint32_t getEndLine() const { return LineInf.getEndLine(); } - - uint16_t getStartColumn() const { return ColumnInf.getStartColumn(); } - - uint16_t getEndColumn() const { return ColumnInf.getEndColumn(); } - - bool isStatement() const { return LineInf.isStatement(); } - - bool isAlwaysStepInto() const { return LineInf.isAlwaysStepInto(); } - - bool isNeverStepInto() const { return LineInf.isNeverStepInto(); } -}; - -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Line.h ---------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_LINE_H +#define LLVM_DEBUGINFO_CODEVIEW_LINE_H + +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/Endian.h" +#include <cinttypes> + +namespace llvm { +namespace codeview { + +using llvm::support::ulittle32_t; + +class LineInfo { +public: + enum : uint32_t { + AlwaysStepIntoLineNumber = 0xfeefee, + NeverStepIntoLineNumber = 0xf00f00 + }; + + enum : int { EndLineDeltaShift = 24 }; + + enum : uint32_t { + StartLineMask = 0x00ffffff, + EndLineDeltaMask = 0x7f000000, + StatementFlag = 0x80000000u + }; + + LineInfo(uint32_t StartLine, uint32_t EndLine, bool IsStatement); + LineInfo(uint32_t LineData) : LineData(LineData) {} + + uint32_t getStartLine() const { return LineData & StartLineMask; } + + uint32_t getLineDelta() const { + return (LineData & EndLineDeltaMask) >> EndLineDeltaShift; + } + + uint32_t getEndLine() const { return getStartLine() + getLineDelta(); } + + bool isStatement() const { return (LineData & StatementFlag) != 0; } + + uint32_t getRawData() const { return LineData; } + + bool isAlwaysStepInto() const { + return getStartLine() == AlwaysStepIntoLineNumber; + } + + bool isNeverStepInto() const { + return getStartLine() == NeverStepIntoLineNumber; + } + +private: + uint32_t LineData; +}; + +class ColumnInfo { +private: + static const uint32_t StartColumnMask = 0x0000ffffu; + static const uint32_t EndColumnMask = 0xffff0000u; + static const int EndColumnShift = 16; + +public: + ColumnInfo(uint16_t StartColumn, uint16_t EndColumn) { + ColumnData = + (static_cast<uint32_t>(StartColumn) & StartColumnMask) | + ((static_cast<uint32_t>(EndColumn) << EndColumnShift) & EndColumnMask); + } + + uint16_t getStartColumn() const { + return static_cast<uint16_t>(ColumnData & StartColumnMask); + } + + uint16_t getEndColumn() const { + return static_cast<uint16_t>((ColumnData & EndColumnMask) >> + EndColumnShift); + } + + uint32_t getRawData() const { return ColumnData; } + +private: + uint32_t ColumnData; +}; + +class Line { +private: + int32_t CodeOffset; + LineInfo LineInf; + ColumnInfo ColumnInf; + +public: + Line(int32_t CodeOffset, uint32_t StartLine, uint32_t EndLine, + uint16_t StartColumn, uint16_t EndColumn, bool IsStatement) + : CodeOffset(CodeOffset), LineInf(StartLine, EndLine, IsStatement), + ColumnInf(StartColumn, EndColumn) {} + + Line(int32_t CodeOffset, LineInfo LineInf, ColumnInfo ColumnInf) + : CodeOffset(CodeOffset), LineInf(LineInf), ColumnInf(ColumnInf) {} + + LineInfo getLineInfo() const { return LineInf; } + + ColumnInfo getColumnInfo() const { return ColumnInf; } + + int32_t getCodeOffset() const { return CodeOffset; } + + uint32_t getStartLine() const { return LineInf.getStartLine(); } + + uint32_t getLineDelta() const { return LineInf.getLineDelta(); } + + uint32_t getEndLine() const { return LineInf.getEndLine(); } + + uint16_t getStartColumn() const { return ColumnInf.getStartColumn(); } + + uint16_t getEndColumn() const { return ColumnInf.getEndColumn(); } + + bool isStatement() const { return LineInf.isStatement(); } + + bool isAlwaysStepInto() const { return LineInf.isAlwaysStepInto(); } + + bool isNeverStepInto() const { return LineInf.isNeverStepInto(); } +}; + +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h index a4d6260789..fdbadcf2c5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h @@ -1,92 +1,92 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MergingTypeTableBuilder.h ---------------------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H -#define LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeHashing.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Allocator.h" -#include <cassert> -#include <cstdint> -#include <memory> -#include <vector> - -namespace llvm { -namespace codeview { - -class ContinuationRecordBuilder; - -class MergingTypeTableBuilder : public TypeCollection { - /// Storage for records. These need to outlive the TypeTableBuilder. - BumpPtrAllocator &RecordStorage; - - /// A serializer that can write non-continuation leaf types. Only used as - /// a convenience function so that we can provide an interface method to - /// write an unserialized record. - SimpleTypeSerializer SimpleSerializer; - - /// Hash table. - DenseMap<LocallyHashedType, TypeIndex> HashedRecords; - - /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). - SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; - -public: - explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage); - ~MergingTypeTableBuilder(); - - // TypeCollection overrides - Optional<TypeIndex> getFirst() override; - Optional<TypeIndex> getNext(TypeIndex Prev) override; - CVType getType(TypeIndex Index) override; - StringRef getTypeName(TypeIndex Index) override; - bool contains(TypeIndex Index) override; - uint32_t size() override; - uint32_t capacity() override; - bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; - - // public interface - void reset(); - TypeIndex nextTypeIndex() const; - - BumpPtrAllocator &getAllocator() { return RecordStorage; } - - ArrayRef<ArrayRef<uint8_t>> records() const; - - TypeIndex insertRecordAs(hash_code Hash, ArrayRef<uint8_t> &Record); - TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record); - TypeIndex insertRecord(ContinuationRecordBuilder &Builder); - - template <typename T> TypeIndex writeLeafType(T &Record) { - ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); - return insertRecordBytes(Data); - } -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MergingTypeTableBuilder.h ---------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H +#define LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SimpleTypeSerializer.h" +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeHashing.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/Allocator.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { +namespace codeview { + +class ContinuationRecordBuilder; + +class MergingTypeTableBuilder : public TypeCollection { + /// Storage for records. These need to outlive the TypeTableBuilder. + BumpPtrAllocator &RecordStorage; + + /// A serializer that can write non-continuation leaf types. Only used as + /// a convenience function so that we can provide an interface method to + /// write an unserialized record. + SimpleTypeSerializer SimpleSerializer; + + /// Hash table. + DenseMap<LocallyHashedType, TypeIndex> HashedRecords; + + /// Contains a list of all records indexed by TypeIndex.toArrayIndex(). + SmallVector<ArrayRef<uint8_t>, 2> SeenRecords; + +public: + explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage); + ~MergingTypeTableBuilder(); + + // TypeCollection overrides + Optional<TypeIndex> getFirst() override; + Optional<TypeIndex> getNext(TypeIndex Prev) override; + CVType getType(TypeIndex Index) override; + StringRef getTypeName(TypeIndex Index) override; + bool contains(TypeIndex Index) override; + uint32_t size() override; + uint32_t capacity() override; + bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; + + // public interface + void reset(); + TypeIndex nextTypeIndex() const; + + BumpPtrAllocator &getAllocator() { return RecordStorage; } + + ArrayRef<ArrayRef<uint8_t>> records() const; + + TypeIndex insertRecordAs(hash_code Hash, ArrayRef<uint8_t> &Record); + TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record); + TypeIndex insertRecord(ContinuationRecordBuilder &Builder); + + template <typename T> TypeIndex writeLeafType(T &Record) { + ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record); + return insertRecordBytes(Data); + } +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordName.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordName.h index 4a45b4066b..dd12afb5a1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordName.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordName.h @@ -1,33 +1,33 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- RecordName.h ------------------------------------------- *- C++ --*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H -#define LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H - -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" - -namespace llvm { -namespace codeview { -std::string computeTypeName(TypeCollection &Types, TypeIndex Index); -StringRef getSymbolName(CVSymbol Sym); -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- RecordName.h ------------------------------------------- *- C++ --*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H +#define LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H + +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" + +namespace llvm { +namespace codeview { +std::string computeTypeName(TypeCollection &Types, TypeIndex Index); +StringRef getSymbolName(CVSymbol Sym); +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordSerialization.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordSerialization.h index 44d6090c15..b04302e450 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordSerialization.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/RecordSerialization.h @@ -1,241 +1,241 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- RecordSerialization.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDSERIALIZATION_H -#define LLVM_DEBUGINFO_CODEVIEW_RECORDSERIALIZATION_H - -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cinttypes> -#include <tuple> - -namespace llvm { -namespace codeview { -using llvm::support::little32_t; -using llvm::support::ulittle16_t; -using llvm::support::ulittle32_t; - -/// Limit on the size of all codeview symbol and type records, including the -/// RecordPrefix. MSVC does not emit any records larger than this. -enum : unsigned { MaxRecordLength = 0xFF00 }; - -struct RecordPrefix { - RecordPrefix() = default; - explicit RecordPrefix(uint16_t Kind) : RecordLen(2), RecordKind(Kind) {} - - ulittle16_t RecordLen; // Record length, starting from &RecordKind. - ulittle16_t RecordKind; // Record kind enum (SymRecordKind or TypeRecordKind) -}; - -/// Reinterpret a byte array as an array of characters. Does not interpret as -/// a C string, as StringRef has several helpers (split) that make that easy. -StringRef getBytesAsCharacters(ArrayRef<uint8_t> LeafData); -StringRef getBytesAsCString(ArrayRef<uint8_t> LeafData); - -inline Error consume(BinaryStreamReader &Reader) { return Error::success(); } - -/// Decodes a numeric "leaf" value. These are integer literals encountered in -/// the type stream. If the value is positive and less than LF_NUMERIC (1 << -/// 15), it is emitted directly in Data. Otherwise, it has a tag like LF_CHAR -/// that indicates the bitwidth and sign of the numeric data. -Error consume(BinaryStreamReader &Reader, APSInt &Num); - -/// Decodes a numeric leaf value that is known to be a particular type. -Error consume_numeric(BinaryStreamReader &Reader, uint64_t &Value); - -/// Decodes signed and unsigned fixed-length integers. -Error consume(BinaryStreamReader &Reader, uint32_t &Item); -Error consume(BinaryStreamReader &Reader, int32_t &Item); - -/// Decodes a null terminated string. -Error consume(BinaryStreamReader &Reader, StringRef &Item); - -Error consume(StringRef &Data, APSInt &Num); -Error consume(StringRef &Data, uint32_t &Item); - -/// Decodes an arbitrary object whose layout matches that of the underlying -/// byte sequence, and returns a pointer to the object. -template <typename T> Error consume(BinaryStreamReader &Reader, T *&Item) { - return Reader.readObject(Item); -} - -template <typename T, typename U> struct serialize_conditional_impl { - serialize_conditional_impl(T &Item, U Func) : Item(Item), Func(Func) {} - - Error deserialize(BinaryStreamReader &Reader) const { - if (!Func()) - return Error::success(); - return consume(Reader, Item); - } - - T &Item; - U Func; -}; - -template <typename T, typename U> -serialize_conditional_impl<T, U> serialize_conditional(T &Item, U Func) { - return serialize_conditional_impl<T, U>(Item, Func); -} - -template <typename T, typename U> struct serialize_array_impl { - serialize_array_impl(ArrayRef<T> &Item, U Func) : Item(Item), Func(Func) {} - - Error deserialize(BinaryStreamReader &Reader) const { - return Reader.readArray(Item, Func()); - } - - ArrayRef<T> &Item; - U Func; -}; - -template <typename T> struct serialize_vector_tail_impl { - serialize_vector_tail_impl(std::vector<T> &Item) : Item(Item) {} - - Error deserialize(BinaryStreamReader &Reader) const { - T Field; - // Stop when we run out of bytes or we hit record padding bytes. - while (!Reader.empty() && Reader.peek() < LF_PAD0) { - if (auto EC = consume(Reader, Field)) - return EC; - Item.push_back(Field); - } - return Error::success(); - } - - std::vector<T> &Item; -}; - -struct serialize_null_term_string_array_impl { - serialize_null_term_string_array_impl(std::vector<StringRef> &Item) - : Item(Item) {} - - Error deserialize(BinaryStreamReader &Reader) const { - if (Reader.empty()) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer, - "Null terminated string is empty!"); - - while (Reader.peek() != 0) { - StringRef Field; - if (auto EC = Reader.readCString(Field)) - return EC; - Item.push_back(Field); - } - return Reader.skip(1); - } - - std::vector<StringRef> &Item; -}; - -template <typename T> struct serialize_arrayref_tail_impl { - serialize_arrayref_tail_impl(ArrayRef<T> &Item) : Item(Item) {} - - Error deserialize(BinaryStreamReader &Reader) const { - uint32_t Count = Reader.bytesRemaining() / sizeof(T); - return Reader.readArray(Item, Count); - } - - ArrayRef<T> &Item; -}; - -template <typename T> struct serialize_numeric_impl { - serialize_numeric_impl(T &Item) : Item(Item) {} - - Error deserialize(BinaryStreamReader &Reader) const { - return consume_numeric(Reader, Item); - } - - T &Item; -}; - -template <typename T, typename U> -serialize_array_impl<T, U> serialize_array(ArrayRef<T> &Item, U Func) { - return serialize_array_impl<T, U>(Item, Func); -} - -inline serialize_null_term_string_array_impl -serialize_null_term_string_array(std::vector<StringRef> &Item) { - return serialize_null_term_string_array_impl(Item); -} - -template <typename T> -serialize_vector_tail_impl<T> serialize_array_tail(std::vector<T> &Item) { - return serialize_vector_tail_impl<T>(Item); -} - -template <typename T> -serialize_arrayref_tail_impl<T> serialize_array_tail(ArrayRef<T> &Item) { - return serialize_arrayref_tail_impl<T>(Item); -} - -template <typename T> serialize_numeric_impl<T> serialize_numeric(T &Item) { - return serialize_numeric_impl<T>(Item); -} - -template <typename T, typename U> -Error consume(BinaryStreamReader &Reader, - const serialize_conditional_impl<T, U> &Item) { - return Item.deserialize(Reader); -} - -template <typename T, typename U> -Error consume(BinaryStreamReader &Reader, - const serialize_array_impl<T, U> &Item) { - return Item.deserialize(Reader); -} - -inline Error consume(BinaryStreamReader &Reader, - const serialize_null_term_string_array_impl &Item) { - return Item.deserialize(Reader); -} - -template <typename T> -Error consume(BinaryStreamReader &Reader, - const serialize_vector_tail_impl<T> &Item) { - return Item.deserialize(Reader); -} - -template <typename T> -Error consume(BinaryStreamReader &Reader, - const serialize_arrayref_tail_impl<T> &Item) { - return Item.deserialize(Reader); -} - -template <typename T> -Error consume(BinaryStreamReader &Reader, - const serialize_numeric_impl<T> &Item) { - return Item.deserialize(Reader); -} - -template <typename T, typename U, typename... Args> -Error consume(BinaryStreamReader &Reader, T &&X, U &&Y, Args &&... Rest) { - if (auto EC = consume(Reader, X)) - return EC; - return consume(Reader, Y, std::forward<Args>(Rest)...); -} - -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- RecordSerialization.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDSERIALIZATION_H +#define LLVM_DEBUGINFO_CODEVIEW_RECORDSERIALIZATION_H + +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/CodeViewError.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cinttypes> +#include <tuple> + +namespace llvm { +namespace codeview { +using llvm::support::little32_t; +using llvm::support::ulittle16_t; +using llvm::support::ulittle32_t; + +/// Limit on the size of all codeview symbol and type records, including the +/// RecordPrefix. MSVC does not emit any records larger than this. +enum : unsigned { MaxRecordLength = 0xFF00 }; + +struct RecordPrefix { + RecordPrefix() = default; + explicit RecordPrefix(uint16_t Kind) : RecordLen(2), RecordKind(Kind) {} + + ulittle16_t RecordLen; // Record length, starting from &RecordKind. + ulittle16_t RecordKind; // Record kind enum (SymRecordKind or TypeRecordKind) +}; + +/// Reinterpret a byte array as an array of characters. Does not interpret as +/// a C string, as StringRef has several helpers (split) that make that easy. +StringRef getBytesAsCharacters(ArrayRef<uint8_t> LeafData); +StringRef getBytesAsCString(ArrayRef<uint8_t> LeafData); + +inline Error consume(BinaryStreamReader &Reader) { return Error::success(); } + +/// Decodes a numeric "leaf" value. These are integer literals encountered in +/// the type stream. If the value is positive and less than LF_NUMERIC (1 << +/// 15), it is emitted directly in Data. Otherwise, it has a tag like LF_CHAR +/// that indicates the bitwidth and sign of the numeric data. +Error consume(BinaryStreamReader &Reader, APSInt &Num); + +/// Decodes a numeric leaf value that is known to be a particular type. +Error consume_numeric(BinaryStreamReader &Reader, uint64_t &Value); + +/// Decodes signed and unsigned fixed-length integers. +Error consume(BinaryStreamReader &Reader, uint32_t &Item); +Error consume(BinaryStreamReader &Reader, int32_t &Item); + +/// Decodes a null terminated string. +Error consume(BinaryStreamReader &Reader, StringRef &Item); + +Error consume(StringRef &Data, APSInt &Num); +Error consume(StringRef &Data, uint32_t &Item); + +/// Decodes an arbitrary object whose layout matches that of the underlying +/// byte sequence, and returns a pointer to the object. +template <typename T> Error consume(BinaryStreamReader &Reader, T *&Item) { + return Reader.readObject(Item); +} + +template <typename T, typename U> struct serialize_conditional_impl { + serialize_conditional_impl(T &Item, U Func) : Item(Item), Func(Func) {} + + Error deserialize(BinaryStreamReader &Reader) const { + if (!Func()) + return Error::success(); + return consume(Reader, Item); + } + + T &Item; + U Func; +}; + +template <typename T, typename U> +serialize_conditional_impl<T, U> serialize_conditional(T &Item, U Func) { + return serialize_conditional_impl<T, U>(Item, Func); +} + +template <typename T, typename U> struct serialize_array_impl { + serialize_array_impl(ArrayRef<T> &Item, U Func) : Item(Item), Func(Func) {} + + Error deserialize(BinaryStreamReader &Reader) const { + return Reader.readArray(Item, Func()); + } + + ArrayRef<T> &Item; + U Func; +}; + +template <typename T> struct serialize_vector_tail_impl { + serialize_vector_tail_impl(std::vector<T> &Item) : Item(Item) {} + + Error deserialize(BinaryStreamReader &Reader) const { + T Field; + // Stop when we run out of bytes or we hit record padding bytes. + while (!Reader.empty() && Reader.peek() < LF_PAD0) { + if (auto EC = consume(Reader, Field)) + return EC; + Item.push_back(Field); + } + return Error::success(); + } + + std::vector<T> &Item; +}; + +struct serialize_null_term_string_array_impl { + serialize_null_term_string_array_impl(std::vector<StringRef> &Item) + : Item(Item) {} + + Error deserialize(BinaryStreamReader &Reader) const { + if (Reader.empty()) + return make_error<CodeViewError>(cv_error_code::insufficient_buffer, + "Null terminated string is empty!"); + + while (Reader.peek() != 0) { + StringRef Field; + if (auto EC = Reader.readCString(Field)) + return EC; + Item.push_back(Field); + } + return Reader.skip(1); + } + + std::vector<StringRef> &Item; +}; + +template <typename T> struct serialize_arrayref_tail_impl { + serialize_arrayref_tail_impl(ArrayRef<T> &Item) : Item(Item) {} + + Error deserialize(BinaryStreamReader &Reader) const { + uint32_t Count = Reader.bytesRemaining() / sizeof(T); + return Reader.readArray(Item, Count); + } + + ArrayRef<T> &Item; +}; + +template <typename T> struct serialize_numeric_impl { + serialize_numeric_impl(T &Item) : Item(Item) {} + + Error deserialize(BinaryStreamReader &Reader) const { + return consume_numeric(Reader, Item); + } + + T &Item; +}; + +template <typename T, typename U> +serialize_array_impl<T, U> serialize_array(ArrayRef<T> &Item, U Func) { + return serialize_array_impl<T, U>(Item, Func); +} + +inline serialize_null_term_string_array_impl +serialize_null_term_string_array(std::vector<StringRef> &Item) { + return serialize_null_term_string_array_impl(Item); +} + +template <typename T> +serialize_vector_tail_impl<T> serialize_array_tail(std::vector<T> &Item) { + return serialize_vector_tail_impl<T>(Item); +} + +template <typename T> +serialize_arrayref_tail_impl<T> serialize_array_tail(ArrayRef<T> &Item) { + return serialize_arrayref_tail_impl<T>(Item); +} + +template <typename T> serialize_numeric_impl<T> serialize_numeric(T &Item) { + return serialize_numeric_impl<T>(Item); +} + +template <typename T, typename U> +Error consume(BinaryStreamReader &Reader, + const serialize_conditional_impl<T, U> &Item) { + return Item.deserialize(Reader); +} + +template <typename T, typename U> +Error consume(BinaryStreamReader &Reader, + const serialize_array_impl<T, U> &Item) { + return Item.deserialize(Reader); +} + +inline Error consume(BinaryStreamReader &Reader, + const serialize_null_term_string_array_impl &Item) { + return Item.deserialize(Reader); +} + +template <typename T> +Error consume(BinaryStreamReader &Reader, + const serialize_vector_tail_impl<T> &Item) { + return Item.deserialize(Reader); +} + +template <typename T> +Error consume(BinaryStreamReader &Reader, + const serialize_arrayref_tail_impl<T> &Item) { + return Item.deserialize(Reader); +} + +template <typename T> +Error consume(BinaryStreamReader &Reader, + const serialize_numeric_impl<T> &Item) { + return Item.deserialize(Reader); +} + +template <typename T, typename U, typename... Args> +Error consume(BinaryStreamReader &Reader, T &&X, U &&Y, Args &&... Rest) { + if (auto EC = consume(Reader, X)) + return EC; + return consume(Reader, Y, std::forward<Args>(Rest)...); +} + +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h index 5906b0ae05..75c6e34ffd 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h @@ -1,49 +1,49 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SimpleTypeSerializer.h -----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H -#define LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H - -#include "llvm/ADT/ArrayRef.h" -#include <vector> - -namespace llvm { -namespace codeview { -class FieldListRecord; - -class SimpleTypeSerializer { - std::vector<uint8_t> ScratchBuffer; - -public: - SimpleTypeSerializer(); - ~SimpleTypeSerializer(); - - // This template is explicitly instantiated in the implementation file for all - // supported types. The method itself is ugly, so inlining it into the header - // file clutters an otherwise straightforward interface. - template <typename T> ArrayRef<uint8_t> serialize(T &Record); - - // Don't allow serialization of field list records using this interface. - ArrayRef<uint8_t> serialize(const FieldListRecord &Record) = delete; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SimpleTypeSerializer.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H +#define LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H + +#include "llvm/ADT/ArrayRef.h" +#include <vector> + +namespace llvm { +namespace codeview { +class FieldListRecord; + +class SimpleTypeSerializer { + std::vector<uint8_t> ScratchBuffer; + +public: + SimpleTypeSerializer(); + ~SimpleTypeSerializer(); + + // This template is explicitly instantiated in the implementation file for all + // supported types. The method itself is ugly, so inlining it into the header + // file clutters an otherwise straightforward interface. + template <typename T> ArrayRef<uint8_t> serialize(T &Record); + + // Don't allow serialization of field list records using this interface. + ArrayRef<uint8_t> serialize(const FieldListRecord &Record) = delete; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h index 3df135d6a7..7e2c4d54f1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h @@ -1,117 +1,117 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- StringsAndChecksums.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H -#define LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" -#include <memory> - -namespace llvm { -namespace codeview { - -class StringsAndChecksumsRef { -public: - // If no subsections are known about initially, we find as much as we can. - StringsAndChecksumsRef(); - - // If only a string table subsection is given, we find a checksums subsection. - explicit StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings); - - // If both subsections are given, we don't need to find anything. - StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings, - const DebugChecksumsSubsectionRef &Checksums); - - void setStrings(const DebugStringTableSubsectionRef &Strings); - void setChecksums(const DebugChecksumsSubsectionRef &CS); - - void reset(); - void resetStrings(); - void resetChecksums(); - - template <typename T> void initialize(T &&FragmentRange) { - for (const DebugSubsectionRecord &R : FragmentRange) { - if (Strings && Checksums) - return; - if (R.kind() == DebugSubsectionKind::FileChecksums) { - initializeChecksums(R); - continue; - } - if (R.kind() == DebugSubsectionKind::StringTable && !Strings) { - // While in practice we should never encounter a string table even - // though the string table is already initialized, in theory it's - // possible. PDBs are supposed to have one global string table and - // then this subsection should not appear. Whereas object files are - // supposed to have this subsection appear exactly once. However, - // for testing purposes it's nice to be able to test this subsection - // independently of one format or the other, so for some tests we - // manually construct a PDB that contains this subsection in addition - // to a global string table. - initializeStrings(R); - continue; - } - } - } - - const DebugStringTableSubsectionRef &strings() const { return *Strings; } - const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; } - - bool hasStrings() const { return Strings != nullptr; } - bool hasChecksums() const { return Checksums != nullptr; } - -private: - void initializeStrings(const DebugSubsectionRecord &SR); - void initializeChecksums(const DebugSubsectionRecord &FCR); - - std::shared_ptr<DebugStringTableSubsectionRef> OwnedStrings; - std::shared_ptr<DebugChecksumsSubsectionRef> OwnedChecksums; - - const DebugStringTableSubsectionRef *Strings = nullptr; - const DebugChecksumsSubsectionRef *Checksums = nullptr; -}; - -class StringsAndChecksums { -public: - using StringsPtr = std::shared_ptr<DebugStringTableSubsection>; - using ChecksumsPtr = std::shared_ptr<DebugChecksumsSubsection>; - - // If no subsections are known about initially, we find as much as we can. - StringsAndChecksums() = default; - - void setStrings(const StringsPtr &SP) { Strings = SP; } - void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; } - - const StringsPtr &strings() const { return Strings; } - const ChecksumsPtr &checksums() const { return Checksums; } - - bool hasStrings() const { return Strings != nullptr; } - bool hasChecksums() const { return Checksums != nullptr; } - -private: - StringsPtr Strings; - ChecksumsPtr Checksums; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- StringsAndChecksums.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H +#define LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" +#include <memory> + +namespace llvm { +namespace codeview { + +class StringsAndChecksumsRef { +public: + // If no subsections are known about initially, we find as much as we can. + StringsAndChecksumsRef(); + + // If only a string table subsection is given, we find a checksums subsection. + explicit StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings); + + // If both subsections are given, we don't need to find anything. + StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings, + const DebugChecksumsSubsectionRef &Checksums); + + void setStrings(const DebugStringTableSubsectionRef &Strings); + void setChecksums(const DebugChecksumsSubsectionRef &CS); + + void reset(); + void resetStrings(); + void resetChecksums(); + + template <typename T> void initialize(T &&FragmentRange) { + for (const DebugSubsectionRecord &R : FragmentRange) { + if (Strings && Checksums) + return; + if (R.kind() == DebugSubsectionKind::FileChecksums) { + initializeChecksums(R); + continue; + } + if (R.kind() == DebugSubsectionKind::StringTable && !Strings) { + // While in practice we should never encounter a string table even + // though the string table is already initialized, in theory it's + // possible. PDBs are supposed to have one global string table and + // then this subsection should not appear. Whereas object files are + // supposed to have this subsection appear exactly once. However, + // for testing purposes it's nice to be able to test this subsection + // independently of one format or the other, so for some tests we + // manually construct a PDB that contains this subsection in addition + // to a global string table. + initializeStrings(R); + continue; + } + } + } + + const DebugStringTableSubsectionRef &strings() const { return *Strings; } + const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; } + + bool hasStrings() const { return Strings != nullptr; } + bool hasChecksums() const { return Checksums != nullptr; } + +private: + void initializeStrings(const DebugSubsectionRecord &SR); + void initializeChecksums(const DebugSubsectionRecord &FCR); + + std::shared_ptr<DebugStringTableSubsectionRef> OwnedStrings; + std::shared_ptr<DebugChecksumsSubsectionRef> OwnedChecksums; + + const DebugStringTableSubsectionRef *Strings = nullptr; + const DebugChecksumsSubsectionRef *Checksums = nullptr; +}; + +class StringsAndChecksums { +public: + using StringsPtr = std::shared_ptr<DebugStringTableSubsection>; + using ChecksumsPtr = std::shared_ptr<DebugChecksumsSubsection>; + + // If no subsections are known about initially, we find as much as we can. + StringsAndChecksums() = default; + + void setStrings(const StringsPtr &SP) { Strings = SP; } + void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; } + + const StringsPtr &strings() const { return Strings; } + const ChecksumsPtr &checksums() const { return Checksums; } + + bool hasStrings() const { return Strings != nullptr; } + bool hasChecksums() const { return Checksums != nullptr; } + +private: + StringsPtr Strings; + ChecksumsPtr Checksums; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h index f17eb873bf..d0fc60e122 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h @@ -1,110 +1,110 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolDeserializer.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -class SymbolVisitorDelegate; -class SymbolDeserializer : public SymbolVisitorCallbacks { - struct MappingInfo { - MappingInfo(ArrayRef<uint8_t> RecordData, CodeViewContainer Container) - : Stream(RecordData, llvm::support::little), Reader(Stream), - Mapping(Reader, Container) {} - - BinaryByteStream Stream; - BinaryStreamReader Reader; - SymbolRecordMapping Mapping; - }; - -public: - template <typename T> static Error deserializeAs(CVSymbol Symbol, T &Record) { - // If we're just deserializing one record, then don't worry about alignment - // as there's nothing that comes after. - SymbolDeserializer S(nullptr, CodeViewContainer::ObjectFile); - if (auto EC = S.visitSymbolBegin(Symbol)) - return EC; - if (auto EC = S.visitKnownRecord(Symbol, Record)) - return EC; - if (auto EC = S.visitSymbolEnd(Symbol)) - return EC; - return Error::success(); - } - template <typename T> static Expected<T> deserializeAs(CVSymbol Symbol) { - T Record(static_cast<SymbolRecordKind>(Symbol.kind())); - if (auto EC = deserializeAs<T>(Symbol, Record)) - return std::move(EC); - return Record; - } - - explicit SymbolDeserializer(SymbolVisitorDelegate *Delegate, - CodeViewContainer Container) - : Delegate(Delegate), Container(Container) {} - - Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { - return visitSymbolBegin(Record); - } - - Error visitSymbolBegin(CVSymbol &Record) override { - assert(!Mapping && "Already in a symbol mapping!"); - Mapping = std::make_unique<MappingInfo>(Record.content(), Container); - return Mapping->Mapping.visitSymbolBegin(Record); - } - Error visitSymbolEnd(CVSymbol &Record) override { - assert(Mapping && "Not in a symbol mapping!"); - auto EC = Mapping->Mapping.visitSymbolEnd(Record); - Mapping.reset(); - return EC; - } - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ - return visitKnownRecordImpl(CVR, Record); \ - } -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" - -private: - template <typename T> Error visitKnownRecordImpl(CVSymbol &CVR, T &Record) { - - Record.RecordOffset = - Delegate ? Delegate->getRecordOffset(Mapping->Reader) : 0; - if (auto EC = Mapping->Mapping.visitKnownRecord(CVR, Record)) - return EC; - return Error::success(); - } - - SymbolVisitorDelegate *Delegate; - CodeViewContainer Container; - std::unique_ptr<MappingInfo> Mapping; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolDeserializer.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDESERIALIZER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class SymbolVisitorDelegate; +class SymbolDeserializer : public SymbolVisitorCallbacks { + struct MappingInfo { + MappingInfo(ArrayRef<uint8_t> RecordData, CodeViewContainer Container) + : Stream(RecordData, llvm::support::little), Reader(Stream), + Mapping(Reader, Container) {} + + BinaryByteStream Stream; + BinaryStreamReader Reader; + SymbolRecordMapping Mapping; + }; + +public: + template <typename T> static Error deserializeAs(CVSymbol Symbol, T &Record) { + // If we're just deserializing one record, then don't worry about alignment + // as there's nothing that comes after. + SymbolDeserializer S(nullptr, CodeViewContainer::ObjectFile); + if (auto EC = S.visitSymbolBegin(Symbol)) + return EC; + if (auto EC = S.visitKnownRecord(Symbol, Record)) + return EC; + if (auto EC = S.visitSymbolEnd(Symbol)) + return EC; + return Error::success(); + } + template <typename T> static Expected<T> deserializeAs(CVSymbol Symbol) { + T Record(static_cast<SymbolRecordKind>(Symbol.kind())); + if (auto EC = deserializeAs<T>(Symbol, Record)) + return std::move(EC); + return Record; + } + + explicit SymbolDeserializer(SymbolVisitorDelegate *Delegate, + CodeViewContainer Container) + : Delegate(Delegate), Container(Container) {} + + Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { + return visitSymbolBegin(Record); + } + + Error visitSymbolBegin(CVSymbol &Record) override { + assert(!Mapping && "Already in a symbol mapping!"); + Mapping = std::make_unique<MappingInfo>(Record.content(), Container); + return Mapping->Mapping.visitSymbolBegin(Record); + } + Error visitSymbolEnd(CVSymbol &Record) override { + assert(Mapping && "Not in a symbol mapping!"); + auto EC = Mapping->Mapping.visitSymbolEnd(Record); + Mapping.reset(); + return EC; + } + +#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ + return visitKnownRecordImpl(CVR, Record); \ + } +#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" + +private: + template <typename T> Error visitKnownRecordImpl(CVSymbol &CVR, T &Record) { + + Record.RecordOffset = + Delegate ? Delegate->getRecordOffset(Mapping->Reader) : 0; + if (auto EC = Mapping->Mapping.visitKnownRecord(CVR, Record)) + return EC; + return Error::success(); + } + + SymbolVisitorDelegate *Delegate; + CodeViewContainer Container; + std::unique_ptr<MappingInfo> Mapping; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumpDelegate.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumpDelegate.h index c6e18b0c88..9f5f2114ef 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumpDelegate.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumpDelegate.h @@ -1,45 +1,45 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- SymbolDumpDelegate.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" -#include <cstdint> - -namespace llvm { -namespace codeview { - -class SymbolDumpDelegate : public SymbolVisitorDelegate { -public: - ~SymbolDumpDelegate() override = default; - - virtual void printRelocatedField(StringRef Label, uint32_t RelocOffset, - uint32_t Offset, - StringRef *RelocSym = nullptr) = 0; - virtual void printBinaryBlockWithRelocs(StringRef Label, - ArrayRef<uint8_t> Block) = 0; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- SymbolDumpDelegate.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" +#include <cstdint> + +namespace llvm { +namespace codeview { + +class SymbolDumpDelegate : public SymbolVisitorDelegate { +public: + ~SymbolDumpDelegate() override = default; + + virtual void printRelocatedField(StringRef Label, uint32_t RelocOffset, + uint32_t Offset, + StringRef *RelocSym = nullptr) = 0; + virtual void printBinaryBlockWithRelocs(StringRef Label, + ArrayRef<uint8_t> Block) = 0; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPDELEGATE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumper.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumper.h index 28faa3b975..2191657b0f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumper.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolDumper.h @@ -1,69 +1,69 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- SymbolDumper.h - CodeView symbol info dumper ------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringSet.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- SymbolDumper.h - CodeView symbol info dumper ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringSet.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" - -namespace llvm { -class ScopedPrinter; - -namespace codeview { -class TypeCollection; - -/// Dumper for CodeView symbol streams found in COFF object files and PDB files. -class CVSymbolDumper { -public: - CVSymbolDumper(ScopedPrinter &W, TypeCollection &Types, - CodeViewContainer Container, - std::unique_ptr<SymbolDumpDelegate> ObjDelegate, CPUType CPU, - bool PrintRecordBytes) - : W(W), Types(Types), Container(Container), - ObjDelegate(std::move(ObjDelegate)), CompilationCPUType(CPU), - PrintRecordBytes(PrintRecordBytes) {} - - /// Dumps one type record. Returns false if there was a type parsing error, - /// and true otherwise. This should be called in order, since the dumper - /// maintains state about previous records which are necessary for cross - /// type references. - Error dump(CVRecord<SymbolKind> &Record); - - /// Dumps the type records in Data. Returns false if there was a type stream - /// parse error, and true otherwise. - Error dump(const CVSymbolArray &Symbols); - - CPUType getCompilationCPUType() const { return CompilationCPUType; } - -private: - ScopedPrinter &W; - TypeCollection &Types; - CodeViewContainer Container; - std::unique_ptr<SymbolDumpDelegate> ObjDelegate; - CPUType CompilationCPUType; - bool PrintRecordBytes; -}; -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" + +namespace llvm { +class ScopedPrinter; + +namespace codeview { +class TypeCollection; + +/// Dumper for CodeView symbol streams found in COFF object files and PDB files. +class CVSymbolDumper { +public: + CVSymbolDumper(ScopedPrinter &W, TypeCollection &Types, + CodeViewContainer Container, + std::unique_ptr<SymbolDumpDelegate> ObjDelegate, CPUType CPU, + bool PrintRecordBytes) + : W(W), Types(Types), Container(Container), + ObjDelegate(std::move(ObjDelegate)), CompilationCPUType(CPU), + PrintRecordBytes(PrintRecordBytes) {} + + /// Dumps one type record. Returns false if there was a type parsing error, + /// and true otherwise. This should be called in order, since the dumper + /// maintains state about previous records which are necessary for cross + /// type references. + Error dump(CVRecord<SymbolKind> &Record); + + /// Dumps the type records in Data. Returns false if there was a type stream + /// parse error, and true otherwise. + Error dump(const CVSymbolArray &Symbols); + + CPUType getCompilationCPUType() const { return CompilationCPUType; } + +private: + ScopedPrinter &W; + TypeCollection &Types; + CodeViewContainer Container; + std::unique_ptr<SymbolDumpDelegate> ObjDelegate; + CPUType CompilationCPUType; + bool PrintRecordBytes; +}; +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 6d3aa2973d..b2d09fb470 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -1,1023 +1,1023 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolRecord.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H - -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Endian.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace codeview { - -class SymbolRecord { -protected: - explicit SymbolRecord(SymbolRecordKind Kind) : Kind(Kind) {} - -public: - SymbolRecordKind getKind() const { return Kind; } - - SymbolRecordKind Kind; -}; - -// S_GPROC32, S_LPROC32, S_GPROC32_ID, S_LPROC32_ID, S_LPROC32_DPC or -// S_LPROC32_DPC_ID -class ProcSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 32; - -public: - explicit ProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ProcSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t Parent = 0; - uint32_t End = 0; - uint32_t Next = 0; - uint32_t CodeSize = 0; - uint32_t DbgStart = 0; - uint32_t DbgEnd = 0; - TypeIndex FunctionType; - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - ProcSymFlags Flags = ProcSymFlags::None; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_THUNK32 -class Thunk32Sym : public SymbolRecord { -public: - explicit Thunk32Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - uint32_t Parent = 0; - uint32_t End = 0; - uint32_t Next = 0; - uint32_t Offset = 0; - uint16_t Segment = 0; - uint16_t Length = 0; - ThunkOrdinal Thunk = ThunkOrdinal::Standard; - StringRef Name; - ArrayRef<uint8_t> VariantData; - - uint32_t RecordOffset = 0; -}; - -// S_TRAMPOLINE -class TrampolineSym : public SymbolRecord { -public: - explicit TrampolineSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - TrampolineSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - TrampolineType Type; - uint16_t Size = 0; - uint32_t ThunkOffset = 0; - uint32_t TargetOffset = 0; - uint16_t ThunkSection = 0; - uint16_t TargetSection = 0; - - uint32_t RecordOffset = 0; -}; - -// S_SECTION -class SectionSym : public SymbolRecord { -public: - explicit SectionSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - SectionSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - uint16_t SectionNumber = 0; - uint8_t Alignment = 0; - uint32_t Rva = 0; - uint32_t Length = 0; - uint32_t Characteristics = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_COFFGROUP -class CoffGroupSym : public SymbolRecord { -public: - explicit CoffGroupSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - CoffGroupSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - uint32_t Size = 0; - uint32_t Characteristics = 0; - uint32_t Offset = 0; - uint16_t Segment = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -class ScopeEndSym : public SymbolRecord { -public: - explicit ScopeEndSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ScopeEndSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - uint32_t RecordOffset = 0; -}; - -class CallerSym : public SymbolRecord { -public: - explicit CallerSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} - - std::vector<TypeIndex> Indices; - - uint32_t RecordOffset = 0; -}; - -struct DecodedAnnotation { - StringRef Name; - ArrayRef<uint8_t> Bytes; - BinaryAnnotationsOpCode OpCode = BinaryAnnotationsOpCode::Invalid; - uint32_t U1 = 0; - uint32_t U2 = 0; - int32_t S1 = 0; -}; - -struct BinaryAnnotationIterator - : public iterator_facade_base<BinaryAnnotationIterator, - std::forward_iterator_tag, - DecodedAnnotation> { - BinaryAnnotationIterator() = default; - BinaryAnnotationIterator(ArrayRef<uint8_t> Annotations) : Data(Annotations) {} - BinaryAnnotationIterator(const BinaryAnnotationIterator &Other) - : Data(Other.Data) {} - - bool operator==(BinaryAnnotationIterator Other) const { - return Data == Other.Data; - } - - BinaryAnnotationIterator &operator=(const BinaryAnnotationIterator Other) { - Data = Other.Data; - return *this; - } - - BinaryAnnotationIterator &operator++() { - if (!ParseCurrentAnnotation()) { - *this = BinaryAnnotationIterator(); - return *this; - } - Data = Next; - Next = ArrayRef<uint8_t>(); - Current.reset(); - return *this; - } - - const DecodedAnnotation &operator*() { - ParseCurrentAnnotation(); - return Current.getValue(); - } - -private: - static uint32_t GetCompressedAnnotation(ArrayRef<uint8_t> &Annotations) { - if (Annotations.empty()) - return -1; - - uint8_t FirstByte = Annotations.front(); - Annotations = Annotations.drop_front(); - - if ((FirstByte & 0x80) == 0x00) - return FirstByte; - - if (Annotations.empty()) - return -1; - - uint8_t SecondByte = Annotations.front(); - Annotations = Annotations.drop_front(); - - if ((FirstByte & 0xC0) == 0x80) - return ((FirstByte & 0x3F) << 8) | SecondByte; - - if (Annotations.empty()) - return -1; - - uint8_t ThirdByte = Annotations.front(); - Annotations = Annotations.drop_front(); - - if (Annotations.empty()) - return -1; - - uint8_t FourthByte = Annotations.front(); - Annotations = Annotations.drop_front(); - - if ((FirstByte & 0xE0) == 0xC0) - return ((FirstByte & 0x1F) << 24) | (SecondByte << 16) | - (ThirdByte << 8) | FourthByte; - - return -1; - } - - static int32_t DecodeSignedOperand(uint32_t Operand) { - if (Operand & 1) - return -(Operand >> 1); - return Operand >> 1; - } - - static int32_t DecodeSignedOperand(ArrayRef<uint8_t> &Annotations) { - return DecodeSignedOperand(GetCompressedAnnotation(Annotations)); - } - - bool ParseCurrentAnnotation() { - if (Current.hasValue()) - return true; - - Next = Data; - uint32_t Op = GetCompressedAnnotation(Next); - DecodedAnnotation Result; - Result.OpCode = static_cast<BinaryAnnotationsOpCode>(Op); - switch (Result.OpCode) { - case BinaryAnnotationsOpCode::Invalid: - Result.Name = "Invalid"; - Next = ArrayRef<uint8_t>(); - break; - case BinaryAnnotationsOpCode::CodeOffset: - Result.Name = "CodeOffset"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeCodeOffsetBase: - Result.Name = "ChangeCodeOffsetBase"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeCodeOffset: - Result.Name = "ChangeCodeOffset"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeCodeLength: - Result.Name = "ChangeCodeLength"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeFile: - Result.Name = "ChangeFile"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeLineEndDelta: - Result.Name = "ChangeLineEndDelta"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeRangeKind: - Result.Name = "ChangeRangeKind"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeColumnStart: - Result.Name = "ChangeColumnStart"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeColumnEnd: - Result.Name = "ChangeColumnEnd"; - Result.U1 = GetCompressedAnnotation(Next); - break; - case BinaryAnnotationsOpCode::ChangeLineOffset: - Result.Name = "ChangeLineOffset"; - Result.S1 = DecodeSignedOperand(Next); - break; - case BinaryAnnotationsOpCode::ChangeColumnEndDelta: - Result.Name = "ChangeColumnEndDelta"; - Result.S1 = DecodeSignedOperand(Next); - break; - case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: { - Result.Name = "ChangeCodeOffsetAndLineOffset"; - uint32_t Annotation = GetCompressedAnnotation(Next); - Result.S1 = DecodeSignedOperand(Annotation >> 4); - Result.U1 = Annotation & 0xf; - break; - } - case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: { - Result.Name = "ChangeCodeLengthAndCodeOffset"; - Result.U1 = GetCompressedAnnotation(Next); - Result.U2 = GetCompressedAnnotation(Next); - break; - } - } - Result.Bytes = Data.take_front(Data.size() - Next.size()); - Current = Result; - return true; - } - - Optional<DecodedAnnotation> Current; - ArrayRef<uint8_t> Data; - ArrayRef<uint8_t> Next; -}; - -// S_INLINESITE -class InlineSiteSym : public SymbolRecord { -public: - explicit InlineSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit InlineSiteSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::InlineSiteSym), - RecordOffset(RecordOffset) {} - - iterator_range<BinaryAnnotationIterator> annotations() const { - return make_range(BinaryAnnotationIterator(AnnotationData), - BinaryAnnotationIterator()); - } - - uint32_t Parent = 0; - uint32_t End = 0; - TypeIndex Inlinee; - std::vector<uint8_t> AnnotationData; - - uint32_t RecordOffset = 0; -}; - -struct PublicSym32Header { - ulittle32_t Flags; - ulittle32_t Offset; - ulittle16_t Segment; - // char Name[]; -}; - -// S_PUB32 -class PublicSym32 : public SymbolRecord { -public: - PublicSym32() : SymbolRecord(SymbolRecordKind::PublicSym32) {} - explicit PublicSym32(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit PublicSym32(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::PublicSym32), - RecordOffset(RecordOffset) {} - - PublicSymFlags Flags = PublicSymFlags::None; - uint32_t Offset = 0; - uint16_t Segment = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_REGISTER -class RegisterSym : public SymbolRecord { -public: - explicit RegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit RegisterSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::RegisterSym), - RecordOffset(RecordOffset) {} - - TypeIndex Index; - RegisterId Register; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_PROCREF, S_LPROCREF -class ProcRefSym : public SymbolRecord { -public: - explicit ProcRefSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ProcRefSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ProcRefSym), RecordOffset(RecordOffset) { - } - - uint32_t SumName = 0; - uint32_t SymOffset = 0; - uint16_t Module = 0; - StringRef Name; - - uint16_t modi() const { return Module - 1; } - uint32_t RecordOffset = 0; -}; - -// S_LOCAL -class LocalSym : public SymbolRecord { -public: - explicit LocalSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit LocalSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::LocalSym), RecordOffset(RecordOffset) {} - - TypeIndex Type; - LocalSymFlags Flags = LocalSymFlags::None; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -struct LocalVariableAddrRange { - uint32_t OffsetStart = 0; - uint16_t ISectStart = 0; - uint16_t Range = 0; -}; - -struct LocalVariableAddrGap { - uint16_t GapStartOffset = 0; - uint16_t Range = 0; -}; - -enum : uint16_t { MaxDefRange = 0xf000 }; - -// S_DEFRANGE -class DefRangeSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 8; - -public: - explicit DefRangeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t Program = 0; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -// S_DEFRANGE_SUBFIELD -class DefRangeSubfieldSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 12; - -public: - explicit DefRangeSubfieldSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeSubfieldSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeSubfieldSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t Program = 0; - uint16_t OffsetInParent = 0; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -struct DefRangeRegisterHeader { - ulittle16_t Register; - ulittle16_t MayHaveNoName; -}; - -// S_DEFRANGE_REGISTER -class DefRangeRegisterSym : public SymbolRecord { -public: - explicit DefRangeRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeRegisterSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeRegisterHeader); } - - DefRangeRegisterHeader Hdr; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -struct DefRangeSubfieldRegisterHeader { - ulittle16_t Register; - ulittle16_t MayHaveNoName; - ulittle32_t OffsetInParent; -}; - -// S_DEFRANGE_SUBFIELD_REGISTER -class DefRangeSubfieldRegisterSym : public SymbolRecord { -public: - explicit DefRangeSubfieldRegisterSym(SymbolRecordKind Kind) - : SymbolRecord(Kind) {} - explicit DefRangeSubfieldRegisterSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeSubfieldRegisterHeader); } - - DefRangeSubfieldRegisterHeader Hdr; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -struct DefRangeFramePointerRelHeader { - little32_t Offset; -}; - -// S_DEFRANGE_FRAMEPOINTER_REL -class DefRangeFramePointerRelSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 8; - -public: - explicit DefRangeFramePointerRelSym(SymbolRecordKind Kind) - : SymbolRecord(Kind) {} - explicit DefRangeFramePointerRelSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - DefRangeFramePointerRelHeader Hdr; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -struct DefRangeRegisterRelHeader { - ulittle16_t Register; - ulittle16_t Flags; - little32_t BasePointerOffset; -}; - -// S_DEFRANGE_REGISTER_REL -class DefRangeRegisterRelSym : public SymbolRecord { -public: - explicit DefRangeRegisterRelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeRegisterRelSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym), - RecordOffset(RecordOffset) {} - - // The flags implement this notional bitfield: - // uint16_t IsSubfield : 1; - // uint16_t Padding : 3; - // uint16_t OffsetInParent : 12; - enum : uint16_t { - IsSubfieldFlag = 1, - OffsetInParentShift = 4, - }; - - bool hasSpilledUDTMember() const { return Hdr.Flags & IsSubfieldFlag; } - uint16_t offsetInParent() const { return Hdr.Flags >> OffsetInParentShift; } - - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeRegisterRelHeader); } - - DefRangeRegisterRelHeader Hdr; - LocalVariableAddrRange Range; - std::vector<LocalVariableAddrGap> Gaps; - - uint32_t RecordOffset = 0; -}; - -// S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE -class DefRangeFramePointerRelFullScopeSym : public SymbolRecord { -public: - explicit DefRangeFramePointerRelFullScopeSym(SymbolRecordKind Kind) - : SymbolRecord(Kind) {} - explicit DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelFullScopeSym), - RecordOffset(RecordOffset) {} - - int32_t Offset = 0; - - uint32_t RecordOffset = 0; -}; - -// S_BLOCK32 -class BlockSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 16; - -public: - explicit BlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit BlockSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BlockSym), RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t Parent = 0; - uint32_t End = 0; - uint32_t CodeSize = 0; - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_LABEL32 -class LabelSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 4; - -public: - explicit LabelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit LabelSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::LabelSym), RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - ProcSymFlags Flags = ProcSymFlags::None; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_OBJNAME -class ObjNameSym : public SymbolRecord { -public: - explicit ObjNameSym() : SymbolRecord(SymbolRecordKind::ObjNameSym) {} - explicit ObjNameSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ObjNameSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ObjNameSym), RecordOffset(RecordOffset) { - } - - uint32_t Signature = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_ENVBLOCK -class EnvBlockSym : public SymbolRecord { -public: - explicit EnvBlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit EnvBlockSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::EnvBlockSym), - RecordOffset(RecordOffset) {} - - std::vector<StringRef> Fields; - - uint32_t RecordOffset = 0; -}; - -// S_EXPORT -class ExportSym : public SymbolRecord { -public: - explicit ExportSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ExportSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ExportSym), RecordOffset(RecordOffset) {} - - uint16_t Ordinal = 0; - ExportFlags Flags = ExportFlags::None; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_FILESTATIC -class FileStaticSym : public SymbolRecord { -public: - explicit FileStaticSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit FileStaticSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FileStaticSym), - RecordOffset(RecordOffset) {} - - TypeIndex Index; - uint32_t ModFilenameOffset = 0; - LocalSymFlags Flags = LocalSymFlags::None; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_COMPILE2 -class Compile2Sym : public SymbolRecord { -public: - explicit Compile2Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit Compile2Sym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::Compile2Sym), - RecordOffset(RecordOffset) {} - - CompileSym2Flags Flags = CompileSym2Flags::None; - CPUType Machine; - uint16_t VersionFrontendMajor = 0; - uint16_t VersionFrontendMinor = 0; - uint16_t VersionFrontendBuild = 0; - uint16_t VersionBackendMajor = 0; - uint16_t VersionBackendMinor = 0; - uint16_t VersionBackendBuild = 0; - StringRef Version; - std::vector<StringRef> ExtraStrings; - - uint8_t getLanguage() const { return static_cast<uint32_t>(Flags) & 0xFF; } - uint32_t getFlags() const { return static_cast<uint32_t>(Flags) & ~0xFF; } - - uint32_t RecordOffset = 0; -}; - -// S_COMPILE3 -class Compile3Sym : public SymbolRecord { -public: - Compile3Sym() : SymbolRecord(SymbolRecordKind::Compile3Sym) {} - explicit Compile3Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit Compile3Sym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::Compile3Sym), - RecordOffset(RecordOffset) {} - - CompileSym3Flags Flags = CompileSym3Flags::None; - CPUType Machine; - uint16_t VersionFrontendMajor = 0; - uint16_t VersionFrontendMinor = 0; - uint16_t VersionFrontendBuild = 0; - uint16_t VersionFrontendQFE = 0; - uint16_t VersionBackendMajor = 0; - uint16_t VersionBackendMinor = 0; - uint16_t VersionBackendBuild = 0; - uint16_t VersionBackendQFE = 0; - StringRef Version; - - void setLanguage(SourceLanguage Lang) { - Flags = CompileSym3Flags((uint32_t(Flags) & 0xFFFFFF00) | uint32_t(Lang)); - } - - SourceLanguage getLanguage() const { - return static_cast<SourceLanguage>(static_cast<uint32_t>(Flags) & 0xFF); - } - CompileSym3Flags getFlags() const { - return static_cast<CompileSym3Flags>(static_cast<uint32_t>(Flags) & ~0xFF); - } - - bool hasOptimizations() const { - return CompileSym3Flags::None != - (getFlags() & (CompileSym3Flags::PGO | CompileSym3Flags::LTCG)); - } - - uint32_t RecordOffset = 0; -}; - -// S_FRAMEPROC -class FrameProcSym : public SymbolRecord { -public: - explicit FrameProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit FrameProcSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FrameProcSym), - RecordOffset(RecordOffset) {} - - uint32_t TotalFrameBytes = 0; - uint32_t PaddingFrameBytes = 0; - uint32_t OffsetToPadding = 0; - uint32_t BytesOfCalleeSavedRegisters = 0; - uint32_t OffsetOfExceptionHandler = 0; - uint16_t SectionIdOfExceptionHandler = 0; - FrameProcedureOptions Flags = FrameProcedureOptions::None; - - /// Extract the register this frame uses to refer to local variables. - RegisterId getLocalFramePtrReg(CPUType CPU) const { - return decodeFramePtrReg( - EncodedFramePtrReg((uint32_t(Flags) >> 14U) & 0x3U), CPU); - } - - /// Extract the register this frame uses to refer to parameters. - RegisterId getParamFramePtrReg(CPUType CPU) const { - return decodeFramePtrReg( - EncodedFramePtrReg((uint32_t(Flags) >> 16U) & 0x3U), CPU); - } - - uint32_t RecordOffset = 0; - -private: -}; - -// S_CALLSITEINFO -class CallSiteInfoSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 4; - -public: - explicit CallSiteInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit CallSiteInfoSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::CallSiteInfoSym) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - TypeIndex Type; - - uint32_t RecordOffset = 0; -}; - -// S_HEAPALLOCSITE -class HeapAllocationSiteSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 4; - -public: - explicit HeapAllocationSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit HeapAllocationSiteSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::HeapAllocationSiteSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - uint16_t CallInstructionSize = 0; - TypeIndex Type; - - uint32_t RecordOffset = 0; -}; - -// S_FRAMECOOKIE -class FrameCookieSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 4; - -public: - explicit FrameCookieSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit FrameCookieSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FrameCookieSym) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - uint32_t CodeOffset = 0; - uint16_t Register = 0; - FrameCookieKind CookieKind; - uint8_t Flags = 0; - - uint32_t RecordOffset = 0; -}; - -// S_UDT, S_COBOLUDT -class UDTSym : public SymbolRecord { -public: - explicit UDTSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit UDTSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::UDTSym) {} - - TypeIndex Type; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_BUILDINFO -class BuildInfoSym : public SymbolRecord { -public: - explicit BuildInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit BuildInfoSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BuildInfoSym), - RecordOffset(RecordOffset) {} - - TypeIndex BuildId; - - uint32_t RecordOffset = 0; -}; - -// S_BPREL32 -class BPRelativeSym : public SymbolRecord { -public: - explicit BPRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit BPRelativeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BPRelativeSym), - RecordOffset(RecordOffset) {} - - int32_t Offset = 0; - TypeIndex Type; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_REGREL32 -class RegRelativeSym : public SymbolRecord { -public: - explicit RegRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit RegRelativeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::RegRelativeSym), - RecordOffset(RecordOffset) {} - - uint32_t Offset = 0; - TypeIndex Type; - RegisterId Register; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_CONSTANT, S_MANCONSTANT -class ConstantSym : public SymbolRecord { -public: - explicit ConstantSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ConstantSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ConstantSym), - RecordOffset(RecordOffset) {} - - TypeIndex Type; - APSInt Value; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_LDATA32, S_GDATA32, S_LMANDATA, S_GMANDATA -class DataSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 8; - -public: - explicit DataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DataSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DataSym), RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - TypeIndex Type; - uint32_t DataOffset = 0; - uint16_t Segment = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_LTHREAD32, S_GTHREAD32 -class ThreadLocalDataSym : public SymbolRecord { - static constexpr uint32_t RelocationOffset = 8; - -public: - explicit ThreadLocalDataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ThreadLocalDataSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ThreadLocalDataSym), - RecordOffset(RecordOffset) {} - - uint32_t getRelocationOffset() const { - return RecordOffset + RelocationOffset; - } - - TypeIndex Type; - uint32_t DataOffset = 0; - uint16_t Segment = 0; - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_UNAMESPACE -class UsingNamespaceSym : public SymbolRecord { -public: - explicit UsingNamespaceSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit UsingNamespaceSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::UsingNamespaceSym), - RecordOffset(RecordOffset) {} - - StringRef Name; - - uint32_t RecordOffset = 0; -}; - -// S_ANNOTATION -class AnnotationSym : public SymbolRecord { -public: - explicit AnnotationSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit AnnotationSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::AnnotationSym), - RecordOffset(RecordOffset) {} - - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - std::vector<StringRef> Strings; - - uint32_t RecordOffset = 0; -}; - -Expected<CVSymbol> readSymbolFromStream(BinaryStreamRef Stream, - uint32_t Offset); - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolRecord.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H + +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Endian.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace codeview { + +class SymbolRecord { +protected: + explicit SymbolRecord(SymbolRecordKind Kind) : Kind(Kind) {} + +public: + SymbolRecordKind getKind() const { return Kind; } + + SymbolRecordKind Kind; +}; + +// S_GPROC32, S_LPROC32, S_GPROC32_ID, S_LPROC32_ID, S_LPROC32_DPC or +// S_LPROC32_DPC_ID +class ProcSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 32; + +public: + explicit ProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ProcSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t Parent = 0; + uint32_t End = 0; + uint32_t Next = 0; + uint32_t CodeSize = 0; + uint32_t DbgStart = 0; + uint32_t DbgEnd = 0; + TypeIndex FunctionType; + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + ProcSymFlags Flags = ProcSymFlags::None; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_THUNK32 +class Thunk32Sym : public SymbolRecord { +public: + explicit Thunk32Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + uint32_t Parent = 0; + uint32_t End = 0; + uint32_t Next = 0; + uint32_t Offset = 0; + uint16_t Segment = 0; + uint16_t Length = 0; + ThunkOrdinal Thunk = ThunkOrdinal::Standard; + StringRef Name; + ArrayRef<uint8_t> VariantData; + + uint32_t RecordOffset = 0; +}; + +// S_TRAMPOLINE +class TrampolineSym : public SymbolRecord { +public: + explicit TrampolineSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + TrampolineSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + TrampolineType Type; + uint16_t Size = 0; + uint32_t ThunkOffset = 0; + uint32_t TargetOffset = 0; + uint16_t ThunkSection = 0; + uint16_t TargetSection = 0; + + uint32_t RecordOffset = 0; +}; + +// S_SECTION +class SectionSym : public SymbolRecord { +public: + explicit SectionSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + SectionSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + uint16_t SectionNumber = 0; + uint8_t Alignment = 0; + uint32_t Rva = 0; + uint32_t Length = 0; + uint32_t Characteristics = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_COFFGROUP +class CoffGroupSym : public SymbolRecord { +public: + explicit CoffGroupSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + CoffGroupSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + uint32_t Size = 0; + uint32_t Characteristics = 0; + uint32_t Offset = 0; + uint16_t Segment = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +class ScopeEndSym : public SymbolRecord { +public: + explicit ScopeEndSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ScopeEndSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + uint32_t RecordOffset = 0; +}; + +class CallerSym : public SymbolRecord { +public: + explicit CallerSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset) + : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + + std::vector<TypeIndex> Indices; + + uint32_t RecordOffset = 0; +}; + +struct DecodedAnnotation { + StringRef Name; + ArrayRef<uint8_t> Bytes; + BinaryAnnotationsOpCode OpCode = BinaryAnnotationsOpCode::Invalid; + uint32_t U1 = 0; + uint32_t U2 = 0; + int32_t S1 = 0; +}; + +struct BinaryAnnotationIterator + : public iterator_facade_base<BinaryAnnotationIterator, + std::forward_iterator_tag, + DecodedAnnotation> { + BinaryAnnotationIterator() = default; + BinaryAnnotationIterator(ArrayRef<uint8_t> Annotations) : Data(Annotations) {} + BinaryAnnotationIterator(const BinaryAnnotationIterator &Other) + : Data(Other.Data) {} + + bool operator==(BinaryAnnotationIterator Other) const { + return Data == Other.Data; + } + + BinaryAnnotationIterator &operator=(const BinaryAnnotationIterator Other) { + Data = Other.Data; + return *this; + } + + BinaryAnnotationIterator &operator++() { + if (!ParseCurrentAnnotation()) { + *this = BinaryAnnotationIterator(); + return *this; + } + Data = Next; + Next = ArrayRef<uint8_t>(); + Current.reset(); + return *this; + } + + const DecodedAnnotation &operator*() { + ParseCurrentAnnotation(); + return Current.getValue(); + } + +private: + static uint32_t GetCompressedAnnotation(ArrayRef<uint8_t> &Annotations) { + if (Annotations.empty()) + return -1; + + uint8_t FirstByte = Annotations.front(); + Annotations = Annotations.drop_front(); + + if ((FirstByte & 0x80) == 0x00) + return FirstByte; + + if (Annotations.empty()) + return -1; + + uint8_t SecondByte = Annotations.front(); + Annotations = Annotations.drop_front(); + + if ((FirstByte & 0xC0) == 0x80) + return ((FirstByte & 0x3F) << 8) | SecondByte; + + if (Annotations.empty()) + return -1; + + uint8_t ThirdByte = Annotations.front(); + Annotations = Annotations.drop_front(); + + if (Annotations.empty()) + return -1; + + uint8_t FourthByte = Annotations.front(); + Annotations = Annotations.drop_front(); + + if ((FirstByte & 0xE0) == 0xC0) + return ((FirstByte & 0x1F) << 24) | (SecondByte << 16) | + (ThirdByte << 8) | FourthByte; + + return -1; + } + + static int32_t DecodeSignedOperand(uint32_t Operand) { + if (Operand & 1) + return -(Operand >> 1); + return Operand >> 1; + } + + static int32_t DecodeSignedOperand(ArrayRef<uint8_t> &Annotations) { + return DecodeSignedOperand(GetCompressedAnnotation(Annotations)); + } + + bool ParseCurrentAnnotation() { + if (Current.hasValue()) + return true; + + Next = Data; + uint32_t Op = GetCompressedAnnotation(Next); + DecodedAnnotation Result; + Result.OpCode = static_cast<BinaryAnnotationsOpCode>(Op); + switch (Result.OpCode) { + case BinaryAnnotationsOpCode::Invalid: + Result.Name = "Invalid"; + Next = ArrayRef<uint8_t>(); + break; + case BinaryAnnotationsOpCode::CodeOffset: + Result.Name = "CodeOffset"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeCodeOffsetBase: + Result.Name = "ChangeCodeOffsetBase"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeCodeOffset: + Result.Name = "ChangeCodeOffset"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeCodeLength: + Result.Name = "ChangeCodeLength"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeFile: + Result.Name = "ChangeFile"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeLineEndDelta: + Result.Name = "ChangeLineEndDelta"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeRangeKind: + Result.Name = "ChangeRangeKind"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeColumnStart: + Result.Name = "ChangeColumnStart"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeColumnEnd: + Result.Name = "ChangeColumnEnd"; + Result.U1 = GetCompressedAnnotation(Next); + break; + case BinaryAnnotationsOpCode::ChangeLineOffset: + Result.Name = "ChangeLineOffset"; + Result.S1 = DecodeSignedOperand(Next); + break; + case BinaryAnnotationsOpCode::ChangeColumnEndDelta: + Result.Name = "ChangeColumnEndDelta"; + Result.S1 = DecodeSignedOperand(Next); + break; + case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: { + Result.Name = "ChangeCodeOffsetAndLineOffset"; + uint32_t Annotation = GetCompressedAnnotation(Next); + Result.S1 = DecodeSignedOperand(Annotation >> 4); + Result.U1 = Annotation & 0xf; + break; + } + case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: { + Result.Name = "ChangeCodeLengthAndCodeOffset"; + Result.U1 = GetCompressedAnnotation(Next); + Result.U2 = GetCompressedAnnotation(Next); + break; + } + } + Result.Bytes = Data.take_front(Data.size() - Next.size()); + Current = Result; + return true; + } + + Optional<DecodedAnnotation> Current; + ArrayRef<uint8_t> Data; + ArrayRef<uint8_t> Next; +}; + +// S_INLINESITE +class InlineSiteSym : public SymbolRecord { +public: + explicit InlineSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit InlineSiteSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::InlineSiteSym), + RecordOffset(RecordOffset) {} + + iterator_range<BinaryAnnotationIterator> annotations() const { + return make_range(BinaryAnnotationIterator(AnnotationData), + BinaryAnnotationIterator()); + } + + uint32_t Parent = 0; + uint32_t End = 0; + TypeIndex Inlinee; + std::vector<uint8_t> AnnotationData; + + uint32_t RecordOffset = 0; +}; + +struct PublicSym32Header { + ulittle32_t Flags; + ulittle32_t Offset; + ulittle16_t Segment; + // char Name[]; +}; + +// S_PUB32 +class PublicSym32 : public SymbolRecord { +public: + PublicSym32() : SymbolRecord(SymbolRecordKind::PublicSym32) {} + explicit PublicSym32(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit PublicSym32(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::PublicSym32), + RecordOffset(RecordOffset) {} + + PublicSymFlags Flags = PublicSymFlags::None; + uint32_t Offset = 0; + uint16_t Segment = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_REGISTER +class RegisterSym : public SymbolRecord { +public: + explicit RegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit RegisterSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::RegisterSym), + RecordOffset(RecordOffset) {} + + TypeIndex Index; + RegisterId Register; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_PROCREF, S_LPROCREF +class ProcRefSym : public SymbolRecord { +public: + explicit ProcRefSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit ProcRefSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::ProcRefSym), RecordOffset(RecordOffset) { + } + + uint32_t SumName = 0; + uint32_t SymOffset = 0; + uint16_t Module = 0; + StringRef Name; + + uint16_t modi() const { return Module - 1; } + uint32_t RecordOffset = 0; +}; + +// S_LOCAL +class LocalSym : public SymbolRecord { +public: + explicit LocalSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit LocalSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::LocalSym), RecordOffset(RecordOffset) {} + + TypeIndex Type; + LocalSymFlags Flags = LocalSymFlags::None; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +struct LocalVariableAddrRange { + uint32_t OffsetStart = 0; + uint16_t ISectStart = 0; + uint16_t Range = 0; +}; + +struct LocalVariableAddrGap { + uint16_t GapStartOffset = 0; + uint16_t Range = 0; +}; + +enum : uint16_t { MaxDefRange = 0xf000 }; + +// S_DEFRANGE +class DefRangeSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 8; + +public: + explicit DefRangeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit DefRangeSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t Program = 0; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +// S_DEFRANGE_SUBFIELD +class DefRangeSubfieldSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 12; + +public: + explicit DefRangeSubfieldSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit DefRangeSubfieldSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeSubfieldSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t Program = 0; + uint16_t OffsetInParent = 0; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +struct DefRangeRegisterHeader { + ulittle16_t Register; + ulittle16_t MayHaveNoName; +}; + +// S_DEFRANGE_REGISTER +class DefRangeRegisterSym : public SymbolRecord { +public: + explicit DefRangeRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit DefRangeRegisterSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeRegisterHeader); } + + DefRangeRegisterHeader Hdr; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +struct DefRangeSubfieldRegisterHeader { + ulittle16_t Register; + ulittle16_t MayHaveNoName; + ulittle32_t OffsetInParent; +}; + +// S_DEFRANGE_SUBFIELD_REGISTER +class DefRangeSubfieldRegisterSym : public SymbolRecord { +public: + explicit DefRangeSubfieldRegisterSym(SymbolRecordKind Kind) + : SymbolRecord(Kind) {} + explicit DefRangeSubfieldRegisterSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeSubfieldRegisterHeader); } + + DefRangeSubfieldRegisterHeader Hdr; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +struct DefRangeFramePointerRelHeader { + little32_t Offset; +}; + +// S_DEFRANGE_FRAMEPOINTER_REL +class DefRangeFramePointerRelSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 8; + +public: + explicit DefRangeFramePointerRelSym(SymbolRecordKind Kind) + : SymbolRecord(Kind) {} + explicit DefRangeFramePointerRelSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + DefRangeFramePointerRelHeader Hdr; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +struct DefRangeRegisterRelHeader { + ulittle16_t Register; + ulittle16_t Flags; + little32_t BasePointerOffset; +}; + +// S_DEFRANGE_REGISTER_REL +class DefRangeRegisterRelSym : public SymbolRecord { +public: + explicit DefRangeRegisterRelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit DefRangeRegisterRelSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym), + RecordOffset(RecordOffset) {} + + // The flags implement this notional bitfield: + // uint16_t IsSubfield : 1; + // uint16_t Padding : 3; + // uint16_t OffsetInParent : 12; + enum : uint16_t { + IsSubfieldFlag = 1, + OffsetInParentShift = 4, + }; + + bool hasSpilledUDTMember() const { return Hdr.Flags & IsSubfieldFlag; } + uint16_t offsetInParent() const { return Hdr.Flags >> OffsetInParentShift; } + + uint32_t getRelocationOffset() const { return RecordOffset + sizeof(DefRangeRegisterRelHeader); } + + DefRangeRegisterRelHeader Hdr; + LocalVariableAddrRange Range; + std::vector<LocalVariableAddrGap> Gaps; + + uint32_t RecordOffset = 0; +}; + +// S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE +class DefRangeFramePointerRelFullScopeSym : public SymbolRecord { +public: + explicit DefRangeFramePointerRelFullScopeSym(SymbolRecordKind Kind) + : SymbolRecord(Kind) {} + explicit DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelFullScopeSym), + RecordOffset(RecordOffset) {} + + int32_t Offset = 0; + + uint32_t RecordOffset = 0; +}; + +// S_BLOCK32 +class BlockSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 16; + +public: + explicit BlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit BlockSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::BlockSym), RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t Parent = 0; + uint32_t End = 0; + uint32_t CodeSize = 0; + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_LABEL32 +class LabelSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 4; + +public: + explicit LabelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit LabelSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::LabelSym), RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + ProcSymFlags Flags = ProcSymFlags::None; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_OBJNAME +class ObjNameSym : public SymbolRecord { +public: + explicit ObjNameSym() : SymbolRecord(SymbolRecordKind::ObjNameSym) {} + explicit ObjNameSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit ObjNameSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::ObjNameSym), RecordOffset(RecordOffset) { + } + + uint32_t Signature = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_ENVBLOCK +class EnvBlockSym : public SymbolRecord { +public: + explicit EnvBlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit EnvBlockSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::EnvBlockSym), + RecordOffset(RecordOffset) {} + + std::vector<StringRef> Fields; + + uint32_t RecordOffset = 0; +}; + +// S_EXPORT +class ExportSym : public SymbolRecord { +public: + explicit ExportSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit ExportSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::ExportSym), RecordOffset(RecordOffset) {} + + uint16_t Ordinal = 0; + ExportFlags Flags = ExportFlags::None; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_FILESTATIC +class FileStaticSym : public SymbolRecord { +public: + explicit FileStaticSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit FileStaticSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::FileStaticSym), + RecordOffset(RecordOffset) {} + + TypeIndex Index; + uint32_t ModFilenameOffset = 0; + LocalSymFlags Flags = LocalSymFlags::None; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_COMPILE2 +class Compile2Sym : public SymbolRecord { +public: + explicit Compile2Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit Compile2Sym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::Compile2Sym), + RecordOffset(RecordOffset) {} + + CompileSym2Flags Flags = CompileSym2Flags::None; + CPUType Machine; + uint16_t VersionFrontendMajor = 0; + uint16_t VersionFrontendMinor = 0; + uint16_t VersionFrontendBuild = 0; + uint16_t VersionBackendMajor = 0; + uint16_t VersionBackendMinor = 0; + uint16_t VersionBackendBuild = 0; + StringRef Version; + std::vector<StringRef> ExtraStrings; + + uint8_t getLanguage() const { return static_cast<uint32_t>(Flags) & 0xFF; } + uint32_t getFlags() const { return static_cast<uint32_t>(Flags) & ~0xFF; } + + uint32_t RecordOffset = 0; +}; + +// S_COMPILE3 +class Compile3Sym : public SymbolRecord { +public: + Compile3Sym() : SymbolRecord(SymbolRecordKind::Compile3Sym) {} + explicit Compile3Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit Compile3Sym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::Compile3Sym), + RecordOffset(RecordOffset) {} + + CompileSym3Flags Flags = CompileSym3Flags::None; + CPUType Machine; + uint16_t VersionFrontendMajor = 0; + uint16_t VersionFrontendMinor = 0; + uint16_t VersionFrontendBuild = 0; + uint16_t VersionFrontendQFE = 0; + uint16_t VersionBackendMajor = 0; + uint16_t VersionBackendMinor = 0; + uint16_t VersionBackendBuild = 0; + uint16_t VersionBackendQFE = 0; + StringRef Version; + + void setLanguage(SourceLanguage Lang) { + Flags = CompileSym3Flags((uint32_t(Flags) & 0xFFFFFF00) | uint32_t(Lang)); + } + + SourceLanguage getLanguage() const { + return static_cast<SourceLanguage>(static_cast<uint32_t>(Flags) & 0xFF); + } + CompileSym3Flags getFlags() const { + return static_cast<CompileSym3Flags>(static_cast<uint32_t>(Flags) & ~0xFF); + } + + bool hasOptimizations() const { + return CompileSym3Flags::None != + (getFlags() & (CompileSym3Flags::PGO | CompileSym3Flags::LTCG)); + } + + uint32_t RecordOffset = 0; +}; + +// S_FRAMEPROC +class FrameProcSym : public SymbolRecord { +public: + explicit FrameProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit FrameProcSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::FrameProcSym), + RecordOffset(RecordOffset) {} + + uint32_t TotalFrameBytes = 0; + uint32_t PaddingFrameBytes = 0; + uint32_t OffsetToPadding = 0; + uint32_t BytesOfCalleeSavedRegisters = 0; + uint32_t OffsetOfExceptionHandler = 0; + uint16_t SectionIdOfExceptionHandler = 0; + FrameProcedureOptions Flags = FrameProcedureOptions::None; + + /// Extract the register this frame uses to refer to local variables. + RegisterId getLocalFramePtrReg(CPUType CPU) const { + return decodeFramePtrReg( + EncodedFramePtrReg((uint32_t(Flags) >> 14U) & 0x3U), CPU); + } + + /// Extract the register this frame uses to refer to parameters. + RegisterId getParamFramePtrReg(CPUType CPU) const { + return decodeFramePtrReg( + EncodedFramePtrReg((uint32_t(Flags) >> 16U) & 0x3U), CPU); + } + + uint32_t RecordOffset = 0; + +private: +}; + +// S_CALLSITEINFO +class CallSiteInfoSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 4; + +public: + explicit CallSiteInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit CallSiteInfoSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::CallSiteInfoSym) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + TypeIndex Type; + + uint32_t RecordOffset = 0; +}; + +// S_HEAPALLOCSITE +class HeapAllocationSiteSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 4; + +public: + explicit HeapAllocationSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit HeapAllocationSiteSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::HeapAllocationSiteSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + uint16_t CallInstructionSize = 0; + TypeIndex Type; + + uint32_t RecordOffset = 0; +}; + +// S_FRAMECOOKIE +class FrameCookieSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 4; + +public: + explicit FrameCookieSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit FrameCookieSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::FrameCookieSym) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + uint32_t CodeOffset = 0; + uint16_t Register = 0; + FrameCookieKind CookieKind; + uint8_t Flags = 0; + + uint32_t RecordOffset = 0; +}; + +// S_UDT, S_COBOLUDT +class UDTSym : public SymbolRecord { +public: + explicit UDTSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit UDTSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::UDTSym) {} + + TypeIndex Type; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_BUILDINFO +class BuildInfoSym : public SymbolRecord { +public: + explicit BuildInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit BuildInfoSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::BuildInfoSym), + RecordOffset(RecordOffset) {} + + TypeIndex BuildId; + + uint32_t RecordOffset = 0; +}; + +// S_BPREL32 +class BPRelativeSym : public SymbolRecord { +public: + explicit BPRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit BPRelativeSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::BPRelativeSym), + RecordOffset(RecordOffset) {} + + int32_t Offset = 0; + TypeIndex Type; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_REGREL32 +class RegRelativeSym : public SymbolRecord { +public: + explicit RegRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit RegRelativeSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::RegRelativeSym), + RecordOffset(RecordOffset) {} + + uint32_t Offset = 0; + TypeIndex Type; + RegisterId Register; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_CONSTANT, S_MANCONSTANT +class ConstantSym : public SymbolRecord { +public: + explicit ConstantSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit ConstantSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::ConstantSym), + RecordOffset(RecordOffset) {} + + TypeIndex Type; + APSInt Value; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_LDATA32, S_GDATA32, S_LMANDATA, S_GMANDATA +class DataSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 8; + +public: + explicit DataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit DataSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::DataSym), RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + TypeIndex Type; + uint32_t DataOffset = 0; + uint16_t Segment = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_LTHREAD32, S_GTHREAD32 +class ThreadLocalDataSym : public SymbolRecord { + static constexpr uint32_t RelocationOffset = 8; + +public: + explicit ThreadLocalDataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit ThreadLocalDataSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::ThreadLocalDataSym), + RecordOffset(RecordOffset) {} + + uint32_t getRelocationOffset() const { + return RecordOffset + RelocationOffset; + } + + TypeIndex Type; + uint32_t DataOffset = 0; + uint16_t Segment = 0; + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_UNAMESPACE +class UsingNamespaceSym : public SymbolRecord { +public: + explicit UsingNamespaceSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit UsingNamespaceSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::UsingNamespaceSym), + RecordOffset(RecordOffset) {} + + StringRef Name; + + uint32_t RecordOffset = 0; +}; + +// S_ANNOTATION +class AnnotationSym : public SymbolRecord { +public: + explicit AnnotationSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + explicit AnnotationSym(uint32_t RecordOffset) + : SymbolRecord(SymbolRecordKind::AnnotationSym), + RecordOffset(RecordOffset) {} + + uint32_t CodeOffset = 0; + uint16_t Segment = 0; + std::vector<StringRef> Strings; + + uint32_t RecordOffset = 0; +}; + +Expected<CVSymbol> readSymbolFromStream(BinaryStreamRef Stream, + uint32_t Offset); + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORD_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h index fcae284cfe..db805026eb 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h @@ -1,73 +1,73 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolRecordHelpers.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolRecordHelpers.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H + #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/CodeView.h" - -namespace llvm { -namespace codeview { -/// Return true if this symbol opens a scope. This implies that the symbol has -/// "parent" and "end" fields, which contain the offset of the S_END or -/// S_INLINESITE_END record. -inline bool symbolOpensScope(SymbolKind Kind) { - switch (Kind) { - case SymbolKind::S_GPROC32: - case SymbolKind::S_LPROC32: - case SymbolKind::S_LPROC32_ID: - case SymbolKind::S_GPROC32_ID: - case SymbolKind::S_BLOCK32: - case SymbolKind::S_SEPCODE: - case SymbolKind::S_THUNK32: - case SymbolKind::S_INLINESITE: - case SymbolKind::S_INLINESITE2: - return true; - default: - break; - } - return false; -} - -/// Return true if this ssymbol ends a scope. -inline bool symbolEndsScope(SymbolKind Kind) { - switch (Kind) { - case SymbolKind::S_END: - case SymbolKind::S_PROC_ID_END: - case SymbolKind::S_INLINESITE_END: - return true; - default: - break; - } - return false; -} - -/// Given a symbol P for which symbolOpensScope(P) == true, return the -/// corresponding end offset. -uint32_t getScopeEndOffset(const CVSymbol &Symbol); -uint32_t getScopeParentOffset(const CVSymbol &Symbol); - -CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols, - uint32_t ScopeBegin); - -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + +namespace llvm { +namespace codeview { +/// Return true if this symbol opens a scope. This implies that the symbol has +/// "parent" and "end" fields, which contain the offset of the S_END or +/// S_INLINESITE_END record. +inline bool symbolOpensScope(SymbolKind Kind) { + switch (Kind) { + case SymbolKind::S_GPROC32: + case SymbolKind::S_LPROC32: + case SymbolKind::S_LPROC32_ID: + case SymbolKind::S_GPROC32_ID: + case SymbolKind::S_BLOCK32: + case SymbolKind::S_SEPCODE: + case SymbolKind::S_THUNK32: + case SymbolKind::S_INLINESITE: + case SymbolKind::S_INLINESITE2: + return true; + default: + break; + } + return false; +} + +/// Return true if this ssymbol ends a scope. +inline bool symbolEndsScope(SymbolKind Kind) { + switch (Kind) { + case SymbolKind::S_END: + case SymbolKind::S_PROC_ID_END: + case SymbolKind::S_INLINESITE_END: + return true; + default: + break; + } + return false; +} + +/// Given a symbol P for which symbolOpensScope(P) == true, return the +/// corresponding end offset. +uint32_t getScopeEndOffset(const CVSymbol &Symbol); +uint32_t getScopeParentOffset(const CVSymbol &Symbol); + +CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols, + uint32_t ScopeBegin); + +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h index 72bd87c52f..e290b4fd3d 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h @@ -1,57 +1,57 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolRecordMapping.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H - -#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" - -namespace llvm { -class BinaryStreamReader; -class BinaryStreamWriter; - -namespace codeview { -class SymbolRecordMapping : public SymbolVisitorCallbacks { -public: - explicit SymbolRecordMapping(BinaryStreamReader &Reader, - CodeViewContainer Container) - : IO(Reader), Container(Container) {} - explicit SymbolRecordMapping(BinaryStreamWriter &Writer, - CodeViewContainer Container) - : IO(Writer), Container(Container) {} - - Error visitSymbolBegin(CVSymbol &Record) override; - Error visitSymbolEnd(CVSymbol &Record) override; - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" - -private: - Optional<SymbolKind> Kind; - - CodeViewRecordIO IO; - CodeViewContainer Container; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolRecordMapping.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H + +#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" + +namespace llvm { +class BinaryStreamReader; +class BinaryStreamWriter; + +namespace codeview { +class SymbolRecordMapping : public SymbolVisitorCallbacks { +public: + explicit SymbolRecordMapping(BinaryStreamReader &Reader, + CodeViewContainer Container) + : IO(Reader), Container(Container) {} + explicit SymbolRecordMapping(BinaryStreamWriter &Writer, + CodeViewContainer Container) + : IO(Writer), Container(Container) {} + + Error visitSymbolBegin(CVSymbol &Record) override; + Error visitSymbolEnd(CVSymbol &Record) override; + +#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; +#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" + +private: + Optional<SymbolKind> Kind; + + CodeViewRecordIO IO; + CodeViewContainer Container; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolSerializer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolSerializer.h index e0204db2dd..5a6bc3ba09 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolSerializer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolSerializer.h @@ -1,94 +1,94 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolSerializer.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace codeview { - -class SymbolSerializer : public SymbolVisitorCallbacks { - BumpPtrAllocator &Storage; - // Since this is a fixed size buffer, use a stack allocated buffer. This - // yields measurable performance increase over the repeated heap allocations - // when serializing many independent records via writeOneSymbol. - std::array<uint8_t, MaxRecordLength> RecordBuffer; - MutableBinaryByteStream Stream; - BinaryStreamWriter Writer; - SymbolRecordMapping Mapping; - Optional<SymbolKind> CurrentSymbol; - - Error writeRecordPrefix(SymbolKind Kind) { - RecordPrefix Prefix; - Prefix.RecordKind = Kind; - Prefix.RecordLen = 0; - if (auto EC = Writer.writeObject(Prefix)) - return EC; - return Error::success(); - } - -public: - SymbolSerializer(BumpPtrAllocator &Storage, CodeViewContainer Container); - - template <typename SymType> - static CVSymbol writeOneSymbol(SymType &Sym, BumpPtrAllocator &Storage, - CodeViewContainer Container) { - RecordPrefix Prefix{uint16_t(Sym.Kind)}; - CVSymbol Result(&Prefix, sizeof(Prefix)); - SymbolSerializer Serializer(Storage, Container); - consumeError(Serializer.visitSymbolBegin(Result)); - consumeError(Serializer.visitKnownRecord(Result, Sym)); - consumeError(Serializer.visitSymbolEnd(Result)); - return Result; - } - - Error visitSymbolBegin(CVSymbol &Record) override; - Error visitSymbolEnd(CVSymbol &Record) override; - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ - return visitKnownRecordImpl(CVR, Record); \ - } -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" - -private: - template <typename RecordKind> - Error visitKnownRecordImpl(CVSymbol &CVR, RecordKind &Record) { - return Mapping.visitKnownRecord(CVR, Record); - } -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolSerializer.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace codeview { + +class SymbolSerializer : public SymbolVisitorCallbacks { + BumpPtrAllocator &Storage; + // Since this is a fixed size buffer, use a stack allocated buffer. This + // yields measurable performance increase over the repeated heap allocations + // when serializing many independent records via writeOneSymbol. + std::array<uint8_t, MaxRecordLength> RecordBuffer; + MutableBinaryByteStream Stream; + BinaryStreamWriter Writer; + SymbolRecordMapping Mapping; + Optional<SymbolKind> CurrentSymbol; + + Error writeRecordPrefix(SymbolKind Kind) { + RecordPrefix Prefix; + Prefix.RecordKind = Kind; + Prefix.RecordLen = 0; + if (auto EC = Writer.writeObject(Prefix)) + return EC; + return Error::success(); + } + +public: + SymbolSerializer(BumpPtrAllocator &Storage, CodeViewContainer Container); + + template <typename SymType> + static CVSymbol writeOneSymbol(SymType &Sym, BumpPtrAllocator &Storage, + CodeViewContainer Container) { + RecordPrefix Prefix{uint16_t(Sym.Kind)}; + CVSymbol Result(&Prefix, sizeof(Prefix)); + SymbolSerializer Serializer(Storage, Container); + consumeError(Serializer.visitSymbolBegin(Result)); + consumeError(Serializer.visitKnownRecord(Result, Sym)); + consumeError(Serializer.visitSymbolEnd(Result)); + return Result; + } + + Error visitSymbolBegin(CVSymbol &Record) override; + Error visitSymbolEnd(CVSymbol &Record) override; + +#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ + return visitKnownRecordImpl(CVR, Record); \ + } +#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" + +private: + template <typename RecordKind> + Error visitKnownRecordImpl(CVSymbol &CVR, RecordKind &Record) { + return Mapping.visitKnownRecord(CVR, Record); + } +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h index 6826e0031c..ff30b1ffa4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolVisitorCallbackPipeline.h --------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H - -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" -#include "llvm/Support/Error.h" -#include <vector> - -namespace llvm { -namespace codeview { - -class SymbolVisitorCallbackPipeline : public SymbolVisitorCallbacks { -public: - SymbolVisitorCallbackPipeline() = default; - - Error visitUnknownSymbol(CVSymbol &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitUnknownSymbol(Record)) - return EC; - } - return Error::success(); - } - - Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitSymbolBegin(Record, Offset)) - return EC; - } - return Error::success(); - } - - Error visitSymbolBegin(CVSymbol &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitSymbolBegin(Record)) - return EC; - } - return Error::success(); - } - - Error visitSymbolEnd(CVSymbol &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitSymbolEnd(Record)) - return EC; - } - return Error::success(); - } - - void addCallbackToPipeline(SymbolVisitorCallbacks &Callbacks) { - Pipeline.push_back(&Callbacks); - } - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ - for (auto Visitor : Pipeline) { \ - if (auto EC = Visitor->visitKnownRecord(CVR, Record)) \ - return EC; \ - } \ - return Error::success(); \ - } -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" - -private: - std::vector<SymbolVisitorCallbacks *> Pipeline; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolVisitorCallbackPipeline.h --------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" +#include "llvm/Support/Error.h" +#include <vector> + +namespace llvm { +namespace codeview { + +class SymbolVisitorCallbackPipeline : public SymbolVisitorCallbacks { +public: + SymbolVisitorCallbackPipeline() = default; + + Error visitUnknownSymbol(CVSymbol &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitUnknownSymbol(Record)) + return EC; + } + return Error::success(); + } + + Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitSymbolBegin(Record, Offset)) + return EC; + } + return Error::success(); + } + + Error visitSymbolBegin(CVSymbol &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitSymbolBegin(Record)) + return EC; + } + return Error::success(); + } + + Error visitSymbolEnd(CVSymbol &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitSymbolEnd(Record)) + return EC; + } + return Error::success(); + } + + void addCallbackToPipeline(SymbolVisitorCallbacks &Callbacks) { + Pipeline.push_back(&Callbacks); + } + +#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ + for (auto Visitor : Pipeline) { \ + if (auto EC = Visitor->visitKnownRecord(CVR, Record)) \ + return EC; \ + } \ + return Error::success(); \ + } +#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" + +private: + std::vector<SymbolVisitorCallbacks *> Pipeline; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h index a3acbd0074..30f4856dc7 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolVisitorCallbacks.h ---------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H - -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { - -class SymbolVisitorCallbacks { - friend class CVSymbolVisitor; - -public: - virtual ~SymbolVisitorCallbacks() = default; - - /// Action to take on unknown symbols. By default, they are ignored. - virtual Error visitUnknownSymbol(CVSymbol &Record) { - return Error::success(); - } - - /// Paired begin/end actions for all symbols. Receives all record data, - /// including the fixed-length record prefix. visitSymbolBegin() should - /// return the type of the Symbol, or an error if it cannot be determined. - virtual Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) { - return Error::success(); - } - virtual Error visitSymbolBegin(CVSymbol &Record) { return Error::success(); } - virtual Error visitSymbolEnd(CVSymbol &Record) { return Error::success(); } - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - virtual Error visitKnownRecord(CVSymbol &CVR, Name &Record) { \ - return Error::success(); \ - } -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolVisitorCallbacks.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { + +class SymbolVisitorCallbacks { + friend class CVSymbolVisitor; + +public: + virtual ~SymbolVisitorCallbacks() = default; + + /// Action to take on unknown symbols. By default, they are ignored. + virtual Error visitUnknownSymbol(CVSymbol &Record) { + return Error::success(); + } + + /// Paired begin/end actions for all symbols. Receives all record data, + /// including the fixed-length record prefix. visitSymbolBegin() should + /// return the type of the Symbol, or an error if it cannot be determined. + virtual Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) { + return Error::success(); + } + virtual Error visitSymbolBegin(CVSymbol &Record) { return Error::success(); } + virtual Error visitSymbolEnd(CVSymbol &Record) { return Error::success(); } + +#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ + virtual Error visitKnownRecord(CVSymbol &CVR, Name &Record) { \ + return Error::success(); \ + } +#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h index c7aa565cd8..09250e42be 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h @@ -1,47 +1,47 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- SymbolVisitorDelegate.h ---------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H - -#include "llvm/ADT/StringRef.h" -#include <cstdint> - -namespace llvm { - -class BinaryStreamReader; - -namespace codeview { - -class DebugStringTableSubsectionRef; - -class SymbolVisitorDelegate { -public: - virtual ~SymbolVisitorDelegate() = default; - - virtual uint32_t getRecordOffset(BinaryStreamReader Reader) = 0; - virtual StringRef getFileNameForFileOffset(uint32_t FileOffset) = 0; - virtual DebugStringTableSubsectionRef getStringTable() = 0; -}; - -} // end namespace codeview - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- SymbolVisitorDelegate.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H +#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H + +#include "llvm/ADT/StringRef.h" +#include <cstdint> + +namespace llvm { + +class BinaryStreamReader; + +namespace codeview { + +class DebugStringTableSubsectionRef; + +class SymbolVisitorDelegate { +public: + virtual ~SymbolVisitorDelegate() = default; + + virtual uint32_t getRecordOffset(BinaryStreamReader Reader) = 0; + virtual StringRef getFileNameForFileOffset(uint32_t FileOffset) = 0; + virtual DebugStringTableSubsectionRef getStringTable() = 0; +}; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORDELEGATE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeCollection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeCollection.h index 9bfaa65c08..6bb3a1f0c5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeCollection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeCollection.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeCollection.h - A collection of CodeView type records -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPECOLLECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPECOLLECTION_H - -#include "llvm/ADT/StringRef.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeCollection.h - A collection of CodeView type records -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPECOLLECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPECOLLECTION_H + +#include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" - -namespace llvm { -namespace codeview { -class TypeCollection { -public: - virtual ~TypeCollection() = default; - - bool empty() { return size() == 0; } - - virtual Optional<TypeIndex> getFirst() = 0; - virtual Optional<TypeIndex> getNext(TypeIndex Prev) = 0; - - virtual CVType getType(TypeIndex Index) = 0; - virtual StringRef getTypeName(TypeIndex Index) = 0; - virtual bool contains(TypeIndex Index) = 0; - virtual uint32_t size() = 0; - virtual uint32_t capacity() = 0; - virtual bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) = 0; - - template <typename TFunc> void ForEachRecord(TFunc Func) { - Optional<TypeIndex> Next = getFirst(); - - while (Next.hasValue()) { - TypeIndex N = *Next; - Func(N, getType(N)); - Next = getNext(N); - } - } -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/DebugInfo/CodeView/TypeIndex.h" + +namespace llvm { +namespace codeview { +class TypeCollection { +public: + virtual ~TypeCollection() = default; + + bool empty() { return size() == 0; } + + virtual Optional<TypeIndex> getFirst() = 0; + virtual Optional<TypeIndex> getNext(TypeIndex Prev) = 0; + + virtual CVType getType(TypeIndex Index) = 0; + virtual StringRef getTypeName(TypeIndex Index) = 0; + virtual bool contains(TypeIndex Index) = 0; + virtual uint32_t size() = 0; + virtual uint32_t capacity() = 0; + virtual bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) = 0; + + template <typename TFunc> void ForEachRecord(TFunc Func) { + Optional<TypeIndex> Next = getFirst(); + + while (Next.hasValue()) { + TypeIndex N = *Next; + Func(N, getType(N)); + Next = getNext(N); + } + } +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDeserializer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDeserializer.h index ff344c25af..7ab84abd35 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDeserializer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDeserializer.h @@ -1,176 +1,176 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeDeserializer.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Error.h" -#include <cassert> -#include <cstdint> -#include <memory> - -namespace llvm { -namespace codeview { - -class TypeDeserializer : public TypeVisitorCallbacks { - struct MappingInfo { - explicit MappingInfo(ArrayRef<uint8_t> RecordData) - : Stream(RecordData, llvm::support::little), Reader(Stream), - Mapping(Reader) {} - - BinaryByteStream Stream; - BinaryStreamReader Reader; - TypeRecordMapping Mapping; - }; - -public: - TypeDeserializer() = default; - - template <typename T> static Error deserializeAs(CVType &CVT, T &Record) { - Record.Kind = static_cast<TypeRecordKind>(CVT.kind()); - MappingInfo I(CVT.content()); - if (auto EC = I.Mapping.visitTypeBegin(CVT)) - return EC; - if (auto EC = I.Mapping.visitKnownRecord(CVT, Record)) - return EC; - if (auto EC = I.Mapping.visitTypeEnd(CVT)) - return EC; - return Error::success(); - } - - template <typename T> - static Expected<T> deserializeAs(ArrayRef<uint8_t> Data) { - const RecordPrefix *Prefix = - reinterpret_cast<const RecordPrefix *>(Data.data()); - TypeRecordKind K = - static_cast<TypeRecordKind>(uint16_t(Prefix->RecordKind)); - T Record(K); - CVType CVT(Data); - if (auto EC = deserializeAs<T>(CVT, Record)) - return std::move(EC); - return Record; - } - - Error visitTypeBegin(CVType &Record) override { - assert(!Mapping && "Already in a type mapping!"); - Mapping = std::make_unique<MappingInfo>(Record.content()); - return Mapping->Mapping.visitTypeBegin(Record); - } - - Error visitTypeBegin(CVType &Record, TypeIndex Index) override { - return visitTypeBegin(Record); - } - - Error visitTypeEnd(CVType &Record) override { - assert(Mapping && "Not in a type mapping!"); - auto EC = Mapping->Mapping.visitTypeEnd(Record); - Mapping.reset(); - return EC; - } - -#define TYPE_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \ - return visitKnownRecordImpl<Name##Record>(CVR, Record); \ - } -#define MEMBER_RECORD(EnumName, EnumVal, Name) -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: - template <typename RecordType> - Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) { - return Mapping->Mapping.visitKnownRecord(CVR, Record); - } - - std::unique_ptr<MappingInfo> Mapping; -}; - -class FieldListDeserializer : public TypeVisitorCallbacks { - struct MappingInfo { - explicit MappingInfo(BinaryStreamReader &R) - : Reader(R), Mapping(Reader), StartOffset(0) {} - - BinaryStreamReader &Reader; - TypeRecordMapping Mapping; - uint32_t StartOffset; - }; - -public: - explicit FieldListDeserializer(BinaryStreamReader &Reader) : Mapping(Reader) { - RecordPrefix Pre(static_cast<uint16_t>(TypeLeafKind::LF_FIELDLIST)); - CVType FieldList(&Pre, sizeof(Pre)); - consumeError(Mapping.Mapping.visitTypeBegin(FieldList)); - } - - ~FieldListDeserializer() override { - RecordPrefix Pre(static_cast<uint16_t>(TypeLeafKind::LF_FIELDLIST)); - CVType FieldList(&Pre, sizeof(Pre)); - consumeError(Mapping.Mapping.visitTypeEnd(FieldList)); - } - - Error visitMemberBegin(CVMemberRecord &Record) override { - Mapping.StartOffset = Mapping.Reader.getOffset(); - return Mapping.Mapping.visitMemberBegin(Record); - } - - Error visitMemberEnd(CVMemberRecord &Record) override { - if (auto EC = Mapping.Mapping.visitMemberEnd(Record)) - return EC; - return Error::success(); - } - -#define TYPE_RECORD(EnumName, EnumVal, Name) -#define MEMBER_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \ - return visitKnownMemberImpl<Name##Record>(CVR, Record); \ - } -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: - template <typename RecordType> - Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) { - if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record)) - return EC; - - uint32_t EndOffset = Mapping.Reader.getOffset(); - uint32_t RecordLength = EndOffset - Mapping.StartOffset; - Mapping.Reader.setOffset(Mapping.StartOffset); - if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength)) - return EC; - assert(Mapping.Reader.getOffset() == EndOffset); - return Error::success(); - } - MappingInfo Mapping; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeDeserializer.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Error.h" +#include <cassert> +#include <cstdint> +#include <memory> + +namespace llvm { +namespace codeview { + +class TypeDeserializer : public TypeVisitorCallbacks { + struct MappingInfo { + explicit MappingInfo(ArrayRef<uint8_t> RecordData) + : Stream(RecordData, llvm::support::little), Reader(Stream), + Mapping(Reader) {} + + BinaryByteStream Stream; + BinaryStreamReader Reader; + TypeRecordMapping Mapping; + }; + +public: + TypeDeserializer() = default; + + template <typename T> static Error deserializeAs(CVType &CVT, T &Record) { + Record.Kind = static_cast<TypeRecordKind>(CVT.kind()); + MappingInfo I(CVT.content()); + if (auto EC = I.Mapping.visitTypeBegin(CVT)) + return EC; + if (auto EC = I.Mapping.visitKnownRecord(CVT, Record)) + return EC; + if (auto EC = I.Mapping.visitTypeEnd(CVT)) + return EC; + return Error::success(); + } + + template <typename T> + static Expected<T> deserializeAs(ArrayRef<uint8_t> Data) { + const RecordPrefix *Prefix = + reinterpret_cast<const RecordPrefix *>(Data.data()); + TypeRecordKind K = + static_cast<TypeRecordKind>(uint16_t(Prefix->RecordKind)); + T Record(K); + CVType CVT(Data); + if (auto EC = deserializeAs<T>(CVT, Record)) + return std::move(EC); + return Record; + } + + Error visitTypeBegin(CVType &Record) override { + assert(!Mapping && "Already in a type mapping!"); + Mapping = std::make_unique<MappingInfo>(Record.content()); + return Mapping->Mapping.visitTypeBegin(Record); + } + + Error visitTypeBegin(CVType &Record, TypeIndex Index) override { + return visitTypeBegin(Record); + } + + Error visitTypeEnd(CVType &Record) override { + assert(Mapping && "Not in a type mapping!"); + auto EC = Mapping->Mapping.visitTypeEnd(Record); + Mapping.reset(); + return EC; + } + +#define TYPE_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \ + return visitKnownRecordImpl<Name##Record>(CVR, Record); \ + } +#define MEMBER_RECORD(EnumName, EnumVal, Name) +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + +private: + template <typename RecordType> + Error visitKnownRecordImpl(CVType &CVR, RecordType &Record) { + return Mapping->Mapping.visitKnownRecord(CVR, Record); + } + + std::unique_ptr<MappingInfo> Mapping; +}; + +class FieldListDeserializer : public TypeVisitorCallbacks { + struct MappingInfo { + explicit MappingInfo(BinaryStreamReader &R) + : Reader(R), Mapping(Reader), StartOffset(0) {} + + BinaryStreamReader &Reader; + TypeRecordMapping Mapping; + uint32_t StartOffset; + }; + +public: + explicit FieldListDeserializer(BinaryStreamReader &Reader) : Mapping(Reader) { + RecordPrefix Pre(static_cast<uint16_t>(TypeLeafKind::LF_FIELDLIST)); + CVType FieldList(&Pre, sizeof(Pre)); + consumeError(Mapping.Mapping.visitTypeBegin(FieldList)); + } + + ~FieldListDeserializer() override { + RecordPrefix Pre(static_cast<uint16_t>(TypeLeafKind::LF_FIELDLIST)); + CVType FieldList(&Pre, sizeof(Pre)); + consumeError(Mapping.Mapping.visitTypeEnd(FieldList)); + } + + Error visitMemberBegin(CVMemberRecord &Record) override { + Mapping.StartOffset = Mapping.Reader.getOffset(); + return Mapping.Mapping.visitMemberBegin(Record); + } + + Error visitMemberEnd(CVMemberRecord &Record) override { + if (auto EC = Mapping.Mapping.visitMemberEnd(Record)) + return EC; + return Error::success(); + } + +#define TYPE_RECORD(EnumName, EnumVal, Name) +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \ + return visitKnownMemberImpl<Name##Record>(CVR, Record); \ + } +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + +private: + template <typename RecordType> + Error visitKnownMemberImpl(CVMemberRecord &CVR, RecordType &Record) { + if (auto EC = Mapping.Mapping.visitKnownMember(CVR, Record)) + return EC; + + uint32_t EndOffset = Mapping.Reader.getOffset(); + uint32_t RecordLength = EndOffset - Mapping.StartOffset; + Mapping.Reader.setOffset(Mapping.StartOffset); + if (auto EC = Mapping.Reader.readBytes(CVR.Data, RecordLength)) + return EC; + assert(Mapping.Reader.getOffset() == EndOffset); + return Error::success(); + } + MappingInfo Mapping; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDESERIALIZER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h index 843ceb97cb..21914c924a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h @@ -1,96 +1,96 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" - -namespace llvm { -class ScopedPrinter; - -namespace codeview { - -class TypeCollection; - -/// Dumper for CodeView type streams found in COFF object files and PDB files. -class TypeDumpVisitor : public TypeVisitorCallbacks { -public: - TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W, - bool PrintRecordBytes) - : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {} - - /// When dumping types from an IPI stream in a PDB, a type index may refer to - /// a type or an item ID. The dumper will lookup the "name" of the index in - /// the item database if appropriate. If ItemDB is null, it will use TypeDB, - /// which is correct when dumping types from an object file (/Z7). - void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; } - - void printTypeIndex(StringRef FieldName, TypeIndex TI) const; - - void printItemIndex(StringRef FieldName, TypeIndex TI) const; - - /// Action to take on unknown types. By default, they are ignored. - Error visitUnknownType(CVType &Record) override; - Error visitUnknownMember(CVMemberRecord &Record) override; - - /// Paired begin/end actions for all types. Receives all record data, - /// including the fixed-length record prefix. - Error visitTypeBegin(CVType &Record) override; - Error visitTypeBegin(CVType &Record, TypeIndex Index) override; - Error visitTypeEnd(CVType &Record) override; - Error visitMemberBegin(CVMemberRecord &Record) override; - Error visitMemberEnd(CVMemberRecord &Record) override; - -#define TYPE_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; -#define MEMBER_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: - void printMemberAttributes(MemberAttributes Attrs); - void printMemberAttributes(MemberAccess Access, MethodKind Kind, - MethodOptions Options); - - /// Get the database of indices for the stream that we are dumping. If ItemDB - /// is set, then we must be dumping an item (IPI) stream. This will also - /// always get the appropriate DB for printing item names. - TypeCollection &getSourceTypes() const { - return IpiTypes ? *IpiTypes : TpiTypes; - } - - ScopedPrinter *W; - - bool PrintRecordBytes = false; - - TypeCollection &TpiTypes; - TypeCollection *IpiTypes = nullptr; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" + +namespace llvm { +class ScopedPrinter; + +namespace codeview { + +class TypeCollection; + +/// Dumper for CodeView type streams found in COFF object files and PDB files. +class TypeDumpVisitor : public TypeVisitorCallbacks { +public: + TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W, + bool PrintRecordBytes) + : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {} + + /// When dumping types from an IPI stream in a PDB, a type index may refer to + /// a type or an item ID. The dumper will lookup the "name" of the index in + /// the item database if appropriate. If ItemDB is null, it will use TypeDB, + /// which is correct when dumping types from an object file (/Z7). + void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; } + + void printTypeIndex(StringRef FieldName, TypeIndex TI) const; + + void printItemIndex(StringRef FieldName, TypeIndex TI) const; + + /// Action to take on unknown types. By default, they are ignored. + Error visitUnknownType(CVType &Record) override; + Error visitUnknownMember(CVMemberRecord &Record) override; + + /// Paired begin/end actions for all types. Receives all record data, + /// including the fixed-length record prefix. + Error visitTypeBegin(CVType &Record) override; + Error visitTypeBegin(CVType &Record, TypeIndex Index) override; + Error visitTypeEnd(CVType &Record) override; + Error visitMemberBegin(CVMemberRecord &Record) override; + Error visitMemberEnd(CVMemberRecord &Record) override; + +#define TYPE_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + +private: + void printMemberAttributes(MemberAttributes Attrs); + void printMemberAttributes(MemberAccess Access, MethodKind Kind, + MethodOptions Options); + + /// Get the database of indices for the stream that we are dumping. If ItemDB + /// is set, then we must be dumping an item (IPI) stream. This will also + /// always get the appropriate DB for printing item names. + TypeCollection &getSourceTypes() const { + return IpiTypes ? *IpiTypes : TpiTypes; + } + + ScopedPrinter *W; + + bool PrintRecordBytes = false; + + TypeCollection &TpiTypes; + TypeCollection *IpiTypes = nullptr; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeHashing.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeHashing.h index e4f053c5a7..b0b784aef0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeHashing.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeHashing.h @@ -1,98 +1,98 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeHashing.h ---------------------------------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H - -#include "llvm/ADT/DenseMapInfo.h" -#include "llvm/ADT/Hashing.h" - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" - -#include "llvm/Support/FormatProviders.h" - -#include <type_traits> - -namespace llvm { -namespace codeview { - -/// A locally hashed type represents a straightforward hash code of a serialized -/// record. The record is simply serialized, and then the bytes are hashed by -/// a standard algorithm. This is sufficient for the case of de-duplicating -/// records within a single sequence of types, because if two records both have -/// a back-reference to the same type in the same stream, they will both have -/// the same numeric value for the TypeIndex of the back reference. -struct LocallyHashedType { - hash_code Hash; - ArrayRef<uint8_t> RecordData; - - /// Given a type, compute its local hash. - static LocallyHashedType hashType(ArrayRef<uint8_t> RecordData); - - /// Given a sequence of types, compute all of the local hashes. - template <typename Range> - static std::vector<LocallyHashedType> hashTypes(Range &&Records) { - std::vector<LocallyHashedType> Hashes; - Hashes.reserve(std::distance(std::begin(Records), std::end(Records))); - for (const auto &R : Records) - Hashes.push_back(hashType(R)); - - return Hashes; - } - - static std::vector<LocallyHashedType> - hashTypeCollection(TypeCollection &Types) { - std::vector<LocallyHashedType> Hashes; - Types.ForEachRecord([&Hashes](TypeIndex TI, const CVType &Type) { - Hashes.push_back(hashType(Type.RecordData)); - }); - return Hashes; - } -}; - -enum class GlobalTypeHashAlg : uint16_t { - SHA1 = 0, // standard 20-byte SHA1 hash - SHA1_8 // last 8-bytes of standard SHA1 hash -}; - -/// A globally hashed type represents a hash value that is sufficient to -/// uniquely identify a record across multiple type streams or type sequences. -/// This works by, for any given record A which references B, replacing the -/// TypeIndex that refers to B with a previously-computed global hash for B. As -/// this is a recursive algorithm (e.g. the global hash of B also depends on the -/// global hashes of the types that B refers to), a global hash can uniquely -/// identify identify that A occurs in another stream that has a completely -/// different graph structure. Although the hash itself is slower to compute, -/// probing is much faster with a globally hashed type, because the hash itself -/// is considered "as good as" the original type. Since type records can be -/// quite large, this makes the equality comparison of the hash much faster than -/// equality comparison of a full record. -struct GloballyHashedType { - GloballyHashedType() = default; - GloballyHashedType(StringRef H) - : GloballyHashedType(ArrayRef<uint8_t>(H.bytes_begin(), H.bytes_end())) {} - GloballyHashedType(ArrayRef<uint8_t> H) { - assert(H.size() == 8); - ::memcpy(Hash.data(), H.data(), 8); - } - std::array<uint8_t, 8> Hash; - - bool empty() const { return *(const uint64_t*)Hash.data() == 0; } - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeHashing.h ---------------------------------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEHASHING_H + +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/Hashing.h" + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" + +#include "llvm/Support/FormatProviders.h" + +#include <type_traits> + +namespace llvm { +namespace codeview { + +/// A locally hashed type represents a straightforward hash code of a serialized +/// record. The record is simply serialized, and then the bytes are hashed by +/// a standard algorithm. This is sufficient for the case of de-duplicating +/// records within a single sequence of types, because if two records both have +/// a back-reference to the same type in the same stream, they will both have +/// the same numeric value for the TypeIndex of the back reference. +struct LocallyHashedType { + hash_code Hash; + ArrayRef<uint8_t> RecordData; + + /// Given a type, compute its local hash. + static LocallyHashedType hashType(ArrayRef<uint8_t> RecordData); + + /// Given a sequence of types, compute all of the local hashes. + template <typename Range> + static std::vector<LocallyHashedType> hashTypes(Range &&Records) { + std::vector<LocallyHashedType> Hashes; + Hashes.reserve(std::distance(std::begin(Records), std::end(Records))); + for (const auto &R : Records) + Hashes.push_back(hashType(R)); + + return Hashes; + } + + static std::vector<LocallyHashedType> + hashTypeCollection(TypeCollection &Types) { + std::vector<LocallyHashedType> Hashes; + Types.ForEachRecord([&Hashes](TypeIndex TI, const CVType &Type) { + Hashes.push_back(hashType(Type.RecordData)); + }); + return Hashes; + } +}; + +enum class GlobalTypeHashAlg : uint16_t { + SHA1 = 0, // standard 20-byte SHA1 hash + SHA1_8 // last 8-bytes of standard SHA1 hash +}; + +/// A globally hashed type represents a hash value that is sufficient to +/// uniquely identify a record across multiple type streams or type sequences. +/// This works by, for any given record A which references B, replacing the +/// TypeIndex that refers to B with a previously-computed global hash for B. As +/// this is a recursive algorithm (e.g. the global hash of B also depends on the +/// global hashes of the types that B refers to), a global hash can uniquely +/// identify identify that A occurs in another stream that has a completely +/// different graph structure. Although the hash itself is slower to compute, +/// probing is much faster with a globally hashed type, because the hash itself +/// is considered "as good as" the original type. Since type records can be +/// quite large, this makes the equality comparison of the hash much faster than +/// equality comparison of a full record. +struct GloballyHashedType { + GloballyHashedType() = default; + GloballyHashedType(StringRef H) + : GloballyHashedType(ArrayRef<uint8_t>(H.bytes_begin(), H.bytes_end())) {} + GloballyHashedType(ArrayRef<uint8_t> H) { + assert(H.size() == 8); + ::memcpy(Hash.data(), H.data(), 8); + } + std::array<uint8_t, 8> Hash; + + bool empty() const { return *(const uint64_t*)Hash.data() == 0; } + friend inline bool operator==(const GloballyHashedType &L, const GloballyHashedType &R) { return L.Hash == R.Hash; @@ -103,147 +103,147 @@ struct GloballyHashedType { return !(L.Hash == R.Hash); } - /// Given a sequence of bytes representing a record, compute a global hash for - /// this record. Due to the nature of global hashes incorporating the hashes - /// of referenced records, this function requires a list of types and ids - /// that RecordData might reference, indexable by TypeIndex. - static GloballyHashedType hashType(ArrayRef<uint8_t> RecordData, - ArrayRef<GloballyHashedType> PreviousTypes, - ArrayRef<GloballyHashedType> PreviousIds); - - /// Given a sequence of bytes representing a record, compute a global hash for - /// this record. Due to the nature of global hashes incorporating the hashes - /// of referenced records, this function requires a list of types and ids - /// that RecordData might reference, indexable by TypeIndex. - static GloballyHashedType hashType(CVType Type, - ArrayRef<GloballyHashedType> PreviousTypes, - ArrayRef<GloballyHashedType> PreviousIds) { - return hashType(Type.RecordData, PreviousTypes, PreviousIds); - } - - /// Given a sequence of combined type and ID records, compute global hashes - /// for each of them, returning the results in a vector of hashed types. - template <typename Range> - static std::vector<GloballyHashedType> hashTypes(Range &&Records) { - std::vector<GloballyHashedType> Hashes; - bool UnresolvedRecords = false; - for (const auto &R : Records) { - GloballyHashedType H = hashType(R, Hashes, Hashes); - if (H.empty()) - UnresolvedRecords = true; - Hashes.push_back(H); - } - - // In some rare cases, there might be records with forward references in the - // stream. Several passes might be needed to fully hash each record in the - // Type stream. However this occurs on very small OBJs generated by MASM, - // with a dozen records at most. Therefore this codepath isn't - // time-critical, as it isn't taken in 99% of cases. - while (UnresolvedRecords) { - UnresolvedRecords = false; - auto HashIt = Hashes.begin(); - for (const auto &R : Records) { - if (HashIt->empty()) { - GloballyHashedType H = hashType(R, Hashes, Hashes); - if (H.empty()) - UnresolvedRecords = true; - else - *HashIt = H; - } - ++HashIt; - } - } - - return Hashes; - } - - /// Given a sequence of combined type and ID records, compute global hashes - /// for each of them, returning the results in a vector of hashed types. - template <typename Range> - static std::vector<GloballyHashedType> - hashIds(Range &&Records, ArrayRef<GloballyHashedType> TypeHashes) { - std::vector<GloballyHashedType> IdHashes; - for (const auto &R : Records) - IdHashes.push_back(hashType(R, TypeHashes, IdHashes)); - - return IdHashes; - } - - static std::vector<GloballyHashedType> - hashTypeCollection(TypeCollection &Types) { - std::vector<GloballyHashedType> Hashes; - Types.ForEachRecord([&Hashes](TypeIndex TI, const CVType &Type) { - Hashes.push_back(hashType(Type.RecordData, Hashes, Hashes)); - }); - return Hashes; - } -}; -static_assert(std::is_trivially_copyable<GloballyHashedType>::value, - "GloballyHashedType must be trivially copyable so that we can " - "reinterpret_cast arrays of hash data to arrays of " - "GloballyHashedType"); -} // namespace codeview - -template <> struct DenseMapInfo<codeview::LocallyHashedType> { - static codeview::LocallyHashedType Empty; - static codeview::LocallyHashedType Tombstone; - - static codeview::LocallyHashedType getEmptyKey() { return Empty; } - - static codeview::LocallyHashedType getTombstoneKey() { return Tombstone; } - - static unsigned getHashValue(codeview::LocallyHashedType Val) { - return Val.Hash; - } - - static bool isEqual(codeview::LocallyHashedType LHS, - codeview::LocallyHashedType RHS) { - if (LHS.Hash != RHS.Hash) - return false; - return LHS.RecordData == RHS.RecordData; - } -}; - -template <> struct DenseMapInfo<codeview::GloballyHashedType> { - static codeview::GloballyHashedType Empty; - static codeview::GloballyHashedType Tombstone; - - static codeview::GloballyHashedType getEmptyKey() { return Empty; } - - static codeview::GloballyHashedType getTombstoneKey() { return Tombstone; } - - static unsigned getHashValue(codeview::GloballyHashedType Val) { - return *reinterpret_cast<const unsigned *>(Val.Hash.data()); - } - - static bool isEqual(codeview::GloballyHashedType LHS, - codeview::GloballyHashedType RHS) { + /// Given a sequence of bytes representing a record, compute a global hash for + /// this record. Due to the nature of global hashes incorporating the hashes + /// of referenced records, this function requires a list of types and ids + /// that RecordData might reference, indexable by TypeIndex. + static GloballyHashedType hashType(ArrayRef<uint8_t> RecordData, + ArrayRef<GloballyHashedType> PreviousTypes, + ArrayRef<GloballyHashedType> PreviousIds); + + /// Given a sequence of bytes representing a record, compute a global hash for + /// this record. Due to the nature of global hashes incorporating the hashes + /// of referenced records, this function requires a list of types and ids + /// that RecordData might reference, indexable by TypeIndex. + static GloballyHashedType hashType(CVType Type, + ArrayRef<GloballyHashedType> PreviousTypes, + ArrayRef<GloballyHashedType> PreviousIds) { + return hashType(Type.RecordData, PreviousTypes, PreviousIds); + } + + /// Given a sequence of combined type and ID records, compute global hashes + /// for each of them, returning the results in a vector of hashed types. + template <typename Range> + static std::vector<GloballyHashedType> hashTypes(Range &&Records) { + std::vector<GloballyHashedType> Hashes; + bool UnresolvedRecords = false; + for (const auto &R : Records) { + GloballyHashedType H = hashType(R, Hashes, Hashes); + if (H.empty()) + UnresolvedRecords = true; + Hashes.push_back(H); + } + + // In some rare cases, there might be records with forward references in the + // stream. Several passes might be needed to fully hash each record in the + // Type stream. However this occurs on very small OBJs generated by MASM, + // with a dozen records at most. Therefore this codepath isn't + // time-critical, as it isn't taken in 99% of cases. + while (UnresolvedRecords) { + UnresolvedRecords = false; + auto HashIt = Hashes.begin(); + for (const auto &R : Records) { + if (HashIt->empty()) { + GloballyHashedType H = hashType(R, Hashes, Hashes); + if (H.empty()) + UnresolvedRecords = true; + else + *HashIt = H; + } + ++HashIt; + } + } + + return Hashes; + } + + /// Given a sequence of combined type and ID records, compute global hashes + /// for each of them, returning the results in a vector of hashed types. + template <typename Range> + static std::vector<GloballyHashedType> + hashIds(Range &&Records, ArrayRef<GloballyHashedType> TypeHashes) { + std::vector<GloballyHashedType> IdHashes; + for (const auto &R : Records) + IdHashes.push_back(hashType(R, TypeHashes, IdHashes)); + + return IdHashes; + } + + static std::vector<GloballyHashedType> + hashTypeCollection(TypeCollection &Types) { + std::vector<GloballyHashedType> Hashes; + Types.ForEachRecord([&Hashes](TypeIndex TI, const CVType &Type) { + Hashes.push_back(hashType(Type.RecordData, Hashes, Hashes)); + }); + return Hashes; + } +}; +static_assert(std::is_trivially_copyable<GloballyHashedType>::value, + "GloballyHashedType must be trivially copyable so that we can " + "reinterpret_cast arrays of hash data to arrays of " + "GloballyHashedType"); +} // namespace codeview + +template <> struct DenseMapInfo<codeview::LocallyHashedType> { + static codeview::LocallyHashedType Empty; + static codeview::LocallyHashedType Tombstone; + + static codeview::LocallyHashedType getEmptyKey() { return Empty; } + + static codeview::LocallyHashedType getTombstoneKey() { return Tombstone; } + + static unsigned getHashValue(codeview::LocallyHashedType Val) { + return Val.Hash; + } + + static bool isEqual(codeview::LocallyHashedType LHS, + codeview::LocallyHashedType RHS) { + if (LHS.Hash != RHS.Hash) + return false; + return LHS.RecordData == RHS.RecordData; + } +}; + +template <> struct DenseMapInfo<codeview::GloballyHashedType> { + static codeview::GloballyHashedType Empty; + static codeview::GloballyHashedType Tombstone; + + static codeview::GloballyHashedType getEmptyKey() { return Empty; } + + static codeview::GloballyHashedType getTombstoneKey() { return Tombstone; } + + static unsigned getHashValue(codeview::GloballyHashedType Val) { + return *reinterpret_cast<const unsigned *>(Val.Hash.data()); + } + + static bool isEqual(codeview::GloballyHashedType LHS, + codeview::GloballyHashedType RHS) { return LHS == RHS; - } -}; - -template <> struct format_provider<codeview::LocallyHashedType> { -public: - static void format(const codeview::LocallyHashedType &V, - llvm::raw_ostream &Stream, StringRef Style) { - write_hex(Stream, V.Hash, HexPrintStyle::Upper, 8); - } -}; - -template <> struct format_provider<codeview::GloballyHashedType> { -public: - static void format(const codeview::GloballyHashedType &V, - llvm::raw_ostream &Stream, StringRef Style) { - for (uint8_t B : V.Hash) { - write_hex(Stream, B, HexPrintStyle::Upper, 2); - } - } -}; - -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + } +}; + +template <> struct format_provider<codeview::LocallyHashedType> { +public: + static void format(const codeview::LocallyHashedType &V, + llvm::raw_ostream &Stream, StringRef Style) { + write_hex(Stream, V.Hash, HexPrintStyle::Upper, 8); + } +}; + +template <> struct format_provider<codeview::GloballyHashedType> { +public: + static void format(const codeview::GloballyHashedType &V, + llvm::raw_ostream &Stream, StringRef Style) { + for (uint8_t B : V.Hash) { + write_hex(Stream, B, HexPrintStyle::Upper, 2); + } + } +}; + +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndex.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndex.h index 812a941243..498a353d2b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndex.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndex.h @@ -1,135 +1,135 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeIndex.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H - -#include "llvm/ADT/DenseMapInfo.h" -#include "llvm/Support/Endian.h" -#include <cassert> -#include <cinttypes> -#include <functional> - -namespace llvm { - -class ScopedPrinter; - -namespace codeview { - -class TypeCollection; - -enum class SimpleTypeKind : uint32_t { - None = 0x0000, // uncharacterized type (no type) - Void = 0x0003, // void - NotTranslated = 0x0007, // type not translated by cvpack - HResult = 0x0008, // OLE/COM HRESULT - - SignedCharacter = 0x0010, // 8 bit signed - UnsignedCharacter = 0x0020, // 8 bit unsigned - NarrowCharacter = 0x0070, // really a char - WideCharacter = 0x0071, // wide char - Character16 = 0x007a, // char16_t - Character32 = 0x007b, // char32_t - - SByte = 0x0068, // 8 bit signed int - Byte = 0x0069, // 8 bit unsigned int - Int16Short = 0x0011, // 16 bit signed - UInt16Short = 0x0021, // 16 bit unsigned - Int16 = 0x0072, // 16 bit signed int - UInt16 = 0x0073, // 16 bit unsigned int - Int32Long = 0x0012, // 32 bit signed - UInt32Long = 0x0022, // 32 bit unsigned - Int32 = 0x0074, // 32 bit signed int - UInt32 = 0x0075, // 32 bit unsigned int - Int64Quad = 0x0013, // 64 bit signed - UInt64Quad = 0x0023, // 64 bit unsigned - Int64 = 0x0076, // 64 bit signed int - UInt64 = 0x0077, // 64 bit unsigned int - Int128Oct = 0x0014, // 128 bit signed int - UInt128Oct = 0x0024, // 128 bit unsigned int - Int128 = 0x0078, // 128 bit signed int - UInt128 = 0x0079, // 128 bit unsigned int - - Float16 = 0x0046, // 16 bit real - Float32 = 0x0040, // 32 bit real - Float32PartialPrecision = 0x0045, // 32 bit PP real - Float48 = 0x0044, // 48 bit real - Float64 = 0x0041, // 64 bit real - Float80 = 0x0042, // 80 bit real - Float128 = 0x0043, // 128 bit real - - Complex16 = 0x0056, // 16 bit complex - Complex32 = 0x0050, // 32 bit complex - Complex32PartialPrecision = 0x0055, // 32 bit PP complex - Complex48 = 0x0054, // 48 bit complex - Complex64 = 0x0051, // 64 bit complex - Complex80 = 0x0052, // 80 bit complex - Complex128 = 0x0053, // 128 bit complex - - Boolean8 = 0x0030, // 8 bit boolean - Boolean16 = 0x0031, // 16 bit boolean - Boolean32 = 0x0032, // 32 bit boolean - Boolean64 = 0x0033, // 64 bit boolean - Boolean128 = 0x0034, // 128 bit boolean -}; - -enum class SimpleTypeMode : uint32_t { - Direct = 0x00000000, // Not a pointer - NearPointer = 0x00000100, // Near pointer - FarPointer = 0x00000200, // Far pointer - HugePointer = 0x00000300, // Huge pointer - NearPointer32 = 0x00000400, // 32 bit near pointer - FarPointer32 = 0x00000500, // 32 bit far pointer - NearPointer64 = 0x00000600, // 64 bit near pointer - NearPointer128 = 0x00000700 // 128 bit near pointer -}; - -/// A 32-bit type reference. Types are indexed by their order of appearance in -/// .debug$T plus 0x1000. Type indices less than 0x1000 are "simple" types, -/// composed of a SimpleTypeMode byte followed by a SimpleTypeKind byte. -class TypeIndex { -public: - static const uint32_t FirstNonSimpleIndex = 0x1000; - static const uint32_t SimpleKindMask = 0x000000ff; - static const uint32_t SimpleModeMask = 0x00000700; - static const uint32_t DecoratedItemIdMask = 0x80000000; - -public: - TypeIndex() : Index(static_cast<uint32_t>(SimpleTypeKind::None)) {} - explicit TypeIndex(uint32_t Index) : Index(Index) {} - explicit TypeIndex(SimpleTypeKind Kind) - : Index(static_cast<uint32_t>(Kind)) {} - TypeIndex(SimpleTypeKind Kind, SimpleTypeMode Mode) - : Index(static_cast<uint32_t>(Kind) | static_cast<uint32_t>(Mode)) {} - - uint32_t getIndex() const { return Index; } - void setIndex(uint32_t I) { Index = I; } - bool isSimple() const { return Index < FirstNonSimpleIndex; } - bool isDecoratedItemId() const { return !!(Index & DecoratedItemIdMask); } - - bool isNoneType() const { return *this == None(); } - - uint32_t toArrayIndex() const { - assert(!isSimple()); +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeIndex.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H + +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/Support/Endian.h" +#include <cassert> +#include <cinttypes> +#include <functional> + +namespace llvm { + +class ScopedPrinter; + +namespace codeview { + +class TypeCollection; + +enum class SimpleTypeKind : uint32_t { + None = 0x0000, // uncharacterized type (no type) + Void = 0x0003, // void + NotTranslated = 0x0007, // type not translated by cvpack + HResult = 0x0008, // OLE/COM HRESULT + + SignedCharacter = 0x0010, // 8 bit signed + UnsignedCharacter = 0x0020, // 8 bit unsigned + NarrowCharacter = 0x0070, // really a char + WideCharacter = 0x0071, // wide char + Character16 = 0x007a, // char16_t + Character32 = 0x007b, // char32_t + + SByte = 0x0068, // 8 bit signed int + Byte = 0x0069, // 8 bit unsigned int + Int16Short = 0x0011, // 16 bit signed + UInt16Short = 0x0021, // 16 bit unsigned + Int16 = 0x0072, // 16 bit signed int + UInt16 = 0x0073, // 16 bit unsigned int + Int32Long = 0x0012, // 32 bit signed + UInt32Long = 0x0022, // 32 bit unsigned + Int32 = 0x0074, // 32 bit signed int + UInt32 = 0x0075, // 32 bit unsigned int + Int64Quad = 0x0013, // 64 bit signed + UInt64Quad = 0x0023, // 64 bit unsigned + Int64 = 0x0076, // 64 bit signed int + UInt64 = 0x0077, // 64 bit unsigned int + Int128Oct = 0x0014, // 128 bit signed int + UInt128Oct = 0x0024, // 128 bit unsigned int + Int128 = 0x0078, // 128 bit signed int + UInt128 = 0x0079, // 128 bit unsigned int + + Float16 = 0x0046, // 16 bit real + Float32 = 0x0040, // 32 bit real + Float32PartialPrecision = 0x0045, // 32 bit PP real + Float48 = 0x0044, // 48 bit real + Float64 = 0x0041, // 64 bit real + Float80 = 0x0042, // 80 bit real + Float128 = 0x0043, // 128 bit real + + Complex16 = 0x0056, // 16 bit complex + Complex32 = 0x0050, // 32 bit complex + Complex32PartialPrecision = 0x0055, // 32 bit PP complex + Complex48 = 0x0054, // 48 bit complex + Complex64 = 0x0051, // 64 bit complex + Complex80 = 0x0052, // 80 bit complex + Complex128 = 0x0053, // 128 bit complex + + Boolean8 = 0x0030, // 8 bit boolean + Boolean16 = 0x0031, // 16 bit boolean + Boolean32 = 0x0032, // 32 bit boolean + Boolean64 = 0x0033, // 64 bit boolean + Boolean128 = 0x0034, // 128 bit boolean +}; + +enum class SimpleTypeMode : uint32_t { + Direct = 0x00000000, // Not a pointer + NearPointer = 0x00000100, // Near pointer + FarPointer = 0x00000200, // Far pointer + HugePointer = 0x00000300, // Huge pointer + NearPointer32 = 0x00000400, // 32 bit near pointer + FarPointer32 = 0x00000500, // 32 bit far pointer + NearPointer64 = 0x00000600, // 64 bit near pointer + NearPointer128 = 0x00000700 // 128 bit near pointer +}; + +/// A 32-bit type reference. Types are indexed by their order of appearance in +/// .debug$T plus 0x1000. Type indices less than 0x1000 are "simple" types, +/// composed of a SimpleTypeMode byte followed by a SimpleTypeKind byte. +class TypeIndex { +public: + static const uint32_t FirstNonSimpleIndex = 0x1000; + static const uint32_t SimpleKindMask = 0x000000ff; + static const uint32_t SimpleModeMask = 0x00000700; + static const uint32_t DecoratedItemIdMask = 0x80000000; + +public: + TypeIndex() : Index(static_cast<uint32_t>(SimpleTypeKind::None)) {} + explicit TypeIndex(uint32_t Index) : Index(Index) {} + explicit TypeIndex(SimpleTypeKind Kind) + : Index(static_cast<uint32_t>(Kind)) {} + TypeIndex(SimpleTypeKind Kind, SimpleTypeMode Mode) + : Index(static_cast<uint32_t>(Kind) | static_cast<uint32_t>(Mode)) {} + + uint32_t getIndex() const { return Index; } + void setIndex(uint32_t I) { Index = I; } + bool isSimple() const { return Index < FirstNonSimpleIndex; } + bool isDecoratedItemId() const { return !!(Index & DecoratedItemIdMask); } + + bool isNoneType() const { return *this == None(); } + + uint32_t toArrayIndex() const { + assert(!isSimple()); return (getIndex() & ~DecoratedItemIdMask) - FirstNonSimpleIndex; - } - - static TypeIndex fromArrayIndex(uint32_t Index) { - return TypeIndex(Index + FirstNonSimpleIndex); - } - + } + + static TypeIndex fromArrayIndex(uint32_t Index) { + return TypeIndex(Index + FirstNonSimpleIndex); + } + static TypeIndex fromDecoratedArrayIndex(bool IsItem, uint32_t Index) { return TypeIndex((Index + FirstNonSimpleIndex) | (IsItem ? DecoratedItemIdMask : 0)); @@ -139,181 +139,181 @@ public: return TypeIndex(Index & ~DecoratedItemIdMask); } - SimpleTypeKind getSimpleKind() const { - assert(isSimple()); - return static_cast<SimpleTypeKind>(Index & SimpleKindMask); - } - - SimpleTypeMode getSimpleMode() const { - assert(isSimple()); - return static_cast<SimpleTypeMode>(Index & SimpleModeMask); - } - - TypeIndex makeDirect() const { return TypeIndex{getSimpleKind()}; } - - static TypeIndex None() { return TypeIndex(SimpleTypeKind::None); } - static TypeIndex Void() { return TypeIndex(SimpleTypeKind::Void); } - static TypeIndex VoidPointer32() { - return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer32); - } - static TypeIndex VoidPointer64() { - return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer64); - } - - static TypeIndex NullptrT() { - // std::nullptr_t uses the pointer mode that doesn't indicate bit-width, - // presumably because std::nullptr_t is intended to be compatible with any - // pointer type. - return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer); - } - - static TypeIndex SignedCharacter() { - return TypeIndex(SimpleTypeKind::SignedCharacter); - } - static TypeIndex UnsignedCharacter() { - return TypeIndex(SimpleTypeKind::UnsignedCharacter); - } - static TypeIndex NarrowCharacter() { - return TypeIndex(SimpleTypeKind::NarrowCharacter); - } - static TypeIndex WideCharacter() { - return TypeIndex(SimpleTypeKind::WideCharacter); - } - static TypeIndex Int16Short() { - return TypeIndex(SimpleTypeKind::Int16Short); - } - static TypeIndex UInt16Short() { - return TypeIndex(SimpleTypeKind::UInt16Short); - } - static TypeIndex Int32() { return TypeIndex(SimpleTypeKind::Int32); } - static TypeIndex UInt32() { return TypeIndex(SimpleTypeKind::UInt32); } - static TypeIndex Int32Long() { return TypeIndex(SimpleTypeKind::Int32Long); } - static TypeIndex UInt32Long() { - return TypeIndex(SimpleTypeKind::UInt32Long); - } - static TypeIndex Int64() { return TypeIndex(SimpleTypeKind::Int64); } - static TypeIndex UInt64() { return TypeIndex(SimpleTypeKind::UInt64); } - static TypeIndex Int64Quad() { return TypeIndex(SimpleTypeKind::Int64Quad); } - static TypeIndex UInt64Quad() { - return TypeIndex(SimpleTypeKind::UInt64Quad); - } - - static TypeIndex Float32() { return TypeIndex(SimpleTypeKind::Float32); } - static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); } - - TypeIndex &operator+=(unsigned N) { - Index += N; - return *this; - } - - TypeIndex &operator++() { - Index += 1; - return *this; - } - - TypeIndex operator++(int) { - TypeIndex Copy = *this; - operator++(); - return Copy; - } - - TypeIndex &operator-=(unsigned N) { - assert(Index >= N); - Index -= N; - return *this; - } - - TypeIndex &operator--() { - Index -= 1; - return *this; - } - - TypeIndex operator--(int) { - TypeIndex Copy = *this; - operator--(); - return Copy; - } - - friend inline bool operator==(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() == B.getIndex(); - } - - friend inline bool operator!=(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() != B.getIndex(); - } - - friend inline bool operator<(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() < B.getIndex(); - } - - friend inline bool operator<=(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() <= B.getIndex(); - } - - friend inline bool operator>(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() > B.getIndex(); - } - - friend inline bool operator>=(const TypeIndex &A, const TypeIndex &B) { - return A.getIndex() >= B.getIndex(); - } - - friend inline TypeIndex operator+(const TypeIndex &A, uint32_t N) { - TypeIndex Result(A); - Result += N; - return Result; - } - - friend inline TypeIndex operator-(const TypeIndex &A, uint32_t N) { - assert(A.getIndex() >= N); - TypeIndex Result(A); - Result -= N; - return Result; - } - - friend inline uint32_t operator-(const TypeIndex &A, const TypeIndex &B) { - assert(A >= B); - return A.toArrayIndex() - B.toArrayIndex(); - } - - static StringRef simpleTypeName(TypeIndex TI); - -private: - support::ulittle32_t Index; -}; - -// Used for pseudo-indexing an array of type records. An array of such records -// sorted by TypeIndex can allow log(N) lookups even though such a type record -// stream does not provide random access. -struct TypeIndexOffset { - TypeIndex Type; - support::ulittle32_t Offset; -}; - -void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, - TypeCollection &Types); -} - -template <> struct DenseMapInfo<codeview::TypeIndex> { - static inline codeview::TypeIndex getEmptyKey() { - return codeview::TypeIndex{DenseMapInfo<uint32_t>::getEmptyKey()}; - } - static inline codeview::TypeIndex getTombstoneKey() { - return codeview::TypeIndex{DenseMapInfo<uint32_t>::getTombstoneKey()}; - } - static unsigned getHashValue(const codeview::TypeIndex &TI) { - return DenseMapInfo<uint32_t>::getHashValue(TI.getIndex()); - } - static bool isEqual(const codeview::TypeIndex &LHS, - const codeview::TypeIndex &RHS) { - return LHS == RHS; - } -}; - -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + SimpleTypeKind getSimpleKind() const { + assert(isSimple()); + return static_cast<SimpleTypeKind>(Index & SimpleKindMask); + } + + SimpleTypeMode getSimpleMode() const { + assert(isSimple()); + return static_cast<SimpleTypeMode>(Index & SimpleModeMask); + } + + TypeIndex makeDirect() const { return TypeIndex{getSimpleKind()}; } + + static TypeIndex None() { return TypeIndex(SimpleTypeKind::None); } + static TypeIndex Void() { return TypeIndex(SimpleTypeKind::Void); } + static TypeIndex VoidPointer32() { + return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer32); + } + static TypeIndex VoidPointer64() { + return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer64); + } + + static TypeIndex NullptrT() { + // std::nullptr_t uses the pointer mode that doesn't indicate bit-width, + // presumably because std::nullptr_t is intended to be compatible with any + // pointer type. + return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer); + } + + static TypeIndex SignedCharacter() { + return TypeIndex(SimpleTypeKind::SignedCharacter); + } + static TypeIndex UnsignedCharacter() { + return TypeIndex(SimpleTypeKind::UnsignedCharacter); + } + static TypeIndex NarrowCharacter() { + return TypeIndex(SimpleTypeKind::NarrowCharacter); + } + static TypeIndex WideCharacter() { + return TypeIndex(SimpleTypeKind::WideCharacter); + } + static TypeIndex Int16Short() { + return TypeIndex(SimpleTypeKind::Int16Short); + } + static TypeIndex UInt16Short() { + return TypeIndex(SimpleTypeKind::UInt16Short); + } + static TypeIndex Int32() { return TypeIndex(SimpleTypeKind::Int32); } + static TypeIndex UInt32() { return TypeIndex(SimpleTypeKind::UInt32); } + static TypeIndex Int32Long() { return TypeIndex(SimpleTypeKind::Int32Long); } + static TypeIndex UInt32Long() { + return TypeIndex(SimpleTypeKind::UInt32Long); + } + static TypeIndex Int64() { return TypeIndex(SimpleTypeKind::Int64); } + static TypeIndex UInt64() { return TypeIndex(SimpleTypeKind::UInt64); } + static TypeIndex Int64Quad() { return TypeIndex(SimpleTypeKind::Int64Quad); } + static TypeIndex UInt64Quad() { + return TypeIndex(SimpleTypeKind::UInt64Quad); + } + + static TypeIndex Float32() { return TypeIndex(SimpleTypeKind::Float32); } + static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); } + + TypeIndex &operator+=(unsigned N) { + Index += N; + return *this; + } + + TypeIndex &operator++() { + Index += 1; + return *this; + } + + TypeIndex operator++(int) { + TypeIndex Copy = *this; + operator++(); + return Copy; + } + + TypeIndex &operator-=(unsigned N) { + assert(Index >= N); + Index -= N; + return *this; + } + + TypeIndex &operator--() { + Index -= 1; + return *this; + } + + TypeIndex operator--(int) { + TypeIndex Copy = *this; + operator--(); + return Copy; + } + + friend inline bool operator==(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() == B.getIndex(); + } + + friend inline bool operator!=(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() != B.getIndex(); + } + + friend inline bool operator<(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() < B.getIndex(); + } + + friend inline bool operator<=(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() <= B.getIndex(); + } + + friend inline bool operator>(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() > B.getIndex(); + } + + friend inline bool operator>=(const TypeIndex &A, const TypeIndex &B) { + return A.getIndex() >= B.getIndex(); + } + + friend inline TypeIndex operator+(const TypeIndex &A, uint32_t N) { + TypeIndex Result(A); + Result += N; + return Result; + } + + friend inline TypeIndex operator-(const TypeIndex &A, uint32_t N) { + assert(A.getIndex() >= N); + TypeIndex Result(A); + Result -= N; + return Result; + } + + friend inline uint32_t operator-(const TypeIndex &A, const TypeIndex &B) { + assert(A >= B); + return A.toArrayIndex() - B.toArrayIndex(); + } + + static StringRef simpleTypeName(TypeIndex TI); + +private: + support::ulittle32_t Index; +}; + +// Used for pseudo-indexing an array of type records. An array of such records +// sorted by TypeIndex can allow log(N) lookups even though such a type record +// stream does not provide random access. +struct TypeIndexOffset { + TypeIndex Type; + support::ulittle32_t Offset; +}; + +void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, + TypeCollection &Types); +} + +template <> struct DenseMapInfo<codeview::TypeIndex> { + static inline codeview::TypeIndex getEmptyKey() { + return codeview::TypeIndex{DenseMapInfo<uint32_t>::getEmptyKey()}; + } + static inline codeview::TypeIndex getTombstoneKey() { + return codeview::TypeIndex{DenseMapInfo<uint32_t>::getTombstoneKey()}; + } + static unsigned getHashValue(const codeview::TypeIndex &TI) { + return DenseMapInfo<uint32_t>::getHashValue(TI.getIndex()); + } + static bool isEqual(const codeview::TypeIndex &LHS, + const codeview::TypeIndex &RHS) { + return LHS == RHS; + } +}; + +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h index 4f9c507bd7..4116cb7942 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h @@ -1,57 +1,57 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeIndexDiscovery.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H - -#include "llvm/ADT/SmallVector.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeIndexDiscovery.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H + +#include "llvm/ADT/SmallVector.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -enum class TiRefKind { TypeRef, IndexRef }; -struct TiReference { - TiRefKind Kind; - uint32_t Offset; - uint32_t Count; -}; - -void discoverTypeIndices(ArrayRef<uint8_t> RecordData, - SmallVectorImpl<TiReference> &Refs); -void discoverTypeIndices(const CVType &Type, - SmallVectorImpl<TiReference> &Refs); -void discoverTypeIndices(const CVType &Type, - SmallVectorImpl<TypeIndex> &Indices); -void discoverTypeIndices(ArrayRef<uint8_t> RecordData, - SmallVectorImpl<TypeIndex> &Indices); - -/// Discover type indices in symbol records. Returns false if this is an unknown -/// record. -bool discoverTypeIndicesInSymbol(const CVSymbol &Symbol, - SmallVectorImpl<TiReference> &Refs); -bool discoverTypeIndicesInSymbol(ArrayRef<uint8_t> RecordData, - SmallVectorImpl<TiReference> &Refs); -bool discoverTypeIndicesInSymbol(ArrayRef<uint8_t> RecordData, - SmallVectorImpl<TypeIndex> &Indices); -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +enum class TiRefKind { TypeRef, IndexRef }; +struct TiReference { + TiRefKind Kind; + uint32_t Offset; + uint32_t Count; +}; + +void discoverTypeIndices(ArrayRef<uint8_t> RecordData, + SmallVectorImpl<TiReference> &Refs); +void discoverTypeIndices(const CVType &Type, + SmallVectorImpl<TiReference> &Refs); +void discoverTypeIndices(const CVType &Type, + SmallVectorImpl<TypeIndex> &Indices); +void discoverTypeIndices(ArrayRef<uint8_t> RecordData, + SmallVectorImpl<TypeIndex> &Indices); + +/// Discover type indices in symbol records. Returns false if this is an unknown +/// record. +bool discoverTypeIndicesInSymbol(const CVSymbol &Symbol, + SmallVectorImpl<TiReference> &Refs); +bool discoverTypeIndicesInSymbol(ArrayRef<uint8_t> RecordData, + SmallVectorImpl<TiReference> &Refs); +bool discoverTypeIndicesInSymbol(ArrayRef<uint8_t> RecordData, + SmallVectorImpl<TypeIndex> &Indices); +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecord.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecord.h index 72156c0f94..d1a26a4ea3 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -1,969 +1,969 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeRecord.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H - -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/GUID.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Endian.h" -#include <algorithm> -#include <cstdint> -#include <vector> - -namespace llvm { -namespace codeview { - -using support::little32_t; -using support::ulittle16_t; -using support::ulittle32_t; - -struct CVMemberRecord { - TypeLeafKind Kind; - ArrayRef<uint8_t> Data; -}; - -/// Equvalent to CV_fldattr_t in cvinfo.h. -struct MemberAttributes { - uint16_t Attrs = 0; - - enum { - MethodKindShift = 2, - }; - - MemberAttributes() = default; - - explicit MemberAttributes(MemberAccess Access) - : Attrs(static_cast<uint16_t>(Access)) {} - - MemberAttributes(MemberAccess Access, MethodKind Kind, MethodOptions Flags) { - Attrs = static_cast<uint16_t>(Access); - Attrs |= (static_cast<uint16_t>(Kind) << MethodKindShift); - Attrs |= static_cast<uint16_t>(Flags); - } - - /// Get the access specifier. Valid for any kind of member. - MemberAccess getAccess() const { - return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask)); - } - - /// Indicates if a method is defined with friend, virtual, static, etc. - MethodKind getMethodKind() const { - return MethodKind( - (unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >> - MethodKindShift); - } - - /// Get the flags that are not included in access control or method - /// properties. - MethodOptions getFlags() const { - return MethodOptions( - unsigned(Attrs) & - ~unsigned(MethodOptions::AccessMask | MethodOptions::MethodKindMask)); - } - - /// Is this method virtual. - bool isVirtual() const { - auto MP = getMethodKind(); - return MP != MethodKind::Vanilla && MP != MethodKind::Friend && - MP != MethodKind::Static; - } - - /// Does this member introduce a new virtual method. - bool isIntroducedVirtual() const { - auto MP = getMethodKind(); - return MP == MethodKind::IntroducingVirtual || - MP == MethodKind::PureIntroducingVirtual; - } - - /// Is this method static. - bool isStatic() const { - return getMethodKind() == MethodKind::Static; - } -}; - -// Does not correspond to any tag, this is the tail of an LF_POINTER record -// if it represents a member pointer. -class MemberPointerInfo { -public: - MemberPointerInfo() = default; - - MemberPointerInfo(TypeIndex ContainingType, - PointerToMemberRepresentation Representation) - : ContainingType(ContainingType), Representation(Representation) {} - - TypeIndex getContainingType() const { return ContainingType; } - PointerToMemberRepresentation getRepresentation() const { - return Representation; - } - - TypeIndex ContainingType; - PointerToMemberRepresentation Representation; -}; - -class TypeRecord { -protected: - TypeRecord() = default; - explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {} - -public: - TypeRecordKind getKind() const { return Kind; } - - TypeRecordKind Kind; -}; - -// LF_MODIFIER -class ModifierRecord : public TypeRecord { -public: - ModifierRecord() = default; - explicit ModifierRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - ModifierRecord(TypeIndex ModifiedType, ModifierOptions Modifiers) - : TypeRecord(TypeRecordKind::Modifier), ModifiedType(ModifiedType), - Modifiers(Modifiers) {} - - TypeIndex getModifiedType() const { return ModifiedType; } - ModifierOptions getModifiers() const { return Modifiers; } - - TypeIndex ModifiedType; - ModifierOptions Modifiers = ModifierOptions::None; -}; - -// LF_PROCEDURE -class ProcedureRecord : public TypeRecord { -public: - ProcedureRecord() = default; - explicit ProcedureRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - ProcedureRecord(TypeIndex ReturnType, CallingConvention CallConv, - FunctionOptions Options, uint16_t ParameterCount, - TypeIndex ArgumentList) - : TypeRecord(TypeRecordKind::Procedure), ReturnType(ReturnType), - CallConv(CallConv), Options(Options), ParameterCount(ParameterCount), - ArgumentList(ArgumentList) {} - - TypeIndex getReturnType() const { return ReturnType; } - CallingConvention getCallConv() const { return CallConv; } - FunctionOptions getOptions() const { return Options; } - uint16_t getParameterCount() const { return ParameterCount; } - TypeIndex getArgumentList() const { return ArgumentList; } - - TypeIndex ReturnType; - CallingConvention CallConv; - FunctionOptions Options; - uint16_t ParameterCount = 0; - TypeIndex ArgumentList; -}; - -// LF_MFUNCTION -class MemberFunctionRecord : public TypeRecord { -public: - MemberFunctionRecord() = default; - explicit MemberFunctionRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - MemberFunctionRecord(TypeIndex ReturnType, TypeIndex ClassType, - TypeIndex ThisType, CallingConvention CallConv, - FunctionOptions Options, uint16_t ParameterCount, - TypeIndex ArgumentList, int32_t ThisPointerAdjustment) - : TypeRecord(TypeRecordKind::MemberFunction), ReturnType(ReturnType), - ClassType(ClassType), ThisType(ThisType), CallConv(CallConv), - Options(Options), ParameterCount(ParameterCount), - ArgumentList(ArgumentList), - ThisPointerAdjustment(ThisPointerAdjustment) {} - - TypeIndex getReturnType() const { return ReturnType; } - TypeIndex getClassType() const { return ClassType; } - TypeIndex getThisType() const { return ThisType; } - CallingConvention getCallConv() const { return CallConv; } - FunctionOptions getOptions() const { return Options; } - uint16_t getParameterCount() const { return ParameterCount; } - TypeIndex getArgumentList() const { return ArgumentList; } - int32_t getThisPointerAdjustment() const { return ThisPointerAdjustment; } - - TypeIndex ReturnType; - TypeIndex ClassType; - TypeIndex ThisType; - CallingConvention CallConv; - FunctionOptions Options; - uint16_t ParameterCount = 0; - TypeIndex ArgumentList; - int32_t ThisPointerAdjustment = 0; -}; - -// LF_LABEL -class LabelRecord : public TypeRecord { -public: - LabelRecord() = default; - explicit LabelRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - LabelRecord(LabelType Mode) : TypeRecord(TypeRecordKind::Label), Mode(Mode) {} - - LabelType Mode; -}; - -// LF_MFUNC_ID -class MemberFuncIdRecord : public TypeRecord { -public: - MemberFuncIdRecord() = default; - explicit MemberFuncIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - MemberFuncIdRecord(TypeIndex ClassType, TypeIndex FunctionType, - StringRef Name) - : TypeRecord(TypeRecordKind::MemberFuncId), ClassType(ClassType), - FunctionType(FunctionType), Name(Name) {} - - TypeIndex getClassType() const { return ClassType; } - TypeIndex getFunctionType() const { return FunctionType; } - StringRef getName() const { return Name; } - - TypeIndex ClassType; - TypeIndex FunctionType; - StringRef Name; -}; - -// LF_ARGLIST -class ArgListRecord : public TypeRecord { -public: - ArgListRecord() = default; - explicit ArgListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - ArgListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices) - : TypeRecord(Kind), ArgIndices(Indices) {} - - ArrayRef<TypeIndex> getIndices() const { return ArgIndices; } - - std::vector<TypeIndex> ArgIndices; -}; - -// LF_SUBSTR_LIST -class StringListRecord : public TypeRecord { -public: - StringListRecord() = default; - explicit StringListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - StringListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices) - : TypeRecord(Kind), StringIndices(Indices) {} - - ArrayRef<TypeIndex> getIndices() const { return StringIndices; } - - std::vector<TypeIndex> StringIndices; -}; - -// LF_POINTER -class PointerRecord : public TypeRecord { -public: - // ---------------------------XXXXX - static const uint32_t PointerKindShift = 0; - static const uint32_t PointerKindMask = 0x1F; - - // ------------------------XXX----- - static const uint32_t PointerModeShift = 5; - static const uint32_t PointerModeMask = 0x07; - - // ----------XXX------XXXXX-------- - static const uint32_t PointerOptionMask = 0x381f00; - - // -------------XXXXXX------------ - static const uint32_t PointerSizeShift = 13; - static const uint32_t PointerSizeMask = 0xFF; - - PointerRecord() = default; - explicit PointerRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - PointerRecord(TypeIndex ReferentType, uint32_t Attrs) - : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), - Attrs(Attrs) {} - - PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, - PointerOptions PO, uint8_t Size) - : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), - Attrs(calcAttrs(PK, PM, PO, Size)) {} - - PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, - PointerOptions PO, uint8_t Size, const MemberPointerInfo &MPI) - : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), - Attrs(calcAttrs(PK, PM, PO, Size)), MemberInfo(MPI) {} - - TypeIndex getReferentType() const { return ReferentType; } - - PointerKind getPointerKind() const { - return static_cast<PointerKind>((Attrs >> PointerKindShift) & - PointerKindMask); - } - - PointerMode getMode() const { - return static_cast<PointerMode>((Attrs >> PointerModeShift) & - PointerModeMask); - } - - PointerOptions getOptions() const { - return static_cast<PointerOptions>(Attrs & PointerOptionMask); - } - - uint8_t getSize() const { - return (Attrs >> PointerSizeShift) & PointerSizeMask; - } - - MemberPointerInfo getMemberInfo() const { return *MemberInfo; } - - bool isPointerToMember() const { - return getMode() == PointerMode::PointerToDataMember || - getMode() == PointerMode::PointerToMemberFunction; - } - - bool isFlat() const { return !!(Attrs & uint32_t(PointerOptions::Flat32)); } - bool isConst() const { return !!(Attrs & uint32_t(PointerOptions::Const)); } - - bool isVolatile() const { - return !!(Attrs & uint32_t(PointerOptions::Volatile)); - } - - bool isUnaligned() const { - return !!(Attrs & uint32_t(PointerOptions::Unaligned)); - } - - bool isRestrict() const { - return !!(Attrs & uint32_t(PointerOptions::Restrict)); - } - - bool isLValueReferenceThisPtr() const { - return !!(Attrs & uint32_t(PointerOptions::LValueRefThisPointer)); - } - - bool isRValueReferenceThisPtr() const { - return !!(Attrs & uint32_t(PointerOptions::RValueRefThisPointer)); - } - - TypeIndex ReferentType; - uint32_t Attrs = 0; - Optional<MemberPointerInfo> MemberInfo; - - void setAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, - uint8_t Size) { - Attrs = calcAttrs(PK, PM, PO, Size); - } - -private: - static uint32_t calcAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, - uint8_t Size) { - uint32_t A = 0; - A |= static_cast<uint32_t>(PK); - A |= static_cast<uint32_t>(PO); - A |= (static_cast<uint32_t>(PM) << PointerModeShift); - A |= (static_cast<uint32_t>(Size) << PointerSizeShift); - return A; - } -}; - -// LF_NESTTYPE -class NestedTypeRecord : public TypeRecord { -public: - NestedTypeRecord() = default; - explicit NestedTypeRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - NestedTypeRecord(TypeIndex Type, StringRef Name) - : TypeRecord(TypeRecordKind::NestedType), Type(Type), Name(Name) {} - - TypeIndex getNestedType() const { return Type; } - StringRef getName() const { return Name; } - - TypeIndex Type; - StringRef Name; -}; - -// LF_FIELDLIST -class FieldListRecord : public TypeRecord { -public: - FieldListRecord() = default; - explicit FieldListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - explicit FieldListRecord(ArrayRef<uint8_t> Data) - : TypeRecord(TypeRecordKind::FieldList), Data(Data) {} - - ArrayRef<uint8_t> Data; -}; - -// LF_ARRAY -class ArrayRecord : public TypeRecord { -public: - ArrayRecord() = default; - explicit ArrayRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - ArrayRecord(TypeIndex ElementType, TypeIndex IndexType, uint64_t Size, - StringRef Name) - : TypeRecord(TypeRecordKind::Array), ElementType(ElementType), - IndexType(IndexType), Size(Size), Name(Name) {} - - TypeIndex getElementType() const { return ElementType; } - TypeIndex getIndexType() const { return IndexType; } - uint64_t getSize() const { return Size; } - StringRef getName() const { return Name; } - - TypeIndex ElementType; - TypeIndex IndexType; - uint64_t Size = 0; - StringRef Name; -}; - -class TagRecord : public TypeRecord { -protected: - TagRecord() = default; - explicit TagRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - TagRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, - TypeIndex FieldList, StringRef Name, StringRef UniqueName) - : TypeRecord(Kind), MemberCount(MemberCount), Options(Options), - FieldList(FieldList), Name(Name), UniqueName(UniqueName) {} - -public: - static const int HfaKindShift = 11; - static const int HfaKindMask = 0x1800; - static const int WinRTKindShift = 14; - static const int WinRTKindMask = 0xC000; - - bool hasUniqueName() const { - return (Options & ClassOptions::HasUniqueName) != ClassOptions::None; - } - - bool isNested() const { - return (Options & ClassOptions::Nested) != ClassOptions::None; - } - - bool isForwardRef() const { - return (Options & ClassOptions::ForwardReference) != ClassOptions::None; - } - - bool containsNestedClass() const { - return (Options & ClassOptions::ContainsNestedClass) != ClassOptions::None; - } - - bool isScoped() const { - return (Options & ClassOptions::Scoped) != ClassOptions::None; - } - - uint16_t getMemberCount() const { return MemberCount; } - ClassOptions getOptions() const { return Options; } - TypeIndex getFieldList() const { return FieldList; } - StringRef getName() const { return Name; } - StringRef getUniqueName() const { return UniqueName; } - - uint16_t MemberCount = 0; - ClassOptions Options; - TypeIndex FieldList; - StringRef Name; - StringRef UniqueName; -}; - -// LF_CLASS, LF_STRUCTURE, LF_INTERFACE -class ClassRecord : public TagRecord { -public: - ClassRecord() = default; - explicit ClassRecord(TypeRecordKind Kind) : TagRecord(Kind) {} - ClassRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, - TypeIndex FieldList, TypeIndex DerivationList, - TypeIndex VTableShape, uint64_t Size, StringRef Name, - StringRef UniqueName) - : TagRecord(Kind, MemberCount, Options, FieldList, Name, UniqueName), - DerivationList(DerivationList), VTableShape(VTableShape), Size(Size) {} - - HfaKind getHfa() const { - uint16_t Value = static_cast<uint16_t>(Options); - Value = (Value & HfaKindMask) >> HfaKindShift; - return static_cast<HfaKind>(Value); - } - - WindowsRTClassKind getWinRTKind() const { - uint16_t Value = static_cast<uint16_t>(Options); - Value = (Value & WinRTKindMask) >> WinRTKindShift; - return static_cast<WindowsRTClassKind>(Value); - } - - TypeIndex getDerivationList() const { return DerivationList; } - TypeIndex getVTableShape() const { return VTableShape; } - uint64_t getSize() const { return Size; } - - TypeIndex DerivationList; - TypeIndex VTableShape; - uint64_t Size = 0; -}; - -// LF_UNION -struct UnionRecord : public TagRecord { - UnionRecord() = default; - explicit UnionRecord(TypeRecordKind Kind) : TagRecord(Kind) {} - UnionRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, - uint64_t Size, StringRef Name, StringRef UniqueName) - : TagRecord(TypeRecordKind::Union, MemberCount, Options, FieldList, Name, - UniqueName), - Size(Size) {} - - HfaKind getHfa() const { - uint16_t Value = static_cast<uint16_t>(Options); - Value = (Value & HfaKindMask) >> HfaKindShift; - return static_cast<HfaKind>(Value); - } - - uint64_t getSize() const { return Size; } - - uint64_t Size = 0; -}; - -// LF_ENUM -class EnumRecord : public TagRecord { -public: - EnumRecord() = default; - explicit EnumRecord(TypeRecordKind Kind) : TagRecord(Kind) {} - EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, - StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType) - : TagRecord(TypeRecordKind::Enum, MemberCount, Options, FieldList, Name, - UniqueName), - UnderlyingType(UnderlyingType) {} - - TypeIndex getUnderlyingType() const { return UnderlyingType; } - - TypeIndex UnderlyingType; -}; - -// LF_BITFIELD -class BitFieldRecord : public TypeRecord { -public: - BitFieldRecord() = default; - explicit BitFieldRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset) - : TypeRecord(TypeRecordKind::BitField), Type(Type), BitSize(BitSize), - BitOffset(BitOffset) {} - - TypeIndex getType() const { return Type; } - uint8_t getBitOffset() const { return BitOffset; } - uint8_t getBitSize() const { return BitSize; } - - TypeIndex Type; - uint8_t BitSize = 0; - uint8_t BitOffset = 0; -}; - -// LF_VTSHAPE -class VFTableShapeRecord : public TypeRecord { -public: - VFTableShapeRecord() = default; - explicit VFTableShapeRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - explicit VFTableShapeRecord(ArrayRef<VFTableSlotKind> Slots) - : TypeRecord(TypeRecordKind::VFTableShape), SlotsRef(Slots) {} - explicit VFTableShapeRecord(std::vector<VFTableSlotKind> Slots) - : TypeRecord(TypeRecordKind::VFTableShape), Slots(std::move(Slots)) {} - - ArrayRef<VFTableSlotKind> getSlots() const { - if (!SlotsRef.empty()) - return SlotsRef; - return Slots; - } - - uint32_t getEntryCount() const { return getSlots().size(); } - - ArrayRef<VFTableSlotKind> SlotsRef; - std::vector<VFTableSlotKind> Slots; -}; - -// LF_TYPESERVER2 -class TypeServer2Record : public TypeRecord { -public: - TypeServer2Record() = default; - explicit TypeServer2Record(TypeRecordKind Kind) : TypeRecord(Kind) {} - TypeServer2Record(StringRef GuidStr, uint32_t Age, StringRef Name) - : TypeRecord(TypeRecordKind::TypeServer2), Age(Age), Name(Name) { - assert(GuidStr.size() == 16 && "guid isn't 16 bytes"); - ::memcpy(Guid.Guid, GuidStr.data(), 16); - } - - const GUID &getGuid() const { return Guid; } - uint32_t getAge() const { return Age; } - StringRef getName() const { return Name; } - - GUID Guid; - uint32_t Age = 0; - StringRef Name; -}; - -// LF_STRING_ID -class StringIdRecord : public TypeRecord { -public: - StringIdRecord() = default; - explicit StringIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - StringIdRecord(TypeIndex Id, StringRef String) - : TypeRecord(TypeRecordKind::StringId), Id(Id), String(String) {} - - TypeIndex getId() const { return Id; } - StringRef getString() const { return String; } - - TypeIndex Id; - StringRef String; -}; - -// LF_FUNC_ID -class FuncIdRecord : public TypeRecord { -public: - FuncIdRecord() = default; - explicit FuncIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - FuncIdRecord(TypeIndex ParentScope, TypeIndex FunctionType, StringRef Name) - : TypeRecord(TypeRecordKind::FuncId), ParentScope(ParentScope), - FunctionType(FunctionType), Name(Name) {} - - TypeIndex getParentScope() const { return ParentScope; } - TypeIndex getFunctionType() const { return FunctionType; } - StringRef getName() const { return Name; } - - TypeIndex ParentScope; - TypeIndex FunctionType; - StringRef Name; -}; - -// LF_UDT_SRC_LINE -class UdtSourceLineRecord : public TypeRecord { -public: - UdtSourceLineRecord() = default; - explicit UdtSourceLineRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - UdtSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, uint32_t LineNumber) - : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT), - SourceFile(SourceFile), LineNumber(LineNumber) {} - - TypeIndex getUDT() const { return UDT; } - TypeIndex getSourceFile() const { return SourceFile; } - uint32_t getLineNumber() const { return LineNumber; } - - TypeIndex UDT; - TypeIndex SourceFile; - uint32_t LineNumber = 0; -}; - -// LF_UDT_MOD_SRC_LINE -class UdtModSourceLineRecord : public TypeRecord { -public: - UdtModSourceLineRecord() = default; - explicit UdtModSourceLineRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - UdtModSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, - uint32_t LineNumber, uint16_t Module) - : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT), - SourceFile(SourceFile), LineNumber(LineNumber), Module(Module) {} - - TypeIndex getUDT() const { return UDT; } - TypeIndex getSourceFile() const { return SourceFile; } - uint32_t getLineNumber() const { return LineNumber; } - uint16_t getModule() const { return Module; } - - TypeIndex UDT; - TypeIndex SourceFile; - uint32_t LineNumber = 0; - uint16_t Module = 0; -}; - -// LF_BUILDINFO -class BuildInfoRecord : public TypeRecord { -public: - BuildInfoRecord() = default; - explicit BuildInfoRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - BuildInfoRecord(ArrayRef<TypeIndex> ArgIndices) - : TypeRecord(TypeRecordKind::BuildInfo), - ArgIndices(ArgIndices.begin(), ArgIndices.end()) {} - - ArrayRef<TypeIndex> getArgs() const { return ArgIndices; } - - /// Indices of known build info arguments. - enum BuildInfoArg { - CurrentDirectory, ///< Absolute CWD path - BuildTool, ///< Absolute compiler path - SourceFile, ///< Path to main source file, relative or absolute - TypeServerPDB, ///< Absolute path of type server PDB (/Fd) - CommandLine, ///< Full canonical command line (maybe -cc1) - MaxArgs - }; - - SmallVector<TypeIndex, MaxArgs> ArgIndices; -}; - -// LF_VFTABLE -class VFTableRecord : public TypeRecord { -public: - VFTableRecord() = default; - explicit VFTableRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - VFTableRecord(TypeIndex CompleteClass, TypeIndex OverriddenVFTable, - uint32_t VFPtrOffset, StringRef Name, - ArrayRef<StringRef> Methods) - : TypeRecord(TypeRecordKind::VFTable), CompleteClass(CompleteClass), - OverriddenVFTable(OverriddenVFTable), VFPtrOffset(VFPtrOffset) { - MethodNames.push_back(Name); +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeRecord.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H + +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/GUID.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Endian.h" +#include <algorithm> +#include <cstdint> +#include <vector> + +namespace llvm { +namespace codeview { + +using support::little32_t; +using support::ulittle16_t; +using support::ulittle32_t; + +struct CVMemberRecord { + TypeLeafKind Kind; + ArrayRef<uint8_t> Data; +}; + +/// Equvalent to CV_fldattr_t in cvinfo.h. +struct MemberAttributes { + uint16_t Attrs = 0; + + enum { + MethodKindShift = 2, + }; + + MemberAttributes() = default; + + explicit MemberAttributes(MemberAccess Access) + : Attrs(static_cast<uint16_t>(Access)) {} + + MemberAttributes(MemberAccess Access, MethodKind Kind, MethodOptions Flags) { + Attrs = static_cast<uint16_t>(Access); + Attrs |= (static_cast<uint16_t>(Kind) << MethodKindShift); + Attrs |= static_cast<uint16_t>(Flags); + } + + /// Get the access specifier. Valid for any kind of member. + MemberAccess getAccess() const { + return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask)); + } + + /// Indicates if a method is defined with friend, virtual, static, etc. + MethodKind getMethodKind() const { + return MethodKind( + (unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >> + MethodKindShift); + } + + /// Get the flags that are not included in access control or method + /// properties. + MethodOptions getFlags() const { + return MethodOptions( + unsigned(Attrs) & + ~unsigned(MethodOptions::AccessMask | MethodOptions::MethodKindMask)); + } + + /// Is this method virtual. + bool isVirtual() const { + auto MP = getMethodKind(); + return MP != MethodKind::Vanilla && MP != MethodKind::Friend && + MP != MethodKind::Static; + } + + /// Does this member introduce a new virtual method. + bool isIntroducedVirtual() const { + auto MP = getMethodKind(); + return MP == MethodKind::IntroducingVirtual || + MP == MethodKind::PureIntroducingVirtual; + } + + /// Is this method static. + bool isStatic() const { + return getMethodKind() == MethodKind::Static; + } +}; + +// Does not correspond to any tag, this is the tail of an LF_POINTER record +// if it represents a member pointer. +class MemberPointerInfo { +public: + MemberPointerInfo() = default; + + MemberPointerInfo(TypeIndex ContainingType, + PointerToMemberRepresentation Representation) + : ContainingType(ContainingType), Representation(Representation) {} + + TypeIndex getContainingType() const { return ContainingType; } + PointerToMemberRepresentation getRepresentation() const { + return Representation; + } + + TypeIndex ContainingType; + PointerToMemberRepresentation Representation; +}; + +class TypeRecord { +protected: + TypeRecord() = default; + explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {} + +public: + TypeRecordKind getKind() const { return Kind; } + + TypeRecordKind Kind; +}; + +// LF_MODIFIER +class ModifierRecord : public TypeRecord { +public: + ModifierRecord() = default; + explicit ModifierRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + ModifierRecord(TypeIndex ModifiedType, ModifierOptions Modifiers) + : TypeRecord(TypeRecordKind::Modifier), ModifiedType(ModifiedType), + Modifiers(Modifiers) {} + + TypeIndex getModifiedType() const { return ModifiedType; } + ModifierOptions getModifiers() const { return Modifiers; } + + TypeIndex ModifiedType; + ModifierOptions Modifiers = ModifierOptions::None; +}; + +// LF_PROCEDURE +class ProcedureRecord : public TypeRecord { +public: + ProcedureRecord() = default; + explicit ProcedureRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + ProcedureRecord(TypeIndex ReturnType, CallingConvention CallConv, + FunctionOptions Options, uint16_t ParameterCount, + TypeIndex ArgumentList) + : TypeRecord(TypeRecordKind::Procedure), ReturnType(ReturnType), + CallConv(CallConv), Options(Options), ParameterCount(ParameterCount), + ArgumentList(ArgumentList) {} + + TypeIndex getReturnType() const { return ReturnType; } + CallingConvention getCallConv() const { return CallConv; } + FunctionOptions getOptions() const { return Options; } + uint16_t getParameterCount() const { return ParameterCount; } + TypeIndex getArgumentList() const { return ArgumentList; } + + TypeIndex ReturnType; + CallingConvention CallConv; + FunctionOptions Options; + uint16_t ParameterCount = 0; + TypeIndex ArgumentList; +}; + +// LF_MFUNCTION +class MemberFunctionRecord : public TypeRecord { +public: + MemberFunctionRecord() = default; + explicit MemberFunctionRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + MemberFunctionRecord(TypeIndex ReturnType, TypeIndex ClassType, + TypeIndex ThisType, CallingConvention CallConv, + FunctionOptions Options, uint16_t ParameterCount, + TypeIndex ArgumentList, int32_t ThisPointerAdjustment) + : TypeRecord(TypeRecordKind::MemberFunction), ReturnType(ReturnType), + ClassType(ClassType), ThisType(ThisType), CallConv(CallConv), + Options(Options), ParameterCount(ParameterCount), + ArgumentList(ArgumentList), + ThisPointerAdjustment(ThisPointerAdjustment) {} + + TypeIndex getReturnType() const { return ReturnType; } + TypeIndex getClassType() const { return ClassType; } + TypeIndex getThisType() const { return ThisType; } + CallingConvention getCallConv() const { return CallConv; } + FunctionOptions getOptions() const { return Options; } + uint16_t getParameterCount() const { return ParameterCount; } + TypeIndex getArgumentList() const { return ArgumentList; } + int32_t getThisPointerAdjustment() const { return ThisPointerAdjustment; } + + TypeIndex ReturnType; + TypeIndex ClassType; + TypeIndex ThisType; + CallingConvention CallConv; + FunctionOptions Options; + uint16_t ParameterCount = 0; + TypeIndex ArgumentList; + int32_t ThisPointerAdjustment = 0; +}; + +// LF_LABEL +class LabelRecord : public TypeRecord { +public: + LabelRecord() = default; + explicit LabelRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + LabelRecord(LabelType Mode) : TypeRecord(TypeRecordKind::Label), Mode(Mode) {} + + LabelType Mode; +}; + +// LF_MFUNC_ID +class MemberFuncIdRecord : public TypeRecord { +public: + MemberFuncIdRecord() = default; + explicit MemberFuncIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + MemberFuncIdRecord(TypeIndex ClassType, TypeIndex FunctionType, + StringRef Name) + : TypeRecord(TypeRecordKind::MemberFuncId), ClassType(ClassType), + FunctionType(FunctionType), Name(Name) {} + + TypeIndex getClassType() const { return ClassType; } + TypeIndex getFunctionType() const { return FunctionType; } + StringRef getName() const { return Name; } + + TypeIndex ClassType; + TypeIndex FunctionType; + StringRef Name; +}; + +// LF_ARGLIST +class ArgListRecord : public TypeRecord { +public: + ArgListRecord() = default; + explicit ArgListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + ArgListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices) + : TypeRecord(Kind), ArgIndices(Indices) {} + + ArrayRef<TypeIndex> getIndices() const { return ArgIndices; } + + std::vector<TypeIndex> ArgIndices; +}; + +// LF_SUBSTR_LIST +class StringListRecord : public TypeRecord { +public: + StringListRecord() = default; + explicit StringListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + StringListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices) + : TypeRecord(Kind), StringIndices(Indices) {} + + ArrayRef<TypeIndex> getIndices() const { return StringIndices; } + + std::vector<TypeIndex> StringIndices; +}; + +// LF_POINTER +class PointerRecord : public TypeRecord { +public: + // ---------------------------XXXXX + static const uint32_t PointerKindShift = 0; + static const uint32_t PointerKindMask = 0x1F; + + // ------------------------XXX----- + static const uint32_t PointerModeShift = 5; + static const uint32_t PointerModeMask = 0x07; + + // ----------XXX------XXXXX-------- + static const uint32_t PointerOptionMask = 0x381f00; + + // -------------XXXXXX------------ + static const uint32_t PointerSizeShift = 13; + static const uint32_t PointerSizeMask = 0xFF; + + PointerRecord() = default; + explicit PointerRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + PointerRecord(TypeIndex ReferentType, uint32_t Attrs) + : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), + Attrs(Attrs) {} + + PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, + PointerOptions PO, uint8_t Size) + : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), + Attrs(calcAttrs(PK, PM, PO, Size)) {} + + PointerRecord(TypeIndex ReferentType, PointerKind PK, PointerMode PM, + PointerOptions PO, uint8_t Size, const MemberPointerInfo &MPI) + : TypeRecord(TypeRecordKind::Pointer), ReferentType(ReferentType), + Attrs(calcAttrs(PK, PM, PO, Size)), MemberInfo(MPI) {} + + TypeIndex getReferentType() const { return ReferentType; } + + PointerKind getPointerKind() const { + return static_cast<PointerKind>((Attrs >> PointerKindShift) & + PointerKindMask); + } + + PointerMode getMode() const { + return static_cast<PointerMode>((Attrs >> PointerModeShift) & + PointerModeMask); + } + + PointerOptions getOptions() const { + return static_cast<PointerOptions>(Attrs & PointerOptionMask); + } + + uint8_t getSize() const { + return (Attrs >> PointerSizeShift) & PointerSizeMask; + } + + MemberPointerInfo getMemberInfo() const { return *MemberInfo; } + + bool isPointerToMember() const { + return getMode() == PointerMode::PointerToDataMember || + getMode() == PointerMode::PointerToMemberFunction; + } + + bool isFlat() const { return !!(Attrs & uint32_t(PointerOptions::Flat32)); } + bool isConst() const { return !!(Attrs & uint32_t(PointerOptions::Const)); } + + bool isVolatile() const { + return !!(Attrs & uint32_t(PointerOptions::Volatile)); + } + + bool isUnaligned() const { + return !!(Attrs & uint32_t(PointerOptions::Unaligned)); + } + + bool isRestrict() const { + return !!(Attrs & uint32_t(PointerOptions::Restrict)); + } + + bool isLValueReferenceThisPtr() const { + return !!(Attrs & uint32_t(PointerOptions::LValueRefThisPointer)); + } + + bool isRValueReferenceThisPtr() const { + return !!(Attrs & uint32_t(PointerOptions::RValueRefThisPointer)); + } + + TypeIndex ReferentType; + uint32_t Attrs = 0; + Optional<MemberPointerInfo> MemberInfo; + + void setAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, + uint8_t Size) { + Attrs = calcAttrs(PK, PM, PO, Size); + } + +private: + static uint32_t calcAttrs(PointerKind PK, PointerMode PM, PointerOptions PO, + uint8_t Size) { + uint32_t A = 0; + A |= static_cast<uint32_t>(PK); + A |= static_cast<uint32_t>(PO); + A |= (static_cast<uint32_t>(PM) << PointerModeShift); + A |= (static_cast<uint32_t>(Size) << PointerSizeShift); + return A; + } +}; + +// LF_NESTTYPE +class NestedTypeRecord : public TypeRecord { +public: + NestedTypeRecord() = default; + explicit NestedTypeRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + NestedTypeRecord(TypeIndex Type, StringRef Name) + : TypeRecord(TypeRecordKind::NestedType), Type(Type), Name(Name) {} + + TypeIndex getNestedType() const { return Type; } + StringRef getName() const { return Name; } + + TypeIndex Type; + StringRef Name; +}; + +// LF_FIELDLIST +class FieldListRecord : public TypeRecord { +public: + FieldListRecord() = default; + explicit FieldListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + explicit FieldListRecord(ArrayRef<uint8_t> Data) + : TypeRecord(TypeRecordKind::FieldList), Data(Data) {} + + ArrayRef<uint8_t> Data; +}; + +// LF_ARRAY +class ArrayRecord : public TypeRecord { +public: + ArrayRecord() = default; + explicit ArrayRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + ArrayRecord(TypeIndex ElementType, TypeIndex IndexType, uint64_t Size, + StringRef Name) + : TypeRecord(TypeRecordKind::Array), ElementType(ElementType), + IndexType(IndexType), Size(Size), Name(Name) {} + + TypeIndex getElementType() const { return ElementType; } + TypeIndex getIndexType() const { return IndexType; } + uint64_t getSize() const { return Size; } + StringRef getName() const { return Name; } + + TypeIndex ElementType; + TypeIndex IndexType; + uint64_t Size = 0; + StringRef Name; +}; + +class TagRecord : public TypeRecord { +protected: + TagRecord() = default; + explicit TagRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + TagRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, + TypeIndex FieldList, StringRef Name, StringRef UniqueName) + : TypeRecord(Kind), MemberCount(MemberCount), Options(Options), + FieldList(FieldList), Name(Name), UniqueName(UniqueName) {} + +public: + static const int HfaKindShift = 11; + static const int HfaKindMask = 0x1800; + static const int WinRTKindShift = 14; + static const int WinRTKindMask = 0xC000; + + bool hasUniqueName() const { + return (Options & ClassOptions::HasUniqueName) != ClassOptions::None; + } + + bool isNested() const { + return (Options & ClassOptions::Nested) != ClassOptions::None; + } + + bool isForwardRef() const { + return (Options & ClassOptions::ForwardReference) != ClassOptions::None; + } + + bool containsNestedClass() const { + return (Options & ClassOptions::ContainsNestedClass) != ClassOptions::None; + } + + bool isScoped() const { + return (Options & ClassOptions::Scoped) != ClassOptions::None; + } + + uint16_t getMemberCount() const { return MemberCount; } + ClassOptions getOptions() const { return Options; } + TypeIndex getFieldList() const { return FieldList; } + StringRef getName() const { return Name; } + StringRef getUniqueName() const { return UniqueName; } + + uint16_t MemberCount = 0; + ClassOptions Options; + TypeIndex FieldList; + StringRef Name; + StringRef UniqueName; +}; + +// LF_CLASS, LF_STRUCTURE, LF_INTERFACE +class ClassRecord : public TagRecord { +public: + ClassRecord() = default; + explicit ClassRecord(TypeRecordKind Kind) : TagRecord(Kind) {} + ClassRecord(TypeRecordKind Kind, uint16_t MemberCount, ClassOptions Options, + TypeIndex FieldList, TypeIndex DerivationList, + TypeIndex VTableShape, uint64_t Size, StringRef Name, + StringRef UniqueName) + : TagRecord(Kind, MemberCount, Options, FieldList, Name, UniqueName), + DerivationList(DerivationList), VTableShape(VTableShape), Size(Size) {} + + HfaKind getHfa() const { + uint16_t Value = static_cast<uint16_t>(Options); + Value = (Value & HfaKindMask) >> HfaKindShift; + return static_cast<HfaKind>(Value); + } + + WindowsRTClassKind getWinRTKind() const { + uint16_t Value = static_cast<uint16_t>(Options); + Value = (Value & WinRTKindMask) >> WinRTKindShift; + return static_cast<WindowsRTClassKind>(Value); + } + + TypeIndex getDerivationList() const { return DerivationList; } + TypeIndex getVTableShape() const { return VTableShape; } + uint64_t getSize() const { return Size; } + + TypeIndex DerivationList; + TypeIndex VTableShape; + uint64_t Size = 0; +}; + +// LF_UNION +struct UnionRecord : public TagRecord { + UnionRecord() = default; + explicit UnionRecord(TypeRecordKind Kind) : TagRecord(Kind) {} + UnionRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, + uint64_t Size, StringRef Name, StringRef UniqueName) + : TagRecord(TypeRecordKind::Union, MemberCount, Options, FieldList, Name, + UniqueName), + Size(Size) {} + + HfaKind getHfa() const { + uint16_t Value = static_cast<uint16_t>(Options); + Value = (Value & HfaKindMask) >> HfaKindShift; + return static_cast<HfaKind>(Value); + } + + uint64_t getSize() const { return Size; } + + uint64_t Size = 0; +}; + +// LF_ENUM +class EnumRecord : public TagRecord { +public: + EnumRecord() = default; + explicit EnumRecord(TypeRecordKind Kind) : TagRecord(Kind) {} + EnumRecord(uint16_t MemberCount, ClassOptions Options, TypeIndex FieldList, + StringRef Name, StringRef UniqueName, TypeIndex UnderlyingType) + : TagRecord(TypeRecordKind::Enum, MemberCount, Options, FieldList, Name, + UniqueName), + UnderlyingType(UnderlyingType) {} + + TypeIndex getUnderlyingType() const { return UnderlyingType; } + + TypeIndex UnderlyingType; +}; + +// LF_BITFIELD +class BitFieldRecord : public TypeRecord { +public: + BitFieldRecord() = default; + explicit BitFieldRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset) + : TypeRecord(TypeRecordKind::BitField), Type(Type), BitSize(BitSize), + BitOffset(BitOffset) {} + + TypeIndex getType() const { return Type; } + uint8_t getBitOffset() const { return BitOffset; } + uint8_t getBitSize() const { return BitSize; } + + TypeIndex Type; + uint8_t BitSize = 0; + uint8_t BitOffset = 0; +}; + +// LF_VTSHAPE +class VFTableShapeRecord : public TypeRecord { +public: + VFTableShapeRecord() = default; + explicit VFTableShapeRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + explicit VFTableShapeRecord(ArrayRef<VFTableSlotKind> Slots) + : TypeRecord(TypeRecordKind::VFTableShape), SlotsRef(Slots) {} + explicit VFTableShapeRecord(std::vector<VFTableSlotKind> Slots) + : TypeRecord(TypeRecordKind::VFTableShape), Slots(std::move(Slots)) {} + + ArrayRef<VFTableSlotKind> getSlots() const { + if (!SlotsRef.empty()) + return SlotsRef; + return Slots; + } + + uint32_t getEntryCount() const { return getSlots().size(); } + + ArrayRef<VFTableSlotKind> SlotsRef; + std::vector<VFTableSlotKind> Slots; +}; + +// LF_TYPESERVER2 +class TypeServer2Record : public TypeRecord { +public: + TypeServer2Record() = default; + explicit TypeServer2Record(TypeRecordKind Kind) : TypeRecord(Kind) {} + TypeServer2Record(StringRef GuidStr, uint32_t Age, StringRef Name) + : TypeRecord(TypeRecordKind::TypeServer2), Age(Age), Name(Name) { + assert(GuidStr.size() == 16 && "guid isn't 16 bytes"); + ::memcpy(Guid.Guid, GuidStr.data(), 16); + } + + const GUID &getGuid() const { return Guid; } + uint32_t getAge() const { return Age; } + StringRef getName() const { return Name; } + + GUID Guid; + uint32_t Age = 0; + StringRef Name; +}; + +// LF_STRING_ID +class StringIdRecord : public TypeRecord { +public: + StringIdRecord() = default; + explicit StringIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + StringIdRecord(TypeIndex Id, StringRef String) + : TypeRecord(TypeRecordKind::StringId), Id(Id), String(String) {} + + TypeIndex getId() const { return Id; } + StringRef getString() const { return String; } + + TypeIndex Id; + StringRef String; +}; + +// LF_FUNC_ID +class FuncIdRecord : public TypeRecord { +public: + FuncIdRecord() = default; + explicit FuncIdRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + FuncIdRecord(TypeIndex ParentScope, TypeIndex FunctionType, StringRef Name) + : TypeRecord(TypeRecordKind::FuncId), ParentScope(ParentScope), + FunctionType(FunctionType), Name(Name) {} + + TypeIndex getParentScope() const { return ParentScope; } + TypeIndex getFunctionType() const { return FunctionType; } + StringRef getName() const { return Name; } + + TypeIndex ParentScope; + TypeIndex FunctionType; + StringRef Name; +}; + +// LF_UDT_SRC_LINE +class UdtSourceLineRecord : public TypeRecord { +public: + UdtSourceLineRecord() = default; + explicit UdtSourceLineRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + UdtSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, uint32_t LineNumber) + : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT), + SourceFile(SourceFile), LineNumber(LineNumber) {} + + TypeIndex getUDT() const { return UDT; } + TypeIndex getSourceFile() const { return SourceFile; } + uint32_t getLineNumber() const { return LineNumber; } + + TypeIndex UDT; + TypeIndex SourceFile; + uint32_t LineNumber = 0; +}; + +// LF_UDT_MOD_SRC_LINE +class UdtModSourceLineRecord : public TypeRecord { +public: + UdtModSourceLineRecord() = default; + explicit UdtModSourceLineRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + UdtModSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile, + uint32_t LineNumber, uint16_t Module) + : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT), + SourceFile(SourceFile), LineNumber(LineNumber), Module(Module) {} + + TypeIndex getUDT() const { return UDT; } + TypeIndex getSourceFile() const { return SourceFile; } + uint32_t getLineNumber() const { return LineNumber; } + uint16_t getModule() const { return Module; } + + TypeIndex UDT; + TypeIndex SourceFile; + uint32_t LineNumber = 0; + uint16_t Module = 0; +}; + +// LF_BUILDINFO +class BuildInfoRecord : public TypeRecord { +public: + BuildInfoRecord() = default; + explicit BuildInfoRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + BuildInfoRecord(ArrayRef<TypeIndex> ArgIndices) + : TypeRecord(TypeRecordKind::BuildInfo), + ArgIndices(ArgIndices.begin(), ArgIndices.end()) {} + + ArrayRef<TypeIndex> getArgs() const { return ArgIndices; } + + /// Indices of known build info arguments. + enum BuildInfoArg { + CurrentDirectory, ///< Absolute CWD path + BuildTool, ///< Absolute compiler path + SourceFile, ///< Path to main source file, relative or absolute + TypeServerPDB, ///< Absolute path of type server PDB (/Fd) + CommandLine, ///< Full canonical command line (maybe -cc1) + MaxArgs + }; + + SmallVector<TypeIndex, MaxArgs> ArgIndices; +}; + +// LF_VFTABLE +class VFTableRecord : public TypeRecord { +public: + VFTableRecord() = default; + explicit VFTableRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + VFTableRecord(TypeIndex CompleteClass, TypeIndex OverriddenVFTable, + uint32_t VFPtrOffset, StringRef Name, + ArrayRef<StringRef> Methods) + : TypeRecord(TypeRecordKind::VFTable), CompleteClass(CompleteClass), + OverriddenVFTable(OverriddenVFTable), VFPtrOffset(VFPtrOffset) { + MethodNames.push_back(Name); llvm::append_range(MethodNames, Methods); - } - - TypeIndex getCompleteClass() const { return CompleteClass; } - TypeIndex getOverriddenVTable() const { return OverriddenVFTable; } - uint32_t getVFPtrOffset() const { return VFPtrOffset; } - StringRef getName() const { return makeArrayRef(MethodNames).front(); } - - ArrayRef<StringRef> getMethodNames() const { - return makeArrayRef(MethodNames).drop_front(); - } - - TypeIndex CompleteClass; - TypeIndex OverriddenVFTable; - uint32_t VFPtrOffset = 0; - std::vector<StringRef> MethodNames; -}; - -// LF_ONEMETHOD -class OneMethodRecord : public TypeRecord { -public: - OneMethodRecord() = default; - explicit OneMethodRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - OneMethodRecord(TypeIndex Type, MemberAttributes Attrs, int32_t VFTableOffset, - StringRef Name) - : TypeRecord(TypeRecordKind::OneMethod), Type(Type), Attrs(Attrs), - VFTableOffset(VFTableOffset), Name(Name) {} - OneMethodRecord(TypeIndex Type, MemberAccess Access, MethodKind MK, - MethodOptions Options, int32_t VFTableOffset, StringRef Name) - : TypeRecord(TypeRecordKind::OneMethod), Type(Type), - Attrs(Access, MK, Options), VFTableOffset(VFTableOffset), Name(Name) {} - - TypeIndex getType() const { return Type; } - MethodKind getMethodKind() const { return Attrs.getMethodKind(); } - MethodOptions getOptions() const { return Attrs.getFlags(); } - MemberAccess getAccess() const { return Attrs.getAccess(); } - int32_t getVFTableOffset() const { return VFTableOffset; } - StringRef getName() const { return Name; } - - bool isIntroducingVirtual() const { - return getMethodKind() == MethodKind::IntroducingVirtual || - getMethodKind() == MethodKind::PureIntroducingVirtual; - } - - TypeIndex Type; - MemberAttributes Attrs; - int32_t VFTableOffset = 0; - StringRef Name; -}; - -// LF_METHODLIST -class MethodOverloadListRecord : public TypeRecord { -public: - MethodOverloadListRecord() = default; - explicit MethodOverloadListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - MethodOverloadListRecord(ArrayRef<OneMethodRecord> Methods) - : TypeRecord(TypeRecordKind::MethodOverloadList), Methods(Methods) {} - - ArrayRef<OneMethodRecord> getMethods() const { return Methods; } - - std::vector<OneMethodRecord> Methods; -}; - -/// For method overload sets. LF_METHOD -class OverloadedMethodRecord : public TypeRecord { -public: - OverloadedMethodRecord() = default; - explicit OverloadedMethodRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - OverloadedMethodRecord(uint16_t NumOverloads, TypeIndex MethodList, - StringRef Name) - : TypeRecord(TypeRecordKind::OverloadedMethod), - NumOverloads(NumOverloads), MethodList(MethodList), Name(Name) {} - - uint16_t getNumOverloads() const { return NumOverloads; } - TypeIndex getMethodList() const { return MethodList; } - StringRef getName() const { return Name; } - - uint16_t NumOverloads = 0; - TypeIndex MethodList; - StringRef Name; -}; - -// LF_MEMBER -class DataMemberRecord : public TypeRecord { -public: - DataMemberRecord() = default; - explicit DataMemberRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - DataMemberRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset, - StringRef Name) - : TypeRecord(TypeRecordKind::DataMember), Attrs(Attrs), Type(Type), - FieldOffset(Offset), Name(Name) {} - DataMemberRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset, - StringRef Name) - : TypeRecord(TypeRecordKind::DataMember), Attrs(Access), Type(Type), - FieldOffset(Offset), Name(Name) {} - - MemberAccess getAccess() const { return Attrs.getAccess(); } - TypeIndex getType() const { return Type; } - uint64_t getFieldOffset() const { return FieldOffset; } - StringRef getName() const { return Name; } - - MemberAttributes Attrs; - TypeIndex Type; - uint64_t FieldOffset = 0; - StringRef Name; -}; - -// LF_STMEMBER -class StaticDataMemberRecord : public TypeRecord { -public: - StaticDataMemberRecord() = default; - explicit StaticDataMemberRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - StaticDataMemberRecord(MemberAttributes Attrs, TypeIndex Type, StringRef Name) - : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Attrs), Type(Type), - Name(Name) {} - StaticDataMemberRecord(MemberAccess Access, TypeIndex Type, StringRef Name) - : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Access), Type(Type), - Name(Name) {} - - MemberAccess getAccess() const { return Attrs.getAccess(); } - TypeIndex getType() const { return Type; } - StringRef getName() const { return Name; } - - MemberAttributes Attrs; - TypeIndex Type; - StringRef Name; -}; - -// LF_ENUMERATE -class EnumeratorRecord : public TypeRecord { -public: - EnumeratorRecord() = default; - explicit EnumeratorRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - EnumeratorRecord(MemberAttributes Attrs, APSInt Value, StringRef Name) - : TypeRecord(TypeRecordKind::Enumerator), Attrs(Attrs), - Value(std::move(Value)), Name(Name) {} - EnumeratorRecord(MemberAccess Access, APSInt Value, StringRef Name) - : TypeRecord(TypeRecordKind::Enumerator), Attrs(Access), - Value(std::move(Value)), Name(Name) {} - - MemberAccess getAccess() const { return Attrs.getAccess(); } - APSInt getValue() const { return Value; } - StringRef getName() const { return Name; } - - MemberAttributes Attrs; - APSInt Value; - StringRef Name; -}; - -// LF_VFUNCTAB -class VFPtrRecord : public TypeRecord { -public: - VFPtrRecord() = default; - explicit VFPtrRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - VFPtrRecord(TypeIndex Type) - : TypeRecord(TypeRecordKind::VFPtr), Type(Type) {} - - TypeIndex getType() const { return Type; } - - TypeIndex Type; -}; - -// LF_BCLASS, LF_BINTERFACE -class BaseClassRecord : public TypeRecord { -public: - BaseClassRecord() = default; - explicit BaseClassRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - BaseClassRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset) - : TypeRecord(TypeRecordKind::BaseClass), Attrs(Attrs), Type(Type), - Offset(Offset) {} - BaseClassRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset) - : TypeRecord(TypeRecordKind::BaseClass), Attrs(Access), Type(Type), - Offset(Offset) {} - - MemberAccess getAccess() const { return Attrs.getAccess(); } - TypeIndex getBaseType() const { return Type; } - uint64_t getBaseOffset() const { return Offset; } - - MemberAttributes Attrs; - TypeIndex Type; - uint64_t Offset = 0; -}; - -// LF_VBCLASS, LF_IVBCLASS -class VirtualBaseClassRecord : public TypeRecord { -public: - VirtualBaseClassRecord() = default; - explicit VirtualBaseClassRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - VirtualBaseClassRecord(TypeRecordKind Kind, MemberAttributes Attrs, - TypeIndex BaseType, TypeIndex VBPtrType, - uint64_t Offset, uint64_t Index) - : TypeRecord(Kind), Attrs(Attrs), BaseType(BaseType), - VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {} - VirtualBaseClassRecord(TypeRecordKind Kind, MemberAccess Access, - TypeIndex BaseType, TypeIndex VBPtrType, - uint64_t Offset, uint64_t Index) - : TypeRecord(Kind), Attrs(Access), BaseType(BaseType), - VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {} - - MemberAccess getAccess() const { return Attrs.getAccess(); } - TypeIndex getBaseType() const { return BaseType; } - TypeIndex getVBPtrType() const { return VBPtrType; } - uint64_t getVBPtrOffset() const { return VBPtrOffset; } - uint64_t getVTableIndex() const { return VTableIndex; } - - MemberAttributes Attrs; - TypeIndex BaseType; - TypeIndex VBPtrType; - uint64_t VBPtrOffset = 0; - uint64_t VTableIndex = 0; -}; - -/// LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records -/// together. The first will end in an LF_INDEX record that points to the next. -class ListContinuationRecord : public TypeRecord { -public: - ListContinuationRecord() = default; - explicit ListContinuationRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - ListContinuationRecord(TypeIndex ContinuationIndex) - : TypeRecord(TypeRecordKind::ListContinuation), - ContinuationIndex(ContinuationIndex) {} - - TypeIndex getContinuationIndex() const { return ContinuationIndex; } - - TypeIndex ContinuationIndex; -}; - -// LF_PRECOMP -class PrecompRecord : public TypeRecord { -public: - PrecompRecord() = default; - explicit PrecompRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - uint32_t getStartTypeIndex() const { return StartTypeIndex; } - uint32_t getTypesCount() const { return TypesCount; } - uint32_t getSignature() const { return Signature; } - StringRef getPrecompFilePath() const { return PrecompFilePath; } - - uint32_t StartTypeIndex = 0; - uint32_t TypesCount = 0; - uint32_t Signature = 0; - StringRef PrecompFilePath; -}; - -// LF_ENDPRECOMP -class EndPrecompRecord : public TypeRecord { -public: - EndPrecompRecord() = default; - explicit EndPrecompRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} - - uint32_t getSignature() const { return Signature; } - - uint32_t Signature = 0; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + } + + TypeIndex getCompleteClass() const { return CompleteClass; } + TypeIndex getOverriddenVTable() const { return OverriddenVFTable; } + uint32_t getVFPtrOffset() const { return VFPtrOffset; } + StringRef getName() const { return makeArrayRef(MethodNames).front(); } + + ArrayRef<StringRef> getMethodNames() const { + return makeArrayRef(MethodNames).drop_front(); + } + + TypeIndex CompleteClass; + TypeIndex OverriddenVFTable; + uint32_t VFPtrOffset = 0; + std::vector<StringRef> MethodNames; +}; + +// LF_ONEMETHOD +class OneMethodRecord : public TypeRecord { +public: + OneMethodRecord() = default; + explicit OneMethodRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + OneMethodRecord(TypeIndex Type, MemberAttributes Attrs, int32_t VFTableOffset, + StringRef Name) + : TypeRecord(TypeRecordKind::OneMethod), Type(Type), Attrs(Attrs), + VFTableOffset(VFTableOffset), Name(Name) {} + OneMethodRecord(TypeIndex Type, MemberAccess Access, MethodKind MK, + MethodOptions Options, int32_t VFTableOffset, StringRef Name) + : TypeRecord(TypeRecordKind::OneMethod), Type(Type), + Attrs(Access, MK, Options), VFTableOffset(VFTableOffset), Name(Name) {} + + TypeIndex getType() const { return Type; } + MethodKind getMethodKind() const { return Attrs.getMethodKind(); } + MethodOptions getOptions() const { return Attrs.getFlags(); } + MemberAccess getAccess() const { return Attrs.getAccess(); } + int32_t getVFTableOffset() const { return VFTableOffset; } + StringRef getName() const { return Name; } + + bool isIntroducingVirtual() const { + return getMethodKind() == MethodKind::IntroducingVirtual || + getMethodKind() == MethodKind::PureIntroducingVirtual; + } + + TypeIndex Type; + MemberAttributes Attrs; + int32_t VFTableOffset = 0; + StringRef Name; +}; + +// LF_METHODLIST +class MethodOverloadListRecord : public TypeRecord { +public: + MethodOverloadListRecord() = default; + explicit MethodOverloadListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + MethodOverloadListRecord(ArrayRef<OneMethodRecord> Methods) + : TypeRecord(TypeRecordKind::MethodOverloadList), Methods(Methods) {} + + ArrayRef<OneMethodRecord> getMethods() const { return Methods; } + + std::vector<OneMethodRecord> Methods; +}; + +/// For method overload sets. LF_METHOD +class OverloadedMethodRecord : public TypeRecord { +public: + OverloadedMethodRecord() = default; + explicit OverloadedMethodRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + OverloadedMethodRecord(uint16_t NumOverloads, TypeIndex MethodList, + StringRef Name) + : TypeRecord(TypeRecordKind::OverloadedMethod), + NumOverloads(NumOverloads), MethodList(MethodList), Name(Name) {} + + uint16_t getNumOverloads() const { return NumOverloads; } + TypeIndex getMethodList() const { return MethodList; } + StringRef getName() const { return Name; } + + uint16_t NumOverloads = 0; + TypeIndex MethodList; + StringRef Name; +}; + +// LF_MEMBER +class DataMemberRecord : public TypeRecord { +public: + DataMemberRecord() = default; + explicit DataMemberRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + DataMemberRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset, + StringRef Name) + : TypeRecord(TypeRecordKind::DataMember), Attrs(Attrs), Type(Type), + FieldOffset(Offset), Name(Name) {} + DataMemberRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset, + StringRef Name) + : TypeRecord(TypeRecordKind::DataMember), Attrs(Access), Type(Type), + FieldOffset(Offset), Name(Name) {} + + MemberAccess getAccess() const { return Attrs.getAccess(); } + TypeIndex getType() const { return Type; } + uint64_t getFieldOffset() const { return FieldOffset; } + StringRef getName() const { return Name; } + + MemberAttributes Attrs; + TypeIndex Type; + uint64_t FieldOffset = 0; + StringRef Name; +}; + +// LF_STMEMBER +class StaticDataMemberRecord : public TypeRecord { +public: + StaticDataMemberRecord() = default; + explicit StaticDataMemberRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + StaticDataMemberRecord(MemberAttributes Attrs, TypeIndex Type, StringRef Name) + : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Attrs), Type(Type), + Name(Name) {} + StaticDataMemberRecord(MemberAccess Access, TypeIndex Type, StringRef Name) + : TypeRecord(TypeRecordKind::StaticDataMember), Attrs(Access), Type(Type), + Name(Name) {} + + MemberAccess getAccess() const { return Attrs.getAccess(); } + TypeIndex getType() const { return Type; } + StringRef getName() const { return Name; } + + MemberAttributes Attrs; + TypeIndex Type; + StringRef Name; +}; + +// LF_ENUMERATE +class EnumeratorRecord : public TypeRecord { +public: + EnumeratorRecord() = default; + explicit EnumeratorRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + EnumeratorRecord(MemberAttributes Attrs, APSInt Value, StringRef Name) + : TypeRecord(TypeRecordKind::Enumerator), Attrs(Attrs), + Value(std::move(Value)), Name(Name) {} + EnumeratorRecord(MemberAccess Access, APSInt Value, StringRef Name) + : TypeRecord(TypeRecordKind::Enumerator), Attrs(Access), + Value(std::move(Value)), Name(Name) {} + + MemberAccess getAccess() const { return Attrs.getAccess(); } + APSInt getValue() const { return Value; } + StringRef getName() const { return Name; } + + MemberAttributes Attrs; + APSInt Value; + StringRef Name; +}; + +// LF_VFUNCTAB +class VFPtrRecord : public TypeRecord { +public: + VFPtrRecord() = default; + explicit VFPtrRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + VFPtrRecord(TypeIndex Type) + : TypeRecord(TypeRecordKind::VFPtr), Type(Type) {} + + TypeIndex getType() const { return Type; } + + TypeIndex Type; +}; + +// LF_BCLASS, LF_BINTERFACE +class BaseClassRecord : public TypeRecord { +public: + BaseClassRecord() = default; + explicit BaseClassRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + BaseClassRecord(MemberAttributes Attrs, TypeIndex Type, uint64_t Offset) + : TypeRecord(TypeRecordKind::BaseClass), Attrs(Attrs), Type(Type), + Offset(Offset) {} + BaseClassRecord(MemberAccess Access, TypeIndex Type, uint64_t Offset) + : TypeRecord(TypeRecordKind::BaseClass), Attrs(Access), Type(Type), + Offset(Offset) {} + + MemberAccess getAccess() const { return Attrs.getAccess(); } + TypeIndex getBaseType() const { return Type; } + uint64_t getBaseOffset() const { return Offset; } + + MemberAttributes Attrs; + TypeIndex Type; + uint64_t Offset = 0; +}; + +// LF_VBCLASS, LF_IVBCLASS +class VirtualBaseClassRecord : public TypeRecord { +public: + VirtualBaseClassRecord() = default; + explicit VirtualBaseClassRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + VirtualBaseClassRecord(TypeRecordKind Kind, MemberAttributes Attrs, + TypeIndex BaseType, TypeIndex VBPtrType, + uint64_t Offset, uint64_t Index) + : TypeRecord(Kind), Attrs(Attrs), BaseType(BaseType), + VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {} + VirtualBaseClassRecord(TypeRecordKind Kind, MemberAccess Access, + TypeIndex BaseType, TypeIndex VBPtrType, + uint64_t Offset, uint64_t Index) + : TypeRecord(Kind), Attrs(Access), BaseType(BaseType), + VBPtrType(VBPtrType), VBPtrOffset(Offset), VTableIndex(Index) {} + + MemberAccess getAccess() const { return Attrs.getAccess(); } + TypeIndex getBaseType() const { return BaseType; } + TypeIndex getVBPtrType() const { return VBPtrType; } + uint64_t getVBPtrOffset() const { return VBPtrOffset; } + uint64_t getVTableIndex() const { return VTableIndex; } + + MemberAttributes Attrs; + TypeIndex BaseType; + TypeIndex VBPtrType; + uint64_t VBPtrOffset = 0; + uint64_t VTableIndex = 0; +}; + +/// LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records +/// together. The first will end in an LF_INDEX record that points to the next. +class ListContinuationRecord : public TypeRecord { +public: + ListContinuationRecord() = default; + explicit ListContinuationRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + ListContinuationRecord(TypeIndex ContinuationIndex) + : TypeRecord(TypeRecordKind::ListContinuation), + ContinuationIndex(ContinuationIndex) {} + + TypeIndex getContinuationIndex() const { return ContinuationIndex; } + + TypeIndex ContinuationIndex; +}; + +// LF_PRECOMP +class PrecompRecord : public TypeRecord { +public: + PrecompRecord() = default; + explicit PrecompRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + uint32_t getStartTypeIndex() const { return StartTypeIndex; } + uint32_t getTypesCount() const { return TypesCount; } + uint32_t getSignature() const { return Signature; } + StringRef getPrecompFilePath() const { return PrecompFilePath; } + + uint32_t StartTypeIndex = 0; + uint32_t TypesCount = 0; + uint32_t Signature = 0; + StringRef PrecompFilePath; +}; + +// LF_ENDPRECOMP +class EndPrecompRecord : public TypeRecord { +public: + EndPrecompRecord() = default; + explicit EndPrecompRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} + + uint32_t getSignature() const { return Signature; } + + uint32_t Signature = 0; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h index 48861cbfbd..a396b0d824 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeRecordHelpers.h --------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeRecordHelpers.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H + #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" - -namespace llvm { -namespace codeview { - -/// Given an arbitrary codeview type, determine if it is an LF_STRUCTURE, -/// LF_CLASS, LF_INTERFACE, LF_UNION, or LF_ENUM with the forward ref class -/// option. -bool isUdtForwardRef(CVType CVT); - -/// Given a CVType which is assumed to be an LF_MODIFIER, return the -/// TypeIndex of the type that the LF_MODIFIER modifies. -TypeIndex getModifiedType(const CVType &CVT); - -/// Return true if this record should be in the IPI stream of a PDB. In an -/// object file, these record kinds will appear mixed into the .debug$T section. -inline bool isIdRecord(TypeLeafKind K) { - switch (K) { - case TypeLeafKind::LF_FUNC_ID: - case TypeLeafKind::LF_MFUNC_ID: - case TypeLeafKind::LF_STRING_ID: - case TypeLeafKind::LF_SUBSTR_LIST: - case TypeLeafKind::LF_BUILDINFO: - case TypeLeafKind::LF_UDT_SRC_LINE: - case TypeLeafKind::LF_UDT_MOD_SRC_LINE: - return true; - default: - return false; - } -} - -} // namespace codeview -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + +namespace llvm { +namespace codeview { + +/// Given an arbitrary codeview type, determine if it is an LF_STRUCTURE, +/// LF_CLASS, LF_INTERFACE, LF_UNION, or LF_ENUM with the forward ref class +/// option. +bool isUdtForwardRef(CVType CVT); + +/// Given a CVType which is assumed to be an LF_MODIFIER, return the +/// TypeIndex of the type that the LF_MODIFIER modifies. +TypeIndex getModifiedType(const CVType &CVT); + +/// Return true if this record should be in the IPI stream of a PDB. In an +/// object file, these record kinds will appear mixed into the .debug$T section. +inline bool isIdRecord(TypeLeafKind K) { + switch (K) { + case TypeLeafKind::LF_FUNC_ID: + case TypeLeafKind::LF_MFUNC_ID: + case TypeLeafKind::LF_STRING_ID: + case TypeLeafKind::LF_SUBSTR_LIST: + case TypeLeafKind::LF_BUILDINFO: + case TypeLeafKind::LF_UDT_SRC_LINE: + case TypeLeafKind::LF_UDT_MOD_SRC_LINE: + return true; + default: + return false; + } +} + +} // namespace codeview +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h index 69799a7a79..93c60fdaf6 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h @@ -1,65 +1,65 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeRecordMapping.h --------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" -#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" -#include "llvm/Support/Error.h" - -namespace llvm { -class BinaryStreamReader; -class BinaryStreamWriter; - -namespace codeview { -class TypeRecordMapping : public TypeVisitorCallbacks { -public: - explicit TypeRecordMapping(BinaryStreamReader &Reader) : IO(Reader) {} - explicit TypeRecordMapping(BinaryStreamWriter &Writer) : IO(Writer) {} - explicit TypeRecordMapping(CodeViewRecordStreamer &Streamer) : IO(Streamer) {} - - using TypeVisitorCallbacks::visitTypeBegin; - Error visitTypeBegin(CVType &Record) override; - Error visitTypeBegin(CVType &Record, TypeIndex Index) override; - Error visitTypeEnd(CVType &Record) override; - - Error visitMemberBegin(CVMemberRecord &Record) override; - Error visitMemberEnd(CVMemberRecord &Record) override; - -#define TYPE_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; -#define MEMBER_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: - Optional<TypeLeafKind> TypeKind; - Optional<TypeLeafKind> MemberKind; - - CodeViewRecordIO IO; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeRecordMapping.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" +#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/Support/Error.h" + +namespace llvm { +class BinaryStreamReader; +class BinaryStreamWriter; + +namespace codeview { +class TypeRecordMapping : public TypeVisitorCallbacks { +public: + explicit TypeRecordMapping(BinaryStreamReader &Reader) : IO(Reader) {} + explicit TypeRecordMapping(BinaryStreamWriter &Writer) : IO(Writer) {} + explicit TypeRecordMapping(CodeViewRecordStreamer &Streamer) : IO(Streamer) {} + + using TypeVisitorCallbacks::visitTypeBegin; + Error visitTypeBegin(CVType &Record) override; + Error visitTypeBegin(CVType &Record, TypeIndex Index) override; + Error visitTypeEnd(CVType &Record) override; + + Error visitMemberBegin(CVMemberRecord &Record) override; + Error visitMemberEnd(CVMemberRecord &Record) override; + +#define TYPE_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + +private: + Optional<TypeLeafKind> TypeKind; + Optional<TypeLeafKind> MemberKind; + + CodeViewRecordIO IO; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h index e00a440a60..66de771e52 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h @@ -1,120 +1,120 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeStreamMerger.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/SmallVector.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeStreamMerger.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { - -class TypeIndex; -struct GloballyHashedType; -class GlobalTypeTableBuilder; -class MergingTypeTableBuilder; - -/// Merge one set of type records into another. This method assumes -/// that all records are type records, and there are no Id records present. -/// -/// \param Dest The table to store the re-written type records into. -/// -/// \param SourceToDest A vector, indexed by the TypeIndex in the source -/// type stream, that contains the index of the corresponding type record -/// in the destination stream. -/// -/// \param Types The collection of types to merge in. -/// -/// \returns Error::success() if the operation succeeded, otherwise an -/// appropriate error code. -Error mergeTypeRecords(MergingTypeTableBuilder &Dest, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &Types); - -/// Merge one set of id records into another. This method assumes -/// that all records are id records, and there are no Type records present. -/// However, since Id records can refer back to Type records, this method -/// assumes that the referenced type records have also been merged into -/// another type stream (for example using the above method), and accepts -/// the mapping from source to dest for that stream so that it can re-write -/// the type record mappings accordingly. -/// -/// \param Dest The table to store the re-written id records into. -/// -/// \param Types The mapping to use for the type records that these id -/// records refer to. -/// -/// \param SourceToDest A vector, indexed by the TypeIndex in the source -/// id stream, that contains the index of the corresponding id record -/// in the destination stream. -/// -/// \param Ids The collection of id records to merge in. -/// -/// \returns Error::success() if the operation succeeded, otherwise an -/// appropriate error code. -Error mergeIdRecords(MergingTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &Ids); - -/// Merge a unified set of type and id records, splitting them into -/// separate output streams. -/// -/// \param DestIds The table to store the re-written id records into. -/// -/// \param DestTypes the table to store the re-written type records into. -/// -/// \param SourceToDest A vector, indexed by the TypeIndex in the source -/// id stream, that contains the index of the corresponding id record -/// in the destination stream. -/// -/// \param IdsAndTypes The collection of id records to merge in. -/// -/// \returns Error::success() if the operation succeeded, otherwise an -/// appropriate error code. -Error mergeTypeAndIdRecords(MergingTypeTableBuilder &DestIds, - MergingTypeTableBuilder &DestTypes, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &IdsAndTypes, - Optional<uint32_t> &PCHSignature); - -Error mergeTypeAndIdRecords(GlobalTypeTableBuilder &DestIds, - GlobalTypeTableBuilder &DestTypes, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &IdsAndTypes, - ArrayRef<GloballyHashedType> Hashes, - Optional<uint32_t> &PCHSignature); - -Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &Types, - ArrayRef<GloballyHashedType> Hashes, - Optional<uint32_t> &PCHSignature); - -Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types, - SmallVectorImpl<TypeIndex> &SourceToDest, - const CVTypeArray &Ids, - ArrayRef<GloballyHashedType> Hashes); - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { + +class TypeIndex; +struct GloballyHashedType; +class GlobalTypeTableBuilder; +class MergingTypeTableBuilder; + +/// Merge one set of type records into another. This method assumes +/// that all records are type records, and there are no Id records present. +/// +/// \param Dest The table to store the re-written type records into. +/// +/// \param SourceToDest A vector, indexed by the TypeIndex in the source +/// type stream, that contains the index of the corresponding type record +/// in the destination stream. +/// +/// \param Types The collection of types to merge in. +/// +/// \returns Error::success() if the operation succeeded, otherwise an +/// appropriate error code. +Error mergeTypeRecords(MergingTypeTableBuilder &Dest, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &Types); + +/// Merge one set of id records into another. This method assumes +/// that all records are id records, and there are no Type records present. +/// However, since Id records can refer back to Type records, this method +/// assumes that the referenced type records have also been merged into +/// another type stream (for example using the above method), and accepts +/// the mapping from source to dest for that stream so that it can re-write +/// the type record mappings accordingly. +/// +/// \param Dest The table to store the re-written id records into. +/// +/// \param Types The mapping to use for the type records that these id +/// records refer to. +/// +/// \param SourceToDest A vector, indexed by the TypeIndex in the source +/// id stream, that contains the index of the corresponding id record +/// in the destination stream. +/// +/// \param Ids The collection of id records to merge in. +/// +/// \returns Error::success() if the operation succeeded, otherwise an +/// appropriate error code. +Error mergeIdRecords(MergingTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &Ids); + +/// Merge a unified set of type and id records, splitting them into +/// separate output streams. +/// +/// \param DestIds The table to store the re-written id records into. +/// +/// \param DestTypes the table to store the re-written type records into. +/// +/// \param SourceToDest A vector, indexed by the TypeIndex in the source +/// id stream, that contains the index of the corresponding id record +/// in the destination stream. +/// +/// \param IdsAndTypes The collection of id records to merge in. +/// +/// \returns Error::success() if the operation succeeded, otherwise an +/// appropriate error code. +Error mergeTypeAndIdRecords(MergingTypeTableBuilder &DestIds, + MergingTypeTableBuilder &DestTypes, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &IdsAndTypes, + Optional<uint32_t> &PCHSignature); + +Error mergeTypeAndIdRecords(GlobalTypeTableBuilder &DestIds, + GlobalTypeTableBuilder &DestTypes, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &IdsAndTypes, + ArrayRef<GloballyHashedType> Hashes, + Optional<uint32_t> &PCHSignature); + +Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &Types, + ArrayRef<GloballyHashedType> Hashes, + Optional<uint32_t> &PCHSignature); + +Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types, + SmallVectorImpl<TypeIndex> &SourceToDest, + const CVTypeArray &Ids, + ArrayRef<GloballyHashedType> Hashes); + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeSymbolEmitter.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeSymbolEmitter.h index d9b6714cd9..9500bdb088 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeSymbolEmitter.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeSymbolEmitter.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeSymbolEmitter.h --------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESYMBOLEMITTER_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPESYMBOLEMITTER_H - -namespace llvm { -class StringRef; - -namespace codeview { -class TypeIndex; - -class TypeSymbolEmitter { -private: - TypeSymbolEmitter(const TypeSymbolEmitter &) = delete; - TypeSymbolEmitter &operator=(const TypeSymbolEmitter &) = delete; - -protected: - TypeSymbolEmitter() {} - -public: - virtual ~TypeSymbolEmitter() {} - -public: - virtual void writeUserDefinedType(TypeIndex TI, StringRef Name) = 0; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeSymbolEmitter.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESYMBOLEMITTER_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPESYMBOLEMITTER_H + +namespace llvm { +class StringRef; + +namespace codeview { +class TypeIndex; + +class TypeSymbolEmitter { +private: + TypeSymbolEmitter(const TypeSymbolEmitter &) = delete; + TypeSymbolEmitter &operator=(const TypeSymbolEmitter &) = delete; + +protected: + TypeSymbolEmitter() {} + +public: + virtual ~TypeSymbolEmitter() {} + +public: + virtual void writeUserDefinedType(TypeIndex TI, StringRef Name) = 0; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeTableCollection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeTableCollection.h index 7788c34f34..50e1df8276 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeTableCollection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeTableCollection.h @@ -1,54 +1,54 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeTableCollection.h ---------------------------------- *- C++ --*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H - -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/Support/StringSaver.h" - -#include <vector> - -namespace llvm { -namespace codeview { - -class TypeTableCollection : public TypeCollection { -public: - explicit TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records); - - Optional<TypeIndex> getFirst() override; - Optional<TypeIndex> getNext(TypeIndex Prev) override; - - CVType getType(TypeIndex Index) override; - StringRef getTypeName(TypeIndex Index) override; - bool contains(TypeIndex Index) override; - uint32_t size() override; - uint32_t capacity() override; - bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; - -private: - BumpPtrAllocator Allocator; - StringSaver NameStorage; - std::vector<StringRef> Names; - ArrayRef<ArrayRef<uint8_t>> Records; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeTableCollection.h ---------------------------------- *- C++ --*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H + +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/Support/StringSaver.h" + +#include <vector> + +namespace llvm { +namespace codeview { + +class TypeTableCollection : public TypeCollection { +public: + explicit TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records); + + Optional<TypeIndex> getFirst() override; + Optional<TypeIndex> getNext(TypeIndex Prev) override; + + CVType getType(TypeIndex Index) override; + StringRef getTypeName(TypeIndex Index) override; + bool contains(TypeIndex Index) override; + uint32_t size() override; + uint32_t capacity() override; + bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override; + +private: + BumpPtrAllocator Allocator; + StringSaver NameStorage; + std::vector<StringRef> Names; + ArrayRef<ArrayRef<uint8_t>> Records; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h index d73f988a40..afe7bcd2f8 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h @@ -1,132 +1,132 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeVisitorCallbackPipeline.h ----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" -#include "llvm/Support/Error.h" -#include <vector> - -namespace llvm { -namespace codeview { - -class TypeVisitorCallbackPipeline : public TypeVisitorCallbacks { -public: - TypeVisitorCallbackPipeline() = default; - - Error visitUnknownType(CVRecord<TypeLeafKind> &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitUnknownType(Record)) - return EC; - } - return Error::success(); - } - - Error visitUnknownMember(CVMemberRecord &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitUnknownMember(Record)) - return EC; - } - return Error::success(); - } - - Error visitTypeBegin(CVType &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitTypeBegin(Record)) - return EC; - } - return Error::success(); - } - - Error visitTypeBegin(CVType &Record, TypeIndex Index) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitTypeBegin(Record, Index)) - return EC; - } - return Error::success(); - } - - Error visitTypeEnd(CVType &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitTypeEnd(Record)) - return EC; - } - return Error::success(); - } - - Error visitMemberBegin(CVMemberRecord &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitMemberBegin(Record)) - return EC; - } - return Error::success(); - } - - Error visitMemberEnd(CVMemberRecord &Record) override { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitMemberEnd(Record)) - return EC; - } - return Error::success(); - } - - void addCallbackToPipeline(TypeVisitorCallbacks &Callbacks) { - Pipeline.push_back(&Callbacks); - } - -#define TYPE_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \ - return visitKnownRecordImpl(CVR, Record); \ - } -#define MEMBER_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownMember(CVMemberRecord &CVMR, Name##Record &Record) \ - override { \ - return visitKnownMemberImpl(CVMR, Record); \ - } -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: - template <typename T> Error visitKnownRecordImpl(CVType &CVR, T &Record) { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitKnownRecord(CVR, Record)) - return EC; - } - return Error::success(); - } - - template <typename T> - Error visitKnownMemberImpl(CVMemberRecord &CVMR, T &Record) { - for (auto Visitor : Pipeline) { - if (auto EC = Visitor->visitKnownMember(CVMR, Record)) - return EC; - } - return Error::success(); - } - std::vector<TypeVisitorCallbacks *> Pipeline; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeVisitorCallbackPipeline.h ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/Support/Error.h" +#include <vector> + +namespace llvm { +namespace codeview { + +class TypeVisitorCallbackPipeline : public TypeVisitorCallbacks { +public: + TypeVisitorCallbackPipeline() = default; + + Error visitUnknownType(CVRecord<TypeLeafKind> &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitUnknownType(Record)) + return EC; + } + return Error::success(); + } + + Error visitUnknownMember(CVMemberRecord &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitUnknownMember(Record)) + return EC; + } + return Error::success(); + } + + Error visitTypeBegin(CVType &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitTypeBegin(Record)) + return EC; + } + return Error::success(); + } + + Error visitTypeBegin(CVType &Record, TypeIndex Index) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitTypeBegin(Record, Index)) + return EC; + } + return Error::success(); + } + + Error visitTypeEnd(CVType &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitTypeEnd(Record)) + return EC; + } + return Error::success(); + } + + Error visitMemberBegin(CVMemberRecord &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitMemberBegin(Record)) + return EC; + } + return Error::success(); + } + + Error visitMemberEnd(CVMemberRecord &Record) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitMemberEnd(Record)) + return EC; + } + return Error::success(); + } + + void addCallbackToPipeline(TypeVisitorCallbacks &Callbacks) { + Pipeline.push_back(&Callbacks); + } + +#define TYPE_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \ + return visitKnownRecordImpl(CVR, Record); \ + } +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + Error visitKnownMember(CVMemberRecord &CVMR, Name##Record &Record) \ + override { \ + return visitKnownMemberImpl(CVMR, Record); \ + } +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" + +private: + template <typename T> Error visitKnownRecordImpl(CVType &CVR, T &Record) { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitKnownRecord(CVR, Record)) + return EC; + } + return Error::success(); + } + + template <typename T> + Error visitKnownMemberImpl(CVMemberRecord &CVMR, T &Record) { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitKnownMember(CVMR, Record)) + return EC; + } + return Error::success(); + } + std::vector<TypeVisitorCallbacks *> Pipeline; +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h index d81fc752a4..2a7c77a06c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h @@ -1,81 +1,81 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TypeVisitorCallbacks.h -----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H - -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { - -class TypeVisitorCallbacks { -public: - virtual ~TypeVisitorCallbacks() = default; - - /// Action to take on unknown types. By default, they are ignored. - virtual Error visitUnknownType(CVType &Record) { return Error::success(); } - /// Paired begin/end actions for all types. Receives all record data, - /// including the fixed-length record prefix. visitTypeBegin() should return - /// the type of the Record, or an error if it cannot be determined. Exactly - /// one of the two visitTypeBegin methods will be called, depending on whether - /// records are being visited sequentially or randomly. An implementation - /// should be prepared to handle both (or assert if it can't handle random - /// access visitation). - virtual Error visitTypeBegin(CVType &Record) { return Error::success(); } - virtual Error visitTypeBegin(CVType &Record, TypeIndex Index) { - return Error::success(); - } - virtual Error visitTypeEnd(CVType &Record) { return Error::success(); } - - virtual Error visitUnknownMember(CVMemberRecord &Record) { - return Error::success(); - } - - virtual Error visitMemberBegin(CVMemberRecord &Record) { - return Error::success(); - } - - virtual Error visitMemberEnd(CVMemberRecord &Record) { - return Error::success(); - } - -#define TYPE_RECORD(EnumName, EnumVal, Name) \ - virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) { \ - return Error::success(); \ - } -#define MEMBER_RECORD(EnumName, EnumVal, Name) \ - virtual Error visitKnownMember(CVMemberRecord &CVM, Name##Record &Record) { \ - return Error::success(); \ - } - -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" -#undef TYPE_RECORD -#undef TYPE_RECORD_ALIAS -#undef MEMBER_RECORD -#undef MEMBER_RECORD_ALIAS -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TypeVisitorCallbacks.h -----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H + +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { + +class TypeVisitorCallbacks { +public: + virtual ~TypeVisitorCallbacks() = default; + + /// Action to take on unknown types. By default, they are ignored. + virtual Error visitUnknownType(CVType &Record) { return Error::success(); } + /// Paired begin/end actions for all types. Receives all record data, + /// including the fixed-length record prefix. visitTypeBegin() should return + /// the type of the Record, or an error if it cannot be determined. Exactly + /// one of the two visitTypeBegin methods will be called, depending on whether + /// records are being visited sequentially or randomly. An implementation + /// should be prepared to handle both (or assert if it can't handle random + /// access visitation). + virtual Error visitTypeBegin(CVType &Record) { return Error::success(); } + virtual Error visitTypeBegin(CVType &Record, TypeIndex Index) { + return Error::success(); + } + virtual Error visitTypeEnd(CVType &Record) { return Error::success(); } + + virtual Error visitUnknownMember(CVMemberRecord &Record) { + return Error::success(); + } + + virtual Error visitMemberBegin(CVMemberRecord &Record) { + return Error::success(); + } + + virtual Error visitMemberEnd(CVMemberRecord &Record) { + return Error::success(); + } + +#define TYPE_RECORD(EnumName, EnumVal, Name) \ + virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) { \ + return Error::success(); \ + } +#define MEMBER_RECORD(EnumName, EnumVal, Name) \ + virtual Error visitKnownMember(CVMemberRecord &CVM, Name##Record &Record) { \ + return Error::success(); \ + } + +#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) +#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" +#undef TYPE_RECORD +#undef TYPE_RECORD_ALIAS +#undef MEMBER_RECORD +#undef MEMBER_RECORD_ALIAS +}; + +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DIContext.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DIContext.h index 3f4c7bd091..5be5936216 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DIContext.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DIContext.h @@ -1,333 +1,333 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIContext.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines DIContext, an abstract data structure that holds -// debug information data. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DICONTEXT_H -#define LLVM_DEBUGINFO_DICONTEXT_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/WithColor.h" -#include "llvm/Support/raw_ostream.h" -#include <cassert> -#include <cstdint> -#include <memory> -#include <string> -#include <tuple> -#include <utility> - -namespace llvm { - -/// A format-neutral container for source line information. -struct DILineInfo { - // DILineInfo contains "<invalid>" for function/filename it cannot fetch. - static constexpr const char *const BadString = "<invalid>"; - // Use "??" instead of "<invalid>" to make our output closer to addr2line. - static constexpr const char *const Addr2LineBadString = "??"; - std::string FileName; - std::string FunctionName; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIContext.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines DIContext, an abstract data structure that holds +// debug information data. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DICONTEXT_H +#define LLVM_DEBUGINFO_DICONTEXT_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/WithColor.h" +#include "llvm/Support/raw_ostream.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <string> +#include <tuple> +#include <utility> + +namespace llvm { + +/// A format-neutral container for source line information. +struct DILineInfo { + // DILineInfo contains "<invalid>" for function/filename it cannot fetch. + static constexpr const char *const BadString = "<invalid>"; + // Use "??" instead of "<invalid>" to make our output closer to addr2line. + static constexpr const char *const Addr2LineBadString = "??"; + std::string FileName; + std::string FunctionName; std::string StartFileName; - Optional<StringRef> Source; - uint32_t Line = 0; - uint32_t Column = 0; - uint32_t StartLine = 0; - - // DWARF-specific. - uint32_t Discriminator = 0; - + Optional<StringRef> Source; + uint32_t Line = 0; + uint32_t Column = 0; + uint32_t StartLine = 0; + + // DWARF-specific. + uint32_t Discriminator = 0; + DILineInfo() : FileName(BadString), FunctionName(BadString), StartFileName(BadString) { } - - bool operator==(const DILineInfo &RHS) const { - return Line == RHS.Line && Column == RHS.Column && - FileName == RHS.FileName && FunctionName == RHS.FunctionName && + + bool operator==(const DILineInfo &RHS) const { + return Line == RHS.Line && Column == RHS.Column && + FileName == RHS.FileName && FunctionName == RHS.FunctionName && StartFileName == RHS.StartFileName && StartLine == RHS.StartLine && Discriminator == RHS.Discriminator; - } - - bool operator!=(const DILineInfo &RHS) const { - return !(*this == RHS); - } - - bool operator<(const DILineInfo &RHS) const { + } + + bool operator!=(const DILineInfo &RHS) const { + return !(*this == RHS); + } + + bool operator<(const DILineInfo &RHS) const { return std::tie(FileName, FunctionName, StartFileName, Line, Column, StartLine, Discriminator) < std::tie(RHS.FileName, RHS.FunctionName, RHS.StartFileName, RHS.Line, RHS.Column, RHS.StartLine, RHS.Discriminator); - } - - explicit operator bool() const { return *this != DILineInfo(); } - - void dump(raw_ostream &OS) { - OS << "Line info: "; - if (FileName != BadString) - OS << "file '" << FileName << "', "; - if (FunctionName != BadString) - OS << "function '" << FunctionName << "', "; - OS << "line " << Line << ", "; - OS << "column " << Column << ", "; + } + + explicit operator bool() const { return *this != DILineInfo(); } + + void dump(raw_ostream &OS) { + OS << "Line info: "; + if (FileName != BadString) + OS << "file '" << FileName << "', "; + if (FunctionName != BadString) + OS << "function '" << FunctionName << "', "; + OS << "line " << Line << ", "; + OS << "column " << Column << ", "; if (StartFileName != BadString) OS << "start file '" << StartFileName << "', "; - OS << "start line " << StartLine << '\n'; - } -}; - -using DILineInfoTable = SmallVector<std::pair<uint64_t, DILineInfo>, 16>; - -/// A format-neutral container for inlined code description. -class DIInliningInfo { - SmallVector<DILineInfo, 4> Frames; - -public: - DIInliningInfo() = default; - - const DILineInfo & getFrame(unsigned Index) const { - assert(Index < Frames.size()); - return Frames[Index]; - } - - DILineInfo *getMutableFrame(unsigned Index) { - assert(Index < Frames.size()); - return &Frames[Index]; - } - - uint32_t getNumberOfFrames() const { - return Frames.size(); - } - - void addFrame(const DILineInfo &Frame) { - Frames.push_back(Frame); - } - - void resize(unsigned i) { - Frames.resize(i); - } -}; - -/// Container for description of a global variable. -struct DIGlobal { - std::string Name; - uint64_t Start = 0; - uint64_t Size = 0; - - DIGlobal() : Name(DILineInfo::BadString) {} -}; - -struct DILocal { - std::string FunctionName; - std::string Name; - std::string DeclFile; - uint64_t DeclLine = 0; - Optional<int64_t> FrameOffset; - Optional<uint64_t> Size; - Optional<uint64_t> TagOffset; -}; - -/// A DINameKind is passed to name search methods to specify a -/// preference regarding the type of name resolution the caller wants. -enum class DINameKind { None, ShortName, LinkageName }; - -/// Controls which fields of DILineInfo container should be filled -/// with data. -struct DILineInfoSpecifier { - enum class FileLineInfoKind { - None, - // RawValue is whatever the compiler stored in the filename table. Could be - // a full path, could be something else. - RawValue, - BaseNameOnly, - // Relative to the compilation directory. - RelativeFilePath, - AbsoluteFilePath - }; - using FunctionNameKind = DINameKind; - - FileLineInfoKind FLIKind; - FunctionNameKind FNKind; - - DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::RawValue, - FunctionNameKind FNKind = FunctionNameKind::None) - : FLIKind(FLIKind), FNKind(FNKind) {} -}; - -/// This is just a helper to programmatically construct DIDumpType. -enum DIDumpTypeCounter { -#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \ - DIDT_ID_##ENUM_NAME, -#include "llvm/BinaryFormat/Dwarf.def" -#undef HANDLE_DWARF_SECTION - DIDT_ID_UUID, - DIDT_ID_Count -}; -static_assert(DIDT_ID_Count <= 32, "section types overflow storage"); - -/// Selects which debug sections get dumped. -enum DIDumpType : unsigned { - DIDT_Null, - DIDT_All = ~0U, -#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \ - DIDT_##ENUM_NAME = 1U << DIDT_ID_##ENUM_NAME, -#include "llvm/BinaryFormat/Dwarf.def" -#undef HANDLE_DWARF_SECTION - DIDT_UUID = 1 << DIDT_ID_UUID, -}; - -/// Container for dump options that control which debug information will be -/// dumped. -struct DIDumpOptions { - unsigned DumpType = DIDT_All; - unsigned ChildRecurseDepth = -1U; - unsigned ParentRecurseDepth = -1U; - uint16_t Version = 0; // DWARF version to assume when extracting. - uint8_t AddrSize = 4; // Address byte size to assume when extracting. - bool ShowAddresses = true; - bool ShowChildren = false; - bool ShowParents = false; - bool ShowForm = false; - bool SummarizeTypes = false; - bool Verbose = false; - bool DisplayRawContents = false; - - /// Return default option set for printing a single DIE without children. - static DIDumpOptions getForSingleDIE() { - DIDumpOptions Opts; - Opts.ChildRecurseDepth = 0; - Opts.ParentRecurseDepth = 0; - return Opts; - } - - /// Return the options with RecurseDepth set to 0 unless explicitly required. - DIDumpOptions noImplicitRecursion() const { - DIDumpOptions Opts = *this; - if (ChildRecurseDepth == -1U && !ShowChildren) - Opts.ChildRecurseDepth = 0; - if (ParentRecurseDepth == -1U && !ShowParents) - Opts.ParentRecurseDepth = 0; - return Opts; - } - - std::function<void(Error)> RecoverableErrorHandler = - WithColor::defaultErrorHandler; - std::function<void(Error)> WarningHandler = WithColor::defaultWarningHandler; -}; - -class DIContext { -public: - enum DIContextKind { - CK_DWARF, - CK_PDB - }; - - DIContext(DIContextKind K) : Kind(K) {} - virtual ~DIContext() = default; - - DIContextKind getKind() const { return Kind; } - - virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; - - virtual bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) { - // No verifier? Just say things went well. - return true; - } - - virtual DILineInfo getLineInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; - virtual DILineInfoTable getLineInfoForAddressRange( - object::SectionedAddress Address, uint64_t Size, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; - virtual DIInliningInfo getInliningInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; - - virtual std::vector<DILocal> - getLocalsForAddress(object::SectionedAddress Address) = 0; - -private: - const DIContextKind Kind; -}; - -/// An inferface for inquiring the load address of a loaded object file -/// to be used by the DIContext implementations when applying relocations -/// on the fly. -class LoadedObjectInfo { -protected: - LoadedObjectInfo() = default; - LoadedObjectInfo(const LoadedObjectInfo &) = default; - -public: - virtual ~LoadedObjectInfo() = default; - - /// Obtain the Load Address of a section by SectionRef. - /// - /// Calculate the address of the given section. - /// The section need not be present in the local address space. The addresses - /// need to be consistent with the addresses used to query the DIContext and - /// the output of this function should be deterministic, i.e. repeated calls - /// with the same Sec should give the same address. - virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const { - return 0; - } - - /// If conveniently available, return the content of the given Section. - /// - /// When the section is available in the local address space, in relocated - /// (loaded) form, e.g. because it was relocated by a JIT for execution, this - /// function should provide the contents of said section in `Data`. If the - /// loaded section is not available, or the cost of retrieving it would be - /// prohibitive, this function should return false. In that case, relocations - /// will be read from the local (unrelocated) object file and applied on the - /// fly. Note that this method is used purely for optimzation purposes in the - /// common case of JITting in the local address space, so returning false - /// should always be correct. - virtual bool getLoadedSectionContents(const object::SectionRef &Sec, - StringRef &Data) const { - return false; - } - - // FIXME: This is untested and unused anywhere in the LLVM project, it's - // used/needed by Julia (an external project). It should have some coverage - // (at least tests, but ideally example functionality). - /// Obtain a copy of this LoadedObjectInfo. - virtual std::unique_ptr<LoadedObjectInfo> clone() const = 0; -}; - -template <typename Derived, typename Base = LoadedObjectInfo> -struct LoadedObjectInfoHelper : Base { -protected: - LoadedObjectInfoHelper(const LoadedObjectInfoHelper &) = default; - LoadedObjectInfoHelper() = default; - -public: - template <typename... Ts> - LoadedObjectInfoHelper(Ts &&... Args) : Base(std::forward<Ts>(Args)...) {} - - std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { - return std::make_unique<Derived>(static_cast<const Derived &>(*this)); - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DICONTEXT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + OS << "start line " << StartLine << '\n'; + } +}; + +using DILineInfoTable = SmallVector<std::pair<uint64_t, DILineInfo>, 16>; + +/// A format-neutral container for inlined code description. +class DIInliningInfo { + SmallVector<DILineInfo, 4> Frames; + +public: + DIInliningInfo() = default; + + const DILineInfo & getFrame(unsigned Index) const { + assert(Index < Frames.size()); + return Frames[Index]; + } + + DILineInfo *getMutableFrame(unsigned Index) { + assert(Index < Frames.size()); + return &Frames[Index]; + } + + uint32_t getNumberOfFrames() const { + return Frames.size(); + } + + void addFrame(const DILineInfo &Frame) { + Frames.push_back(Frame); + } + + void resize(unsigned i) { + Frames.resize(i); + } +}; + +/// Container for description of a global variable. +struct DIGlobal { + std::string Name; + uint64_t Start = 0; + uint64_t Size = 0; + + DIGlobal() : Name(DILineInfo::BadString) {} +}; + +struct DILocal { + std::string FunctionName; + std::string Name; + std::string DeclFile; + uint64_t DeclLine = 0; + Optional<int64_t> FrameOffset; + Optional<uint64_t> Size; + Optional<uint64_t> TagOffset; +}; + +/// A DINameKind is passed to name search methods to specify a +/// preference regarding the type of name resolution the caller wants. +enum class DINameKind { None, ShortName, LinkageName }; + +/// Controls which fields of DILineInfo container should be filled +/// with data. +struct DILineInfoSpecifier { + enum class FileLineInfoKind { + None, + // RawValue is whatever the compiler stored in the filename table. Could be + // a full path, could be something else. + RawValue, + BaseNameOnly, + // Relative to the compilation directory. + RelativeFilePath, + AbsoluteFilePath + }; + using FunctionNameKind = DINameKind; + + FileLineInfoKind FLIKind; + FunctionNameKind FNKind; + + DILineInfoSpecifier(FileLineInfoKind FLIKind = FileLineInfoKind::RawValue, + FunctionNameKind FNKind = FunctionNameKind::None) + : FLIKind(FLIKind), FNKind(FNKind) {} +}; + +/// This is just a helper to programmatically construct DIDumpType. +enum DIDumpTypeCounter { +#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \ + DIDT_ID_##ENUM_NAME, +#include "llvm/BinaryFormat/Dwarf.def" +#undef HANDLE_DWARF_SECTION + DIDT_ID_UUID, + DIDT_ID_Count +}; +static_assert(DIDT_ID_Count <= 32, "section types overflow storage"); + +/// Selects which debug sections get dumped. +enum DIDumpType : unsigned { + DIDT_Null, + DIDT_All = ~0U, +#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \ + DIDT_##ENUM_NAME = 1U << DIDT_ID_##ENUM_NAME, +#include "llvm/BinaryFormat/Dwarf.def" +#undef HANDLE_DWARF_SECTION + DIDT_UUID = 1 << DIDT_ID_UUID, +}; + +/// Container for dump options that control which debug information will be +/// dumped. +struct DIDumpOptions { + unsigned DumpType = DIDT_All; + unsigned ChildRecurseDepth = -1U; + unsigned ParentRecurseDepth = -1U; + uint16_t Version = 0; // DWARF version to assume when extracting. + uint8_t AddrSize = 4; // Address byte size to assume when extracting. + bool ShowAddresses = true; + bool ShowChildren = false; + bool ShowParents = false; + bool ShowForm = false; + bool SummarizeTypes = false; + bool Verbose = false; + bool DisplayRawContents = false; + + /// Return default option set for printing a single DIE without children. + static DIDumpOptions getForSingleDIE() { + DIDumpOptions Opts; + Opts.ChildRecurseDepth = 0; + Opts.ParentRecurseDepth = 0; + return Opts; + } + + /// Return the options with RecurseDepth set to 0 unless explicitly required. + DIDumpOptions noImplicitRecursion() const { + DIDumpOptions Opts = *this; + if (ChildRecurseDepth == -1U && !ShowChildren) + Opts.ChildRecurseDepth = 0; + if (ParentRecurseDepth == -1U && !ShowParents) + Opts.ParentRecurseDepth = 0; + return Opts; + } + + std::function<void(Error)> RecoverableErrorHandler = + WithColor::defaultErrorHandler; + std::function<void(Error)> WarningHandler = WithColor::defaultWarningHandler; +}; + +class DIContext { +public: + enum DIContextKind { + CK_DWARF, + CK_PDB + }; + + DIContext(DIContextKind K) : Kind(K) {} + virtual ~DIContext() = default; + + DIContextKind getKind() const { return Kind; } + + virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; + + virtual bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) { + // No verifier? Just say things went well. + return true; + } + + virtual DILineInfo getLineInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; + virtual DILineInfoTable getLineInfoForAddressRange( + object::SectionedAddress Address, uint64_t Size, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; + virtual DIInliningInfo getInliningInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0; + + virtual std::vector<DILocal> + getLocalsForAddress(object::SectionedAddress Address) = 0; + +private: + const DIContextKind Kind; +}; + +/// An inferface for inquiring the load address of a loaded object file +/// to be used by the DIContext implementations when applying relocations +/// on the fly. +class LoadedObjectInfo { +protected: + LoadedObjectInfo() = default; + LoadedObjectInfo(const LoadedObjectInfo &) = default; + +public: + virtual ~LoadedObjectInfo() = default; + + /// Obtain the Load Address of a section by SectionRef. + /// + /// Calculate the address of the given section. + /// The section need not be present in the local address space. The addresses + /// need to be consistent with the addresses used to query the DIContext and + /// the output of this function should be deterministic, i.e. repeated calls + /// with the same Sec should give the same address. + virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const { + return 0; + } + + /// If conveniently available, return the content of the given Section. + /// + /// When the section is available in the local address space, in relocated + /// (loaded) form, e.g. because it was relocated by a JIT for execution, this + /// function should provide the contents of said section in `Data`. If the + /// loaded section is not available, or the cost of retrieving it would be + /// prohibitive, this function should return false. In that case, relocations + /// will be read from the local (unrelocated) object file and applied on the + /// fly. Note that this method is used purely for optimzation purposes in the + /// common case of JITting in the local address space, so returning false + /// should always be correct. + virtual bool getLoadedSectionContents(const object::SectionRef &Sec, + StringRef &Data) const { + return false; + } + + // FIXME: This is untested and unused anywhere in the LLVM project, it's + // used/needed by Julia (an external project). It should have some coverage + // (at least tests, but ideally example functionality). + /// Obtain a copy of this LoadedObjectInfo. + virtual std::unique_ptr<LoadedObjectInfo> clone() const = 0; +}; + +template <typename Derived, typename Base = LoadedObjectInfo> +struct LoadedObjectInfoHelper : Base { +protected: + LoadedObjectInfoHelper(const LoadedObjectInfoHelper &) = default; + LoadedObjectInfoHelper() = default; + +public: + template <typename... Ts> + LoadedObjectInfoHelper(Ts &&... Args) : Base(std::forward<Ts>(Args)...) {} + + std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { + return std::make_unique<Derived>(static_cast<const Derived &>(*this)); + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DICONTEXT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index 991b7fa444..930cfeb651 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -1,123 +1,123 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFAbbreviationDeclaration.h ---------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H -#define LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/Support/DataExtractor.h" -#include <cassert> -#include <cstddef> -#include <cstdint> - -namespace llvm { - -class DWARFFormValue; -class DWARFUnit; -class raw_ostream; - -class DWARFAbbreviationDeclaration { -public: - struct AttributeSpec { - AttributeSpec(dwarf::Attribute A, dwarf::Form F, int64_t Value) - : Attr(A), Form(F), Value(Value) { - assert(isImplicitConst()); - } - AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize) - : Attr(A), Form(F) { - assert(!isImplicitConst()); - this->ByteSize.HasByteSize = ByteSize.hasValue(); - if (this->ByteSize.HasByteSize) - this->ByteSize.ByteSize = *ByteSize; - } - - dwarf::Attribute Attr; - dwarf::Form Form; - - private: - /// The following field is used for ByteSize for non-implicit_const - /// attributes and as value for implicit_const ones, indicated by - /// Form == DW_FORM_implicit_const. - /// The following cases are distinguished: - /// * Form != DW_FORM_implicit_const and HasByteSize is true: - /// ByteSize contains the fixed size in bytes for the Form in this - /// object. - /// * Form != DW_FORM_implicit_const and HasByteSize is false: - /// byte size of Form either varies according to the DWARFUnit - /// that it is contained in or the value size varies and must be - /// decoded from the debug information in order to determine its size. - /// * Form == DW_FORM_implicit_const: - /// Value contains value for the implicit_const attribute. - struct ByteSizeStorage { - bool HasByteSize; - uint8_t ByteSize; - }; - union { - ByteSizeStorage ByteSize; - int64_t Value; - }; - - public: - bool isImplicitConst() const { - return Form == dwarf::DW_FORM_implicit_const; - } - - int64_t getImplicitConstValue() const { - assert(isImplicitConst()); - return Value; - } - - /// Get the fixed byte size of this Form if possible. This function might - /// use the DWARFUnit to calculate the size of the Form, like for - /// DW_AT_address and DW_AT_ref_addr, so this isn't just an accessor for - /// the ByteSize member. - Optional<int64_t> getByteSize(const DWARFUnit &U) const; - }; - using AttributeSpecVector = SmallVector<AttributeSpec, 8>; - - DWARFAbbreviationDeclaration(); - - uint32_t getCode() const { return Code; } - uint8_t getCodeByteSize() const { return CodeByteSize; } - dwarf::Tag getTag() const { return Tag; } - bool hasChildren() const { return HasChildren; } - - using attr_iterator_range = - iterator_range<AttributeSpecVector::const_iterator>; - - attr_iterator_range attributes() const { - return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); - } - - dwarf::Form getFormByIndex(uint32_t idx) const { - assert(idx < AttributeSpecs.size()); - return AttributeSpecs[idx].Form; - } - - size_t getNumAttributes() const { - return AttributeSpecs.size(); - } - - dwarf::Attribute getAttrByIndex(uint32_t idx) const { - assert(idx < AttributeSpecs.size()); - return AttributeSpecs[idx].Attr; - } - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFAbbreviationDeclaration.h ---------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H +#define LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/Support/DataExtractor.h" +#include <cassert> +#include <cstddef> +#include <cstdint> + +namespace llvm { + +class DWARFFormValue; +class DWARFUnit; +class raw_ostream; + +class DWARFAbbreviationDeclaration { +public: + struct AttributeSpec { + AttributeSpec(dwarf::Attribute A, dwarf::Form F, int64_t Value) + : Attr(A), Form(F), Value(Value) { + assert(isImplicitConst()); + } + AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize) + : Attr(A), Form(F) { + assert(!isImplicitConst()); + this->ByteSize.HasByteSize = ByteSize.hasValue(); + if (this->ByteSize.HasByteSize) + this->ByteSize.ByteSize = *ByteSize; + } + + dwarf::Attribute Attr; + dwarf::Form Form; + + private: + /// The following field is used for ByteSize for non-implicit_const + /// attributes and as value for implicit_const ones, indicated by + /// Form == DW_FORM_implicit_const. + /// The following cases are distinguished: + /// * Form != DW_FORM_implicit_const and HasByteSize is true: + /// ByteSize contains the fixed size in bytes for the Form in this + /// object. + /// * Form != DW_FORM_implicit_const and HasByteSize is false: + /// byte size of Form either varies according to the DWARFUnit + /// that it is contained in or the value size varies and must be + /// decoded from the debug information in order to determine its size. + /// * Form == DW_FORM_implicit_const: + /// Value contains value for the implicit_const attribute. + struct ByteSizeStorage { + bool HasByteSize; + uint8_t ByteSize; + }; + union { + ByteSizeStorage ByteSize; + int64_t Value; + }; + + public: + bool isImplicitConst() const { + return Form == dwarf::DW_FORM_implicit_const; + } + + int64_t getImplicitConstValue() const { + assert(isImplicitConst()); + return Value; + } + + /// Get the fixed byte size of this Form if possible. This function might + /// use the DWARFUnit to calculate the size of the Form, like for + /// DW_AT_address and DW_AT_ref_addr, so this isn't just an accessor for + /// the ByteSize member. + Optional<int64_t> getByteSize(const DWARFUnit &U) const; + }; + using AttributeSpecVector = SmallVector<AttributeSpec, 8>; + + DWARFAbbreviationDeclaration(); + + uint32_t getCode() const { return Code; } + uint8_t getCodeByteSize() const { return CodeByteSize; } + dwarf::Tag getTag() const { return Tag; } + bool hasChildren() const { return HasChildren; } + + using attr_iterator_range = + iterator_range<AttributeSpecVector::const_iterator>; + + attr_iterator_range attributes() const { + return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); + } + + dwarf::Form getFormByIndex(uint32_t idx) const { + assert(idx < AttributeSpecs.size()); + return AttributeSpecs[idx].Form; + } + + size_t getNumAttributes() const { + return AttributeSpecs.size(); + } + + dwarf::Attribute getAttrByIndex(uint32_t idx) const { + assert(idx < AttributeSpecs.size()); + return AttributeSpecs[idx].Attr; + } + bool getAttrIsImplicitConstByIndex(uint32_t idx) const { assert(idx < AttributeSpecs.size()); return AttributeSpecs[idx].isImplicitConst(); @@ -128,77 +128,77 @@ public: return AttributeSpecs[idx].getImplicitConstValue(); } - /// Get the index of the specified attribute. - /// - /// Searches the this abbreviation declaration for the index of the specified - /// attribute. - /// - /// \param attr DWARF attribute to search for. - /// \returns Optional index of the attribute if found, None otherwise. - Optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const; - - /// Extract a DWARF form value from a DIE specified by DIE offset. - /// - /// Extract an attribute value for a DWARFUnit given the DIE offset and the - /// attribute. - /// - /// \param DIEOffset the DIE offset that points to the ULEB128 abbreviation - /// code in the .debug_info data. - /// \param Attr DWARF attribute to search for. - /// \param U the DWARFUnit the contains the DIE. - /// \returns Optional DWARF form value if the attribute was extracted. - Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset, - const dwarf::Attribute Attr, - const DWARFUnit &U) const; - - bool extract(DataExtractor Data, uint64_t* OffsetPtr); - void dump(raw_ostream &OS) const; - - // Return an optional byte size of all attribute data in this abbreviation - // if a constant byte size can be calculated given a DWARFUnit. This allows - // DWARF parsing to be faster as many DWARF DIEs have a fixed byte size. - Optional<size_t> getFixedAttributesByteSize(const DWARFUnit &U) const; - -private: - void clear(); - - /// A helper structure that can quickly determine the size in bytes of an - /// abbreviation declaration. - struct FixedSizeInfo { - /// The fixed byte size for fixed size forms. - uint16_t NumBytes = 0; - /// Number of DW_FORM_address forms in this abbrevation declaration. - uint8_t NumAddrs = 0; - /// Number of DW_FORM_ref_addr forms in this abbrevation declaration. - uint8_t NumRefAddrs = 0; - /// Number of 4 byte in DWARF32 and 8 byte in DWARF64 forms. - uint8_t NumDwarfOffsets = 0; - - FixedSizeInfo() = default; - - /// Calculate the fixed size in bytes given a DWARFUnit. - /// - /// \param U the DWARFUnit to use when determing the byte size. - /// \returns the size in bytes for all attribute data in this abbreviation. - /// The returned size does not include bytes for the ULEB128 abbreviation - /// code - size_t getByteSize(const DWARFUnit &U) const; - }; - - uint32_t Code; - dwarf::Tag Tag; - uint8_t CodeByteSize; - bool HasChildren; - AttributeSpecVector AttributeSpecs; - /// If this abbreviation has a fixed byte size then FixedAttributeSize member - /// variable below will have a value. - Optional<FixedSizeInfo> FixedAttributeSize; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + /// Get the index of the specified attribute. + /// + /// Searches the this abbreviation declaration for the index of the specified + /// attribute. + /// + /// \param attr DWARF attribute to search for. + /// \returns Optional index of the attribute if found, None otherwise. + Optional<uint32_t> findAttributeIndex(dwarf::Attribute attr) const; + + /// Extract a DWARF form value from a DIE specified by DIE offset. + /// + /// Extract an attribute value for a DWARFUnit given the DIE offset and the + /// attribute. + /// + /// \param DIEOffset the DIE offset that points to the ULEB128 abbreviation + /// code in the .debug_info data. + /// \param Attr DWARF attribute to search for. + /// \param U the DWARFUnit the contains the DIE. + /// \returns Optional DWARF form value if the attribute was extracted. + Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset, + const dwarf::Attribute Attr, + const DWARFUnit &U) const; + + bool extract(DataExtractor Data, uint64_t* OffsetPtr); + void dump(raw_ostream &OS) const; + + // Return an optional byte size of all attribute data in this abbreviation + // if a constant byte size can be calculated given a DWARFUnit. This allows + // DWARF parsing to be faster as many DWARF DIEs have a fixed byte size. + Optional<size_t> getFixedAttributesByteSize(const DWARFUnit &U) const; + +private: + void clear(); + + /// A helper structure that can quickly determine the size in bytes of an + /// abbreviation declaration. + struct FixedSizeInfo { + /// The fixed byte size for fixed size forms. + uint16_t NumBytes = 0; + /// Number of DW_FORM_address forms in this abbrevation declaration. + uint8_t NumAddrs = 0; + /// Number of DW_FORM_ref_addr forms in this abbrevation declaration. + uint8_t NumRefAddrs = 0; + /// Number of 4 byte in DWARF32 and 8 byte in DWARF64 forms. + uint8_t NumDwarfOffsets = 0; + + FixedSizeInfo() = default; + + /// Calculate the fixed size in bytes given a DWARFUnit. + /// + /// \param U the DWARFUnit to use when determing the byte size. + /// \returns the size in bytes for all attribute data in this abbreviation. + /// The returned size does not include bytes for the ULEB128 abbreviation + /// code + size_t getByteSize(const DWARFUnit &U) const; + }; + + uint32_t Code; + dwarf::Tag Tag; + uint8_t CodeByteSize; + bool HasChildren; + AttributeSpecVector AttributeSpecs; + /// If this abbreviation has a fixed byte size then FixedAttributeSize member + /// variable below will have a value. + Optional<FixedSizeInfo> FixedAttributeSize; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index ab321a1f7a..a4ce8c6b41 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -1,609 +1,609 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFAcceleratorTable.h ----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H -#define LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H - -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include <cstdint> -#include <utility> - -namespace llvm { - -class raw_ostream; -class ScopedPrinter; - -/// The accelerator tables are designed to allow efficient random access -/// (using a symbol name as a key) into debug info by providing an index of the -/// debug info DIEs. This class implements the common functionality of Apple and -/// DWARF 5 accelerator tables. -/// TODO: Generalize the rest of the AppleAcceleratorTable interface and move it -/// to this class. -class DWARFAcceleratorTable { -protected: - DWARFDataExtractor AccelSection; - DataExtractor StringSection; - -public: - /// An abstract class representing a single entry in the accelerator tables. - class Entry { - protected: - SmallVector<DWARFFormValue, 3> Values; - - Entry() = default; - - // Make these protected so only (final) subclasses can be copied around. - Entry(const Entry &) = default; - Entry(Entry &&) = default; - Entry &operator=(const Entry &) = default; - Entry &operator=(Entry &&) = default; - ~Entry() = default; - - - public: - /// Returns the Offset of the Compilation Unit associated with this - /// Accelerator Entry or None if the Compilation Unit offset is not recorded - /// in this Accelerator Entry. - virtual Optional<uint64_t> getCUOffset() const = 0; - - /// Returns the Tag of the Debug Info Entry associated with this - /// Accelerator Entry or None if the Tag is not recorded in this - /// Accelerator Entry. - virtual Optional<dwarf::Tag> getTag() const = 0; - - /// Returns the raw values of fields in the Accelerator Entry. In general, - /// these can only be interpreted with the help of the metadata in the - /// owning Accelerator Table. - ArrayRef<DWARFFormValue> getValues() const { return Values; } - }; - - DWARFAcceleratorTable(const DWARFDataExtractor &AccelSection, - DataExtractor StringSection) - : AccelSection(AccelSection), StringSection(StringSection) {} - virtual ~DWARFAcceleratorTable(); - - virtual Error extract() = 0; - virtual void dump(raw_ostream &OS) const = 0; - - DWARFAcceleratorTable(const DWARFAcceleratorTable &) = delete; - void operator=(const DWARFAcceleratorTable &) = delete; -}; - -/// This implements the Apple accelerator table format, a precursor of the -/// DWARF 5 accelerator table format. -class AppleAcceleratorTable : public DWARFAcceleratorTable { - struct Header { - uint32_t Magic; - uint16_t Version; - uint16_t HashFunction; - uint32_t BucketCount; - uint32_t HashCount; - uint32_t HeaderDataLength; - - void dump(ScopedPrinter &W) const; - }; - - struct HeaderData { - using AtomType = uint16_t; - using Form = dwarf::Form; - - uint64_t DIEOffsetBase; - SmallVector<std::pair<AtomType, Form>, 3> Atoms; - - Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const; - }; - - struct Header Hdr; - struct HeaderData HdrData; - bool IsValid = false; - - /// Returns true if we should continue scanning for entries or false if we've - /// reached the last (sentinel) entry of encountered a parsing error. - bool dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms, - uint64_t *DataOffset) const; - -public: - /// Apple-specific implementation of an Accelerator Entry. - class Entry final : public DWARFAcceleratorTable::Entry { - const HeaderData *HdrData = nullptr; - - Entry(const HeaderData &Data); - Entry() = default; - - void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); - - public: - Optional<uint64_t> getCUOffset() const override; - - /// Returns the Section Offset of the Debug Info Entry associated with this - /// Accelerator Entry or None if the DIE offset is not recorded in this - /// Accelerator Entry. The returned offset is relative to the start of the - /// Section containing the DIE. - Optional<uint64_t> getDIESectionOffset() const; - - Optional<dwarf::Tag> getTag() const override; - - /// Returns the value of the Atom in this Accelerator Entry, if the Entry - /// contains such Atom. - Optional<DWARFFormValue> lookup(HeaderData::AtomType Atom) const; - - friend class AppleAcceleratorTable; - friend class ValueIterator; - }; - - class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> { - const AppleAcceleratorTable *AccelTable = nullptr; - Entry Current; ///< The current entry. - uint64_t DataOffset = 0; ///< Offset into the section. - unsigned Data = 0; ///< Current data entry. - unsigned NumData = 0; ///< Number of data entries. - - /// Advance the iterator. - void Next(); - public: - /// Construct a new iterator for the entries at \p DataOffset. - ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset); - /// End marker. - ValueIterator() = default; - - const Entry &operator*() const { return Current; } - ValueIterator &operator++() { Next(); return *this; } - ValueIterator operator++(int) { - ValueIterator I = *this; - Next(); - return I; - } - friend bool operator==(const ValueIterator &A, const ValueIterator &B) { - return A.NumData == B.NumData && A.DataOffset == B.DataOffset; - } - friend bool operator!=(const ValueIterator &A, const ValueIterator &B) { - return !(A == B); - } - }; - - AppleAcceleratorTable(const DWARFDataExtractor &AccelSection, - DataExtractor StringSection) - : DWARFAcceleratorTable(AccelSection, StringSection) {} - - Error extract() override; - uint32_t getNumBuckets(); - uint32_t getNumHashes(); - uint32_t getSizeHdr(); - uint32_t getHeaderDataLength(); - - /// Return the Atom description, which can be used to interpret the raw values - /// of the Accelerator Entries in this table. - ArrayRef<std::pair<HeaderData::AtomType, HeaderData::Form>> getAtomsDesc(); - bool validateForms(); - - /// Return information related to the DWARF DIE we're looking for when - /// performing a lookup by name. - /// - /// \param HashDataOffset an offset into the hash data table - /// \returns <DieOffset, DieTag> - /// DieOffset is the offset into the .debug_info section for the DIE - /// related to the input hash data offset. - /// DieTag is the tag of the DIE - std::pair<uint64_t, dwarf::Tag> readAtoms(uint64_t *HashDataOffset); - void dump(raw_ostream &OS) const override; - - /// Look up all entries in the accelerator table matching \c Key. - iterator_range<ValueIterator> equal_range(StringRef Key) const; -}; - -/// .debug_names section consists of one or more units. Each unit starts with a -/// header, which is followed by a list of compilation units, local and foreign -/// type units. -/// -/// These may be followed by an (optional) hash lookup table, which consists of -/// an array of buckets and hashes similar to the apple tables above. The only -/// difference is that the hashes array is 1-based, and consequently an empty -/// bucket is denoted by 0 and not UINT32_MAX. -/// -/// Next is the name table, which consists of an array of names and array of -/// entry offsets. This is different from the apple tables, which store names -/// next to the actual entries. -/// -/// The structure of the entries is described by an abbreviations table, which -/// comes after the name table. Unlike the apple tables, which have a uniform -/// entry structure described in the header, each .debug_names entry may have -/// different index attributes (DW_IDX_???) attached to it. -/// -/// The last segment consists of a list of entries, which is a 0-terminated list -/// referenced by the name table and interpreted with the help of the -/// abbreviation table. -class DWARFDebugNames : public DWARFAcceleratorTable { -public: - class NameIndex; - class NameIterator; - class ValueIterator; - - /// DWARF v5 Name Index header. - struct Header { - uint64_t UnitLength; - dwarf::DwarfFormat Format; - uint16_t Version; - uint32_t CompUnitCount; - uint32_t LocalTypeUnitCount; - uint32_t ForeignTypeUnitCount; - uint32_t BucketCount; - uint32_t NameCount; - uint32_t AbbrevTableSize; - uint32_t AugmentationStringSize; - SmallString<8> AugmentationString; - - Error extract(const DWARFDataExtractor &AS, uint64_t *Offset); - void dump(ScopedPrinter &W) const; - }; - - /// Index attribute and its encoding. - struct AttributeEncoding { - dwarf::Index Index; - dwarf::Form Form; - - constexpr AttributeEncoding(dwarf::Index Index, dwarf::Form Form) - : Index(Index), Form(Form) {} - - friend bool operator==(const AttributeEncoding &LHS, - const AttributeEncoding &RHS) { - return LHS.Index == RHS.Index && LHS.Form == RHS.Form; - } - }; - - /// Abbreviation describing the encoding of Name Index entries. - struct Abbrev { - uint32_t Code; ///< Abbreviation code - dwarf::Tag Tag; ///< Dwarf Tag of the described entity. - std::vector<AttributeEncoding> Attributes; ///< List of index attributes. - - Abbrev(uint32_t Code, dwarf::Tag Tag, - std::vector<AttributeEncoding> Attributes) - : Code(Code), Tag(Tag), Attributes(std::move(Attributes)) {} - - void dump(ScopedPrinter &W) const; - }; - - /// DWARF v5-specific implementation of an Accelerator Entry. - class Entry final : public DWARFAcceleratorTable::Entry { - const NameIndex *NameIdx; - const Abbrev *Abbr; - - Entry(const NameIndex &NameIdx, const Abbrev &Abbr); - - public: - Optional<uint64_t> getCUOffset() const override; - Optional<dwarf::Tag> getTag() const override { return tag(); } - - /// Returns the Index into the Compilation Unit list of the owning Name - /// Index or None if this Accelerator Entry does not have an associated - /// Compilation Unit. It is up to the user to verify that the returned Index - /// is valid in the owning NameIndex (or use getCUOffset(), which will - /// handle that check itself). Note that entries in NameIndexes which index - /// just a single Compilation Unit are implicitly associated with that unit, - /// so this function will return 0 even without an explicit - /// DW_IDX_compile_unit attribute. - Optional<uint64_t> getCUIndex() const; - - /// .debug_names-specific getter, which always succeeds (DWARF v5 index - /// entries always have a tag). - dwarf::Tag tag() const { return Abbr->Tag; } - - /// Returns the Offset of the DIE within the containing CU or TU. - Optional<uint64_t> getDIEUnitOffset() const; - - /// Return the Abbreviation that can be used to interpret the raw values of - /// this Accelerator Entry. - const Abbrev &getAbbrev() const { return *Abbr; } - - /// Returns the value of the Index Attribute in this Accelerator Entry, if - /// the Entry contains such Attribute. - Optional<DWARFFormValue> lookup(dwarf::Index Index) const; - - void dump(ScopedPrinter &W) const; - - friend class NameIndex; - friend class ValueIterator; - }; - - /// Error returned by NameIndex::getEntry to report it has reached the end of - /// the entry list. - class SentinelError : public ErrorInfo<SentinelError> { - public: - static char ID; - - void log(raw_ostream &OS) const override { OS << "Sentinel"; } - std::error_code convertToErrorCode() const override; - }; - -private: - /// DenseMapInfo for struct Abbrev. - struct AbbrevMapInfo { - static Abbrev getEmptyKey(); - static Abbrev getTombstoneKey(); - static unsigned getHashValue(uint32_t Code) { - return DenseMapInfo<uint32_t>::getHashValue(Code); - } - static unsigned getHashValue(const Abbrev &Abbr) { - return getHashValue(Abbr.Code); - } - static bool isEqual(uint32_t LHS, const Abbrev &RHS) { - return LHS == RHS.Code; - } - static bool isEqual(const Abbrev &LHS, const Abbrev &RHS) { - return LHS.Code == RHS.Code; - } - }; - -public: - /// A single entry in the Name Table (DWARF v5 sect. 6.1.1.4.6) of the Name - /// Index. - class NameTableEntry { - DataExtractor StrData; - - uint32_t Index; - uint64_t StringOffset; - uint64_t EntryOffset; - - public: - NameTableEntry(const DataExtractor &StrData, uint32_t Index, - uint64_t StringOffset, uint64_t EntryOffset) - : StrData(StrData), Index(Index), StringOffset(StringOffset), - EntryOffset(EntryOffset) {} - - /// Return the index of this name in the parent Name Index. - uint32_t getIndex() const { return Index; } - - /// Returns the offset of the name of the described entities. - uint64_t getStringOffset() const { return StringOffset; } - - /// Return the string referenced by this name table entry or nullptr if the - /// string offset is not valid. - const char *getString() const { - uint64_t Off = StringOffset; - return StrData.getCStr(&Off); - } - - /// Returns the offset of the first Entry in the list. - uint64_t getEntryOffset() const { return EntryOffset; } - }; - - /// Represents a single accelerator table within the DWARF v5 .debug_names - /// section. - class NameIndex { - DenseSet<Abbrev, AbbrevMapInfo> Abbrevs; - struct Header Hdr; - const DWARFDebugNames &Section; - - // Base of the whole unit and of various important tables, as offsets from - // the start of the section. - uint64_t Base; - uint64_t CUsBase; - uint64_t BucketsBase; - uint64_t HashesBase; - uint64_t StringOffsetsBase; - uint64_t EntryOffsetsBase; - uint64_t EntriesBase; - - void dumpCUs(ScopedPrinter &W) const; - void dumpLocalTUs(ScopedPrinter &W) const; - void dumpForeignTUs(ScopedPrinter &W) const; - void dumpAbbreviations(ScopedPrinter &W) const; - bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const; - void dumpName(ScopedPrinter &W, const NameTableEntry &NTE, - Optional<uint32_t> Hash) const; - void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; - - Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset); - - Expected<std::vector<AttributeEncoding>> - extractAttributeEncodings(uint64_t *Offset); - - Expected<Abbrev> extractAbbrev(uint64_t *Offset); - - public: - NameIndex(const DWARFDebugNames &Section, uint64_t Base) - : Section(Section), Base(Base) {} - - /// Reads offset of compilation unit CU. CU is 0-based. - uint64_t getCUOffset(uint32_t CU) const; - uint32_t getCUCount() const { return Hdr.CompUnitCount; } - - /// Reads offset of local type unit TU, TU is 0-based. - uint64_t getLocalTUOffset(uint32_t TU) const; - uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; } - - /// Reads signature of foreign type unit TU. TU is 0-based. - uint64_t getForeignTUSignature(uint32_t TU) const; - uint32_t getForeignTUCount() const { return Hdr.ForeignTypeUnitCount; } - - /// Reads an entry in the Bucket Array for the given Bucket. The returned - /// value is a (1-based) index into the Names, StringOffsets and - /// EntryOffsets arrays. The input Bucket index is 0-based. - uint32_t getBucketArrayEntry(uint32_t Bucket) const; - uint32_t getBucketCount() const { return Hdr.BucketCount; } - - /// Reads an entry in the Hash Array for the given Index. The input Index - /// is 1-based. - uint32_t getHashArrayEntry(uint32_t Index) const; - - /// Reads an entry in the Name Table for the given Index. The Name Table - /// consists of two arrays -- String Offsets and Entry Offsets. The returned - /// offsets are relative to the starts of respective sections. Input Index - /// is 1-based. - NameTableEntry getNameTableEntry(uint32_t Index) const; - - uint32_t getNameCount() const { return Hdr.NameCount; } - - const DenseSet<Abbrev, AbbrevMapInfo> &getAbbrevs() const { - return Abbrevs; - } - - Expected<Entry> getEntry(uint64_t *Offset) const; - - /// Look up all entries in this Name Index matching \c Key. - iterator_range<ValueIterator> equal_range(StringRef Key) const; - - NameIterator begin() const { return NameIterator(this, 1); } - NameIterator end() const { return NameIterator(this, getNameCount() + 1); } - - Error extract(); - uint64_t getUnitOffset() const { return Base; } - uint64_t getNextUnitOffset() const { - return Base + dwarf::getUnitLengthFieldByteSize(Hdr.Format) + - Hdr.UnitLength; - } - void dump(ScopedPrinter &W) const; - - friend class DWARFDebugNames; - }; - - class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> { - - /// The Name Index we are currently iterating through. The implementation - /// relies on the fact that this can also be used as an iterator into the - /// "NameIndices" vector in the Accelerator section. - const NameIndex *CurrentIndex = nullptr; - - /// Whether this is a local iterator (searches in CurrentIndex only) or not - /// (searches all name indices). - bool IsLocal; - - Optional<Entry> CurrentEntry; - uint64_t DataOffset = 0; ///< Offset into the section. - std::string Key; ///< The Key we are searching for. - Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed. - - bool getEntryAtCurrentOffset(); - Optional<uint64_t> findEntryOffsetInCurrentIndex(); - bool findInCurrentIndex(); - void searchFromStartOfCurrentIndex(); - void next(); - - /// Set the iterator to the "end" state. - void setEnd() { *this = ValueIterator(); } - - public: - /// Create a "begin" iterator for looping over all entries in the - /// accelerator table matching Key. The iterator will run through all Name - /// Indexes in the section in sequence. - ValueIterator(const DWARFDebugNames &AccelTable, StringRef Key); - - /// Create a "begin" iterator for looping over all entries in a specific - /// Name Index. Other indices in the section will not be visited. - ValueIterator(const NameIndex &NI, StringRef Key); - - /// End marker. - ValueIterator() = default; - - const Entry &operator*() const { return *CurrentEntry; } - ValueIterator &operator++() { - next(); - return *this; - } - ValueIterator operator++(int) { - ValueIterator I = *this; - next(); - return I; - } - - friend bool operator==(const ValueIterator &A, const ValueIterator &B) { - return A.CurrentIndex == B.CurrentIndex && A.DataOffset == B.DataOffset; - } - friend bool operator!=(const ValueIterator &A, const ValueIterator &B) { - return !(A == B); - } - }; - - class NameIterator { - - /// The Name Index we are iterating through. - const NameIndex *CurrentIndex; - - /// The current name in the Name Index. - uint32_t CurrentName; - - void next() { - assert(CurrentName <= CurrentIndex->getNameCount()); - ++CurrentName; - } - - public: - using iterator_category = std::input_iterator_tag; - using value_type = NameTableEntry; - using difference_type = uint32_t; - using pointer = NameTableEntry *; - using reference = NameTableEntry; // We return entries by value. - - /// Creates an iterator whose initial position is name CurrentName in - /// CurrentIndex. - NameIterator(const NameIndex *CurrentIndex, uint32_t CurrentName) - : CurrentIndex(CurrentIndex), CurrentName(CurrentName) {} - - NameTableEntry operator*() const { - return CurrentIndex->getNameTableEntry(CurrentName); - } - NameIterator &operator++() { - next(); - return *this; - } - NameIterator operator++(int) { - NameIterator I = *this; - next(); - return I; - } - - friend bool operator==(const NameIterator &A, const NameIterator &B) { - return A.CurrentIndex == B.CurrentIndex && A.CurrentName == B.CurrentName; - } - friend bool operator!=(const NameIterator &A, const NameIterator &B) { - return !(A == B); - } - }; - -private: - SmallVector<NameIndex, 0> NameIndices; - DenseMap<uint64_t, const NameIndex *> CUToNameIndex; - -public: - DWARFDebugNames(const DWARFDataExtractor &AccelSection, - DataExtractor StringSection) - : DWARFAcceleratorTable(AccelSection, StringSection) {} - - Error extract() override; - void dump(raw_ostream &OS) const override; - - /// Look up all entries in the accelerator table matching \c Key. - iterator_range<ValueIterator> equal_range(StringRef Key) const; - - using const_iterator = SmallVector<NameIndex, 0>::const_iterator; - const_iterator begin() const { return NameIndices.begin(); } - const_iterator end() const { return NameIndices.end(); } - - /// Return the Name Index covering the compile unit at CUOffset, or nullptr if - /// there is no Name Index covering that unit. - const NameIndex *getCUNameIndex(uint64_t CUOffset); -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFAcceleratorTable.h ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H +#define LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H + +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include <cstdint> +#include <utility> + +namespace llvm { + +class raw_ostream; +class ScopedPrinter; + +/// The accelerator tables are designed to allow efficient random access +/// (using a symbol name as a key) into debug info by providing an index of the +/// debug info DIEs. This class implements the common functionality of Apple and +/// DWARF 5 accelerator tables. +/// TODO: Generalize the rest of the AppleAcceleratorTable interface and move it +/// to this class. +class DWARFAcceleratorTable { +protected: + DWARFDataExtractor AccelSection; + DataExtractor StringSection; + +public: + /// An abstract class representing a single entry in the accelerator tables. + class Entry { + protected: + SmallVector<DWARFFormValue, 3> Values; + + Entry() = default; + + // Make these protected so only (final) subclasses can be copied around. + Entry(const Entry &) = default; + Entry(Entry &&) = default; + Entry &operator=(const Entry &) = default; + Entry &operator=(Entry &&) = default; + ~Entry() = default; + + + public: + /// Returns the Offset of the Compilation Unit associated with this + /// Accelerator Entry or None if the Compilation Unit offset is not recorded + /// in this Accelerator Entry. + virtual Optional<uint64_t> getCUOffset() const = 0; + + /// Returns the Tag of the Debug Info Entry associated with this + /// Accelerator Entry or None if the Tag is not recorded in this + /// Accelerator Entry. + virtual Optional<dwarf::Tag> getTag() const = 0; + + /// Returns the raw values of fields in the Accelerator Entry. In general, + /// these can only be interpreted with the help of the metadata in the + /// owning Accelerator Table. + ArrayRef<DWARFFormValue> getValues() const { return Values; } + }; + + DWARFAcceleratorTable(const DWARFDataExtractor &AccelSection, + DataExtractor StringSection) + : AccelSection(AccelSection), StringSection(StringSection) {} + virtual ~DWARFAcceleratorTable(); + + virtual Error extract() = 0; + virtual void dump(raw_ostream &OS) const = 0; + + DWARFAcceleratorTable(const DWARFAcceleratorTable &) = delete; + void operator=(const DWARFAcceleratorTable &) = delete; +}; + +/// This implements the Apple accelerator table format, a precursor of the +/// DWARF 5 accelerator table format. +class AppleAcceleratorTable : public DWARFAcceleratorTable { + struct Header { + uint32_t Magic; + uint16_t Version; + uint16_t HashFunction; + uint32_t BucketCount; + uint32_t HashCount; + uint32_t HeaderDataLength; + + void dump(ScopedPrinter &W) const; + }; + + struct HeaderData { + using AtomType = uint16_t; + using Form = dwarf::Form; + + uint64_t DIEOffsetBase; + SmallVector<std::pair<AtomType, Form>, 3> Atoms; + + Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const; + }; + + struct Header Hdr; + struct HeaderData HdrData; + bool IsValid = false; + + /// Returns true if we should continue scanning for entries or false if we've + /// reached the last (sentinel) entry of encountered a parsing error. + bool dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms, + uint64_t *DataOffset) const; + +public: + /// Apple-specific implementation of an Accelerator Entry. + class Entry final : public DWARFAcceleratorTable::Entry { + const HeaderData *HdrData = nullptr; + + Entry(const HeaderData &Data); + Entry() = default; + + void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); + + public: + Optional<uint64_t> getCUOffset() const override; + + /// Returns the Section Offset of the Debug Info Entry associated with this + /// Accelerator Entry or None if the DIE offset is not recorded in this + /// Accelerator Entry. The returned offset is relative to the start of the + /// Section containing the DIE. + Optional<uint64_t> getDIESectionOffset() const; + + Optional<dwarf::Tag> getTag() const override; + + /// Returns the value of the Atom in this Accelerator Entry, if the Entry + /// contains such Atom. + Optional<DWARFFormValue> lookup(HeaderData::AtomType Atom) const; + + friend class AppleAcceleratorTable; + friend class ValueIterator; + }; + + class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> { + const AppleAcceleratorTable *AccelTable = nullptr; + Entry Current; ///< The current entry. + uint64_t DataOffset = 0; ///< Offset into the section. + unsigned Data = 0; ///< Current data entry. + unsigned NumData = 0; ///< Number of data entries. + + /// Advance the iterator. + void Next(); + public: + /// Construct a new iterator for the entries at \p DataOffset. + ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset); + /// End marker. + ValueIterator() = default; + + const Entry &operator*() const { return Current; } + ValueIterator &operator++() { Next(); return *this; } + ValueIterator operator++(int) { + ValueIterator I = *this; + Next(); + return I; + } + friend bool operator==(const ValueIterator &A, const ValueIterator &B) { + return A.NumData == B.NumData && A.DataOffset == B.DataOffset; + } + friend bool operator!=(const ValueIterator &A, const ValueIterator &B) { + return !(A == B); + } + }; + + AppleAcceleratorTable(const DWARFDataExtractor &AccelSection, + DataExtractor StringSection) + : DWARFAcceleratorTable(AccelSection, StringSection) {} + + Error extract() override; + uint32_t getNumBuckets(); + uint32_t getNumHashes(); + uint32_t getSizeHdr(); + uint32_t getHeaderDataLength(); + + /// Return the Atom description, which can be used to interpret the raw values + /// of the Accelerator Entries in this table. + ArrayRef<std::pair<HeaderData::AtomType, HeaderData::Form>> getAtomsDesc(); + bool validateForms(); + + /// Return information related to the DWARF DIE we're looking for when + /// performing a lookup by name. + /// + /// \param HashDataOffset an offset into the hash data table + /// \returns <DieOffset, DieTag> + /// DieOffset is the offset into the .debug_info section for the DIE + /// related to the input hash data offset. + /// DieTag is the tag of the DIE + std::pair<uint64_t, dwarf::Tag> readAtoms(uint64_t *HashDataOffset); + void dump(raw_ostream &OS) const override; + + /// Look up all entries in the accelerator table matching \c Key. + iterator_range<ValueIterator> equal_range(StringRef Key) const; +}; + +/// .debug_names section consists of one or more units. Each unit starts with a +/// header, which is followed by a list of compilation units, local and foreign +/// type units. +/// +/// These may be followed by an (optional) hash lookup table, which consists of +/// an array of buckets and hashes similar to the apple tables above. The only +/// difference is that the hashes array is 1-based, and consequently an empty +/// bucket is denoted by 0 and not UINT32_MAX. +/// +/// Next is the name table, which consists of an array of names and array of +/// entry offsets. This is different from the apple tables, which store names +/// next to the actual entries. +/// +/// The structure of the entries is described by an abbreviations table, which +/// comes after the name table. Unlike the apple tables, which have a uniform +/// entry structure described in the header, each .debug_names entry may have +/// different index attributes (DW_IDX_???) attached to it. +/// +/// The last segment consists of a list of entries, which is a 0-terminated list +/// referenced by the name table and interpreted with the help of the +/// abbreviation table. +class DWARFDebugNames : public DWARFAcceleratorTable { +public: + class NameIndex; + class NameIterator; + class ValueIterator; + + /// DWARF v5 Name Index header. + struct Header { + uint64_t UnitLength; + dwarf::DwarfFormat Format; + uint16_t Version; + uint32_t CompUnitCount; + uint32_t LocalTypeUnitCount; + uint32_t ForeignTypeUnitCount; + uint32_t BucketCount; + uint32_t NameCount; + uint32_t AbbrevTableSize; + uint32_t AugmentationStringSize; + SmallString<8> AugmentationString; + + Error extract(const DWARFDataExtractor &AS, uint64_t *Offset); + void dump(ScopedPrinter &W) const; + }; + + /// Index attribute and its encoding. + struct AttributeEncoding { + dwarf::Index Index; + dwarf::Form Form; + + constexpr AttributeEncoding(dwarf::Index Index, dwarf::Form Form) + : Index(Index), Form(Form) {} + + friend bool operator==(const AttributeEncoding &LHS, + const AttributeEncoding &RHS) { + return LHS.Index == RHS.Index && LHS.Form == RHS.Form; + } + }; + + /// Abbreviation describing the encoding of Name Index entries. + struct Abbrev { + uint32_t Code; ///< Abbreviation code + dwarf::Tag Tag; ///< Dwarf Tag of the described entity. + std::vector<AttributeEncoding> Attributes; ///< List of index attributes. + + Abbrev(uint32_t Code, dwarf::Tag Tag, + std::vector<AttributeEncoding> Attributes) + : Code(Code), Tag(Tag), Attributes(std::move(Attributes)) {} + + void dump(ScopedPrinter &W) const; + }; + + /// DWARF v5-specific implementation of an Accelerator Entry. + class Entry final : public DWARFAcceleratorTable::Entry { + const NameIndex *NameIdx; + const Abbrev *Abbr; + + Entry(const NameIndex &NameIdx, const Abbrev &Abbr); + + public: + Optional<uint64_t> getCUOffset() const override; + Optional<dwarf::Tag> getTag() const override { return tag(); } + + /// Returns the Index into the Compilation Unit list of the owning Name + /// Index or None if this Accelerator Entry does not have an associated + /// Compilation Unit. It is up to the user to verify that the returned Index + /// is valid in the owning NameIndex (or use getCUOffset(), which will + /// handle that check itself). Note that entries in NameIndexes which index + /// just a single Compilation Unit are implicitly associated with that unit, + /// so this function will return 0 even without an explicit + /// DW_IDX_compile_unit attribute. + Optional<uint64_t> getCUIndex() const; + + /// .debug_names-specific getter, which always succeeds (DWARF v5 index + /// entries always have a tag). + dwarf::Tag tag() const { return Abbr->Tag; } + + /// Returns the Offset of the DIE within the containing CU or TU. + Optional<uint64_t> getDIEUnitOffset() const; + + /// Return the Abbreviation that can be used to interpret the raw values of + /// this Accelerator Entry. + const Abbrev &getAbbrev() const { return *Abbr; } + + /// Returns the value of the Index Attribute in this Accelerator Entry, if + /// the Entry contains such Attribute. + Optional<DWARFFormValue> lookup(dwarf::Index Index) const; + + void dump(ScopedPrinter &W) const; + + friend class NameIndex; + friend class ValueIterator; + }; + + /// Error returned by NameIndex::getEntry to report it has reached the end of + /// the entry list. + class SentinelError : public ErrorInfo<SentinelError> { + public: + static char ID; + + void log(raw_ostream &OS) const override { OS << "Sentinel"; } + std::error_code convertToErrorCode() const override; + }; + +private: + /// DenseMapInfo for struct Abbrev. + struct AbbrevMapInfo { + static Abbrev getEmptyKey(); + static Abbrev getTombstoneKey(); + static unsigned getHashValue(uint32_t Code) { + return DenseMapInfo<uint32_t>::getHashValue(Code); + } + static unsigned getHashValue(const Abbrev &Abbr) { + return getHashValue(Abbr.Code); + } + static bool isEqual(uint32_t LHS, const Abbrev &RHS) { + return LHS == RHS.Code; + } + static bool isEqual(const Abbrev &LHS, const Abbrev &RHS) { + return LHS.Code == RHS.Code; + } + }; + +public: + /// A single entry in the Name Table (DWARF v5 sect. 6.1.1.4.6) of the Name + /// Index. + class NameTableEntry { + DataExtractor StrData; + + uint32_t Index; + uint64_t StringOffset; + uint64_t EntryOffset; + + public: + NameTableEntry(const DataExtractor &StrData, uint32_t Index, + uint64_t StringOffset, uint64_t EntryOffset) + : StrData(StrData), Index(Index), StringOffset(StringOffset), + EntryOffset(EntryOffset) {} + + /// Return the index of this name in the parent Name Index. + uint32_t getIndex() const { return Index; } + + /// Returns the offset of the name of the described entities. + uint64_t getStringOffset() const { return StringOffset; } + + /// Return the string referenced by this name table entry or nullptr if the + /// string offset is not valid. + const char *getString() const { + uint64_t Off = StringOffset; + return StrData.getCStr(&Off); + } + + /// Returns the offset of the first Entry in the list. + uint64_t getEntryOffset() const { return EntryOffset; } + }; + + /// Represents a single accelerator table within the DWARF v5 .debug_names + /// section. + class NameIndex { + DenseSet<Abbrev, AbbrevMapInfo> Abbrevs; + struct Header Hdr; + const DWARFDebugNames &Section; + + // Base of the whole unit and of various important tables, as offsets from + // the start of the section. + uint64_t Base; + uint64_t CUsBase; + uint64_t BucketsBase; + uint64_t HashesBase; + uint64_t StringOffsetsBase; + uint64_t EntryOffsetsBase; + uint64_t EntriesBase; + + void dumpCUs(ScopedPrinter &W) const; + void dumpLocalTUs(ScopedPrinter &W) const; + void dumpForeignTUs(ScopedPrinter &W) const; + void dumpAbbreviations(ScopedPrinter &W) const; + bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const; + void dumpName(ScopedPrinter &W, const NameTableEntry &NTE, + Optional<uint32_t> Hash) const; + void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; + + Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset); + + Expected<std::vector<AttributeEncoding>> + extractAttributeEncodings(uint64_t *Offset); + + Expected<Abbrev> extractAbbrev(uint64_t *Offset); + + public: + NameIndex(const DWARFDebugNames &Section, uint64_t Base) + : Section(Section), Base(Base) {} + + /// Reads offset of compilation unit CU. CU is 0-based. + uint64_t getCUOffset(uint32_t CU) const; + uint32_t getCUCount() const { return Hdr.CompUnitCount; } + + /// Reads offset of local type unit TU, TU is 0-based. + uint64_t getLocalTUOffset(uint32_t TU) const; + uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; } + + /// Reads signature of foreign type unit TU. TU is 0-based. + uint64_t getForeignTUSignature(uint32_t TU) const; + uint32_t getForeignTUCount() const { return Hdr.ForeignTypeUnitCount; } + + /// Reads an entry in the Bucket Array for the given Bucket. The returned + /// value is a (1-based) index into the Names, StringOffsets and + /// EntryOffsets arrays. The input Bucket index is 0-based. + uint32_t getBucketArrayEntry(uint32_t Bucket) const; + uint32_t getBucketCount() const { return Hdr.BucketCount; } + + /// Reads an entry in the Hash Array for the given Index. The input Index + /// is 1-based. + uint32_t getHashArrayEntry(uint32_t Index) const; + + /// Reads an entry in the Name Table for the given Index. The Name Table + /// consists of two arrays -- String Offsets and Entry Offsets. The returned + /// offsets are relative to the starts of respective sections. Input Index + /// is 1-based. + NameTableEntry getNameTableEntry(uint32_t Index) const; + + uint32_t getNameCount() const { return Hdr.NameCount; } + + const DenseSet<Abbrev, AbbrevMapInfo> &getAbbrevs() const { + return Abbrevs; + } + + Expected<Entry> getEntry(uint64_t *Offset) const; + + /// Look up all entries in this Name Index matching \c Key. + iterator_range<ValueIterator> equal_range(StringRef Key) const; + + NameIterator begin() const { return NameIterator(this, 1); } + NameIterator end() const { return NameIterator(this, getNameCount() + 1); } + + Error extract(); + uint64_t getUnitOffset() const { return Base; } + uint64_t getNextUnitOffset() const { + return Base + dwarf::getUnitLengthFieldByteSize(Hdr.Format) + + Hdr.UnitLength; + } + void dump(ScopedPrinter &W) const; + + friend class DWARFDebugNames; + }; + + class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> { + + /// The Name Index we are currently iterating through. The implementation + /// relies on the fact that this can also be used as an iterator into the + /// "NameIndices" vector in the Accelerator section. + const NameIndex *CurrentIndex = nullptr; + + /// Whether this is a local iterator (searches in CurrentIndex only) or not + /// (searches all name indices). + bool IsLocal; + + Optional<Entry> CurrentEntry; + uint64_t DataOffset = 0; ///< Offset into the section. + std::string Key; ///< The Key we are searching for. + Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed. + + bool getEntryAtCurrentOffset(); + Optional<uint64_t> findEntryOffsetInCurrentIndex(); + bool findInCurrentIndex(); + void searchFromStartOfCurrentIndex(); + void next(); + + /// Set the iterator to the "end" state. + void setEnd() { *this = ValueIterator(); } + + public: + /// Create a "begin" iterator for looping over all entries in the + /// accelerator table matching Key. The iterator will run through all Name + /// Indexes in the section in sequence. + ValueIterator(const DWARFDebugNames &AccelTable, StringRef Key); + + /// Create a "begin" iterator for looping over all entries in a specific + /// Name Index. Other indices in the section will not be visited. + ValueIterator(const NameIndex &NI, StringRef Key); + + /// End marker. + ValueIterator() = default; + + const Entry &operator*() const { return *CurrentEntry; } + ValueIterator &operator++() { + next(); + return *this; + } + ValueIterator operator++(int) { + ValueIterator I = *this; + next(); + return I; + } + + friend bool operator==(const ValueIterator &A, const ValueIterator &B) { + return A.CurrentIndex == B.CurrentIndex && A.DataOffset == B.DataOffset; + } + friend bool operator!=(const ValueIterator &A, const ValueIterator &B) { + return !(A == B); + } + }; + + class NameIterator { + + /// The Name Index we are iterating through. + const NameIndex *CurrentIndex; + + /// The current name in the Name Index. + uint32_t CurrentName; + + void next() { + assert(CurrentName <= CurrentIndex->getNameCount()); + ++CurrentName; + } + + public: + using iterator_category = std::input_iterator_tag; + using value_type = NameTableEntry; + using difference_type = uint32_t; + using pointer = NameTableEntry *; + using reference = NameTableEntry; // We return entries by value. + + /// Creates an iterator whose initial position is name CurrentName in + /// CurrentIndex. + NameIterator(const NameIndex *CurrentIndex, uint32_t CurrentName) + : CurrentIndex(CurrentIndex), CurrentName(CurrentName) {} + + NameTableEntry operator*() const { + return CurrentIndex->getNameTableEntry(CurrentName); + } + NameIterator &operator++() { + next(); + return *this; + } + NameIterator operator++(int) { + NameIterator I = *this; + next(); + return I; + } + + friend bool operator==(const NameIterator &A, const NameIterator &B) { + return A.CurrentIndex == B.CurrentIndex && A.CurrentName == B.CurrentName; + } + friend bool operator!=(const NameIterator &A, const NameIterator &B) { + return !(A == B); + } + }; + +private: + SmallVector<NameIndex, 0> NameIndices; + DenseMap<uint64_t, const NameIndex *> CUToNameIndex; + +public: + DWARFDebugNames(const DWARFDataExtractor &AccelSection, + DataExtractor StringSection) + : DWARFAcceleratorTable(AccelSection, StringSection) {} + + Error extract() override; + void dump(raw_ostream &OS) const override; + + /// Look up all entries in the accelerator table matching \c Key. + iterator_range<ValueIterator> equal_range(StringRef Key) const; + + using const_iterator = SmallVector<NameIndex, 0>::const_iterator; + const_iterator begin() const { return NameIndices.begin(); } + const_iterator end() const { return NameIndices.end(); } + + /// Return the Name Index covering the compile unit at CUOffset, or nullptr if + /// there is no Name Index covering that unit. + const NameIndex *getCUNameIndex(uint64_t CUOffset); +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h index b4de0593e3..3fa41abdba 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h @@ -1,98 +1,98 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFAddressRange.h --------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H -#define LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H - -#include "llvm/DebugInfo/DIContext.h" -#include <cstdint> -#include <tuple> -#include <vector> - -namespace llvm { - -class raw_ostream; -class DWARFObject; - -struct DWARFAddressRange { - uint64_t LowPC; - uint64_t HighPC; - uint64_t SectionIndex; - - DWARFAddressRange() = default; - - /// Used for unit testing. - DWARFAddressRange( - uint64_t LowPC, uint64_t HighPC, - uint64_t SectionIndex = object::SectionedAddress::UndefSection) - : LowPC(LowPC), HighPC(HighPC), SectionIndex(SectionIndex) {} - - /// Returns true if LowPC is smaller or equal to HighPC. This accounts for - /// dead-stripped ranges. - bool valid() const { return LowPC <= HighPC; } - - /// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC). - bool intersects(const DWARFAddressRange &RHS) const { - assert(valid() && RHS.valid()); - // Empty ranges can't intersect. - if (LowPC == HighPC || RHS.LowPC == RHS.HighPC) - return false; - return LowPC < RHS.HighPC && RHS.LowPC < HighPC; - } - - /// Union two address ranges if they intersect. - /// - /// This function will union two address ranges if they intersect by - /// modifying this range to be the union of both ranges. If the two ranges - /// don't intersect this range will be left alone. - /// - /// \param RHS Another address range to combine with. - /// - /// \returns false if the ranges don't intersect, true if they do and the - /// ranges were combined. - bool merge(const DWARFAddressRange &RHS) { - if (!intersects(RHS)) - return false; - LowPC = std::min<uint64_t>(LowPC, RHS.LowPC); - HighPC = std::max<uint64_t>(HighPC, RHS.HighPC); - return true; - } - - void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts = {}, - const DWARFObject *Obj = nullptr) const; -}; - -inline bool operator<(const DWARFAddressRange &LHS, - const DWARFAddressRange &RHS) { - return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC); -} - -inline bool operator==(const DWARFAddressRange &LHS, - const DWARFAddressRange &RHS) { - return std::tie(LHS.LowPC, LHS.HighPC) == std::tie(RHS.LowPC, RHS.HighPC); -} - -raw_ostream &operator<<(raw_ostream &OS, const DWARFAddressRange &R); - -/// DWARFAddressRangesVector - represents a set of absolute address ranges. -using DWARFAddressRangesVector = std::vector<DWARFAddressRange>; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFAddressRange.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H +#define LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H + +#include "llvm/DebugInfo/DIContext.h" +#include <cstdint> +#include <tuple> +#include <vector> + +namespace llvm { + +class raw_ostream; +class DWARFObject; + +struct DWARFAddressRange { + uint64_t LowPC; + uint64_t HighPC; + uint64_t SectionIndex; + + DWARFAddressRange() = default; + + /// Used for unit testing. + DWARFAddressRange( + uint64_t LowPC, uint64_t HighPC, + uint64_t SectionIndex = object::SectionedAddress::UndefSection) + : LowPC(LowPC), HighPC(HighPC), SectionIndex(SectionIndex) {} + + /// Returns true if LowPC is smaller or equal to HighPC. This accounts for + /// dead-stripped ranges. + bool valid() const { return LowPC <= HighPC; } + + /// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC). + bool intersects(const DWARFAddressRange &RHS) const { + assert(valid() && RHS.valid()); + // Empty ranges can't intersect. + if (LowPC == HighPC || RHS.LowPC == RHS.HighPC) + return false; + return LowPC < RHS.HighPC && RHS.LowPC < HighPC; + } + + /// Union two address ranges if they intersect. + /// + /// This function will union two address ranges if they intersect by + /// modifying this range to be the union of both ranges. If the two ranges + /// don't intersect this range will be left alone. + /// + /// \param RHS Another address range to combine with. + /// + /// \returns false if the ranges don't intersect, true if they do and the + /// ranges were combined. + bool merge(const DWARFAddressRange &RHS) { + if (!intersects(RHS)) + return false; + LowPC = std::min<uint64_t>(LowPC, RHS.LowPC); + HighPC = std::max<uint64_t>(HighPC, RHS.HighPC); + return true; + } + + void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts = {}, + const DWARFObject *Obj = nullptr) const; +}; + +inline bool operator<(const DWARFAddressRange &LHS, + const DWARFAddressRange &RHS) { + return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC); +} + +inline bool operator==(const DWARFAddressRange &LHS, + const DWARFAddressRange &RHS) { + return std::tie(LHS.LowPC, LHS.HighPC) == std::tie(RHS.LowPC, RHS.HighPC); +} + +raw_ostream &operator<<(raw_ostream &OS, const DWARFAddressRange &R); + +/// DWARFAddressRangesVector - represents a set of absolute address ranges. +using DWARFAddressRangesVector = std::vector<DWARFAddressRange>; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAttribute.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAttribute.h index d88b9ece6f..7ed48a382e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAttribute.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFAttribute.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFAttribute.h -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFATTRIBUTE_H -#define LLVM_DEBUGINFO_DWARFATTRIBUTE_H - -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include <cstdint> - -namespace llvm { - -//===----------------------------------------------------------------------===// -/// Encapsulates a DWARF attribute value and all of the data required to -/// describe the attribute value. -/// -/// This class is designed to be used by clients that want to iterate across all -/// attributes in a DWARFDie. -struct DWARFAttribute { - /// The debug info/types offset for this attribute. - uint64_t Offset = 0; - /// The debug info/types section byte size of the data for this attribute. - uint32_t ByteSize = 0; - /// The attribute enumeration of this attribute. - dwarf::Attribute Attr = dwarf::Attribute(0); - /// The form and value for this attribute. - DWARFFormValue Value; - - bool isValid() const { - return Offset != 0 && Attr != dwarf::Attribute(0); - } - - explicit operator bool() const { - return isValid(); - } - - /// Identifies DWARF attributes that may contain a reference to a - /// DWARF expression. - static bool mayHaveLocationDescription(dwarf::Attribute Attr); -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFATTRIBUTE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFAttribute.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFATTRIBUTE_H +#define LLVM_DEBUGINFO_DWARFATTRIBUTE_H + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include <cstdint> + +namespace llvm { + +//===----------------------------------------------------------------------===// +/// Encapsulates a DWARF attribute value and all of the data required to +/// describe the attribute value. +/// +/// This class is designed to be used by clients that want to iterate across all +/// attributes in a DWARFDie. +struct DWARFAttribute { + /// The debug info/types offset for this attribute. + uint64_t Offset = 0; + /// The debug info/types section byte size of the data for this attribute. + uint32_t ByteSize = 0; + /// The attribute enumeration of this attribute. + dwarf::Attribute Attr = dwarf::Attribute(0); + /// The form and value for this attribute. + DWARFFormValue Value; + + bool isValid() const { + return Offset != 0 && Attr != dwarf::Attribute(0); + } + + explicit operator bool() const { + return isValid(); + } + + /// Identifies DWARF attributes that may contain a reference to a + /// DWARF expression. + static bool mayHaveLocationDescription(dwarf::Attribute Attr); +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFATTRIBUTE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h index e6a246b85e..e6b7b89355 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h @@ -1,49 +1,49 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFCompileUnit.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H -#define LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H - -#include "llvm/DebugInfo/DWARF/DWARFUnit.h" -#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" - -namespace llvm { - -class DWARFCompileUnit : public DWARFUnit { -public: - DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, - const DWARFSection *RS, const DWARFSection *LocSection, - StringRef SS, const DWARFSection &SOS, - const DWARFSection *AOS, const DWARFSection &LS, bool LE, - bool IsDWO, const DWARFUnitVector &UnitVector) - : DWARFUnit(Context, Section, Header, DA, RS, LocSection, SS, SOS, AOS, - LS, LE, IsDWO, UnitVector) {} - - /// VTable anchor. - ~DWARFCompileUnit() override; - /// Dump this compile unit to \p OS. - void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override; - /// Enable LLVM-style RTTI. - static bool classof(const DWARFUnit *U) { return !U->isTypeUnit(); } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFCompileUnit.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H +#define LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H + +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" + +namespace llvm { + +class DWARFCompileUnit : public DWARFUnit { +public: + DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, const DWARFSection *LocSection, + StringRef SS, const DWARFSection &SOS, + const DWARFSection *AOS, const DWARFSection &LS, bool LE, + bool IsDWO, const DWARFUnitVector &UnitVector) + : DWARFUnit(Context, Section, Header, DA, RS, LocSection, SS, SOS, AOS, + LS, LE, IsDWO, UnitVector) {} + + /// VTable anchor. + ~DWARFCompileUnit() override; + /// Dump this compile unit to \p OS. + void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override; + /// Enable LLVM-style RTTI. + static bool classof(const DWARFUnit *U) { return !U->isTypeUnit(); } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFCOMPILEUNIT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFContext.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFContext.h index e9d11a7008..e382fe4aa2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -1,442 +1,442 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFContext.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===/ - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H -#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H - -#include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" -#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugAranges.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" -#include "llvm/DebugInfo/DWARF/DWARFDie.h" -#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" -#include "llvm/DebugInfo/DWARF/DWARFObject.h" -#include "llvm/DebugInfo/DWARF/DWARFSection.h" -#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" -#include "llvm/DebugInfo/DWARF/DWARFUnit.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/Error.h" -#include "llvm/Support/Host.h" -#include <cstdint> -#include <deque> -#include <map> -#include <memory> - -namespace llvm { - -class MCRegisterInfo; -class MemoryBuffer; -class raw_ostream; - -/// DWARFContext -/// This data structure is the top level entity that deals with dwarf debug -/// information parsing. The actual data is supplied through DWARFObj. -class DWARFContext : public DIContext { - DWARFUnitVector NormalUnits; - std::unique_ptr<DWARFUnitIndex> CUIndex; - std::unique_ptr<DWARFGdbIndex> GdbIndex; - std::unique_ptr<DWARFUnitIndex> TUIndex; - std::unique_ptr<DWARFDebugAbbrev> Abbrev; - std::unique_ptr<DWARFDebugLoc> Loc; - std::unique_ptr<DWARFDebugAranges> Aranges; - std::unique_ptr<DWARFDebugLine> Line; - std::unique_ptr<DWARFDebugFrame> DebugFrame; - std::unique_ptr<DWARFDebugFrame> EHFrame; - std::unique_ptr<DWARFDebugMacro> Macro; - std::unique_ptr<DWARFDebugMacro> Macinfo; - std::unique_ptr<DWARFDebugNames> Names; - std::unique_ptr<AppleAcceleratorTable> AppleNames; - std::unique_ptr<AppleAcceleratorTable> AppleTypes; - std::unique_ptr<AppleAcceleratorTable> AppleNamespaces; - std::unique_ptr<AppleAcceleratorTable> AppleObjC; - - DWARFUnitVector DWOUnits; - std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO; - std::unique_ptr<DWARFDebugMacro> MacinfoDWO; - std::unique_ptr<DWARFDebugMacro> MacroDWO; - - /// The maximum DWARF version of all units. - unsigned MaxVersion = 0; - - struct DWOFile { - object::OwningBinary<object::ObjectFile> File; - std::unique_ptr<DWARFContext> Context; - }; - StringMap<std::weak_ptr<DWOFile>> DWOFiles; - std::weak_ptr<DWOFile> DWP; - bool CheckedForDWP = false; - std::string DWPName; - - std::unique_ptr<MCRegisterInfo> RegInfo; - - std::function<void(Error)> RecoverableErrorHandler = - WithColor::defaultErrorHandler; - std::function<void(Error)> WarningHandler = WithColor::defaultWarningHandler; - - /// Read compile units from the debug_info section (if necessary) - /// and type units from the debug_types sections (if necessary) - /// and store them in NormalUnits. - void parseNormalUnits(); - - /// Read compile units from the debug_info.dwo section (if necessary) - /// and type units from the debug_types.dwo section (if necessary) - /// and store them in DWOUnits. - /// If \p Lazy is true, set up to parse but don't actually parse them. - enum { EagerParse = false, LazyParse = true }; - void parseDWOUnits(bool Lazy = false); - - std::unique_ptr<const DWARFObject> DObj; - - /// Helper enum to distinguish between macro[.dwo] and macinfo[.dwo] - /// section. - enum MacroSecType { - MacinfoSection, - MacinfoDwoSection, - MacroSection, - MacroDwoSection - }; - -public: - DWARFContext(std::unique_ptr<const DWARFObject> DObj, - std::string DWPName = "", - std::function<void(Error)> RecoverableErrorHandler = - WithColor::defaultErrorHandler, - std::function<void(Error)> WarningHandler = - WithColor::defaultWarningHandler); - ~DWARFContext(); - - DWARFContext(DWARFContext &) = delete; - DWARFContext &operator=(DWARFContext &) = delete; - - const DWARFObject &getDWARFObj() const { return *DObj; } - - static bool classof(const DIContext *DICtx) { - return DICtx->getKind() == CK_DWARF; - } - - /// Dump a textual representation to \p OS. If any \p DumpOffsets are present, - /// dump only the record at the specified offset. - void dump(raw_ostream &OS, DIDumpOptions DumpOpts, - std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets); - - void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override { - std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets; - dump(OS, DumpOpts, DumpOffsets); - } - - bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; - - using unit_iterator_range = DWARFUnitVector::iterator_range; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFContext.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===/ + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H +#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H + +#include "llvm/ADT/MapVector.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" +#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugAranges.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" +#include "llvm/DebugInfo/DWARF/DWARFDie.h" +#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h" +#include "llvm/DebugInfo/DWARF/DWARFObject.h" +#include "llvm/DebugInfo/DWARF/DWARFSection.h" +#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.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/Error.h" +#include "llvm/Support/Host.h" +#include <cstdint> +#include <deque> +#include <map> +#include <memory> + +namespace llvm { + +class MCRegisterInfo; +class MemoryBuffer; +class raw_ostream; + +/// DWARFContext +/// This data structure is the top level entity that deals with dwarf debug +/// information parsing. The actual data is supplied through DWARFObj. +class DWARFContext : public DIContext { + DWARFUnitVector NormalUnits; + std::unique_ptr<DWARFUnitIndex> CUIndex; + std::unique_ptr<DWARFGdbIndex> GdbIndex; + std::unique_ptr<DWARFUnitIndex> TUIndex; + std::unique_ptr<DWARFDebugAbbrev> Abbrev; + std::unique_ptr<DWARFDebugLoc> Loc; + std::unique_ptr<DWARFDebugAranges> Aranges; + std::unique_ptr<DWARFDebugLine> Line; + std::unique_ptr<DWARFDebugFrame> DebugFrame; + std::unique_ptr<DWARFDebugFrame> EHFrame; + std::unique_ptr<DWARFDebugMacro> Macro; + std::unique_ptr<DWARFDebugMacro> Macinfo; + std::unique_ptr<DWARFDebugNames> Names; + std::unique_ptr<AppleAcceleratorTable> AppleNames; + std::unique_ptr<AppleAcceleratorTable> AppleTypes; + std::unique_ptr<AppleAcceleratorTable> AppleNamespaces; + std::unique_ptr<AppleAcceleratorTable> AppleObjC; + + DWARFUnitVector DWOUnits; + std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO; + std::unique_ptr<DWARFDebugMacro> MacinfoDWO; + std::unique_ptr<DWARFDebugMacro> MacroDWO; + + /// The maximum DWARF version of all units. + unsigned MaxVersion = 0; + + struct DWOFile { + object::OwningBinary<object::ObjectFile> File; + std::unique_ptr<DWARFContext> Context; + }; + StringMap<std::weak_ptr<DWOFile>> DWOFiles; + std::weak_ptr<DWOFile> DWP; + bool CheckedForDWP = false; + std::string DWPName; + + std::unique_ptr<MCRegisterInfo> RegInfo; + + std::function<void(Error)> RecoverableErrorHandler = + WithColor::defaultErrorHandler; + std::function<void(Error)> WarningHandler = WithColor::defaultWarningHandler; + + /// Read compile units from the debug_info section (if necessary) + /// and type units from the debug_types sections (if necessary) + /// and store them in NormalUnits. + void parseNormalUnits(); + + /// Read compile units from the debug_info.dwo section (if necessary) + /// and type units from the debug_types.dwo section (if necessary) + /// and store them in DWOUnits. + /// If \p Lazy is true, set up to parse but don't actually parse them. + enum { EagerParse = false, LazyParse = true }; + void parseDWOUnits(bool Lazy = false); + + std::unique_ptr<const DWARFObject> DObj; + + /// Helper enum to distinguish between macro[.dwo] and macinfo[.dwo] + /// section. + enum MacroSecType { + MacinfoSection, + MacinfoDwoSection, + MacroSection, + MacroDwoSection + }; + +public: + DWARFContext(std::unique_ptr<const DWARFObject> DObj, + std::string DWPName = "", + std::function<void(Error)> RecoverableErrorHandler = + WithColor::defaultErrorHandler, + std::function<void(Error)> WarningHandler = + WithColor::defaultWarningHandler); + ~DWARFContext(); + + DWARFContext(DWARFContext &) = delete; + DWARFContext &operator=(DWARFContext &) = delete; + + const DWARFObject &getDWARFObj() const { return *DObj; } + + static bool classof(const DIContext *DICtx) { + return DICtx->getKind() == CK_DWARF; + } + + /// Dump a textual representation to \p OS. If any \p DumpOffsets are present, + /// dump only the record at the specified offset. + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, + std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets); + + void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override { + std::array<Optional<uint64_t>, DIDT_ID_Count> DumpOffsets; + dump(OS, DumpOpts, DumpOffsets); + } + + bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; + + using unit_iterator_range = DWARFUnitVector::iterator_range; using compile_unit_range = DWARFUnitVector::compile_unit_range; - - /// Get units from .debug_info in this context. - unit_iterator_range info_section_units() { - parseNormalUnits(); - return unit_iterator_range(NormalUnits.begin(), - NormalUnits.begin() + - NormalUnits.getNumInfoUnits()); - } - - /// Get units from .debug_types in this context. - unit_iterator_range types_section_units() { - parseNormalUnits(); - return unit_iterator_range( - NormalUnits.begin() + NormalUnits.getNumInfoUnits(), NormalUnits.end()); - } - - /// Get compile units in this context. + + /// Get units from .debug_info in this context. + unit_iterator_range info_section_units() { + parseNormalUnits(); + return unit_iterator_range(NormalUnits.begin(), + NormalUnits.begin() + + NormalUnits.getNumInfoUnits()); + } + + /// Get units from .debug_types in this context. + unit_iterator_range types_section_units() { + parseNormalUnits(); + return unit_iterator_range( + NormalUnits.begin() + NormalUnits.getNumInfoUnits(), NormalUnits.end()); + } + + /// Get compile units in this context. compile_unit_range compile_units() { return make_filter_range(info_section_units(), isCompileUnit); } - + // If you want type_units(), it'll need to be a concat iterator of a filter of // TUs in info_section + all the (all type) units in types_section - - /// Get all normal compile/type units in this context. - unit_iterator_range normal_units() { - parseNormalUnits(); - return unit_iterator_range(NormalUnits.begin(), NormalUnits.end()); - } - - /// Get units from .debug_info..dwo in the DWO context. - unit_iterator_range dwo_info_section_units() { - parseDWOUnits(); - return unit_iterator_range(DWOUnits.begin(), - DWOUnits.begin() + DWOUnits.getNumInfoUnits()); - } - - /// Get units from .debug_types.dwo in the DWO context. - unit_iterator_range dwo_types_section_units() { - parseDWOUnits(); - return unit_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(), - DWOUnits.end()); - } - - /// Get compile units in the DWO context. + + /// Get all normal compile/type units in this context. + unit_iterator_range normal_units() { + parseNormalUnits(); + return unit_iterator_range(NormalUnits.begin(), NormalUnits.end()); + } + + /// Get units from .debug_info..dwo in the DWO context. + unit_iterator_range dwo_info_section_units() { + parseDWOUnits(); + return unit_iterator_range(DWOUnits.begin(), + DWOUnits.begin() + DWOUnits.getNumInfoUnits()); + } + + /// Get units from .debug_types.dwo in the DWO context. + unit_iterator_range dwo_types_section_units() { + parseDWOUnits(); + return unit_iterator_range(DWOUnits.begin() + DWOUnits.getNumInfoUnits(), + DWOUnits.end()); + } + + /// Get compile units in the DWO context. compile_unit_range dwo_compile_units() { return make_filter_range(dwo_info_section_units(), isCompileUnit); } - + // If you want dwo_type_units(), it'll need to be a concat iterator of a // filter of TUs in dwo_info_section + all the (all type) units in // dwo_types_section. - - /// Get all units in the DWO context. - unit_iterator_range dwo_units() { - parseDWOUnits(); - return unit_iterator_range(DWOUnits.begin(), DWOUnits.end()); - } - - /// Get the number of compile units in this context. - unsigned getNumCompileUnits() { - parseNormalUnits(); - return NormalUnits.getNumInfoUnits(); - } - - /// Get the number of type units in this context. - unsigned getNumTypeUnits() { - parseNormalUnits(); - return NormalUnits.getNumTypesUnits(); - } - - /// Get the number of compile units in the DWO context. - unsigned getNumDWOCompileUnits() { - parseDWOUnits(); - return DWOUnits.getNumInfoUnits(); - } - - /// Get the number of type units in the DWO context. - unsigned getNumDWOTypeUnits() { - parseDWOUnits(); - return DWOUnits.getNumTypesUnits(); - } - - /// Get the unit at the specified index. - DWARFUnit *getUnitAtIndex(unsigned index) { - parseNormalUnits(); - return NormalUnits[index].get(); - } - - /// Get the unit at the specified index for the DWO units. - DWARFUnit *getDWOUnitAtIndex(unsigned index) { - parseDWOUnits(); - return DWOUnits[index].get(); - } - - DWARFCompileUnit *getDWOCompileUnitForHash(uint64_t Hash); - - /// Return the compile unit that includes an offset (relative to .debug_info). - DWARFCompileUnit *getCompileUnitForOffset(uint64_t Offset); - - /// Get a DIE given an exact offset. - DWARFDie getDIEForOffset(uint64_t Offset); - - unsigned getMaxVersion() { - // Ensure info units have been parsed to discover MaxVersion - info_section_units(); - return MaxVersion; - } - - unsigned getMaxDWOVersion() { - // Ensure DWO info units have been parsed to discover MaxVersion - dwo_info_section_units(); - return MaxVersion; - } - - void setMaxVersionIfGreater(unsigned Version) { - if (Version > MaxVersion) - MaxVersion = Version; - } - - const DWARFUnitIndex &getCUIndex(); - DWARFGdbIndex &getGdbIndex(); - const DWARFUnitIndex &getTUIndex(); - - /// Get a pointer to the parsed DebugAbbrev object. - const DWARFDebugAbbrev *getDebugAbbrev(); - - /// Get a pointer to the parsed DebugLoc object. - const DWARFDebugLoc *getDebugLoc(); - - /// Get a pointer to the parsed dwo abbreviations object. - const DWARFDebugAbbrev *getDebugAbbrevDWO(); - - /// Get a pointer to the parsed DebugAranges object. - const DWARFDebugAranges *getDebugAranges(); - - /// Get a pointer to the parsed frame information object. - Expected<const DWARFDebugFrame *> getDebugFrame(); - - /// Get a pointer to the parsed eh frame information object. - Expected<const DWARFDebugFrame *> getEHFrame(); - - /// Get a pointer to the parsed DebugMacinfo information object. - const DWARFDebugMacro *getDebugMacinfo(); - - /// Get a pointer to the parsed DebugMacinfoDWO information object. - const DWARFDebugMacro *getDebugMacinfoDWO(); - - /// Get a pointer to the parsed DebugMacro information object. - const DWARFDebugMacro *getDebugMacro(); - - /// Get a pointer to the parsed DebugMacroDWO information object. - const DWARFDebugMacro *getDebugMacroDWO(); - - /// Get a reference to the parsed accelerator table object. - const DWARFDebugNames &getDebugNames(); - - /// Get a reference to the parsed accelerator table object. - const AppleAcceleratorTable &getAppleNames(); - - /// Get a reference to the parsed accelerator table object. - const AppleAcceleratorTable &getAppleTypes(); - - /// Get a reference to the parsed accelerator table object. - const AppleAcceleratorTable &getAppleNamespaces(); - - /// Get a reference to the parsed accelerator table object. - const AppleAcceleratorTable &getAppleObjC(); - - /// Get a pointer to a parsed line table corresponding to a compile unit. - /// Report any parsing issues as warnings on stderr. - const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *U); - - /// Get a pointer to a parsed line table corresponding to a compile unit. - /// Report any recoverable parsing problems using the handler. - Expected<const DWARFDebugLine::LineTable *> - getLineTableForUnit(DWARFUnit *U, - function_ref<void(Error)> RecoverableErrorHandler); - - DataExtractor getStringExtractor() const { - return DataExtractor(DObj->getStrSection(), false, 0); - } - DataExtractor getStringDWOExtractor() const { - return DataExtractor(DObj->getStrDWOSection(), false, 0); - } - DataExtractor getLineStringExtractor() const { - return DataExtractor(DObj->getLineStrSection(), false, 0); - } - - /// Wraps the returned DIEs for a given address. - struct DIEsForAddress { - DWARFCompileUnit *CompileUnit = nullptr; - DWARFDie FunctionDIE; - DWARFDie BlockDIE; - explicit operator bool() const { return CompileUnit != nullptr; } - }; - - /// Get the compilation unit, the function DIE and lexical block DIE for the - /// given address where applicable. - /// TODO: change input parameter from "uint64_t Address" - /// into "SectionedAddress Address" - DIEsForAddress getDIEsForAddress(uint64_t Address); - - DILineInfo getLineInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DILineInfoTable getLineInfoForAddressRange( - object::SectionedAddress Address, uint64_t Size, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DIInliningInfo getInliningInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - - std::vector<DILocal> - getLocalsForAddress(object::SectionedAddress Address) override; - - bool isLittleEndian() const { return DObj->isLittleEndian(); } - static bool isSupportedVersion(unsigned version) { - return version == 2 || version == 3 || version == 4 || version == 5; - } - - static bool isAddressSizeSupported(unsigned AddressSize) { - return AddressSize == 2 || AddressSize == 4 || AddressSize == 8; - } - - std::shared_ptr<DWARFContext> getDWOContext(StringRef AbsolutePath); - - const MCRegisterInfo *getRegisterInfo() const { return RegInfo.get(); } - - function_ref<void(Error)> getRecoverableErrorHandler() { - return RecoverableErrorHandler; - } - - function_ref<void(Error)> getWarningHandler() { return WarningHandler; } - - static std::unique_ptr<DWARFContext> - create(const object::ObjectFile &Obj, const LoadedObjectInfo *L = nullptr, - std::string DWPName = "", - std::function<void(Error)> RecoverableErrorHandler = - WithColor::defaultErrorHandler, - std::function<void(Error)> WarningHandler = - WithColor::defaultWarningHandler); - - static std::unique_ptr<DWARFContext> - create(const StringMap<std::unique_ptr<MemoryBuffer>> &Sections, - uint8_t AddrSize, bool isLittleEndian = sys::IsLittleEndianHost, - std::function<void(Error)> RecoverableErrorHandler = - WithColor::defaultErrorHandler, - std::function<void(Error)> WarningHandler = - WithColor::defaultWarningHandler); - - /// Loads register info for the architecture of the provided object file. - /// Improves readability of dumped DWARF expressions. Requires the caller to - /// have initialized the relevant target descriptions. - Error loadRegisterInfo(const object::ObjectFile &Obj); - - /// Get address size from CUs. - /// TODO: refactor compile_units() to make this const. - uint8_t getCUAddrSize(); - - Triple::ArchType getArch() const { - return getDWARFObj().getFile()->getArch(); - } - - /// Return the compile unit which contains instruction with provided - /// address. - /// TODO: change input parameter from "uint64_t Address" - /// into "SectionedAddress Address" - DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address); - -private: - /// Parse a macro[.dwo] or macinfo[.dwo] section. - std::unique_ptr<DWARFDebugMacro> - parseMacroOrMacinfo(MacroSecType SectionType); - - void addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram, DWARFDie Die, - std::vector<DILocal> &Result); -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + + /// Get all units in the DWO context. + unit_iterator_range dwo_units() { + parseDWOUnits(); + return unit_iterator_range(DWOUnits.begin(), DWOUnits.end()); + } + + /// Get the number of compile units in this context. + unsigned getNumCompileUnits() { + parseNormalUnits(); + return NormalUnits.getNumInfoUnits(); + } + + /// Get the number of type units in this context. + unsigned getNumTypeUnits() { + parseNormalUnits(); + return NormalUnits.getNumTypesUnits(); + } + + /// Get the number of compile units in the DWO context. + unsigned getNumDWOCompileUnits() { + parseDWOUnits(); + return DWOUnits.getNumInfoUnits(); + } + + /// Get the number of type units in the DWO context. + unsigned getNumDWOTypeUnits() { + parseDWOUnits(); + return DWOUnits.getNumTypesUnits(); + } + + /// Get the unit at the specified index. + DWARFUnit *getUnitAtIndex(unsigned index) { + parseNormalUnits(); + return NormalUnits[index].get(); + } + + /// Get the unit at the specified index for the DWO units. + DWARFUnit *getDWOUnitAtIndex(unsigned index) { + parseDWOUnits(); + return DWOUnits[index].get(); + } + + DWARFCompileUnit *getDWOCompileUnitForHash(uint64_t Hash); + + /// Return the compile unit that includes an offset (relative to .debug_info). + DWARFCompileUnit *getCompileUnitForOffset(uint64_t Offset); + + /// Get a DIE given an exact offset. + DWARFDie getDIEForOffset(uint64_t Offset); + + unsigned getMaxVersion() { + // Ensure info units have been parsed to discover MaxVersion + info_section_units(); + return MaxVersion; + } + + unsigned getMaxDWOVersion() { + // Ensure DWO info units have been parsed to discover MaxVersion + dwo_info_section_units(); + return MaxVersion; + } + + void setMaxVersionIfGreater(unsigned Version) { + if (Version > MaxVersion) + MaxVersion = Version; + } + + const DWARFUnitIndex &getCUIndex(); + DWARFGdbIndex &getGdbIndex(); + const DWARFUnitIndex &getTUIndex(); + + /// Get a pointer to the parsed DebugAbbrev object. + const DWARFDebugAbbrev *getDebugAbbrev(); + + /// Get a pointer to the parsed DebugLoc object. + const DWARFDebugLoc *getDebugLoc(); + + /// Get a pointer to the parsed dwo abbreviations object. + const DWARFDebugAbbrev *getDebugAbbrevDWO(); + + /// Get a pointer to the parsed DebugAranges object. + const DWARFDebugAranges *getDebugAranges(); + + /// Get a pointer to the parsed frame information object. + Expected<const DWARFDebugFrame *> getDebugFrame(); + + /// Get a pointer to the parsed eh frame information object. + Expected<const DWARFDebugFrame *> getEHFrame(); + + /// Get a pointer to the parsed DebugMacinfo information object. + const DWARFDebugMacro *getDebugMacinfo(); + + /// Get a pointer to the parsed DebugMacinfoDWO information object. + const DWARFDebugMacro *getDebugMacinfoDWO(); + + /// Get a pointer to the parsed DebugMacro information object. + const DWARFDebugMacro *getDebugMacro(); + + /// Get a pointer to the parsed DebugMacroDWO information object. + const DWARFDebugMacro *getDebugMacroDWO(); + + /// Get a reference to the parsed accelerator table object. + const DWARFDebugNames &getDebugNames(); + + /// Get a reference to the parsed accelerator table object. + const AppleAcceleratorTable &getAppleNames(); + + /// Get a reference to the parsed accelerator table object. + const AppleAcceleratorTable &getAppleTypes(); + + /// Get a reference to the parsed accelerator table object. + const AppleAcceleratorTable &getAppleNamespaces(); + + /// Get a reference to the parsed accelerator table object. + const AppleAcceleratorTable &getAppleObjC(); + + /// Get a pointer to a parsed line table corresponding to a compile unit. + /// Report any parsing issues as warnings on stderr. + const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *U); + + /// Get a pointer to a parsed line table corresponding to a compile unit. + /// Report any recoverable parsing problems using the handler. + Expected<const DWARFDebugLine::LineTable *> + getLineTableForUnit(DWARFUnit *U, + function_ref<void(Error)> RecoverableErrorHandler); + + DataExtractor getStringExtractor() const { + return DataExtractor(DObj->getStrSection(), false, 0); + } + DataExtractor getStringDWOExtractor() const { + return DataExtractor(DObj->getStrDWOSection(), false, 0); + } + DataExtractor getLineStringExtractor() const { + return DataExtractor(DObj->getLineStrSection(), false, 0); + } + + /// Wraps the returned DIEs for a given address. + struct DIEsForAddress { + DWARFCompileUnit *CompileUnit = nullptr; + DWARFDie FunctionDIE; + DWARFDie BlockDIE; + explicit operator bool() const { return CompileUnit != nullptr; } + }; + + /// Get the compilation unit, the function DIE and lexical block DIE for the + /// given address where applicable. + /// TODO: change input parameter from "uint64_t Address" + /// into "SectionedAddress Address" + DIEsForAddress getDIEsForAddress(uint64_t Address); + + DILineInfo getLineInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DILineInfoTable getLineInfoForAddressRange( + object::SectionedAddress Address, uint64_t Size, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DIInliningInfo getInliningInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + + std::vector<DILocal> + getLocalsForAddress(object::SectionedAddress Address) override; + + bool isLittleEndian() const { return DObj->isLittleEndian(); } + static bool isSupportedVersion(unsigned version) { + return version == 2 || version == 3 || version == 4 || version == 5; + } + + static bool isAddressSizeSupported(unsigned AddressSize) { + return AddressSize == 2 || AddressSize == 4 || AddressSize == 8; + } + + std::shared_ptr<DWARFContext> getDWOContext(StringRef AbsolutePath); + + const MCRegisterInfo *getRegisterInfo() const { return RegInfo.get(); } + + function_ref<void(Error)> getRecoverableErrorHandler() { + return RecoverableErrorHandler; + } + + function_ref<void(Error)> getWarningHandler() { return WarningHandler; } + + static std::unique_ptr<DWARFContext> + create(const object::ObjectFile &Obj, const LoadedObjectInfo *L = nullptr, + std::string DWPName = "", + std::function<void(Error)> RecoverableErrorHandler = + WithColor::defaultErrorHandler, + std::function<void(Error)> WarningHandler = + WithColor::defaultWarningHandler); + + static std::unique_ptr<DWARFContext> + create(const StringMap<std::unique_ptr<MemoryBuffer>> &Sections, + uint8_t AddrSize, bool isLittleEndian = sys::IsLittleEndianHost, + std::function<void(Error)> RecoverableErrorHandler = + WithColor::defaultErrorHandler, + std::function<void(Error)> WarningHandler = + WithColor::defaultWarningHandler); + + /// Loads register info for the architecture of the provided object file. + /// Improves readability of dumped DWARF expressions. Requires the caller to + /// have initialized the relevant target descriptions. + Error loadRegisterInfo(const object::ObjectFile &Obj); + + /// Get address size from CUs. + /// TODO: refactor compile_units() to make this const. + uint8_t getCUAddrSize(); + + Triple::ArchType getArch() const { + return getDWARFObj().getFile()->getArch(); + } + + /// Return the compile unit which contains instruction with provided + /// address. + /// TODO: change input parameter from "uint64_t Address" + /// into "SectionedAddress Address" + DWARFCompileUnit *getCompileUnitForAddress(uint64_t Address); + +private: + /// Parse a macro[.dwo] or macinfo[.dwo] section. + std::unique_ptr<DWARFDebugMacro> + parseMacroOrMacinfo(MacroSecType SectionType); + + void addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram, DWARFDie Die, + std::vector<DILocal> &Result); +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h index c4ef506698..6ad47383d0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h @@ -1,101 +1,101 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDataExtractor.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H -#define LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H - -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFSection.h" -#include "llvm/Support/DataExtractor.h" - -namespace llvm { -class DWARFObject; - -/// A DataExtractor (typically for an in-memory copy of an object-file section) -/// plus a relocation map for that section, if there is one. -class DWARFDataExtractor : public DataExtractor { - const DWARFObject *Obj = nullptr; - const DWARFSection *Section = nullptr; - -public: - /// Constructor for the normal case of extracting data from a DWARF section. - /// The DWARFSection's lifetime must be at least as long as the extractor's. - DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section, - bool IsLittleEndian, uint8_t AddressSize) - : DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj), - Section(&Section) {} - - /// Constructor for cases when there are no relocations. - DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize) - : DataExtractor(Data, IsLittleEndian, AddressSize) {} - DWARFDataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian, - uint8_t AddressSize) - : DataExtractor( - StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()), - IsLittleEndian, AddressSize) {} - - /// Truncating constructor - DWARFDataExtractor(const DWARFDataExtractor &Other, size_t Length) - : DataExtractor(Other.getData().substr(0, Length), Other.isLittleEndian(), - Other.getAddressSize()), - Obj(Other.Obj), Section(Other.Section) {} - - /// Extracts the DWARF "initial length" field, which can either be a 32-bit - /// value smaller than 0xfffffff0, or the value 0xffffffff followed by a - /// 64-bit length. Returns the actual length, and the DWARF format which is - /// encoded in the field. In case of errors, it returns {0, DWARF32} and - /// leaves the offset unchanged. - std::pair<uint64_t, dwarf::DwarfFormat> - getInitialLength(uint64_t *Off, Error *Err = nullptr) const; - - std::pair<uint64_t, dwarf::DwarfFormat> getInitialLength(Cursor &C) const { - return getInitialLength(&getOffset(C), &getError(C)); - } - - /// Extracts a value and applies a relocation to the result if - /// one exists for the given offset. - uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off, - uint64_t *SectionIndex = nullptr, - Error *Err = nullptr) const; - uint64_t getRelocatedValue(Cursor &C, uint32_t Size, - uint64_t *SectionIndex = nullptr) const { - return getRelocatedValue(Size, &getOffset(C), SectionIndex, &getError(C)); - } - - /// Extracts an address-sized value and applies a relocation to the result if - /// one exists for the given offset. - uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const { - return getRelocatedValue(getAddressSize(), Off, SecIx); - } - uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const { - return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx, - &getError(C)); - } - - /// Extracts a DWARF-encoded pointer in \p Offset using \p Encoding. - /// There is a DWARF encoding that uses a PC-relative adjustment. - /// For these values, \p AbsPosOffset is used to fix them, which should - /// reflect the absolute address of this pointer. - Optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding, - uint64_t AbsPosOffset = 0) const; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDataExtractor.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H +#define LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFSection.h" +#include "llvm/Support/DataExtractor.h" + +namespace llvm { +class DWARFObject; + +/// A DataExtractor (typically for an in-memory copy of an object-file section) +/// plus a relocation map for that section, if there is one. +class DWARFDataExtractor : public DataExtractor { + const DWARFObject *Obj = nullptr; + const DWARFSection *Section = nullptr; + +public: + /// Constructor for the normal case of extracting data from a DWARF section. + /// The DWARFSection's lifetime must be at least as long as the extractor's. + DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section, + bool IsLittleEndian, uint8_t AddressSize) + : DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj), + Section(&Section) {} + + /// Constructor for cases when there are no relocations. + DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize) + : DataExtractor(Data, IsLittleEndian, AddressSize) {} + DWARFDataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian, + uint8_t AddressSize) + : DataExtractor( + StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()), + IsLittleEndian, AddressSize) {} + + /// Truncating constructor + DWARFDataExtractor(const DWARFDataExtractor &Other, size_t Length) + : DataExtractor(Other.getData().substr(0, Length), Other.isLittleEndian(), + Other.getAddressSize()), + Obj(Other.Obj), Section(Other.Section) {} + + /// Extracts the DWARF "initial length" field, which can either be a 32-bit + /// value smaller than 0xfffffff0, or the value 0xffffffff followed by a + /// 64-bit length. Returns the actual length, and the DWARF format which is + /// encoded in the field. In case of errors, it returns {0, DWARF32} and + /// leaves the offset unchanged. + std::pair<uint64_t, dwarf::DwarfFormat> + getInitialLength(uint64_t *Off, Error *Err = nullptr) const; + + std::pair<uint64_t, dwarf::DwarfFormat> getInitialLength(Cursor &C) const { + return getInitialLength(&getOffset(C), &getError(C)); + } + + /// Extracts a value and applies a relocation to the result if + /// one exists for the given offset. + uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off, + uint64_t *SectionIndex = nullptr, + Error *Err = nullptr) const; + uint64_t getRelocatedValue(Cursor &C, uint32_t Size, + uint64_t *SectionIndex = nullptr) const { + return getRelocatedValue(Size, &getOffset(C), SectionIndex, &getError(C)); + } + + /// Extracts an address-sized value and applies a relocation to the result if + /// one exists for the given offset. + uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const { + return getRelocatedValue(getAddressSize(), Off, SecIx); + } + uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const { + return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx, + &getError(C)); + } + + /// Extracts a DWARF-encoded pointer in \p Offset using \p Encoding. + /// There is a DWARF encoding that uses a PC-relative adjustment. + /// For these values, \p AbsPosOffset is used to fix them, which should + /// reflect the absolute address of this pointer. + Optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding, + uint64_t AbsPosOffset = 0) const; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDATAEXTRACTOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h index b4d546dbdc..8ac2a9ada2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -1,98 +1,98 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugAbbrev.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H -#define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H - -#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" -#include "llvm/Support/DataExtractor.h" -#include <cstdint> -#include <map> -#include <vector> - -namespace llvm { - -class raw_ostream; - -class DWARFAbbreviationDeclarationSet { - uint64_t Offset; - /// Code of the first abbreviation, if all abbreviations in the set have - /// consecutive codes. UINT32_MAX otherwise. - uint32_t FirstAbbrCode; - std::vector<DWARFAbbreviationDeclaration> Decls; - - using const_iterator = - std::vector<DWARFAbbreviationDeclaration>::const_iterator; - -public: - DWARFAbbreviationDeclarationSet(); - - uint64_t getOffset() const { return Offset; } - void dump(raw_ostream &OS) const; - bool extract(DataExtractor Data, uint64_t *OffsetPtr); - - const DWARFAbbreviationDeclaration * - getAbbreviationDeclaration(uint32_t AbbrCode) const; - - const_iterator begin() const { - return Decls.begin(); - } - - const_iterator end() const { - return Decls.end(); - } - -private: - void clear(); -}; - -class DWARFDebugAbbrev { - using DWARFAbbreviationDeclarationSetMap = - std::map<uint64_t, DWARFAbbreviationDeclarationSet>; - - mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets; - mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; - mutable Optional<DataExtractor> Data; - -public: - DWARFDebugAbbrev(); - - const DWARFAbbreviationDeclarationSet * - getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const; - - void dump(raw_ostream &OS) const; - void parse() const; - void extract(DataExtractor Data); - - DWARFAbbreviationDeclarationSetMap::const_iterator begin() const { - parse(); - return AbbrDeclSets.begin(); - } - - DWARFAbbreviationDeclarationSetMap::const_iterator end() const { - return AbbrDeclSets.end(); - } - -private: - void clear(); -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugAbbrev.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H +#define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H + +#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" +#include "llvm/Support/DataExtractor.h" +#include <cstdint> +#include <map> +#include <vector> + +namespace llvm { + +class raw_ostream; + +class DWARFAbbreviationDeclarationSet { + uint64_t Offset; + /// Code of the first abbreviation, if all abbreviations in the set have + /// consecutive codes. UINT32_MAX otherwise. + uint32_t FirstAbbrCode; + std::vector<DWARFAbbreviationDeclaration> Decls; + + using const_iterator = + std::vector<DWARFAbbreviationDeclaration>::const_iterator; + +public: + DWARFAbbreviationDeclarationSet(); + + uint64_t getOffset() const { return Offset; } + void dump(raw_ostream &OS) const; + bool extract(DataExtractor Data, uint64_t *OffsetPtr); + + const DWARFAbbreviationDeclaration * + getAbbreviationDeclaration(uint32_t AbbrCode) const; + + const_iterator begin() const { + return Decls.begin(); + } + + const_iterator end() const { + return Decls.end(); + } + +private: + void clear(); +}; + +class DWARFDebugAbbrev { + using DWARFAbbreviationDeclarationSetMap = + std::map<uint64_t, DWARFAbbreviationDeclarationSet>; + + mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets; + mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos; + mutable Optional<DataExtractor> Data; + +public: + DWARFDebugAbbrev(); + + const DWARFAbbreviationDeclarationSet * + getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const; + + void dump(raw_ostream &OS) const; + void parse() const; + void extract(DataExtractor Data); + + DWARFAbbreviationDeclarationSetMap::const_iterator begin() const { + parse(); + return AbbrDeclSets.begin(); + } + + DWARFAbbreviationDeclarationSetMap::const_iterator end() const { + return AbbrDeclSets.end(); + } + +private: + void clear(); +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h index 6a8b1634f2..ca499104dc 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -1,86 +1,86 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugAddr.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGADDR_H -#define LLVM_DEBUGINFO_DWARFDEBUGADDR_H - -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/Support/Errc.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <map> -#include <vector> - -namespace llvm { - -class Error; -class raw_ostream; - -/// A class representing an address table as specified in DWARF v5. -/// The table consists of a header followed by an array of address values from -/// .debug_addr section. -class DWARFDebugAddrTable { - dwarf::DwarfFormat Format; - uint64_t Offset; - /// The total length of the entries for this table, not including the length - /// field itself. - uint64_t Length = 0; - /// The DWARF version number. - uint16_t Version; - /// The size in bytes of an address on the target architecture. For - /// segmented addressing, this is the size of the offset portion of the - /// address. - uint8_t AddrSize; - /// The size in bytes of a segment selector on the target architecture. - /// If the target system uses a flat address space, this value is 0. - uint8_t SegSize; - std::vector<uint64_t> Addrs; - - /// Invalidate Length field to stop further processing. - void invalidateLength() { Length = 0; } - - Error extractAddresses(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - uint64_t EndOffset); - -public: - - /// Extract the entire table, including all addresses. - Error extract(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - uint16_t CUVersion, uint8_t CUAddrSize, - std::function<void(Error)> WarnCallback); - - /// Extract a DWARFv5 address table. - Error extractV5(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - uint8_t CUAddrSize, std::function<void(Error)> WarnCallback); - - /// Extract a pre-DWARFv5 address table. Such tables do not have a header - /// and consist only of a series of addresses. - /// See https://gcc.gnu.org/wiki/DebugFission for details. - Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - uint16_t CUVersion, uint8_t CUAddrSize); - - void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; - - /// Return the address based on a given index. - Expected<uint64_t> getAddrEntry(uint32_t Index) const; - - /// Return the full length of this table, including the length field. - /// Return None if the length cannot be identified reliably. - Optional<uint64_t> getFullLength() const; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugAddr.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGADDR_H +#define LLVM_DEBUGINFO_DWARFDEBUGADDR_H + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/Support/Errc.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <map> +#include <vector> + +namespace llvm { + +class Error; +class raw_ostream; + +/// A class representing an address table as specified in DWARF v5. +/// The table consists of a header followed by an array of address values from +/// .debug_addr section. +class DWARFDebugAddrTable { + dwarf::DwarfFormat Format; + uint64_t Offset; + /// The total length of the entries for this table, not including the length + /// field itself. + uint64_t Length = 0; + /// The DWARF version number. + uint16_t Version; + /// The size in bytes of an address on the target architecture. For + /// segmented addressing, this is the size of the offset portion of the + /// address. + uint8_t AddrSize; + /// The size in bytes of a segment selector on the target architecture. + /// If the target system uses a flat address space, this value is 0. + uint8_t SegSize; + std::vector<uint64_t> Addrs; + + /// Invalidate Length field to stop further processing. + void invalidateLength() { Length = 0; } + + Error extractAddresses(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + uint64_t EndOffset); + +public: + + /// Extract the entire table, including all addresses. + Error extract(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + uint16_t CUVersion, uint8_t CUAddrSize, + std::function<void(Error)> WarnCallback); + + /// Extract a DWARFv5 address table. + Error extractV5(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + uint8_t CUAddrSize, std::function<void(Error)> WarnCallback); + + /// Extract a pre-DWARFv5 address table. Such tables do not have a header + /// and consist only of a series of addresses. + /// See https://gcc.gnu.org/wiki/DebugFission for details. + Error extractPreStandard(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + uint16_t CUVersion, uint8_t CUAddrSize); + + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; + + /// Return the address based on a given index. + Expected<uint64_t> getAddrEntry(uint32_t Index) const; + + /// Return the full length of this table, including the length field. + /// Return None if the length cannot be identified reliably. + Optional<uint64_t> getFullLength() const; /// Return the DWARF format of this table. dwarf::DwarfFormat getFormat() const { return Format; } @@ -99,12 +99,12 @@ public: /// Return the parsed addresses of this table. ArrayRef<uint64_t> getAddressEntries() const { return Addrs; } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGADDR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGADDR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h index 1ac9c3cc02..01d88a2f24 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -1,90 +1,90 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugArangeSet.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H -#define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H - -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -class raw_ostream; - -class DWARFDebugArangeSet { -public: - struct Header { - /// The total length of the entries for that set, not including the length - /// field itself. - uint64_t Length; - /// The DWARF format of the set. - dwarf::DwarfFormat Format; - /// The offset from the beginning of the .debug_info section of the - /// compilation unit entry referenced by the table. - uint64_t CuOffset; - /// The DWARF version number. - uint16_t Version; - /// The size in bytes of an address on the target architecture. For segmented - /// addressing, this is the size of the offset portion of the address. - uint8_t AddrSize; - /// The size in bytes of a segment descriptor on the target architecture. - /// If the target system uses a flat address space, this value is 0. - uint8_t SegSize; - }; - - struct Descriptor { - uint64_t Address; - uint64_t Length; - - uint64_t getEndAddress() const { return Address + Length; } - void dump(raw_ostream &OS, uint32_t AddressSize) const; - }; - -private: - using DescriptorColl = std::vector<Descriptor>; - using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>; - - uint64_t Offset; - Header HeaderData; - DescriptorColl ArangeDescriptors; - -public: - DWARFDebugArangeSet() { clear(); } - - void clear(); +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugArangeSet.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H +#define LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H + +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +class raw_ostream; + +class DWARFDebugArangeSet { +public: + struct Header { + /// The total length of the entries for that set, not including the length + /// field itself. + uint64_t Length; + /// The DWARF format of the set. + dwarf::DwarfFormat Format; + /// The offset from the beginning of the .debug_info section of the + /// compilation unit entry referenced by the table. + uint64_t CuOffset; + /// The DWARF version number. + uint16_t Version; + /// The size in bytes of an address on the target architecture. For segmented + /// addressing, this is the size of the offset portion of the address. + uint8_t AddrSize; + /// The size in bytes of a segment descriptor on the target architecture. + /// If the target system uses a flat address space, this value is 0. + uint8_t SegSize; + }; + + struct Descriptor { + uint64_t Address; + uint64_t Length; + + uint64_t getEndAddress() const { return Address + Length; } + void dump(raw_ostream &OS, uint32_t AddressSize) const; + }; + +private: + using DescriptorColl = std::vector<Descriptor>; + using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>; + + uint64_t Offset; + Header HeaderData; + DescriptorColl ArangeDescriptors; + +public: + DWARFDebugArangeSet() { clear(); } + + void clear(); Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, function_ref<void(Error)> WarningHandler); - void dump(raw_ostream &OS) const; - - uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } - - const Header &getHeader() const { return HeaderData; } - - desc_iterator_range descriptors() const { - return desc_iterator_range(ArangeDescriptors.begin(), - ArangeDescriptors.end()); - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + void dump(raw_ostream &OS) const; + + uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } + + const Header &getHeader() const { return HeaderData; } + + desc_iterator_range descriptors() const { + return desc_iterator_range(ArangeDescriptors.begin(), + ArangeDescriptors.end()); + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGESET_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h index 0588abccb6..59d6971669 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -1,95 +1,95 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H -#define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H - -#include "llvm/ADT/DenseSet.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -class DWARFContext; - -class DWARFDebugAranges { -public: - void generate(DWARFContext *CTX); - uint64_t findAddress(uint64_t Address) const; - -private: - void clear(); - void extract(DWARFDataExtractor DebugArangesData, - function_ref<void(Error)> RecoverableErrorHandler); - - /// Call appendRange multiple times and then call construct. - void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC); - void construct(); - - struct Range { - explicit Range(uint64_t LowPC, uint64_t HighPC, uint64_t CUOffset) - : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {} - - void setHighPC(uint64_t HighPC) { - if (HighPC == -1ULL || HighPC <= LowPC) - Length = 0; - else - Length = HighPC - LowPC; - } - - uint64_t HighPC() const { - if (Length) - return LowPC + Length; - return -1ULL; - } - - bool operator<(const Range &other) const { - return LowPC < other.LowPC; - } - - uint64_t LowPC; /// Start of address range. - uint64_t Length; /// End of address range (not including this address). - uint64_t CUOffset; /// Offset of the compile unit or die. - }; - - struct RangeEndpoint { - uint64_t Address; - uint64_t CUOffset; - bool IsRangeStart; - - RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart) - : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} - - bool operator<(const RangeEndpoint &Other) const { - return Address < Other.Address; - } - }; - - using RangeColl = std::vector<Range>; - using RangeCollIterator = RangeColl::const_iterator; - - std::vector<RangeEndpoint> Endpoints; - RangeColl Aranges; - DenseSet<uint64_t> ParsedCUOffsets; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugAranges.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H +#define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H + +#include "llvm/ADT/DenseSet.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +class DWARFContext; + +class DWARFDebugAranges { +public: + void generate(DWARFContext *CTX); + uint64_t findAddress(uint64_t Address) const; + +private: + void clear(); + void extract(DWARFDataExtractor DebugArangesData, + function_ref<void(Error)> RecoverableErrorHandler); + + /// Call appendRange multiple times and then call construct. + void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC); + void construct(); + + struct Range { + explicit Range(uint64_t LowPC, uint64_t HighPC, uint64_t CUOffset) + : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {} + + void setHighPC(uint64_t HighPC) { + if (HighPC == -1ULL || HighPC <= LowPC) + Length = 0; + else + Length = HighPC - LowPC; + } + + uint64_t HighPC() const { + if (Length) + return LowPC + Length; + return -1ULL; + } + + bool operator<(const Range &other) const { + return LowPC < other.LowPC; + } + + uint64_t LowPC; /// Start of address range. + uint64_t Length; /// End of address range (not including this address). + uint64_t CUOffset; /// Offset of the compile unit or die. + }; + + struct RangeEndpoint { + uint64_t Address; + uint64_t CUOffset; + bool IsRangeStart; + + RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart) + : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} + + bool operator<(const RangeEndpoint &Other) const { + return Address < Other.Address; + } + }; + + using RangeColl = std::vector<Range>; + using RangeCollIterator = RangeColl::const_iterator; + + std::vector<RangeEndpoint> Endpoints; + RangeColl Aranges; + DenseSet<uint64_t> ParsedCUOffsets; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGARANGES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h index 9a06d8e0e5..b5824ba1c9 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -1,322 +1,322 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugFrame.h - Parsing of .debug_frame --------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H -#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/Triple.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFExpression.h" -#include "llvm/Support/Error.h" -#include <memory> -#include <vector> - -namespace llvm { - -class raw_ostream; - -namespace dwarf { - -/// Represent a sequence of Call Frame Information instructions that, when read -/// in order, construct a table mapping PC to frame state. This can also be -/// referred to as "CFI rules" in DWARF literature to avoid confusion with -/// computer programs in the broader sense, and in this context each instruction -/// would be a rule to establish the mapping. Refer to pg. 172 in the DWARF5 -/// manual, "6.4.1 Structure of Call Frame Information". -class CFIProgram { -public: - typedef SmallVector<uint64_t, 2> Operands; - - /// An instruction consists of a DWARF CFI opcode and an optional sequence of - /// operands. If it refers to an expression, then this expression has its own - /// sequence of operations and operands handled separately by DWARFExpression. - struct Instruction { - Instruction(uint8_t Opcode) : Opcode(Opcode) {} - - uint8_t Opcode; - Operands Ops; - // Associated DWARF expression in case this instruction refers to one - Optional<DWARFExpression> Expression; - }; - - using InstrList = std::vector<Instruction>; - using iterator = InstrList::iterator; - using const_iterator = InstrList::const_iterator; - - iterator begin() { return Instructions.begin(); } - const_iterator begin() const { return Instructions.begin(); } - iterator end() { return Instructions.end(); } - const_iterator end() const { return Instructions.end(); } - - unsigned size() const { return (unsigned)Instructions.size(); } - bool empty() const { return Instructions.empty(); } - - CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, - Triple::ArchType Arch) - : CodeAlignmentFactor(CodeAlignmentFactor), - DataAlignmentFactor(DataAlignmentFactor), - Arch(Arch) {} - - /// Parse and store a sequence of CFI instructions from Data, - /// starting at *Offset and ending at EndOffset. *Offset is updated - /// to EndOffset upon successful parsing, or indicates the offset - /// where a problem occurred in case an error is returned. - Error parse(DWARFDataExtractor Data, uint64_t *Offset, uint64_t EndOffset); - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugFrame.h - Parsing of .debug_frame --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H +#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/Triple.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFExpression.h" +#include "llvm/Support/Error.h" +#include <memory> +#include <vector> + +namespace llvm { + +class raw_ostream; + +namespace dwarf { + +/// Represent a sequence of Call Frame Information instructions that, when read +/// in order, construct a table mapping PC to frame state. This can also be +/// referred to as "CFI rules" in DWARF literature to avoid confusion with +/// computer programs in the broader sense, and in this context each instruction +/// would be a rule to establish the mapping. Refer to pg. 172 in the DWARF5 +/// manual, "6.4.1 Structure of Call Frame Information". +class CFIProgram { +public: + typedef SmallVector<uint64_t, 2> Operands; + + /// An instruction consists of a DWARF CFI opcode and an optional sequence of + /// operands. If it refers to an expression, then this expression has its own + /// sequence of operations and operands handled separately by DWARFExpression. + struct Instruction { + Instruction(uint8_t Opcode) : Opcode(Opcode) {} + + uint8_t Opcode; + Operands Ops; + // Associated DWARF expression in case this instruction refers to one + Optional<DWARFExpression> Expression; + }; + + using InstrList = std::vector<Instruction>; + using iterator = InstrList::iterator; + using const_iterator = InstrList::const_iterator; + + iterator begin() { return Instructions.begin(); } + const_iterator begin() const { return Instructions.begin(); } + iterator end() { return Instructions.end(); } + const_iterator end() const { return Instructions.end(); } + + unsigned size() const { return (unsigned)Instructions.size(); } + bool empty() const { return Instructions.empty(); } + + CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, + Triple::ArchType Arch) + : CodeAlignmentFactor(CodeAlignmentFactor), + DataAlignmentFactor(DataAlignmentFactor), + Arch(Arch) {} + + /// Parse and store a sequence of CFI instructions from Data, + /// starting at *Offset and ending at EndOffset. *Offset is updated + /// to EndOffset upon successful parsing, or indicates the offset + /// where a problem occurred in case an error is returned. + Error parse(DWARFDataExtractor Data, uint64_t *Offset, uint64_t EndOffset); + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel = 1) const; - -private: - std::vector<Instruction> Instructions; - const uint64_t CodeAlignmentFactor; - const int64_t DataAlignmentFactor; - Triple::ArchType Arch; - - /// Convenience method to add a new instruction with the given opcode. - void addInstruction(uint8_t Opcode) { - Instructions.push_back(Instruction(Opcode)); - } - - /// Add a new single-operand instruction. - void addInstruction(uint8_t Opcode, uint64_t Operand1) { - Instructions.push_back(Instruction(Opcode)); - Instructions.back().Ops.push_back(Operand1); - } - - /// Add a new instruction that has two operands. - void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2) { - Instructions.push_back(Instruction(Opcode)); - Instructions.back().Ops.push_back(Operand1); - Instructions.back().Ops.push_back(Operand2); - } - - /// Types of operands to CFI instructions - /// In DWARF, this type is implicitly tied to a CFI instruction opcode and - /// thus this type doesn't need to be explictly written to the file (this is - /// not a DWARF encoding). The relationship of instrs to operand types can - /// be obtained from getOperandTypes() and is only used to simplify - /// instruction printing. - enum OperandType { - OT_Unset, - OT_None, - OT_Address, - OT_Offset, - OT_FactoredCodeOffset, - OT_SignedFactDataOffset, - OT_UnsignedFactDataOffset, - OT_Register, - OT_Expression - }; - - /// Retrieve the array describing the types of operands according to the enum - /// above. This is indexed by opcode. - static ArrayRef<OperandType[2]> getOperandTypes(); - - /// Print \p Opcode's operand number \p OperandIdx which has value \p Operand. + +private: + std::vector<Instruction> Instructions; + const uint64_t CodeAlignmentFactor; + const int64_t DataAlignmentFactor; + Triple::ArchType Arch; + + /// Convenience method to add a new instruction with the given opcode. + void addInstruction(uint8_t Opcode) { + Instructions.push_back(Instruction(Opcode)); + } + + /// Add a new single-operand instruction. + void addInstruction(uint8_t Opcode, uint64_t Operand1) { + Instructions.push_back(Instruction(Opcode)); + Instructions.back().Ops.push_back(Operand1); + } + + /// Add a new instruction that has two operands. + void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2) { + Instructions.push_back(Instruction(Opcode)); + Instructions.back().Ops.push_back(Operand1); + Instructions.back().Ops.push_back(Operand2); + } + + /// Types of operands to CFI instructions + /// In DWARF, this type is implicitly tied to a CFI instruction opcode and + /// thus this type doesn't need to be explictly written to the file (this is + /// not a DWARF encoding). The relationship of instrs to operand types can + /// be obtained from getOperandTypes() and is only used to simplify + /// instruction printing. + enum OperandType { + OT_Unset, + OT_None, + OT_Address, + OT_Offset, + OT_FactoredCodeOffset, + OT_SignedFactDataOffset, + OT_UnsignedFactDataOffset, + OT_Register, + OT_Expression + }; + + /// Retrieve the array describing the types of operands according to the enum + /// above. This is indexed by opcode. + static ArrayRef<OperandType[2]> getOperandTypes(); + + /// Print \p Opcode's operand number \p OperandIdx which has value \p Operand. void printOperand(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH, - const Instruction &Instr, unsigned OperandIdx, - uint64_t Operand) const; -}; - -/// An entry in either debug_frame or eh_frame. This entry can be a CIE or an -/// FDE. -class FrameEntry { -public: - enum FrameKind { FK_CIE, FK_FDE }; - - FrameEntry(FrameKind K, bool IsDWARF64, uint64_t Offset, uint64_t Length, - uint64_t CodeAlign, int64_t DataAlign, Triple::ArchType Arch) - : Kind(K), IsDWARF64(IsDWARF64), Offset(Offset), Length(Length), - CFIs(CodeAlign, DataAlign, Arch) {} - - virtual ~FrameEntry() {} - - FrameKind getKind() const { return Kind; } - uint64_t getOffset() const { return Offset; } - uint64_t getLength() const { return Length; } - const CFIProgram &cfis() const { return CFIs; } - CFIProgram &cfis() { return CFIs; } - - /// Dump the instructions in this CFI fragment + const Instruction &Instr, unsigned OperandIdx, + uint64_t Operand) const; +}; + +/// An entry in either debug_frame or eh_frame. This entry can be a CIE or an +/// FDE. +class FrameEntry { +public: + enum FrameKind { FK_CIE, FK_FDE }; + + FrameEntry(FrameKind K, bool IsDWARF64, uint64_t Offset, uint64_t Length, + uint64_t CodeAlign, int64_t DataAlign, Triple::ArchType Arch) + : Kind(K), IsDWARF64(IsDWARF64), Offset(Offset), Length(Length), + CFIs(CodeAlign, DataAlign, Arch) {} + + virtual ~FrameEntry() {} + + FrameKind getKind() const { return Kind; } + uint64_t getOffset() const { return Offset; } + uint64_t getLength() const { return Length; } + const CFIProgram &cfis() const { return CFIs; } + CFIProgram &cfis() { return CFIs; } + + /// Dump the instructions in this CFI fragment virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const = 0; - -protected: - const FrameKind Kind; - - const bool IsDWARF64; - - /// Offset of this entry in the section. - const uint64_t Offset; - - /// Entry length as specified in DWARF. - const uint64_t Length; - - CFIProgram CFIs; -}; - -/// DWARF Common Information Entry (CIE) -class CIE : public FrameEntry { -public: - // CIEs (and FDEs) are simply container classes, so the only sensible way to - // create them is by providing the full parsed contents in the constructor. - CIE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint8_t Version, - SmallString<8> Augmentation, uint8_t AddressSize, - uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor, - int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister, - SmallString<8> AugmentationData, uint32_t FDEPointerEncoding, - uint32_t LSDAPointerEncoding, Optional<uint64_t> Personality, - Optional<uint32_t> PersonalityEnc, Triple::ArchType Arch) - : FrameEntry(FK_CIE, IsDWARF64, Offset, Length, CodeAlignmentFactor, - DataAlignmentFactor, Arch), - Version(Version), Augmentation(std::move(Augmentation)), - AddressSize(AddressSize), SegmentDescriptorSize(SegmentDescriptorSize), - CodeAlignmentFactor(CodeAlignmentFactor), - DataAlignmentFactor(DataAlignmentFactor), - ReturnAddressRegister(ReturnAddressRegister), - AugmentationData(std::move(AugmentationData)), - FDEPointerEncoding(FDEPointerEncoding), - LSDAPointerEncoding(LSDAPointerEncoding), Personality(Personality), - PersonalityEnc(PersonalityEnc) {} - - static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_CIE; } - - StringRef getAugmentationString() const { return Augmentation; } - uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; } - int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; } - uint8_t getVersion() const { return Version; } - uint64_t getReturnAddressRegister() const { return ReturnAddressRegister; } - Optional<uint64_t> getPersonalityAddress() const { return Personality; } - Optional<uint32_t> getPersonalityEncoding() const { return PersonalityEnc; } - - uint32_t getFDEPointerEncoding() const { return FDEPointerEncoding; } - - uint32_t getLSDAPointerEncoding() const { return LSDAPointerEncoding; } - + +protected: + const FrameKind Kind; + + const bool IsDWARF64; + + /// Offset of this entry in the section. + const uint64_t Offset; + + /// Entry length as specified in DWARF. + const uint64_t Length; + + CFIProgram CFIs; +}; + +/// DWARF Common Information Entry (CIE) +class CIE : public FrameEntry { +public: + // CIEs (and FDEs) are simply container classes, so the only sensible way to + // create them is by providing the full parsed contents in the constructor. + CIE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint8_t Version, + SmallString<8> Augmentation, uint8_t AddressSize, + uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor, + int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister, + SmallString<8> AugmentationData, uint32_t FDEPointerEncoding, + uint32_t LSDAPointerEncoding, Optional<uint64_t> Personality, + Optional<uint32_t> PersonalityEnc, Triple::ArchType Arch) + : FrameEntry(FK_CIE, IsDWARF64, Offset, Length, CodeAlignmentFactor, + DataAlignmentFactor, Arch), + Version(Version), Augmentation(std::move(Augmentation)), + AddressSize(AddressSize), SegmentDescriptorSize(SegmentDescriptorSize), + CodeAlignmentFactor(CodeAlignmentFactor), + DataAlignmentFactor(DataAlignmentFactor), + ReturnAddressRegister(ReturnAddressRegister), + AugmentationData(std::move(AugmentationData)), + FDEPointerEncoding(FDEPointerEncoding), + LSDAPointerEncoding(LSDAPointerEncoding), Personality(Personality), + PersonalityEnc(PersonalityEnc) {} + + static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_CIE; } + + StringRef getAugmentationString() const { return Augmentation; } + uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; } + int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; } + uint8_t getVersion() const { return Version; } + uint64_t getReturnAddressRegister() const { return ReturnAddressRegister; } + Optional<uint64_t> getPersonalityAddress() const { return Personality; } + Optional<uint32_t> getPersonalityEncoding() const { return PersonalityEnc; } + + uint32_t getFDEPointerEncoding() const { return FDEPointerEncoding; } + + uint32_t getLSDAPointerEncoding() const { return LSDAPointerEncoding; } + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, - bool IsEH) const override; - -private: - /// The following fields are defined in section 6.4.1 of the DWARF standard v4 - const uint8_t Version; - const SmallString<8> Augmentation; - const uint8_t AddressSize; - const uint8_t SegmentDescriptorSize; - const uint64_t CodeAlignmentFactor; - const int64_t DataAlignmentFactor; - const uint64_t ReturnAddressRegister; - - // The following are used when the CIE represents an EH frame entry. - const SmallString<8> AugmentationData; - const uint32_t FDEPointerEncoding; - const uint32_t LSDAPointerEncoding; - const Optional<uint64_t> Personality; - const Optional<uint32_t> PersonalityEnc; -}; - -/// DWARF Frame Description Entry (FDE) -class FDE : public FrameEntry { -public: - FDE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CIEPointer, - uint64_t InitialLocation, uint64_t AddressRange, CIE *Cie, - Optional<uint64_t> LSDAAddress, Triple::ArchType Arch) - : FrameEntry(FK_FDE, IsDWARF64, Offset, Length, - Cie ? Cie->getCodeAlignmentFactor() : 0, - Cie ? Cie->getDataAlignmentFactor() : 0, - Arch), - CIEPointer(CIEPointer), InitialLocation(InitialLocation), - AddressRange(AddressRange), LinkedCIE(Cie), LSDAAddress(LSDAAddress) {} - - ~FDE() override = default; - - const CIE *getLinkedCIE() const { return LinkedCIE; } - uint64_t getInitialLocation() const { return InitialLocation; } - uint64_t getAddressRange() const { return AddressRange; } - Optional<uint64_t> getLSDAAddress() const { return LSDAAddress; } - + bool IsEH) const override; + +private: + /// The following fields are defined in section 6.4.1 of the DWARF standard v4 + const uint8_t Version; + const SmallString<8> Augmentation; + const uint8_t AddressSize; + const uint8_t SegmentDescriptorSize; + const uint64_t CodeAlignmentFactor; + const int64_t DataAlignmentFactor; + const uint64_t ReturnAddressRegister; + + // The following are used when the CIE represents an EH frame entry. + const SmallString<8> AugmentationData; + const uint32_t FDEPointerEncoding; + const uint32_t LSDAPointerEncoding; + const Optional<uint64_t> Personality; + const Optional<uint32_t> PersonalityEnc; +}; + +/// DWARF Frame Description Entry (FDE) +class FDE : public FrameEntry { +public: + FDE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CIEPointer, + uint64_t InitialLocation, uint64_t AddressRange, CIE *Cie, + Optional<uint64_t> LSDAAddress, Triple::ArchType Arch) + : FrameEntry(FK_FDE, IsDWARF64, Offset, Length, + Cie ? Cie->getCodeAlignmentFactor() : 0, + Cie ? Cie->getDataAlignmentFactor() : 0, + Arch), + CIEPointer(CIEPointer), InitialLocation(InitialLocation), + AddressRange(AddressRange), LinkedCIE(Cie), LSDAAddress(LSDAAddress) {} + + ~FDE() override = default; + + const CIE *getLinkedCIE() const { return LinkedCIE; } + uint64_t getInitialLocation() const { return InitialLocation; } + uint64_t getAddressRange() const { return AddressRange; } + Optional<uint64_t> getLSDAAddress() const { return LSDAAddress; } + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, - bool IsEH) const override; - - static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_FDE; } - -private: - /// The following fields are defined in section 6.4.1 of the DWARFv3 standard. - /// Note that CIE pointers in EH FDEs, unlike DWARF FDEs, contain relative - /// offsets to the linked CIEs. See the following link for more info: - /// https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html - const uint64_t CIEPointer; - const uint64_t InitialLocation; - const uint64_t AddressRange; - const CIE *LinkedCIE; - const Optional<uint64_t> LSDAAddress; -}; - -} // end namespace dwarf - -/// A parsed .debug_frame or .eh_frame section -class DWARFDebugFrame { - const Triple::ArchType Arch; - // True if this is parsing an eh_frame section. - const bool IsEH; - // Not zero for sane pointer values coming out of eh_frame - const uint64_t EHFrameAddress; - - std::vector<std::unique_ptr<dwarf::FrameEntry>> Entries; - using iterator = pointee_iterator<decltype(Entries)::const_iterator>; - - /// Return the entry at the given offset or nullptr. - dwarf::FrameEntry *getEntryAtOffset(uint64_t Offset) const; - -public: - // If IsEH is true, assume it is a .eh_frame section. Otherwise, - // it is a .debug_frame section. EHFrameAddress should be different - // than zero for correct parsing of .eh_frame addresses when they - // use a PC-relative encoding. - DWARFDebugFrame(Triple::ArchType Arch, - bool IsEH = false, uint64_t EHFrameAddress = 0); - ~DWARFDebugFrame(); - - /// Dump the section data into the given stream. + bool IsEH) const override; + + static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_FDE; } + +private: + /// The following fields are defined in section 6.4.1 of the DWARFv3 standard. + /// Note that CIE pointers in EH FDEs, unlike DWARF FDEs, contain relative + /// offsets to the linked CIEs. See the following link for more info: + /// https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html + const uint64_t CIEPointer; + const uint64_t InitialLocation; + const uint64_t AddressRange; + const CIE *LinkedCIE; + const Optional<uint64_t> LSDAAddress; +}; + +} // end namespace dwarf + +/// A parsed .debug_frame or .eh_frame section +class DWARFDebugFrame { + const Triple::ArchType Arch; + // True if this is parsing an eh_frame section. + const bool IsEH; + // Not zero for sane pointer values coming out of eh_frame + const uint64_t EHFrameAddress; + + std::vector<std::unique_ptr<dwarf::FrameEntry>> Entries; + using iterator = pointee_iterator<decltype(Entries)::const_iterator>; + + /// Return the entry at the given offset or nullptr. + dwarf::FrameEntry *getEntryAtOffset(uint64_t Offset) const; + +public: + // If IsEH is true, assume it is a .eh_frame section. Otherwise, + // it is a .debug_frame section. EHFrameAddress should be different + // than zero for correct parsing of .eh_frame addresses when they + // use a PC-relative encoding. + DWARFDebugFrame(Triple::ArchType Arch, + bool IsEH = false, uint64_t EHFrameAddress = 0); + ~DWARFDebugFrame(); + + /// Dump the section data into the given stream. void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, - Optional<uint64_t> Offset) const; - - /// Parse the section from raw data. \p Data is assumed to contain the whole - /// frame section contents to be parsed. - Error parse(DWARFDataExtractor Data); - - /// Return whether the section has any entries. - bool empty() const { return Entries.empty(); } - - /// DWARF Frame entries accessors - iterator begin() const { return Entries.begin(); } - iterator end() const { return Entries.end(); } - iterator_range<iterator> entries() const { - return iterator_range<iterator>(Entries.begin(), Entries.end()); - } - - uint64_t getEHFrameAddress() const { return EHFrameAddress; } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + Optional<uint64_t> Offset) const; + + /// Parse the section from raw data. \p Data is assumed to contain the whole + /// frame section contents to be parsed. + Error parse(DWARFDataExtractor Data); + + /// Return whether the section has any entries. + bool empty() const { return Entries.empty(); } + + /// DWARF Frame entries accessors + iterator begin() const { return Entries.begin(); } + iterator end() const { return Entries.end(); } + iterator_range<iterator> entries() const { + return iterator_range<iterator>(Entries.begin(), Entries.end()); + } + + uint64_t getEHFrameAddress() const { return EHFrameAddress; } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h index 8959d455db..deb3f9adcd 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h @@ -1,73 +1,73 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H -#define LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H - -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include <cstdint> - -namespace llvm { - -class DataExtractor; -class DWARFUnit; - -/// DWARFDebugInfoEntry - A DIE with only the minimum required data. -class DWARFDebugInfoEntry { - /// Offset within the .debug_info of the start of this entry. - uint64_t Offset = 0; - - /// The integer depth of this DIE within the compile unit DIEs where the - /// compile/type unit DIE has a depth of zero. - uint32_t Depth = 0; - - const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr; - -public: - DWARFDebugInfoEntry() = default; - - /// Extracts a debug info entry, which is a child of a given unit, - /// starting at a given offset. If DIE can't be extracted, returns false and - /// doesn't change OffsetPtr. - bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr); - - /// High performance extraction should use this call. - bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, - const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset, - uint32_t Depth); - - uint64_t getOffset() const { return Offset; } - uint32_t getDepth() const { return Depth; } - - dwarf::Tag getTag() const { - return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null; - } - - bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); } - - const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { - return AbbrevDecl; - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H +#define LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include <cstdint> + +namespace llvm { + +class DataExtractor; +class DWARFUnit; + +/// DWARFDebugInfoEntry - A DIE with only the minimum required data. +class DWARFDebugInfoEntry { + /// Offset within the .debug_info of the start of this entry. + uint64_t Offset = 0; + + /// The integer depth of this DIE within the compile unit DIEs where the + /// compile/type unit DIE has a depth of zero. + uint32_t Depth = 0; + + const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr; + +public: + DWARFDebugInfoEntry() = default; + + /// Extracts a debug info entry, which is a child of a given unit, + /// starting at a given offset. If DIE can't be extracted, returns false and + /// doesn't change OffsetPtr. + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr); + + /// High performance extraction should use this call. + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, + const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset, + uint32_t Depth); + + uint64_t getOffset() const { return Offset; } + uint32_t getDepth() const { return Depth; } + + dwarf::Tag getTag() const { + return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null; + } + + bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); } + + const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { + return AbbrevDecl; + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index c918a40405..d3ef09da62 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -1,434 +1,434 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugLine.h -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H -#define LLVM_DEBUGINFO_DWARFDEBUGLINE_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" -#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" -#include "llvm/Support/MD5.h" -#include "llvm/Support/Path.h" -#include <cstdint> -#include <map> -#include <string> -#include <vector> - -namespace llvm { - -class DWARFUnit; -class raw_ostream; - -class DWARFDebugLine { -public: - struct FileNameEntry { - FileNameEntry() = default; - - DWARFFormValue Name; - uint64_t DirIdx = 0; - uint64_t ModTime = 0; - uint64_t Length = 0; - MD5::MD5Result Checksum; - DWARFFormValue Source; - }; - - /// Tracks which optional content types are present in a DWARF file name - /// entry format. - struct ContentTypeTracker { - ContentTypeTracker() = default; - - /// Whether filename entries provide a modification timestamp. - bool HasModTime = false; - /// Whether filename entries provide a file size. - bool HasLength = false; - /// For v5, whether filename entries provide an MD5 checksum. - bool HasMD5 = false; - /// For v5, whether filename entries provide source text. - bool HasSource = false; - - /// Update tracked content types with \p ContentType. - void trackContentType(dwarf::LineNumberEntryFormat ContentType); - }; - - struct Prologue { - Prologue(); - - /// The size in bytes of the statement information for this compilation unit - /// (not including the total_length field itself). - uint64_t TotalLength; - /// Version, address size (starting in v5), and DWARF32/64 format; these - /// parameters affect interpretation of forms (used in the directory and - /// file tables starting with v5). - dwarf::FormParams FormParams; - /// The number of bytes following the prologue_length field to the beginning - /// of the first byte of the statement program itself. - uint64_t PrologueLength; - /// In v5, size in bytes of a segment selector. - uint8_t SegSelectorSize; - /// The size in bytes of the smallest target machine instruction. Statement - /// program opcodes that alter the address register first multiply their - /// operands by this value. - uint8_t MinInstLength; - /// The maximum number of individual operations that may be encoded in an - /// instruction. - uint8_t MaxOpsPerInst; - /// The initial value of theis_stmtregister. - uint8_t DefaultIsStmt; - /// This parameter affects the meaning of the special opcodes. See below. - int8_t LineBase; - /// This parameter affects the meaning of the special opcodes. See below. - uint8_t LineRange; - /// The number assigned to the first special opcode. - uint8_t OpcodeBase; - /// This tracks which optional file format content types are present. - ContentTypeTracker ContentTypes; - std::vector<uint8_t> StandardOpcodeLengths; - std::vector<DWARFFormValue> IncludeDirectories; - std::vector<FileNameEntry> FileNames; - - const dwarf::FormParams getFormParams() const { return FormParams; } - uint16_t getVersion() const { return FormParams.Version; } - uint8_t getAddressSize() const { return FormParams.AddrSize; } - bool isDWARF64() const { return FormParams.Format == dwarf::DWARF64; } - - uint32_t sizeofTotalLength() const { return isDWARF64() ? 12 : 4; } - - uint32_t sizeofPrologueLength() const { return isDWARF64() ? 8 : 4; } - - bool totalLengthIsValid() const; - - /// Length of the prologue in bytes. - uint64_t getLength() const; - - int32_t getMaxLineIncrementForSpecialOpcode() const { - return LineBase + (int8_t)LineRange - 1; - } - - /// Get DWARF-version aware access to the file name entry at the provided - /// index. - const llvm::DWARFDebugLine::FileNameEntry & - getFileNameEntry(uint64_t Index) const; - - bool hasFileAtIndex(uint64_t FileIndex) const; - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugLine.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H +#define LLVM_DEBUGINFO_DWARFDEBUGLINE_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" +#include "llvm/Support/MD5.h" +#include "llvm/Support/Path.h" +#include <cstdint> +#include <map> +#include <string> +#include <vector> + +namespace llvm { + +class DWARFUnit; +class raw_ostream; + +class DWARFDebugLine { +public: + struct FileNameEntry { + FileNameEntry() = default; + + DWARFFormValue Name; + uint64_t DirIdx = 0; + uint64_t ModTime = 0; + uint64_t Length = 0; + MD5::MD5Result Checksum; + DWARFFormValue Source; + }; + + /// Tracks which optional content types are present in a DWARF file name + /// entry format. + struct ContentTypeTracker { + ContentTypeTracker() = default; + + /// Whether filename entries provide a modification timestamp. + bool HasModTime = false; + /// Whether filename entries provide a file size. + bool HasLength = false; + /// For v5, whether filename entries provide an MD5 checksum. + bool HasMD5 = false; + /// For v5, whether filename entries provide source text. + bool HasSource = false; + + /// Update tracked content types with \p ContentType. + void trackContentType(dwarf::LineNumberEntryFormat ContentType); + }; + + struct Prologue { + Prologue(); + + /// The size in bytes of the statement information for this compilation unit + /// (not including the total_length field itself). + uint64_t TotalLength; + /// Version, address size (starting in v5), and DWARF32/64 format; these + /// parameters affect interpretation of forms (used in the directory and + /// file tables starting with v5). + dwarf::FormParams FormParams; + /// The number of bytes following the prologue_length field to the beginning + /// of the first byte of the statement program itself. + uint64_t PrologueLength; + /// In v5, size in bytes of a segment selector. + uint8_t SegSelectorSize; + /// The size in bytes of the smallest target machine instruction. Statement + /// program opcodes that alter the address register first multiply their + /// operands by this value. + uint8_t MinInstLength; + /// The maximum number of individual operations that may be encoded in an + /// instruction. + uint8_t MaxOpsPerInst; + /// The initial value of theis_stmtregister. + uint8_t DefaultIsStmt; + /// This parameter affects the meaning of the special opcodes. See below. + int8_t LineBase; + /// This parameter affects the meaning of the special opcodes. See below. + uint8_t LineRange; + /// The number assigned to the first special opcode. + uint8_t OpcodeBase; + /// This tracks which optional file format content types are present. + ContentTypeTracker ContentTypes; + std::vector<uint8_t> StandardOpcodeLengths; + std::vector<DWARFFormValue> IncludeDirectories; + std::vector<FileNameEntry> FileNames; + + const dwarf::FormParams getFormParams() const { return FormParams; } + uint16_t getVersion() const { return FormParams.Version; } + uint8_t getAddressSize() const { return FormParams.AddrSize; } + bool isDWARF64() const { return FormParams.Format == dwarf::DWARF64; } + + uint32_t sizeofTotalLength() const { return isDWARF64() ? 12 : 4; } + + uint32_t sizeofPrologueLength() const { return isDWARF64() ? 8 : 4; } + + bool totalLengthIsValid() const; + + /// Length of the prologue in bytes. + uint64_t getLength() const; + + int32_t getMaxLineIncrementForSpecialOpcode() const { + return LineBase + (int8_t)LineRange - 1; + } + + /// Get DWARF-version aware access to the file name entry at the provided + /// index. + const llvm::DWARFDebugLine::FileNameEntry & + getFileNameEntry(uint64_t Index) const; + + bool hasFileAtIndex(uint64_t FileIndex) const; + Optional<uint64_t> getLastValidFileIndex() const; - bool - getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - std::string &Result, - sys::path::Style Style = sys::path::Style::native) const; - - void clear(); - void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; - Error parse(DWARFDataExtractor Data, uint64_t *OffsetPtr, - function_ref<void(Error)> RecoverableErrorHandler, - const DWARFContext &Ctx, const DWARFUnit *U = nullptr); - }; - - /// Standard .debug_line state machine structure. - struct Row { - explicit Row(bool DefaultIsStmt = false); - - /// Called after a row is appended to the matrix. - void postAppend(); - void reset(bool DefaultIsStmt); - void dump(raw_ostream &OS) const; - - static void dumpTableHeader(raw_ostream &OS, unsigned Indent); - - static bool orderByAddress(const Row &LHS, const Row &RHS) { - return std::tie(LHS.Address.SectionIndex, LHS.Address.Address) < - std::tie(RHS.Address.SectionIndex, RHS.Address.Address); - } - - /// The program-counter value corresponding to a machine instruction - /// generated by the compiler and section index pointing to the section - /// containg this PC. If relocation information is present then section - /// index is the index of the section which contains above address. - /// Otherwise this is object::SectionedAddress::Undef value. - object::SectionedAddress Address; - /// An unsigned integer indicating a source line number. Lines are numbered - /// beginning at 1. The compiler may emit the value 0 in cases where an - /// instruction cannot be attributed to any source line. - uint32_t Line; - /// An unsigned integer indicating a column number within a source line. - /// Columns are numbered beginning at 1. The value 0 is reserved to indicate - /// that a statement begins at the 'left edge' of the line. - uint16_t Column; - /// An unsigned integer indicating the identity of the source file - /// corresponding to a machine instruction. - uint16_t File; - /// An unsigned integer representing the DWARF path discriminator value - /// for this location. - uint32_t Discriminator; - /// An unsigned integer whose value encodes the applicable instruction set - /// architecture for the current instruction. - uint8_t Isa; - /// A boolean indicating that the current instruction is the beginning of a - /// statement. - uint8_t IsStmt : 1, - /// A boolean indicating that the current instruction is the - /// beginning of a basic block. - BasicBlock : 1, - /// A boolean indicating that the current address is that of the - /// first byte after the end of a sequence of target machine - /// instructions. - EndSequence : 1, - /// A boolean indicating that the current address is one (of possibly - /// many) where execution should be suspended for an entry breakpoint - /// of a function. - PrologueEnd : 1, - /// A boolean indicating that the current address is one (of possibly - /// many) where execution should be suspended for an exit breakpoint - /// of a function. - EpilogueBegin : 1; - }; - - /// Represents a series of contiguous machine instructions. Line table for - /// each compilation unit may consist of multiple sequences, which are not - /// guaranteed to be in the order of ascending instruction address. - struct Sequence { - Sequence(); - - /// Sequence describes instructions at address range [LowPC, HighPC) - /// and is described by line table rows [FirstRowIndex, LastRowIndex). - uint64_t LowPC; - uint64_t HighPC; - /// If relocation information is present then this is the index of the - /// section which contains above addresses. Otherwise this is - /// object::SectionedAddress::Undef value. - uint64_t SectionIndex; - unsigned FirstRowIndex; - unsigned LastRowIndex; - bool Empty; - - void reset(); - - static bool orderByHighPC(const Sequence &LHS, const Sequence &RHS) { - return std::tie(LHS.SectionIndex, LHS.HighPC) < - std::tie(RHS.SectionIndex, RHS.HighPC); - } - - bool isValid() const { - return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex); - } - - bool containsPC(object::SectionedAddress PC) const { - return SectionIndex == PC.SectionIndex && - (LowPC <= PC.Address && PC.Address < HighPC); - } - }; - - struct LineTable { - LineTable(); - - /// Represents an invalid row - const uint32_t UnknownRowIndex = UINT32_MAX; - - void appendRow(const DWARFDebugLine::Row &R) { Rows.push_back(R); } - - void appendSequence(const DWARFDebugLine::Sequence &S) { - Sequences.push_back(S); - } - - /// Returns the index of the row with file/line info for a given address, - /// or UnknownRowIndex if there is no such row. - uint32_t lookupAddress(object::SectionedAddress Address) const; - - bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size, - std::vector<uint32_t> &Result) const; - - bool hasFileAtIndex(uint64_t FileIndex) const { - return Prologue.hasFileAtIndex(FileIndex); - } - + bool + getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + std::string &Result, + sys::path::Style Style = sys::path::Style::native) const; + + void clear(); + void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; + Error parse(DWARFDataExtractor Data, uint64_t *OffsetPtr, + function_ref<void(Error)> RecoverableErrorHandler, + const DWARFContext &Ctx, const DWARFUnit *U = nullptr); + }; + + /// Standard .debug_line state machine structure. + struct Row { + explicit Row(bool DefaultIsStmt = false); + + /// Called after a row is appended to the matrix. + void postAppend(); + void reset(bool DefaultIsStmt); + void dump(raw_ostream &OS) const; + + static void dumpTableHeader(raw_ostream &OS, unsigned Indent); + + static bool orderByAddress(const Row &LHS, const Row &RHS) { + return std::tie(LHS.Address.SectionIndex, LHS.Address.Address) < + std::tie(RHS.Address.SectionIndex, RHS.Address.Address); + } + + /// The program-counter value corresponding to a machine instruction + /// generated by the compiler and section index pointing to the section + /// containg this PC. If relocation information is present then section + /// index is the index of the section which contains above address. + /// Otherwise this is object::SectionedAddress::Undef value. + object::SectionedAddress Address; + /// An unsigned integer indicating a source line number. Lines are numbered + /// beginning at 1. The compiler may emit the value 0 in cases where an + /// instruction cannot be attributed to any source line. + uint32_t Line; + /// An unsigned integer indicating a column number within a source line. + /// Columns are numbered beginning at 1. The value 0 is reserved to indicate + /// that a statement begins at the 'left edge' of the line. + uint16_t Column; + /// An unsigned integer indicating the identity of the source file + /// corresponding to a machine instruction. + uint16_t File; + /// An unsigned integer representing the DWARF path discriminator value + /// for this location. + uint32_t Discriminator; + /// An unsigned integer whose value encodes the applicable instruction set + /// architecture for the current instruction. + uint8_t Isa; + /// A boolean indicating that the current instruction is the beginning of a + /// statement. + uint8_t IsStmt : 1, + /// A boolean indicating that the current instruction is the + /// beginning of a basic block. + BasicBlock : 1, + /// A boolean indicating that the current address is that of the + /// first byte after the end of a sequence of target machine + /// instructions. + EndSequence : 1, + /// A boolean indicating that the current address is one (of possibly + /// many) where execution should be suspended for an entry breakpoint + /// of a function. + PrologueEnd : 1, + /// A boolean indicating that the current address is one (of possibly + /// many) where execution should be suspended for an exit breakpoint + /// of a function. + EpilogueBegin : 1; + }; + + /// Represents a series of contiguous machine instructions. Line table for + /// each compilation unit may consist of multiple sequences, which are not + /// guaranteed to be in the order of ascending instruction address. + struct Sequence { + Sequence(); + + /// Sequence describes instructions at address range [LowPC, HighPC) + /// and is described by line table rows [FirstRowIndex, LastRowIndex). + uint64_t LowPC; + uint64_t HighPC; + /// If relocation information is present then this is the index of the + /// section which contains above addresses. Otherwise this is + /// object::SectionedAddress::Undef value. + uint64_t SectionIndex; + unsigned FirstRowIndex; + unsigned LastRowIndex; + bool Empty; + + void reset(); + + static bool orderByHighPC(const Sequence &LHS, const Sequence &RHS) { + return std::tie(LHS.SectionIndex, LHS.HighPC) < + std::tie(RHS.SectionIndex, RHS.HighPC); + } + + bool isValid() const { + return !Empty && (LowPC < HighPC) && (FirstRowIndex < LastRowIndex); + } + + bool containsPC(object::SectionedAddress PC) const { + return SectionIndex == PC.SectionIndex && + (LowPC <= PC.Address && PC.Address < HighPC); + } + }; + + struct LineTable { + LineTable(); + + /// Represents an invalid row + const uint32_t UnknownRowIndex = UINT32_MAX; + + void appendRow(const DWARFDebugLine::Row &R) { Rows.push_back(R); } + + void appendSequence(const DWARFDebugLine::Sequence &S) { + Sequences.push_back(S); + } + + /// Returns the index of the row with file/line info for a given address, + /// or UnknownRowIndex if there is no such row. + uint32_t lookupAddress(object::SectionedAddress Address) const; + + bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size, + std::vector<uint32_t> &Result) const; + + bool hasFileAtIndex(uint64_t FileIndex) const { + return Prologue.hasFileAtIndex(FileIndex); + } + Optional<uint64_t> getLastValidFileIndex() const { return Prologue.getLastValidFileIndex(); } - /// Extracts filename by its index in filename table in prologue. - /// In Dwarf 4, the files are 1-indexed and the current compilation file - /// name is not represented in the list. In DWARF v5, the files are - /// 0-indexed and the primary source file has the index 0. - /// Returns true on success. - bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - std::string &Result) const { - return Prologue.getFileNameByIndex(FileIndex, CompDir, Kind, Result); - } - - /// Fills the Result argument with the file and line information - /// corresponding to Address. Returns true on success. - bool getFileLineInfoForAddress(object::SectionedAddress Address, - const char *CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - DILineInfo &Result) const; - - void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; - void clear(); - - /// Parse prologue and all rows. - Error parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, - const DWARFContext &Ctx, const DWARFUnit *U, - function_ref<void(Error)> RecoverableErrorHandler, - raw_ostream *OS = nullptr, bool Verbose = false); - - using RowVector = std::vector<Row>; - using RowIter = RowVector::const_iterator; - using SequenceVector = std::vector<Sequence>; - using SequenceIter = SequenceVector::const_iterator; - - struct Prologue Prologue; - RowVector Rows; - SequenceVector Sequences; - - private: - uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq, - object::SectionedAddress Address) const; - Optional<StringRef> - getSourceByIndex(uint64_t FileIndex, - DILineInfoSpecifier::FileLineInfoKind Kind) const; - - uint32_t lookupAddressImpl(object::SectionedAddress Address) const; - - bool lookupAddressRangeImpl(object::SectionedAddress Address, uint64_t Size, - std::vector<uint32_t> &Result) const; - }; - - const LineTable *getLineTable(uint64_t Offset) const; - Expected<const LineTable *> - getOrParseLineTable(DWARFDataExtractor &DebugLineData, uint64_t Offset, - const DWARFContext &Ctx, const DWARFUnit *U, - function_ref<void(Error)> RecoverableErrorHandler); - - /// Helper to allow for parsing of an entire .debug_line section in sequence. - class SectionParser { - public: - using LineToUnitMap = std::map<uint64_t, DWARFUnit *>; - + /// Extracts filename by its index in filename table in prologue. + /// In Dwarf 4, the files are 1-indexed and the current compilation file + /// name is not represented in the list. In DWARF v5, the files are + /// 0-indexed and the primary source file has the index 0. + /// Returns true on success. + bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + std::string &Result) const { + return Prologue.getFileNameByIndex(FileIndex, CompDir, Kind, Result); + } + + /// Fills the Result argument with the file and line information + /// corresponding to Address. Returns true on success. + bool getFileLineInfoForAddress(object::SectionedAddress Address, + const char *CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + DILineInfo &Result) const; + + void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; + void clear(); + + /// Parse prologue and all rows. + Error parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, + const DWARFContext &Ctx, const DWARFUnit *U, + function_ref<void(Error)> RecoverableErrorHandler, + raw_ostream *OS = nullptr, bool Verbose = false); + + using RowVector = std::vector<Row>; + using RowIter = RowVector::const_iterator; + using SequenceVector = std::vector<Sequence>; + using SequenceIter = SequenceVector::const_iterator; + + struct Prologue Prologue; + RowVector Rows; + SequenceVector Sequences; + + private: + uint32_t findRowInSeq(const DWARFDebugLine::Sequence &Seq, + object::SectionedAddress Address) const; + Optional<StringRef> + getSourceByIndex(uint64_t FileIndex, + DILineInfoSpecifier::FileLineInfoKind Kind) const; + + uint32_t lookupAddressImpl(object::SectionedAddress Address) const; + + bool lookupAddressRangeImpl(object::SectionedAddress Address, uint64_t Size, + std::vector<uint32_t> &Result) const; + }; + + const LineTable *getLineTable(uint64_t Offset) const; + Expected<const LineTable *> + getOrParseLineTable(DWARFDataExtractor &DebugLineData, uint64_t Offset, + const DWARFContext &Ctx, const DWARFUnit *U, + function_ref<void(Error)> RecoverableErrorHandler); + + /// Helper to allow for parsing of an entire .debug_line section in sequence. + class SectionParser { + public: + using LineToUnitMap = std::map<uint64_t, DWARFUnit *>; + SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, DWARFUnitVector::iterator_range Units); - - /// Get the next line table from the section. Report any issues via the - /// handlers. - /// - /// \param RecoverableErrorHandler - any issues that don't prevent further - /// parsing of the table will be reported through this handler. - /// \param UnrecoverableErrorHandler - any issues that prevent further - /// parsing of the table will be reported through this handler. - /// \param OS - if not null, the parser will print information about the - /// table as it parses it. - /// \param Verbose - if true, the parser will print verbose information when - /// printing to the output. - LineTable parseNext(function_ref<void(Error)> RecoverableErrorHandler, - function_ref<void(Error)> UnrecoverableErrorHandler, - raw_ostream *OS = nullptr, bool Verbose = false); - - /// Skip the current line table and go to the following line table (if - /// present) immediately. - /// - /// \param RecoverableErrorHandler - report any recoverable prologue - /// parsing issues via this handler. - /// \param UnrecoverableErrorHandler - report any unrecoverable prologue - /// parsing issues via this handler. - void skip(function_ref<void(Error)> RecoverableErrorHandler, - function_ref<void(Error)> UnrecoverableErrorHandler); - - /// Indicates if the parser has parsed as much as possible. - /// - /// \note Certain problems with the line table structure might mean that - /// parsing stops before the end of the section is reached. - bool done() const { return Done; } - - /// Get the offset the parser has reached. - uint64_t getOffset() const { return Offset; } - - private: - DWARFUnit *prepareToParse(uint64_t Offset); - void moveToNextTable(uint64_t OldOffset, const Prologue &P); - - LineToUnitMap LineToUnit; - - DWARFDataExtractor &DebugLineData; - const DWARFContext &Context; - uint64_t Offset = 0; - bool Done = false; - }; - -private: - struct ParsingState { - ParsingState(struct LineTable *LT, uint64_t TableOffset, - function_ref<void(Error)> ErrorHandler); - - void resetRowAndSequence(); - void appendRowToMatrix(); - - /// Advance the address by the \p OperationAdvance value. \returns the - /// amount advanced by. - uint64_t advanceAddr(uint64_t OperationAdvance, uint8_t Opcode, - uint64_t OpcodeOffset); - - struct AddrAndAdjustedOpcode { - uint64_t AddrDelta; - uint8_t AdjustedOpcode; - }; - - /// Advance the address as required by the specified \p Opcode. - /// \returns the amount advanced by and the calculated adjusted opcode. - AddrAndAdjustedOpcode advanceAddrForOpcode(uint8_t Opcode, - uint64_t OpcodeOffset); - - struct AddrAndLineDelta { - uint64_t Address; - int32_t Line; - }; - - /// Advance the line and address as required by the specified special \p - /// Opcode. \returns the address and line delta. - AddrAndLineDelta handleSpecialOpcode(uint8_t Opcode, uint64_t OpcodeOffset); - - /// Line table we're currently parsing. - struct LineTable *LineTable; - struct Row Row; - struct Sequence Sequence; - - private: - uint64_t LineTableOffset; - - bool ReportAdvanceAddrProblem = true; - bool ReportBadLineRange = true; - function_ref<void(Error)> ErrorHandler; - }; - - using LineTableMapTy = std::map<uint64_t, LineTable>; - using LineTableIter = LineTableMapTy::iterator; - using LineTableConstIter = LineTableMapTy::const_iterator; - - LineTableMapTy LineTableMap; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGLINE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + + /// Get the next line table from the section. Report any issues via the + /// handlers. + /// + /// \param RecoverableErrorHandler - any issues that don't prevent further + /// parsing of the table will be reported through this handler. + /// \param UnrecoverableErrorHandler - any issues that prevent further + /// parsing of the table will be reported through this handler. + /// \param OS - if not null, the parser will print information about the + /// table as it parses it. + /// \param Verbose - if true, the parser will print verbose information when + /// printing to the output. + LineTable parseNext(function_ref<void(Error)> RecoverableErrorHandler, + function_ref<void(Error)> UnrecoverableErrorHandler, + raw_ostream *OS = nullptr, bool Verbose = false); + + /// Skip the current line table and go to the following line table (if + /// present) immediately. + /// + /// \param RecoverableErrorHandler - report any recoverable prologue + /// parsing issues via this handler. + /// \param UnrecoverableErrorHandler - report any unrecoverable prologue + /// parsing issues via this handler. + void skip(function_ref<void(Error)> RecoverableErrorHandler, + function_ref<void(Error)> UnrecoverableErrorHandler); + + /// Indicates if the parser has parsed as much as possible. + /// + /// \note Certain problems with the line table structure might mean that + /// parsing stops before the end of the section is reached. + bool done() const { return Done; } + + /// Get the offset the parser has reached. + uint64_t getOffset() const { return Offset; } + + private: + DWARFUnit *prepareToParse(uint64_t Offset); + void moveToNextTable(uint64_t OldOffset, const Prologue &P); + + LineToUnitMap LineToUnit; + + DWARFDataExtractor &DebugLineData; + const DWARFContext &Context; + uint64_t Offset = 0; + bool Done = false; + }; + +private: + struct ParsingState { + ParsingState(struct LineTable *LT, uint64_t TableOffset, + function_ref<void(Error)> ErrorHandler); + + void resetRowAndSequence(); + void appendRowToMatrix(); + + /// Advance the address by the \p OperationAdvance value. \returns the + /// amount advanced by. + uint64_t advanceAddr(uint64_t OperationAdvance, uint8_t Opcode, + uint64_t OpcodeOffset); + + struct AddrAndAdjustedOpcode { + uint64_t AddrDelta; + uint8_t AdjustedOpcode; + }; + + /// Advance the address as required by the specified \p Opcode. + /// \returns the amount advanced by and the calculated adjusted opcode. + AddrAndAdjustedOpcode advanceAddrForOpcode(uint8_t Opcode, + uint64_t OpcodeOffset); + + struct AddrAndLineDelta { + uint64_t Address; + int32_t Line; + }; + + /// Advance the line and address as required by the specified special \p + /// Opcode. \returns the address and line delta. + AddrAndLineDelta handleSpecialOpcode(uint8_t Opcode, uint64_t OpcodeOffset); + + /// Line table we're currently parsing. + struct LineTable *LineTable; + struct Row Row; + struct Sequence Sequence; + + private: + uint64_t LineTableOffset; + + bool ReportAdvanceAddrProblem = true; + bool ReportBadLineRange = true; + function_ref<void(Error)> ErrorHandler; + }; + + using LineTableMapTy = std::map<uint64_t, LineTable>; + using LineTableIter = LineTableMapTy::iterator; + using LineTableConstIter = LineTableMapTy::const_iterator; + + LineTableMapTy LineTableMap; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGLINE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h index 88f9a0383d..8346f891c2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -1,158 +1,158 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugLoc.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H -#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h" -#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" -#include <cstdint> - -namespace llvm { -class DWARFUnit; -class MCRegisterInfo; -class raw_ostream; - -/// A single location within a location list. Entries are stored in the DWARF5 -/// form even if they originally come from a DWARF<=4 location list. -struct DWARFLocationEntry { - /// The entry kind (DW_LLE_***). - uint8_t Kind; - - /// The first value of the location entry (if applicable). - uint64_t Value0; - - /// The second value of the location entry (if applicable). - uint64_t Value1; - - /// The index of the section this entry is relative to (if applicable). - uint64_t SectionIndex; - - /// The location expression itself (if applicable). - SmallVector<uint8_t, 4> Loc; -}; - -/// An abstract base class for various kinds of location tables (.debug_loc, -/// .debug_loclists, and their dwo variants). -class DWARFLocationTable { -public: - DWARFLocationTable(DWARFDataExtractor Data) : Data(std::move(Data)) {} - virtual ~DWARFLocationTable() = default; - - /// Call the user-provided callback for each entry (including the end-of-list - /// entry) in the location list starting at \p Offset. The callback can return - /// false to terminate the iteration early. Returns an error if it was unable - /// to parse the entire location list correctly. Upon successful termination - /// \p Offset will be updated point past the end of the list. - virtual Error visitLocationList( - uint64_t *Offset, - function_ref<bool(const DWARFLocationEntry &)> Callback) const = 0; - - /// Dump the location list at the given \p Offset. The function returns true - /// iff it has successfully reched the end of the list. This means that one - /// can attempt to parse another list after the current one (\p Offset will be - /// updated to point past the end of the current list). - bool dumpLocationList(uint64_t *Offset, raw_ostream &OS, - Optional<object::SectionedAddress> BaseAddr, - const MCRegisterInfo *MRI, const DWARFObject &Obj, - DWARFUnit *U, DIDumpOptions DumpOpts, - unsigned Indent) const; - - Error visitAbsoluteLocationList( - uint64_t Offset, Optional<object::SectionedAddress> BaseAddr, - std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr, - function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const; - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugLoc.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H +#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h" +#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include <cstdint> + +namespace llvm { +class DWARFUnit; +class MCRegisterInfo; +class raw_ostream; + +/// A single location within a location list. Entries are stored in the DWARF5 +/// form even if they originally come from a DWARF<=4 location list. +struct DWARFLocationEntry { + /// The entry kind (DW_LLE_***). + uint8_t Kind; + + /// The first value of the location entry (if applicable). + uint64_t Value0; + + /// The second value of the location entry (if applicable). + uint64_t Value1; + + /// The index of the section this entry is relative to (if applicable). + uint64_t SectionIndex; + + /// The location expression itself (if applicable). + SmallVector<uint8_t, 4> Loc; +}; + +/// An abstract base class for various kinds of location tables (.debug_loc, +/// .debug_loclists, and their dwo variants). +class DWARFLocationTable { +public: + DWARFLocationTable(DWARFDataExtractor Data) : Data(std::move(Data)) {} + virtual ~DWARFLocationTable() = default; + + /// Call the user-provided callback for each entry (including the end-of-list + /// entry) in the location list starting at \p Offset. The callback can return + /// false to terminate the iteration early. Returns an error if it was unable + /// to parse the entire location list correctly. Upon successful termination + /// \p Offset will be updated point past the end of the list. + virtual Error visitLocationList( + uint64_t *Offset, + function_ref<bool(const DWARFLocationEntry &)> Callback) const = 0; + + /// Dump the location list at the given \p Offset. The function returns true + /// iff it has successfully reched the end of the list. This means that one + /// can attempt to parse another list after the current one (\p Offset will be + /// updated to point past the end of the current list). + bool dumpLocationList(uint64_t *Offset, raw_ostream &OS, + Optional<object::SectionedAddress> BaseAddr, + const MCRegisterInfo *MRI, const DWARFObject &Obj, + DWARFUnit *U, DIDumpOptions DumpOpts, + unsigned Indent) const; + + Error visitAbsoluteLocationList( + uint64_t Offset, Optional<object::SectionedAddress> BaseAddr, + std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr, + function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const; + const DWARFDataExtractor &getData() { return Data; } -protected: - DWARFDataExtractor Data; - - virtual void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, - unsigned Indent, DIDumpOptions DumpOpts, - const DWARFObject &Obj) const = 0; -}; - -class DWARFDebugLoc final : public DWARFLocationTable { -public: - /// A list of locations that contain one variable. - struct LocationList { - /// The beginning offset where this location list is stored in the debug_loc - /// section. - uint64_t Offset; - /// All the locations in which the variable is stored. - SmallVector<DWARFLocationEntry, 2> Entries; - }; - -private: - using LocationLists = SmallVector<LocationList, 4>; - - /// A list of all the variables in the debug_loc section, each one describing - /// the locations in which the variable is stored. - LocationLists Locations; - -public: - DWARFDebugLoc(DWARFDataExtractor Data) - : DWARFLocationTable(std::move(Data)) {} - - /// Print the location lists found within the debug_loc section. - void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, - const DWARFObject &Obj, DIDumpOptions DumpOpts, - Optional<uint64_t> Offset) const; - - Error visitLocationList( - uint64_t *Offset, - function_ref<bool(const DWARFLocationEntry &)> Callback) const override; - -protected: - void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, - unsigned Indent, DIDumpOptions DumpOpts, - const DWARFObject &Obj) const override; -}; - -class DWARFDebugLoclists final : public DWARFLocationTable { -public: - DWARFDebugLoclists(DWARFDataExtractor Data, uint16_t Version) - : DWARFLocationTable(std::move(Data)), Version(Version) {} - - Error visitLocationList( - uint64_t *Offset, - function_ref<bool(const DWARFLocationEntry &)> Callback) const override; - - /// Dump all location lists within the given range. - void dumpRange(uint64_t StartOffset, uint64_t Size, raw_ostream &OS, - const MCRegisterInfo *MRI, const DWARFObject &Obj, - DIDumpOptions DumpOpts); - -protected: - void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, - unsigned Indent, DIDumpOptions DumpOpts, - const DWARFObject &Obj) const override; - -private: - uint16_t Version; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +protected: + DWARFDataExtractor Data; + + virtual void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, + unsigned Indent, DIDumpOptions DumpOpts, + const DWARFObject &Obj) const = 0; +}; + +class DWARFDebugLoc final : public DWARFLocationTable { +public: + /// A list of locations that contain one variable. + struct LocationList { + /// The beginning offset where this location list is stored in the debug_loc + /// section. + uint64_t Offset; + /// All the locations in which the variable is stored. + SmallVector<DWARFLocationEntry, 2> Entries; + }; + +private: + using LocationLists = SmallVector<LocationList, 4>; + + /// A list of all the variables in the debug_loc section, each one describing + /// the locations in which the variable is stored. + LocationLists Locations; + +public: + DWARFDebugLoc(DWARFDataExtractor Data) + : DWARFLocationTable(std::move(Data)) {} + + /// Print the location lists found within the debug_loc section. + void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, + const DWARFObject &Obj, DIDumpOptions DumpOpts, + Optional<uint64_t> Offset) const; + + Error visitLocationList( + uint64_t *Offset, + function_ref<bool(const DWARFLocationEntry &)> Callback) const override; + +protected: + void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, + unsigned Indent, DIDumpOptions DumpOpts, + const DWARFObject &Obj) const override; +}; + +class DWARFDebugLoclists final : public DWARFLocationTable { +public: + DWARFDebugLoclists(DWARFDataExtractor Data, uint16_t Version) + : DWARFLocationTable(std::move(Data)), Version(Version) {} + + Error visitLocationList( + uint64_t *Offset, + function_ref<bool(const DWARFLocationEntry &)> Callback) const override; + + /// Dump all location lists within the given range. + void dumpRange(uint64_t StartOffset, uint64_t Size, raw_ostream &OS, + const MCRegisterInfo *MRI, const DWARFObject &Obj, + DIDumpOptions DumpOpts); + +protected: + void dumpRawEntry(const DWARFLocationEntry &Entry, raw_ostream &OS, + unsigned Indent, DIDumpOptions DumpOpts, + const DWARFObject &Obj) const override; + +private: + uint16_t Version; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h index e48b06f2b5..f731a7f8b3 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h @@ -1,147 +1,147 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugMacro.h ----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H -#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFUnit.h" -#include "llvm/Support/Errc.h" -#include "llvm/Support/Error.h" -#include <cstdint> - -namespace llvm { - -class raw_ostream; - -class DWARFDebugMacro { - /// DWARFv5 section 6.3.1 Macro Information Header. - enum HeaderFlagMask { -#define HANDLE_MACRO_FLAG(ID, NAME) MACRO_##NAME = ID, -#include "llvm/BinaryFormat/Dwarf.def" - }; - struct MacroHeader { - /// Macro version information number. - uint16_t Version = 0; - - /// The bits of the flags field are interpreted as a set of flags, some of - /// which may indicate that additional fields follow. The following flags, - /// beginning with the least significant bit, are defined: - /// offset_size_flag: - /// If the offset_size_flag is zero, the header is for a 32-bit DWARF - /// format macro section and all offsets are 4 bytes long; if it is one, - /// the header is for a 64-bit DWARF format macro section and all offsets - /// are 8 bytes long. - /// debug_line_offset_flag: - /// If the debug_line_offset_flag is one, the debug_line_offset field (see - /// below) is present. If zero, that field is omitted. - /// opcode_operands_table_flag: - /// If the opcode_operands_table_flag is one, the opcode_operands_table - /// field (see below) is present. If zero, that field is omitted. - uint8_t Flags = 0; - - /// debug_line_offset - /// An offset in the .debug_line section of the beginning of the line - /// number information in the containing compilation unit, encoded as a - /// 4-byte offset for a 32-bit DWARF format macro section and an 8-byte - /// offset for a 64-bit DWARF format macro section. - uint64_t DebugLineOffset; - - /// Print the macro header from the debug_macro section. - void dumpMacroHeader(raw_ostream &OS) const; - - /// Parse the debug_macro header. - Error parseMacroHeader(DWARFDataExtractor Data, uint64_t *Offset); - - /// Get the DWARF format according to the flags. - dwarf::DwarfFormat getDwarfFormat() const; - - /// Get the size of a reference according to the DWARF format. - uint8_t getOffsetByteSize() const; - }; - - /// A single macro entry within a macro list. - struct Entry { - /// The type of the macro entry. - uint32_t Type; - union { - /// The source line where the macro is defined. - uint64_t Line; - /// Vendor extension constant value. - uint64_t ExtConstant; - /// Macro unit import offset. - uint64_t ImportOffset; - }; - - union { - /// The string (name, value) of the macro entry. - const char *MacroStr; - // An unsigned integer indicating the identity of the source file. - uint64_t File; - /// Vendor extension string. - const char *ExtStr; - }; - }; - - struct MacroList { - // A value 0 in the `Header.Version` field indicates that we're parsing - // a macinfo[.dwo] section which doesn't have header itself, hence - // for that case other fields in the `Header` are uninitialized. - MacroHeader Header; - SmallVector<Entry, 4> Macros; - uint64_t Offset; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugMacro.h ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H +#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/Support/Errc.h" +#include "llvm/Support/Error.h" +#include <cstdint> + +namespace llvm { + +class raw_ostream; + +class DWARFDebugMacro { + /// DWARFv5 section 6.3.1 Macro Information Header. + enum HeaderFlagMask { +#define HANDLE_MACRO_FLAG(ID, NAME) MACRO_##NAME = ID, +#include "llvm/BinaryFormat/Dwarf.def" + }; + struct MacroHeader { + /// Macro version information number. + uint16_t Version = 0; + + /// The bits of the flags field are interpreted as a set of flags, some of + /// which may indicate that additional fields follow. The following flags, + /// beginning with the least significant bit, are defined: + /// offset_size_flag: + /// If the offset_size_flag is zero, the header is for a 32-bit DWARF + /// format macro section and all offsets are 4 bytes long; if it is one, + /// the header is for a 64-bit DWARF format macro section and all offsets + /// are 8 bytes long. + /// debug_line_offset_flag: + /// If the debug_line_offset_flag is one, the debug_line_offset field (see + /// below) is present. If zero, that field is omitted. + /// opcode_operands_table_flag: + /// If the opcode_operands_table_flag is one, the opcode_operands_table + /// field (see below) is present. If zero, that field is omitted. + uint8_t Flags = 0; + + /// debug_line_offset + /// An offset in the .debug_line section of the beginning of the line + /// number information in the containing compilation unit, encoded as a + /// 4-byte offset for a 32-bit DWARF format macro section and an 8-byte + /// offset for a 64-bit DWARF format macro section. + uint64_t DebugLineOffset; + + /// Print the macro header from the debug_macro section. + void dumpMacroHeader(raw_ostream &OS) const; + + /// Parse the debug_macro header. + Error parseMacroHeader(DWARFDataExtractor Data, uint64_t *Offset); + + /// Get the DWARF format according to the flags. + dwarf::DwarfFormat getDwarfFormat() const; + + /// Get the size of a reference according to the DWARF format. + uint8_t getOffsetByteSize() const; + }; + + /// A single macro entry within a macro list. + struct Entry { + /// The type of the macro entry. + uint32_t Type; + union { + /// The source line where the macro is defined. + uint64_t Line; + /// Vendor extension constant value. + uint64_t ExtConstant; + /// Macro unit import offset. + uint64_t ImportOffset; + }; + + union { + /// The string (name, value) of the macro entry. + const char *MacroStr; + // An unsigned integer indicating the identity of the source file. + uint64_t File; + /// Vendor extension string. + const char *ExtStr; + }; + }; + + struct MacroList { + // A value 0 in the `Header.Version` field indicates that we're parsing + // a macinfo[.dwo] section which doesn't have header itself, hence + // for that case other fields in the `Header` are uninitialized. + MacroHeader Header; + SmallVector<Entry, 4> Macros; + uint64_t Offset; /// Whether or not this is a .debug_macro section. bool IsDebugMacro; - }; - - /// A list of all the macro entries in the debug_macinfo section. - std::vector<MacroList> MacroLists; - -public: - DWARFDebugMacro() = default; - - /// Print the macro list found within the debug_macinfo/debug_macro section. - void dump(raw_ostream &OS) const; - + }; + + /// A list of all the macro entries in the debug_macinfo section. + std::vector<MacroList> MacroLists; + +public: + DWARFDebugMacro() = default; + + /// Print the macro list found within the debug_macinfo/debug_macro section. + void dump(raw_ostream &OS) const; + Error parseMacro(DWARFUnitVector::compile_unit_range Units, - DataExtractor StringExtractor, - DWARFDataExtractor MacroData) { - return parseImpl(Units, StringExtractor, MacroData, /*IsMacro=*/true); - } - - Error parseMacinfo(DWARFDataExtractor MacroData) { - return parseImpl(None, None, MacroData, /*IsMacro=*/false); - } - - /// Return whether the section has any entries. - bool empty() const { return MacroLists.empty(); } - -private: - /// Parse the debug_macinfo/debug_macro section accessible via the 'MacroData' - /// parameter. + DataExtractor StringExtractor, + DWARFDataExtractor MacroData) { + return parseImpl(Units, StringExtractor, MacroData, /*IsMacro=*/true); + } + + Error parseMacinfo(DWARFDataExtractor MacroData) { + return parseImpl(None, None, MacroData, /*IsMacro=*/false); + } + + /// Return whether the section has any entries. + bool empty() const { return MacroLists.empty(); } + +private: + /// Parse the debug_macinfo/debug_macro section accessible via the 'MacroData' + /// parameter. Error parseImpl(Optional<DWARFUnitVector::compile_unit_range> Units, - Optional<DataExtractor> StringExtractor, - DWARFDataExtractor Data, bool IsMacro); -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + Optional<DataExtractor> StringExtractor, + DWARFDataExtractor Data, bool IsMacro); +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h index 36096ad002..e84f5d4c45 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h @@ -1,97 +1,97 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H -#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFObject.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -class raw_ostream; - -/// Represents structure for holding and parsing .debug_pub* tables. -class DWARFDebugPubTable { -public: - struct Entry { - /// Section offset from the beginning of the compilation unit. - uint64_t SecOffset; - - /// An entry of the various gnu_pub* debug sections. - dwarf::PubIndexEntryDescriptor Descriptor; - - /// The name of the object as given by the DW_AT_name attribute of the - /// referenced DIE. - StringRef Name; - }; - - /// Each table consists of sets of variable length entries. Each set describes - /// the names of global objects and functions, or global types, respectively, - /// whose definitions are represented by debugging information entries owned - /// by a single compilation unit. - struct Set { - /// The total length of the entries for that set, not including the length - /// field itself. - uint64_t Length; - - /// The DWARF format of the set. - dwarf::DwarfFormat Format; - - /// This number is specific to the name lookup table and is independent of - /// the DWARF version number. - uint16_t Version; - - /// The offset from the beginning of the .debug_info section of the - /// compilation unit header referenced by the set. - uint64_t Offset; - - /// The size in bytes of the contents of the .debug_info section generated - /// to represent that compilation unit. - uint64_t Size; - - std::vector<Entry> Entries; - }; - -private: - std::vector<Set> Sets; - - /// gnu styled tables contains additional information. - /// This flag determines whether or not section we parse is debug_gnu* table. - bool GnuStyle = false; - -public: - DWARFDebugPubTable() = default; - - void extract(DWARFDataExtractor Data, bool GnuStyle, - function_ref<void(Error)> RecoverableErrorHandler); - - void dump(raw_ostream &OS) const; - - ArrayRef<Set> getData() { return Sets; } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugPubTable.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H +#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFObject.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +class raw_ostream; + +/// Represents structure for holding and parsing .debug_pub* tables. +class DWARFDebugPubTable { +public: + struct Entry { + /// Section offset from the beginning of the compilation unit. + uint64_t SecOffset; + + /// An entry of the various gnu_pub* debug sections. + dwarf::PubIndexEntryDescriptor Descriptor; + + /// The name of the object as given by the DW_AT_name attribute of the + /// referenced DIE. + StringRef Name; + }; + + /// Each table consists of sets of variable length entries. Each set describes + /// the names of global objects and functions, or global types, respectively, + /// whose definitions are represented by debugging information entries owned + /// by a single compilation unit. + struct Set { + /// The total length of the entries for that set, not including the length + /// field itself. + uint64_t Length; + + /// The DWARF format of the set. + dwarf::DwarfFormat Format; + + /// This number is specific to the name lookup table and is independent of + /// the DWARF version number. + uint16_t Version; + + /// The offset from the beginning of the .debug_info section of the + /// compilation unit header referenced by the set. + uint64_t Offset; + + /// The size in bytes of the contents of the .debug_info section generated + /// to represent that compilation unit. + uint64_t Size; + + std::vector<Entry> Entries; + }; + +private: + std::vector<Set> Sets; + + /// gnu styled tables contains additional information. + /// This flag determines whether or not section we parse is debug_gnu* table. + bool GnuStyle = false; + +public: + DWARFDebugPubTable() = default; + + void extract(DWARFDataExtractor Data, bool GnuStyle, + function_ref<void(Error)> RecoverableErrorHandler); + + void dump(raw_ostream &OS) const; + + ArrayRef<Set> getData() { return Sets; } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGPUBTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h index 15dcf96782..f20df06d01 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -1,94 +1,94 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H -#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H - -#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include <cassert> -#include <cstdint> -#include <vector> - -namespace llvm { - -class raw_ostream; - -class DWARFDebugRangeList { -public: - struct RangeListEntry { - /// A beginning address offset. This address offset has the size of an - /// address and is relative to the applicable base address of the - /// compilation unit referencing this range list. It marks the beginning - /// of an address range. - uint64_t StartAddress; - /// An ending address offset. This address offset again has the size of - /// an address and is relative to the applicable base address of the - /// compilation unit referencing this range list. It marks the first - /// address past the end of the address range. The ending address must - /// be greater than or equal to the beginning address. - uint64_t EndAddress; - /// A section index this range belongs to. - uint64_t SectionIndex; - - /// The end of any given range list is marked by an end of list entry, - /// which consists of a 0 for the beginning address offset - /// and a 0 for the ending address offset. - bool isEndOfListEntry() const { - return (StartAddress == 0) && (EndAddress == 0); - } - - /// A base address selection entry consists of: - /// 1. The value of the largest representable address offset - /// (for example, 0xffffffff when the size of an address is 32 bits). - /// 2. An address, which defines the appropriate base address for - /// use in interpreting the beginning and ending address offsets of - /// subsequent entries of the location list. - bool isBaseAddressSelectionEntry(uint8_t AddressSize) const { - assert(AddressSize == 4 || AddressSize == 8); - if (AddressSize == 4) - return StartAddress == -1U; - return StartAddress == -1ULL; - } - }; - -private: - /// Offset in .debug_ranges section. - uint64_t Offset; - uint8_t AddressSize; - std::vector<RangeListEntry> Entries; - -public: - DWARFDebugRangeList() { clear(); } - - void clear(); - void dump(raw_ostream &OS) const; - Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr); - const std::vector<RangeListEntry> &getEntries() { return Entries; } - - /// getAbsoluteRanges - Returns absolute address ranges defined by this range - /// list. Has to be passed base address of the compile unit referencing this - /// range list. - DWARFAddressRangesVector - getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr) const; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H +#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H + +#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include <cassert> +#include <cstdint> +#include <vector> + +namespace llvm { + +class raw_ostream; + +class DWARFDebugRangeList { +public: + struct RangeListEntry { + /// A beginning address offset. This address offset has the size of an + /// address and is relative to the applicable base address of the + /// compilation unit referencing this range list. It marks the beginning + /// of an address range. + uint64_t StartAddress; + /// An ending address offset. This address offset again has the size of + /// an address and is relative to the applicable base address of the + /// compilation unit referencing this range list. It marks the first + /// address past the end of the address range. The ending address must + /// be greater than or equal to the beginning address. + uint64_t EndAddress; + /// A section index this range belongs to. + uint64_t SectionIndex; + + /// The end of any given range list is marked by an end of list entry, + /// which consists of a 0 for the beginning address offset + /// and a 0 for the ending address offset. + bool isEndOfListEntry() const { + return (StartAddress == 0) && (EndAddress == 0); + } + + /// A base address selection entry consists of: + /// 1. The value of the largest representable address offset + /// (for example, 0xffffffff when the size of an address is 32 bits). + /// 2. An address, which defines the appropriate base address for + /// use in interpreting the beginning and ending address offsets of + /// subsequent entries of the location list. + bool isBaseAddressSelectionEntry(uint8_t AddressSize) const { + assert(AddressSize == 4 || AddressSize == 8); + if (AddressSize == 4) + return StartAddress == -1U; + return StartAddress == -1ULL; + } + }; + +private: + /// Offset in .debug_ranges section. + uint64_t Offset; + uint8_t AddressSize; + std::vector<RangeListEntry> Entries; + +public: + DWARFDebugRangeList() { clear(); } + + void clear(); + void dump(raw_ostream &OS) const; + Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr); + const std::vector<RangeListEntry> &getEntries() { return Entries; } + + /// getAbsoluteRanges - Returns absolute address ranges defined by this range + /// list. Has to be passed base address of the compile unit referencing this + /// range list. + DWARFAddressRangesVector + getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr) const; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h index 8c36aff009..e2fe8a3953 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -1,82 +1,82 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDebugRnglists.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H -#define LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H - -#include "llvm/ADT/Optional.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" -#include "llvm/DebugInfo/DWARF/DWARFListTable.h" -#include <cstdint> -#include <map> -#include <vector> - -namespace llvm { - -class Error; -class raw_ostream; -class DWARFUnit; - -/// A class representing a single range list entry. -struct RangeListEntry : public DWARFListEntryBase { - /// The values making up the range list entry. Most represent a range with - /// a start and end address or a start address and a length. Others are - /// single value base addresses or end-of-list with no values. The unneeded - /// values are semantically undefined, but initialized to 0. - uint64_t Value0; - uint64_t Value1; - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDebugRnglists.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H +#define LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H + +#include "llvm/ADT/Optional.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARF/DWARFListTable.h" +#include <cstdint> +#include <map> +#include <vector> + +namespace llvm { + +class Error; +class raw_ostream; +class DWARFUnit; + +/// A class representing a single range list entry. +struct RangeListEntry : public DWARFListEntryBase { + /// The values making up the range list entry. Most represent a range with + /// a start and end address or a start address and a length. Others are + /// single value base addresses or end-of-list with no values. The unneeded + /// values are semantically undefined, but initialized to 0. + uint64_t Value0; + uint64_t Value1; + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); - void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, - uint64_t &CurrentBase, DIDumpOptions DumpOpts, - llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> - LookupPooledAddress) const; - bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; } -}; - -/// A class representing a single rangelist. -class DWARFDebugRnglist : public DWARFListType<RangeListEntry> { -public: - /// Build a DWARFAddressRangesVector from a rangelist. - DWARFAddressRangesVector - getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr, + void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, + uint64_t &CurrentBase, DIDumpOptions DumpOpts, + llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> + LookupPooledAddress) const; + bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; } +}; + +/// A class representing a single rangelist. +class DWARFDebugRnglist : public DWARFListType<RangeListEntry> { +public: + /// Build a DWARFAddressRangesVector from a rangelist. + DWARFAddressRangesVector + getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr, uint8_t AddressByteSize, - function_ref<Optional<object::SectionedAddress>(uint32_t)> - LookupPooledAddress) const; - - /// Build a DWARFAddressRangesVector from a rangelist. - DWARFAddressRangesVector - getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr, - DWARFUnit &U) const; -}; - -class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> { -public: - DWARFDebugRnglistTable() - : DWARFListTableBase(/* SectionName = */ ".debug_rnglists", - /* HeaderString = */ "ranges:", - /* ListTypeString = */ "range") {} -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + function_ref<Optional<object::SectionedAddress>(uint32_t)> + LookupPooledAddress) const; + + /// Build a DWARFAddressRangesVector from a rangelist. + DWARFAddressRangesVector + getAbsoluteRanges(llvm::Optional<object::SectionedAddress> BaseAddr, + DWARFUnit &U) const; +}; + +class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> { +public: + DWARFDebugRnglistTable() + : DWARFListTableBase(/* SectionName = */ ".debug_rnglists", + /* HeaderString = */ "ranges:", + /* ListTypeString = */ "range") {} +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDEBUGRNGLISTS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDie.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDie.h index bea3a8fcf2..e2b027fa8a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -1,492 +1,492 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFDie.h -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFDIE_H -#define LLVM_DEBUGINFO_DWARFDIE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" -#include "llvm/DebugInfo/DWARF/DWARFAttribute.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" -#include <cassert> -#include <cstdint> -#include <iterator> - -namespace llvm { - -class DWARFUnit; -class raw_ostream; - -//===----------------------------------------------------------------------===// -/// Utility class that carries the DWARF compile/type unit and the debug info -/// entry in an object. -/// -/// When accessing information from a debug info entry we always need to DWARF -/// compile/type unit in order to extract the info correctly as some information -/// is relative to the compile/type unit. Prior to this class the DWARFUnit and -/// the DWARFDebugInfoEntry was passed around separately and there was the -/// possibility for error if the wrong DWARFUnit was used to extract a unit -/// relative offset. This class helps to ensure that this doesn't happen and -/// also simplifies the attribute extraction calls by not having to specify the -/// DWARFUnit for each call. -class DWARFDie { - DWARFUnit *U = nullptr; - const DWARFDebugInfoEntry *Die = nullptr; - -public: - DWARFDie() = default; - DWARFDie(DWARFUnit *Unit, const DWARFDebugInfoEntry *D) : U(Unit), Die(D) {} - - bool isValid() const { return U && Die; } - explicit operator bool() const { return isValid(); } - const DWARFDebugInfoEntry *getDebugInfoEntry() const { return Die; } - DWARFUnit *getDwarfUnit() const { return U; } - - /// Get the abbreviation declaration for this DIE. - /// - /// \returns the abbreviation declaration or NULL for null tags. - const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { - assert(isValid() && "must check validity prior to calling"); - return Die->getAbbreviationDeclarationPtr(); - } - - /// Get the absolute offset into the debug info or types section. - /// - /// \returns the DIE offset or -1U if invalid. - uint64_t getOffset() const { - assert(isValid() && "must check validity prior to calling"); - return Die->getOffset(); - } - - dwarf::Tag getTag() const { - auto AbbrevDecl = getAbbreviationDeclarationPtr(); - if (AbbrevDecl) - return AbbrevDecl->getTag(); - return dwarf::DW_TAG_null; - } - - bool hasChildren() const { - assert(isValid() && "must check validity prior to calling"); - return Die->hasChildren(); - } - - /// Returns true for a valid DIE that terminates a sibling chain. - bool isNULL() const { return getAbbreviationDeclarationPtr() == nullptr; } - - /// Returns true if DIE represents a subprogram (not inlined). - bool isSubprogramDIE() const; - - /// Returns true if DIE represents a subprogram or an inlined subroutine. - bool isSubroutineDIE() const; - - /// Get the parent of this DIE object. - /// - /// \returns a valid DWARFDie instance if this object has a parent or an - /// invalid DWARFDie instance if it doesn't. - DWARFDie getParent() const; - - /// Get the sibling of this DIE object. - /// - /// \returns a valid DWARFDie instance if this object has a sibling or an - /// invalid DWARFDie instance if it doesn't. - DWARFDie getSibling() const; - - /// Get the previous sibling of this DIE object. - /// - /// \returns a valid DWARFDie instance if this object has a sibling or an - /// invalid DWARFDie instance if it doesn't. - DWARFDie getPreviousSibling() const; - - /// Get the first child of this DIE object. - /// - /// \returns a valid DWARFDie instance if this object has children or an - /// invalid DWARFDie instance if it doesn't. - DWARFDie getFirstChild() const; - - /// Get the last child of this DIE object. - /// - /// \returns a valid null DWARFDie instance if this object has children or an - /// invalid DWARFDie instance if it doesn't. - DWARFDie getLastChild() const; - - /// Dump the DIE and all of its attributes to the supplied stream. - /// - /// \param OS the stream to use for output. - /// \param indent the number of characters to indent each line that is output. - void dump(raw_ostream &OS, unsigned indent = 0, - DIDumpOptions DumpOpts = DIDumpOptions()) const; - - /// Convenience zero-argument overload for debugging. - LLVM_DUMP_METHOD void dump() const; - - /// Extract the specified attribute from this DIE. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. - /// \returns an optional DWARFFormValue that will have the form value if the - /// attribute was successfully extracted. - Optional<DWARFFormValue> find(dwarf::Attribute Attr) const; - - /// Extract the first value of any attribute in Attrs from this DIE. - /// - /// Extract the first attribute that matches from this DIE only. This call - /// doesn't look for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. The attributes will be searched - /// linearly in the order they are specified within Attrs. - /// - /// \param Attrs an array of DWARF attribute to look for. - /// \returns an optional that has a valid DWARFFormValue for the first - /// matching attribute in Attrs, or None if none of the attributes in Attrs - /// exist in this DIE. - Optional<DWARFFormValue> find(ArrayRef<dwarf::Attribute> Attrs) const; - - /// Extract the first value of any attribute in Attrs from this DIE and - /// recurse into any DW_AT_specification or DW_AT_abstract_origin referenced - /// DIEs. - /// - /// \param Attrs an array of DWARF attribute to look for. - /// \returns an optional that has a valid DWARFFormValue for the first - /// matching attribute in Attrs, or None if none of the attributes in Attrs - /// exist in this DIE or in any DW_AT_specification or DW_AT_abstract_origin - /// DIEs. - Optional<DWARFFormValue> - findRecursively(ArrayRef<dwarf::Attribute> Attrs) const; - - /// Extract the specified attribute from this DIE as the referenced DIE. - /// - /// Regardless of the reference type, return the correct DWARFDie instance if - /// the attribute exists. The returned DWARFDie object might be from another - /// DWARFUnit, but that is all encapsulated in the new DWARFDie object. - /// - /// Extract an attribute value from this DIE only. This call doesn't look - /// for the attribute value in any DW_AT_specification or - /// DW_AT_abstract_origin referenced DIEs. - /// - /// \param Attr the attribute to extract. - /// \returns a valid DWARFDie instance if the attribute exists, or an invalid - /// DWARFDie object if it doesn't. - DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const; - DWARFDie getAttributeValueAsReferencedDie(const DWARFFormValue &V) const; - - /// Extract the range base attribute from this DIE as absolute section offset. - /// - /// This is a utility function that checks for either the DW_AT_rnglists_base - /// or DW_AT_GNU_ranges_base attribute. - /// - /// \returns anm optional absolute section offset value for the attribute. - Optional<uint64_t> getRangesBaseAttribute() const; - Optional<uint64_t> getLocBaseAttribute() const; - - /// Get the DW_AT_high_pc attribute value as an address. - /// - /// In DWARF version 4 and later the high PC can be encoded as an offset from - /// the DW_AT_low_pc. This function takes care of extracting the value as an - /// address or offset and adds it to the low PC if needed and returns the - /// value as an optional in case the DIE doesn't have a DW_AT_high_pc - /// attribute. - /// - /// \param LowPC the low PC that might be needed to calculate the high PC. - /// \returns an optional address value for the attribute. - Optional<uint64_t> getHighPC(uint64_t LowPC) const; - - /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. - /// Returns true if both attributes are present. - bool getLowAndHighPC(uint64_t &LowPC, uint64_t &HighPC, - uint64_t &SectionIndex) const; - - /// Get the address ranges for this DIE. - /// - /// Get the hi/low PC range if both attributes are available or exrtracts the - /// non-contiguous address ranges from the DW_AT_ranges attribute. - /// - /// Extracts the range information from this DIE only. This call doesn't look - /// for the range in any DW_AT_specification or DW_AT_abstract_origin DIEs. - /// - /// \returns a address range vector that might be empty if no address range - /// information is available. - Expected<DWARFAddressRangesVector> getAddressRanges() const; - - /// Get all address ranges for any DW_TAG_subprogram DIEs in this DIE or any - /// of its children. - /// - /// Get the hi/low PC range if both attributes are available or exrtracts the - /// non-contiguous address ranges from the DW_AT_ranges attribute for this DIE - /// and all children. - /// - /// \param Ranges the addres range vector to fill in. - void collectChildrenAddressRanges(DWARFAddressRangesVector &Ranges) const; - - bool addressRangeContainsAddress(const uint64_t Address) const; - - Expected<DWARFLocationExpressionsVector> - getLocations(dwarf::Attribute Attr) const; - - /// If a DIE represents a subprogram (or inlined subroutine), returns its - /// mangled name (or short name, if mangled is missing). This name may be - /// fetched from specification or abstract origin for this subprogram. - /// Returns null if no name is found. - const char *getSubroutineName(DINameKind Kind) const; - - /// Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin - /// references if necessary. For the LinkageName case it additionaly searches - /// for ShortName if LinkageName is not found. - /// Returns null if no name is found. - const char *getName(DINameKind Kind) const; - - /// Return the DIE short name resolving DW_AT_specification or - /// DW_AT_abstract_origin references if necessary. Returns null if no name - /// is found. - const char *getShortName() const; - - /// Return the DIE linkage name resolving DW_AT_specification or - /// DW_AT_abstract_origin references if necessary. Returns null if no name - /// is found. - const char *getLinkageName() const; - - /// Returns the declaration line (start line) for a DIE, assuming it specifies - /// a subprogram. This may be fetched from specification or abstract origin - /// for this subprogram by resolving DW_AT_sepcification or - /// DW_AT_abstract_origin references if necessary. - uint64_t getDeclLine() const; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFDie.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFDIE_H +#define LLVM_DEBUGINFO_DWARFDIE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" +#include "llvm/DebugInfo/DWARF/DWARFAttribute.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" +#include <cassert> +#include <cstdint> +#include <iterator> + +namespace llvm { + +class DWARFUnit; +class raw_ostream; + +//===----------------------------------------------------------------------===// +/// Utility class that carries the DWARF compile/type unit and the debug info +/// entry in an object. +/// +/// When accessing information from a debug info entry we always need to DWARF +/// compile/type unit in order to extract the info correctly as some information +/// is relative to the compile/type unit. Prior to this class the DWARFUnit and +/// the DWARFDebugInfoEntry was passed around separately and there was the +/// possibility for error if the wrong DWARFUnit was used to extract a unit +/// relative offset. This class helps to ensure that this doesn't happen and +/// also simplifies the attribute extraction calls by not having to specify the +/// DWARFUnit for each call. +class DWARFDie { + DWARFUnit *U = nullptr; + const DWARFDebugInfoEntry *Die = nullptr; + +public: + DWARFDie() = default; + DWARFDie(DWARFUnit *Unit, const DWARFDebugInfoEntry *D) : U(Unit), Die(D) {} + + bool isValid() const { return U && Die; } + explicit operator bool() const { return isValid(); } + const DWARFDebugInfoEntry *getDebugInfoEntry() const { return Die; } + DWARFUnit *getDwarfUnit() const { return U; } + + /// Get the abbreviation declaration for this DIE. + /// + /// \returns the abbreviation declaration or NULL for null tags. + const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const { + assert(isValid() && "must check validity prior to calling"); + return Die->getAbbreviationDeclarationPtr(); + } + + /// Get the absolute offset into the debug info or types section. + /// + /// \returns the DIE offset or -1U if invalid. + uint64_t getOffset() const { + assert(isValid() && "must check validity prior to calling"); + return Die->getOffset(); + } + + dwarf::Tag getTag() const { + auto AbbrevDecl = getAbbreviationDeclarationPtr(); + if (AbbrevDecl) + return AbbrevDecl->getTag(); + return dwarf::DW_TAG_null; + } + + bool hasChildren() const { + assert(isValid() && "must check validity prior to calling"); + return Die->hasChildren(); + } + + /// Returns true for a valid DIE that terminates a sibling chain. + bool isNULL() const { return getAbbreviationDeclarationPtr() == nullptr; } + + /// Returns true if DIE represents a subprogram (not inlined). + bool isSubprogramDIE() const; + + /// Returns true if DIE represents a subprogram or an inlined subroutine. + bool isSubroutineDIE() const; + + /// Get the parent of this DIE object. + /// + /// \returns a valid DWARFDie instance if this object has a parent or an + /// invalid DWARFDie instance if it doesn't. + DWARFDie getParent() const; + + /// Get the sibling of this DIE object. + /// + /// \returns a valid DWARFDie instance if this object has a sibling or an + /// invalid DWARFDie instance if it doesn't. + DWARFDie getSibling() const; + + /// Get the previous sibling of this DIE object. + /// + /// \returns a valid DWARFDie instance if this object has a sibling or an + /// invalid DWARFDie instance if it doesn't. + DWARFDie getPreviousSibling() const; + + /// Get the first child of this DIE object. + /// + /// \returns a valid DWARFDie instance if this object has children or an + /// invalid DWARFDie instance if it doesn't. + DWARFDie getFirstChild() const; + + /// Get the last child of this DIE object. + /// + /// \returns a valid null DWARFDie instance if this object has children or an + /// invalid DWARFDie instance if it doesn't. + DWARFDie getLastChild() const; + + /// Dump the DIE and all of its attributes to the supplied stream. + /// + /// \param OS the stream to use for output. + /// \param indent the number of characters to indent each line that is output. + void dump(raw_ostream &OS, unsigned indent = 0, + DIDumpOptions DumpOpts = DIDumpOptions()) const; + + /// Convenience zero-argument overload for debugging. + LLVM_DUMP_METHOD void dump() const; + + /// Extract the specified attribute from this DIE. + /// + /// Extract an attribute value from this DIE only. This call doesn't look + /// for the attribute value in any DW_AT_specification or + /// DW_AT_abstract_origin referenced DIEs. + /// + /// \param Attr the attribute to extract. + /// \returns an optional DWARFFormValue that will have the form value if the + /// attribute was successfully extracted. + Optional<DWARFFormValue> find(dwarf::Attribute Attr) const; + + /// Extract the first value of any attribute in Attrs from this DIE. + /// + /// Extract the first attribute that matches from this DIE only. This call + /// doesn't look for the attribute value in any DW_AT_specification or + /// DW_AT_abstract_origin referenced DIEs. The attributes will be searched + /// linearly in the order they are specified within Attrs. + /// + /// \param Attrs an array of DWARF attribute to look for. + /// \returns an optional that has a valid DWARFFormValue for the first + /// matching attribute in Attrs, or None if none of the attributes in Attrs + /// exist in this DIE. + Optional<DWARFFormValue> find(ArrayRef<dwarf::Attribute> Attrs) const; + + /// Extract the first value of any attribute in Attrs from this DIE and + /// recurse into any DW_AT_specification or DW_AT_abstract_origin referenced + /// DIEs. + /// + /// \param Attrs an array of DWARF attribute to look for. + /// \returns an optional that has a valid DWARFFormValue for the first + /// matching attribute in Attrs, or None if none of the attributes in Attrs + /// exist in this DIE or in any DW_AT_specification or DW_AT_abstract_origin + /// DIEs. + Optional<DWARFFormValue> + findRecursively(ArrayRef<dwarf::Attribute> Attrs) const; + + /// Extract the specified attribute from this DIE as the referenced DIE. + /// + /// Regardless of the reference type, return the correct DWARFDie instance if + /// the attribute exists. The returned DWARFDie object might be from another + /// DWARFUnit, but that is all encapsulated in the new DWARFDie object. + /// + /// Extract an attribute value from this DIE only. This call doesn't look + /// for the attribute value in any DW_AT_specification or + /// DW_AT_abstract_origin referenced DIEs. + /// + /// \param Attr the attribute to extract. + /// \returns a valid DWARFDie instance if the attribute exists, or an invalid + /// DWARFDie object if it doesn't. + DWARFDie getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const; + DWARFDie getAttributeValueAsReferencedDie(const DWARFFormValue &V) const; + + /// Extract the range base attribute from this DIE as absolute section offset. + /// + /// This is a utility function that checks for either the DW_AT_rnglists_base + /// or DW_AT_GNU_ranges_base attribute. + /// + /// \returns anm optional absolute section offset value for the attribute. + Optional<uint64_t> getRangesBaseAttribute() const; + Optional<uint64_t> getLocBaseAttribute() const; + + /// Get the DW_AT_high_pc attribute value as an address. + /// + /// In DWARF version 4 and later the high PC can be encoded as an offset from + /// the DW_AT_low_pc. This function takes care of extracting the value as an + /// address or offset and adds it to the low PC if needed and returns the + /// value as an optional in case the DIE doesn't have a DW_AT_high_pc + /// attribute. + /// + /// \param LowPC the low PC that might be needed to calculate the high PC. + /// \returns an optional address value for the attribute. + Optional<uint64_t> getHighPC(uint64_t LowPC) const; + + /// Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. + /// Returns true if both attributes are present. + bool getLowAndHighPC(uint64_t &LowPC, uint64_t &HighPC, + uint64_t &SectionIndex) const; + + /// Get the address ranges for this DIE. + /// + /// Get the hi/low PC range if both attributes are available or exrtracts the + /// non-contiguous address ranges from the DW_AT_ranges attribute. + /// + /// Extracts the range information from this DIE only. This call doesn't look + /// for the range in any DW_AT_specification or DW_AT_abstract_origin DIEs. + /// + /// \returns a address range vector that might be empty if no address range + /// information is available. + Expected<DWARFAddressRangesVector> getAddressRanges() const; + + /// Get all address ranges for any DW_TAG_subprogram DIEs in this DIE or any + /// of its children. + /// + /// Get the hi/low PC range if both attributes are available or exrtracts the + /// non-contiguous address ranges from the DW_AT_ranges attribute for this DIE + /// and all children. + /// + /// \param Ranges the addres range vector to fill in. + void collectChildrenAddressRanges(DWARFAddressRangesVector &Ranges) const; + + bool addressRangeContainsAddress(const uint64_t Address) const; + + Expected<DWARFLocationExpressionsVector> + getLocations(dwarf::Attribute Attr) const; + + /// If a DIE represents a subprogram (or inlined subroutine), returns its + /// mangled name (or short name, if mangled is missing). This name may be + /// fetched from specification or abstract origin for this subprogram. + /// Returns null if no name is found. + const char *getSubroutineName(DINameKind Kind) const; + + /// Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin + /// references if necessary. For the LinkageName case it additionaly searches + /// for ShortName if LinkageName is not found. + /// Returns null if no name is found. + const char *getName(DINameKind Kind) const; + + /// Return the DIE short name resolving DW_AT_specification or + /// DW_AT_abstract_origin references if necessary. Returns null if no name + /// is found. + const char *getShortName() const; + + /// Return the DIE linkage name resolving DW_AT_specification or + /// DW_AT_abstract_origin references if necessary. Returns null if no name + /// is found. + const char *getLinkageName() const; + + /// Returns the declaration line (start line) for a DIE, assuming it specifies + /// a subprogram. This may be fetched from specification or abstract origin + /// for this subprogram by resolving DW_AT_sepcification or + /// DW_AT_abstract_origin references if necessary. + uint64_t getDeclLine() const; std::string getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const; - - /// Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column - /// from DIE (or zeroes if they are missing). This function looks for - /// DW_AT_call attributes in this DIE only, it will not resolve the attribute - /// values in any DW_AT_specification or DW_AT_abstract_origin DIEs. - /// \param CallFile filled in with non-zero if successful, zero if there is no - /// DW_AT_call_file attribute in this DIE. - /// \param CallLine filled in with non-zero if successful, zero if there is no - /// DW_AT_call_line attribute in this DIE. - /// \param CallColumn filled in with non-zero if successful, zero if there is - /// no DW_AT_call_column attribute in this DIE. - /// \param CallDiscriminator filled in with non-zero if successful, zero if - /// there is no DW_AT_GNU_discriminator attribute in this DIE. - void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, - uint32_t &CallColumn, uint32_t &CallDiscriminator) const; - - class attribute_iterator; - - /// Get an iterator range to all attributes in the current DIE only. - /// - /// \returns an iterator range for the attributes of the current DIE. - iterator_range<attribute_iterator> attributes() const; - - class iterator; - - iterator begin() const; - iterator end() const; - - std::reverse_iterator<iterator> rbegin() const; - std::reverse_iterator<iterator> rend() const; - - iterator_range<iterator> children() const; -}; - -class DWARFDie::attribute_iterator - : public iterator_facade_base<attribute_iterator, std::forward_iterator_tag, - const DWARFAttribute> { - /// The DWARF DIE we are extracting attributes from. - DWARFDie Die; - /// The value vended to clients via the operator*() or operator->(). - DWARFAttribute AttrValue; - /// The attribute index within the abbreviation declaration in Die. - uint32_t Index; - - friend bool operator==(const attribute_iterator &LHS, - const attribute_iterator &RHS); - - /// Update the attribute index and attempt to read the attribute value. If the - /// attribute is able to be read, update AttrValue and the Index member - /// variable. If the attribute value is not able to be read, an appropriate - /// error will be set if the Err member variable is non-NULL and the iterator - /// will be set to the end value so iteration stops. - void updateForIndex(const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I); - -public: - attribute_iterator() = delete; - explicit attribute_iterator(DWARFDie D, bool End); - - attribute_iterator &operator++(); - attribute_iterator &operator--(); - explicit operator bool() const { return AttrValue.isValid(); } - const DWARFAttribute &operator*() const { return AttrValue; } -}; - -inline bool operator==(const DWARFDie::attribute_iterator &LHS, - const DWARFDie::attribute_iterator &RHS) { - return LHS.Index == RHS.Index; -} - -inline bool operator!=(const DWARFDie::attribute_iterator &LHS, - const DWARFDie::attribute_iterator &RHS) { - return !(LHS == RHS); -} - -inline bool operator==(const DWARFDie &LHS, const DWARFDie &RHS) { - return LHS.getDebugInfoEntry() == RHS.getDebugInfoEntry() && - LHS.getDwarfUnit() == RHS.getDwarfUnit(); -} - -inline bool operator!=(const DWARFDie &LHS, const DWARFDie &RHS) { - return !(LHS == RHS); -} - -inline bool operator<(const DWARFDie &LHS, const DWARFDie &RHS) { - return LHS.getOffset() < RHS.getOffset(); -} - -class DWARFDie::iterator - : public iterator_facade_base<iterator, std::bidirectional_iterator_tag, - const DWARFDie> { - DWARFDie Die; - - friend std::reverse_iterator<llvm::DWARFDie::iterator>; - friend bool operator==(const DWARFDie::iterator &LHS, - const DWARFDie::iterator &RHS); - -public: - iterator() = default; - - explicit iterator(DWARFDie D) : Die(D) {} - - iterator &operator++() { - Die = Die.getSibling(); - return *this; - } - - iterator &operator--() { - Die = Die.getPreviousSibling(); - return *this; - } - - const DWARFDie &operator*() const { return Die; } -}; - -inline bool operator==(const DWARFDie::iterator &LHS, - const DWARFDie::iterator &RHS) { - return LHS.Die == RHS.Die; -} - -// These inline functions must follow the DWARFDie::iterator definition above -// as they use functions from that class. -inline DWARFDie::iterator DWARFDie::begin() const { - return iterator(getFirstChild()); -} - -inline DWARFDie::iterator DWARFDie::end() const { - return iterator(getLastChild()); -} - -inline iterator_range<DWARFDie::iterator> DWARFDie::children() const { - return make_range(begin(), end()); -} - -} // end namespace llvm - -namespace std { - -template <> -class reverse_iterator<llvm::DWARFDie::iterator> - : public llvm::iterator_facade_base< - reverse_iterator<llvm::DWARFDie::iterator>, - bidirectional_iterator_tag, const llvm::DWARFDie> { - -private: - llvm::DWARFDie Die; - bool AtEnd; - -public: - reverse_iterator(llvm::DWARFDie::iterator It) - : Die(It.Die), AtEnd(!It.Die.getPreviousSibling()) { - if (!AtEnd) - Die = Die.getPreviousSibling(); - } - - llvm::DWARFDie::iterator base() const { - return llvm::DWARFDie::iterator(AtEnd ? Die : Die.getSibling()); - } - - reverse_iterator<llvm::DWARFDie::iterator> &operator++() { - assert(!AtEnd && "Incrementing rend"); - llvm::DWARFDie D = Die.getPreviousSibling(); - if (D) - Die = D; - else - AtEnd = true; - return *this; - } - - reverse_iterator<llvm::DWARFDie::iterator> &operator--() { - if (AtEnd) { - AtEnd = false; - return *this; - } - Die = Die.getSibling(); - assert(!Die.isNULL() && "Decrementing rbegin"); - return *this; - } - - const llvm::DWARFDie &operator*() const { - assert(Die.isValid()); - return Die; - } - - // FIXME: We should be able to specify the equals operator as a friend, but - // that causes the compiler to think the operator overload is ambiguous - // with the friend declaration and the actual definition as candidates. - bool equals(const reverse_iterator<llvm::DWARFDie::iterator> &RHS) const { - return Die == RHS.Die && AtEnd == RHS.AtEnd; - } -}; - -} // namespace std - -namespace llvm { - -inline bool operator==(const std::reverse_iterator<DWARFDie::iterator> &LHS, - const std::reverse_iterator<DWARFDie::iterator> &RHS) { - return LHS.equals(RHS); -} - + + /// Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column + /// from DIE (or zeroes if they are missing). This function looks for + /// DW_AT_call attributes in this DIE only, it will not resolve the attribute + /// values in any DW_AT_specification or DW_AT_abstract_origin DIEs. + /// \param CallFile filled in with non-zero if successful, zero if there is no + /// DW_AT_call_file attribute in this DIE. + /// \param CallLine filled in with non-zero if successful, zero if there is no + /// DW_AT_call_line attribute in this DIE. + /// \param CallColumn filled in with non-zero if successful, zero if there is + /// no DW_AT_call_column attribute in this DIE. + /// \param CallDiscriminator filled in with non-zero if successful, zero if + /// there is no DW_AT_GNU_discriminator attribute in this DIE. + void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine, + uint32_t &CallColumn, uint32_t &CallDiscriminator) const; + + class attribute_iterator; + + /// Get an iterator range to all attributes in the current DIE only. + /// + /// \returns an iterator range for the attributes of the current DIE. + iterator_range<attribute_iterator> attributes() const; + + class iterator; + + iterator begin() const; + iterator end() const; + + std::reverse_iterator<iterator> rbegin() const; + std::reverse_iterator<iterator> rend() const; + + iterator_range<iterator> children() const; +}; + +class DWARFDie::attribute_iterator + : public iterator_facade_base<attribute_iterator, std::forward_iterator_tag, + const DWARFAttribute> { + /// The DWARF DIE we are extracting attributes from. + DWARFDie Die; + /// The value vended to clients via the operator*() or operator->(). + DWARFAttribute AttrValue; + /// The attribute index within the abbreviation declaration in Die. + uint32_t Index; + + friend bool operator==(const attribute_iterator &LHS, + const attribute_iterator &RHS); + + /// Update the attribute index and attempt to read the attribute value. If the + /// attribute is able to be read, update AttrValue and the Index member + /// variable. If the attribute value is not able to be read, an appropriate + /// error will be set if the Err member variable is non-NULL and the iterator + /// will be set to the end value so iteration stops. + void updateForIndex(const DWARFAbbreviationDeclaration &AbbrDecl, uint32_t I); + +public: + attribute_iterator() = delete; + explicit attribute_iterator(DWARFDie D, bool End); + + attribute_iterator &operator++(); + attribute_iterator &operator--(); + explicit operator bool() const { return AttrValue.isValid(); } + const DWARFAttribute &operator*() const { return AttrValue; } +}; + +inline bool operator==(const DWARFDie::attribute_iterator &LHS, + const DWARFDie::attribute_iterator &RHS) { + return LHS.Index == RHS.Index; +} + +inline bool operator!=(const DWARFDie::attribute_iterator &LHS, + const DWARFDie::attribute_iterator &RHS) { + return !(LHS == RHS); +} + +inline bool operator==(const DWARFDie &LHS, const DWARFDie &RHS) { + return LHS.getDebugInfoEntry() == RHS.getDebugInfoEntry() && + LHS.getDwarfUnit() == RHS.getDwarfUnit(); +} + +inline bool operator!=(const DWARFDie &LHS, const DWARFDie &RHS) { + return !(LHS == RHS); +} + +inline bool operator<(const DWARFDie &LHS, const DWARFDie &RHS) { + return LHS.getOffset() < RHS.getOffset(); +} + +class DWARFDie::iterator + : public iterator_facade_base<iterator, std::bidirectional_iterator_tag, + const DWARFDie> { + DWARFDie Die; + + friend std::reverse_iterator<llvm::DWARFDie::iterator>; + friend bool operator==(const DWARFDie::iterator &LHS, + const DWARFDie::iterator &RHS); + +public: + iterator() = default; + + explicit iterator(DWARFDie D) : Die(D) {} + + iterator &operator++() { + Die = Die.getSibling(); + return *this; + } + + iterator &operator--() { + Die = Die.getPreviousSibling(); + return *this; + } + + const DWARFDie &operator*() const { return Die; } +}; + +inline bool operator==(const DWARFDie::iterator &LHS, + const DWARFDie::iterator &RHS) { + return LHS.Die == RHS.Die; +} + +// These inline functions must follow the DWARFDie::iterator definition above +// as they use functions from that class. +inline DWARFDie::iterator DWARFDie::begin() const { + return iterator(getFirstChild()); +} + +inline DWARFDie::iterator DWARFDie::end() const { + return iterator(getLastChild()); +} + +inline iterator_range<DWARFDie::iterator> DWARFDie::children() const { + return make_range(begin(), end()); +} + +} // end namespace llvm + +namespace std { + +template <> +class reverse_iterator<llvm::DWARFDie::iterator> + : public llvm::iterator_facade_base< + reverse_iterator<llvm::DWARFDie::iterator>, + bidirectional_iterator_tag, const llvm::DWARFDie> { + +private: + llvm::DWARFDie Die; + bool AtEnd; + +public: + reverse_iterator(llvm::DWARFDie::iterator It) + : Die(It.Die), AtEnd(!It.Die.getPreviousSibling()) { + if (!AtEnd) + Die = Die.getPreviousSibling(); + } + + llvm::DWARFDie::iterator base() const { + return llvm::DWARFDie::iterator(AtEnd ? Die : Die.getSibling()); + } + + reverse_iterator<llvm::DWARFDie::iterator> &operator++() { + assert(!AtEnd && "Incrementing rend"); + llvm::DWARFDie D = Die.getPreviousSibling(); + if (D) + Die = D; + else + AtEnd = true; + return *this; + } + + reverse_iterator<llvm::DWARFDie::iterator> &operator--() { + if (AtEnd) { + AtEnd = false; + return *this; + } + Die = Die.getSibling(); + assert(!Die.isNULL() && "Decrementing rbegin"); + return *this; + } + + const llvm::DWARFDie &operator*() const { + assert(Die.isValid()); + return Die; + } + + // FIXME: We should be able to specify the equals operator as a friend, but + // that causes the compiler to think the operator overload is ambiguous + // with the friend declaration and the actual definition as candidates. + bool equals(const reverse_iterator<llvm::DWARFDie::iterator> &RHS) const { + return Die == RHS.Die && AtEnd == RHS.AtEnd; + } +}; + +} // namespace std + +namespace llvm { + +inline bool operator==(const std::reverse_iterator<DWARFDie::iterator> &LHS, + const std::reverse_iterator<DWARFDie::iterator> &RHS) { + return LHS.equals(RHS); +} + inline bool operator!=(const std::reverse_iterator<DWARFDie::iterator> &LHS, const std::reverse_iterator<DWARFDie::iterator> &RHS) { return !(LHS == RHS); } -inline std::reverse_iterator<DWARFDie::iterator> DWARFDie::rbegin() const { - return llvm::make_reverse_iterator(end()); -} - -inline std::reverse_iterator<DWARFDie::iterator> DWARFDie::rend() const { - return llvm::make_reverse_iterator(begin()); -} - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFDIE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +inline std::reverse_iterator<DWARFDie::iterator> DWARFDie::rbegin() const { + return llvm::make_reverse_iterator(end()); +} + +inline std::reverse_iterator<DWARFDie::iterator> DWARFDie::rend() const { + return llvm::make_reverse_iterator(begin()); +} + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFDIE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFExpression.h index 42e2b82046..3e975179a8 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -1,182 +1,182 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===--- DWARFExpression.h - DWARF Expression handling ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFEXPRESSION_H -#define LLVM_DEBUGINFO_DWARFEXPRESSION_H - -#include "llvm/ADT/ArrayRef.h" +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===--- DWARFExpression.h - DWARF Expression handling ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFEXPRESSION_H +#define LLVM_DEBUGINFO_DWARFEXPRESSION_H + +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DIContext.h" -#include "llvm/Support/DataExtractor.h" - -namespace llvm { -class DWARFUnit; -class MCRegisterInfo; -class raw_ostream; - -class DWARFExpression { -public: - class iterator; - - /// This class represents an Operation in the Expression. Each operation can - /// have up to 2 oprerands. - /// - /// An Operation can be in Error state (check with isError()). This - /// means that it couldn't be decoded successfully and if it is the - /// case, all others fields contain undefined values. - class Operation { - public: - /// Size and signedness of expression operations' operands. - enum Encoding : uint8_t { - Size1 = 0, - Size2 = 1, - Size4 = 2, - Size8 = 3, - SizeLEB = 4, - SizeAddr = 5, - SizeRefAddr = 6, - SizeBlock = 7, ///< Preceding operand contains block size - BaseTypeRef = 8, - WasmLocationArg = 30, - SignBit = 0x80, - SignedSize1 = SignBit | Size1, - SignedSize2 = SignBit | Size2, - SignedSize4 = SignBit | Size4, - SignedSize8 = SignBit | Size8, - SignedSizeLEB = SignBit | SizeLEB, - SizeNA = 0xFF ///< Unused operands get this encoding. - }; - - enum DwarfVersion : uint8_t { - DwarfNA, ///< Serves as a marker for unused entries - Dwarf2 = 2, - Dwarf3, - Dwarf4, - Dwarf5 - }; - - /// Description of the encoding of one expression Op. - struct Description { - DwarfVersion Version; ///< Dwarf version where the Op was introduced. - Encoding Op[2]; ///< Encoding for Op operands, or SizeNA. - - Description(DwarfVersion Version = DwarfNA, Encoding Op1 = SizeNA, - Encoding Op2 = SizeNA) - : Version(Version) { - Op[0] = Op1; - Op[1] = Op2; - } - }; - - private: - friend class DWARFExpression::iterator; - uint8_t Opcode; ///< The Op Opcode, DW_OP_<something>. - Description Desc; - bool Error; - uint64_t EndOffset; - uint64_t Operands[2]; - uint64_t OperandEndOffsets[2]; - - public: - Description &getDescription() { return Desc; } - uint8_t getCode() { return Opcode; } - uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } - uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } - uint64_t getEndOffset() { return EndOffset; } - bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, - Optional<dwarf::DwarfFormat> Format); - bool isError() { return Error; } +#include "llvm/Support/DataExtractor.h" + +namespace llvm { +class DWARFUnit; +class MCRegisterInfo; +class raw_ostream; + +class DWARFExpression { +public: + class iterator; + + /// This class represents an Operation in the Expression. Each operation can + /// have up to 2 oprerands. + /// + /// An Operation can be in Error state (check with isError()). This + /// means that it couldn't be decoded successfully and if it is the + /// case, all others fields contain undefined values. + class Operation { + public: + /// Size and signedness of expression operations' operands. + enum Encoding : uint8_t { + Size1 = 0, + Size2 = 1, + Size4 = 2, + Size8 = 3, + SizeLEB = 4, + SizeAddr = 5, + SizeRefAddr = 6, + SizeBlock = 7, ///< Preceding operand contains block size + BaseTypeRef = 8, + WasmLocationArg = 30, + SignBit = 0x80, + SignedSize1 = SignBit | Size1, + SignedSize2 = SignBit | Size2, + SignedSize4 = SignBit | Size4, + SignedSize8 = SignBit | Size8, + SignedSizeLEB = SignBit | SizeLEB, + SizeNA = 0xFF ///< Unused operands get this encoding. + }; + + enum DwarfVersion : uint8_t { + DwarfNA, ///< Serves as a marker for unused entries + Dwarf2 = 2, + Dwarf3, + Dwarf4, + Dwarf5 + }; + + /// Description of the encoding of one expression Op. + struct Description { + DwarfVersion Version; ///< Dwarf version where the Op was introduced. + Encoding Op[2]; ///< Encoding for Op operands, or SizeNA. + + Description(DwarfVersion Version = DwarfNA, Encoding Op1 = SizeNA, + Encoding Op2 = SizeNA) + : Version(Version) { + Op[0] = Op1; + Op[1] = Op2; + } + }; + + private: + friend class DWARFExpression::iterator; + uint8_t Opcode; ///< The Op Opcode, DW_OP_<something>. + Description Desc; + bool Error; + uint64_t EndOffset; + uint64_t Operands[2]; + uint64_t OperandEndOffsets[2]; + + public: + Description &getDescription() { return Desc; } + uint8_t getCode() { return Opcode; } + uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } + uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } + uint64_t getEndOffset() { return EndOffset; } + bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, + Optional<dwarf::DwarfFormat> Format); + bool isError() { return Error; } bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH); - bool verify(DWARFUnit *U); - }; - - /// An iterator to go through the expression operations. - class iterator - : public iterator_facade_base<iterator, std::forward_iterator_tag, - Operation> { - friend class DWARFExpression; - const DWARFExpression *Expr; - uint64_t Offset; - Operation Op; - iterator(const DWARFExpression *Expr, uint64_t Offset) - : Expr(Expr), Offset(Offset) { - Op.Error = - Offset >= Expr->Data.getData().size() || - !Op.extract(Expr->Data, Expr->AddressSize, Offset, Expr->Format); - } - - public: - class Operation &operator++() { - Offset = Op.isError() ? Expr->Data.getData().size() : Op.EndOffset; - Op.Error = - Offset >= Expr->Data.getData().size() || - !Op.extract(Expr->Data, Expr->AddressSize, Offset, Expr->Format); - return Op; - } - - class Operation &operator*() { - return Op; - } - - iterator skipBytes(uint64_t Add) { - return iterator(Expr, Op.EndOffset + Add); - } - - // Comparison operators are provided out of line. - friend bool operator==(const iterator &, const iterator &); - }; - - DWARFExpression(DataExtractor Data, uint8_t AddressSize, - Optional<dwarf::DwarfFormat> Format = None) - : Data(Data), AddressSize(AddressSize), Format(Format) { - assert(AddressSize == 8 || AddressSize == 4 || AddressSize == 2); - } - - iterator begin() const { return iterator(this, 0); } - iterator end() const { return iterator(this, Data.getData().size()); } - + bool verify(DWARFUnit *U); + }; + + /// An iterator to go through the expression operations. + class iterator + : public iterator_facade_base<iterator, std::forward_iterator_tag, + Operation> { + friend class DWARFExpression; + const DWARFExpression *Expr; + uint64_t Offset; + Operation Op; + iterator(const DWARFExpression *Expr, uint64_t Offset) + : Expr(Expr), Offset(Offset) { + Op.Error = + Offset >= Expr->Data.getData().size() || + !Op.extract(Expr->Data, Expr->AddressSize, Offset, Expr->Format); + } + + public: + class Operation &operator++() { + Offset = Op.isError() ? Expr->Data.getData().size() : Op.EndOffset; + Op.Error = + Offset >= Expr->Data.getData().size() || + !Op.extract(Expr->Data, Expr->AddressSize, Offset, Expr->Format); + return Op; + } + + class Operation &operator*() { + return Op; + } + + iterator skipBytes(uint64_t Add) { + return iterator(Expr, Op.EndOffset + Add); + } + + // Comparison operators are provided out of line. + friend bool operator==(const iterator &, const iterator &); + }; + + DWARFExpression(DataExtractor Data, uint8_t AddressSize, + Optional<dwarf::DwarfFormat> Format = None) + : Data(Data), AddressSize(AddressSize), Format(Format) { + assert(AddressSize == 8 || AddressSize == 4 || AddressSize == 2); + } + + iterator begin() const { return iterator(this, 0); } + iterator end() const { return iterator(this, Data.getData().size()); } + void print(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *RegInfo, DWARFUnit *U, - bool IsEH = false) const; - - /// Print the expression in a format intended to be compact and useful to a - /// user, but not perfectly unambiguous, or capable of representing every - /// valid DWARF expression. Returns true if the expression was sucessfully - /// printed. - bool printCompact(raw_ostream &OS, const MCRegisterInfo &RegInfo); - - bool verify(DWARFUnit *U); - -private: - DataExtractor Data; - uint8_t AddressSize; - Optional<dwarf::DwarfFormat> Format; -}; - -inline bool operator==(const DWARFExpression::iterator &LHS, - const DWARFExpression::iterator &RHS) { - return LHS.Expr == RHS.Expr && LHS.Offset == RHS.Offset; -} -} -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + bool IsEH = false) const; + + /// Print the expression in a format intended to be compact and useful to a + /// user, but not perfectly unambiguous, or capable of representing every + /// valid DWARF expression. Returns true if the expression was sucessfully + /// printed. + bool printCompact(raw_ostream &OS, const MCRegisterInfo &RegInfo); + + bool verify(DWARFUnit *U); + +private: + DataExtractor Data; + uint8_t AddressSize; + Optional<dwarf::DwarfFormat> Format; +}; + +inline bool operator==(const DWARFExpression::iterator &LHS, + const DWARFExpression::iterator &RHS) { + return LHS.Expr == RHS.Expr && LHS.Offset == RHS.Offset; +} +} +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFFormValue.h index 4cc118ac5a..87183efe5d 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -1,337 +1,337 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFFormValue.h -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H -#define LLVM_DEBUGINFO_DWARFFORMVALUE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include <cstdint> - -namespace llvm { - -class DWARFContext; -class DWARFUnit; -class raw_ostream; - -class DWARFFormValue { -public: - enum FormClass { - FC_Unknown, - FC_Address, - FC_Block, - FC_Constant, - FC_String, - FC_Flag, - FC_Reference, - FC_Indirect, - FC_SectionOffset, - FC_Exprloc - }; - -private: - struct ValueType { - ValueType() { uval = 0; } - ValueType(int64_t V) : sval(V) {} - ValueType(uint64_t V) : uval(V) {} - ValueType(const char *V) : cstr(V) {} - - union { - uint64_t uval; - int64_t sval; - const char *cstr; - }; - const uint8_t *data = nullptr; - uint64_t SectionIndex; /// Section index for reference forms. - }; - - dwarf::Form Form; /// Form for this value. - dwarf::DwarfFormat Format = - dwarf::DWARF32; /// Remember the DWARF format at extract time. - ValueType Value; /// Contains all data for the form. - const DWARFUnit *U = nullptr; /// Remember the DWARFUnit at extract time. - const DWARFContext *C = nullptr; /// Context for extract time. - - DWARFFormValue(dwarf::Form F, ValueType V) : Form(F), Value(V) {} - -public: - DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {} - - static DWARFFormValue createFromSValue(dwarf::Form F, int64_t V); - static DWARFFormValue createFromUValue(dwarf::Form F, uint64_t V); - static DWARFFormValue createFromPValue(dwarf::Form F, const char *V); - static DWARFFormValue createFromBlockValue(dwarf::Form F, - ArrayRef<uint8_t> D); - static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit, - uint64_t *OffsetPtr); - - dwarf::Form getForm() const { return Form; } - uint64_t getRawUValue() const { return Value.uval; } - - bool isFormClass(FormClass FC) const; - const DWARFUnit *getUnit() const { return U; } - void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const; - void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts, - object::SectionedAddress SA) const; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFFormValue.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H +#define LLVM_DEBUGINFO_DWARFFORMVALUE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include <cstdint> + +namespace llvm { + +class DWARFContext; +class DWARFUnit; +class raw_ostream; + +class DWARFFormValue { +public: + enum FormClass { + FC_Unknown, + FC_Address, + FC_Block, + FC_Constant, + FC_String, + FC_Flag, + FC_Reference, + FC_Indirect, + FC_SectionOffset, + FC_Exprloc + }; + +private: + struct ValueType { + ValueType() { uval = 0; } + ValueType(int64_t V) : sval(V) {} + ValueType(uint64_t V) : uval(V) {} + ValueType(const char *V) : cstr(V) {} + + union { + uint64_t uval; + int64_t sval; + const char *cstr; + }; + const uint8_t *data = nullptr; + uint64_t SectionIndex; /// Section index for reference forms. + }; + + dwarf::Form Form; /// Form for this value. + dwarf::DwarfFormat Format = + dwarf::DWARF32; /// Remember the DWARF format at extract time. + ValueType Value; /// Contains all data for the form. + const DWARFUnit *U = nullptr; /// Remember the DWARFUnit at extract time. + const DWARFContext *C = nullptr; /// Context for extract time. + + DWARFFormValue(dwarf::Form F, ValueType V) : Form(F), Value(V) {} + +public: + DWARFFormValue(dwarf::Form F = dwarf::Form(0)) : Form(F) {} + + static DWARFFormValue createFromSValue(dwarf::Form F, int64_t V); + static DWARFFormValue createFromUValue(dwarf::Form F, uint64_t V); + static DWARFFormValue createFromPValue(dwarf::Form F, const char *V); + static DWARFFormValue createFromBlockValue(dwarf::Form F, + ArrayRef<uint8_t> D); + static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit, + uint64_t *OffsetPtr); + + dwarf::Form getForm() const { return Form; } + uint64_t getRawUValue() const { return Value.uval; } + + bool isFormClass(FormClass FC) const; + const DWARFUnit *getUnit() const { return U; } + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const; + void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts, + object::SectionedAddress SA) const; void dumpAddress(raw_ostream &OS, uint64_t Address) const; static void dumpAddress(raw_ostream &OS, uint8_t AddressSize, uint64_t Address); - static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS, - DIDumpOptions DumpOpts, uint64_t SectionIndex); - - /// Extracts a value in \p Data at offset \p *OffsetPtr. The information - /// in \p FormParams is needed to interpret some forms. The optional - /// \p Context and \p Unit allows extracting information if the form refers - /// to other sections (e.g., .debug_str). - bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - dwarf::FormParams FormParams, - const DWARFContext *Context = nullptr, - const DWARFUnit *Unit = nullptr); - - bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, - dwarf::FormParams FormParams, const DWARFUnit *U) { - return extractValue(Data, OffsetPtr, FormParams, nullptr, U); - } - - bool isInlinedCStr() const { - return Value.data != nullptr && Value.data == (const uint8_t *)Value.cstr; - } - - /// getAsFoo functions below return the extracted value as Foo if only - /// DWARFFormValue has form class is suitable for representing Foo. - Optional<uint64_t> getAsReference() const; - struct UnitOffset { - DWARFUnit *Unit; - uint64_t Offset; - }; - Optional<UnitOffset> getAsRelativeReference() const; - Optional<uint64_t> getAsUnsignedConstant() const; - Optional<int64_t> getAsSignedConstant() const; - Optional<const char *> getAsCString() const; - Optional<uint64_t> getAsAddress() const; - Optional<object::SectionedAddress> getAsSectionedAddress() const; - Optional<uint64_t> getAsSectionOffset() const; - Optional<ArrayRef<uint8_t>> getAsBlock() const; - Optional<uint64_t> getAsCStringOffset() const; - Optional<uint64_t> getAsReferenceUVal() const; - - /// Skip a form's value in \p DebugInfoData at the offset specified by - /// \p OffsetPtr. - /// - /// Skips the bytes for the current form and updates the offset. - /// - /// \param DebugInfoData The data where we want to skip the value. - /// \param OffsetPtr A reference to the offset that will be updated. - /// \param Params DWARF parameters to help interpret forms. - /// \returns true on success, false if the form was not skipped. - bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, - const dwarf::FormParams Params) const { - return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params); - } - - /// Skip a form's value in \p DebugInfoData at the offset specified by - /// \p OffsetPtr. - /// - /// Skips the bytes for the specified form and updates the offset. - /// - /// \param Form The DW_FORM enumeration that indicates the form to skip. - /// \param DebugInfoData The data where we want to skip the value. - /// \param OffsetPtr A reference to the offset that will be updated. - /// \param FormParams DWARF parameters to help interpret forms. - /// \returns true on success, false if the form was not skipped. - static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData, - uint64_t *OffsetPtr, - const dwarf::FormParams FormParams); - -private: - void dumpString(raw_ostream &OS) const; -}; - -namespace dwarf { - -/// Take an optional DWARFFormValue and try to extract a string value from it. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and was a string. -inline Optional<const char *> toString(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsCString(); - return None; -} - -/// Take an optional DWARFFormValue and try to extract a string value from it. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and was a string. -inline StringRef toStringRef(const Optional<DWARFFormValue> &V, - StringRef Default = {}) { - if (V) - if (auto S = V->getAsCString()) - return *S; - return Default; -} - -/// Take an optional DWARFFormValue and extract a string value from it. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the string value or Default if the V doesn't have a value or the -/// form value's encoding wasn't a string. -inline const char *toString(const Optional<DWARFFormValue> &V, - const char *Default) { - return toString(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract an unsigned constant. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a unsigned constant form. -inline Optional<uint64_t> toUnsigned(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsUnsignedConstant(); - return None; -} - -/// Take an optional DWARFFormValue and extract a unsigned constant. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the extracted unsigned value or Default if the V doesn't have a -/// value or the form value's encoding wasn't an unsigned constant form. -inline uint64_t toUnsigned(const Optional<DWARFFormValue> &V, - uint64_t Default) { - return toUnsigned(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract an reference. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a reference form. -inline Optional<uint64_t> toReference(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsReference(); - return None; -} - -/// Take an optional DWARFFormValue and extract a reference. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the extracted reference value or Default if the V doesn't have a -/// value or the form value's encoding wasn't a reference form. -inline uint64_t toReference(const Optional<DWARFFormValue> &V, - uint64_t Default) { - return toReference(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract an signed constant. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a signed constant form. -inline Optional<int64_t> toSigned(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsSignedConstant(); - return None; -} - -/// Take an optional DWARFFormValue and extract a signed integer. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the extracted signed integer value or Default if the V doesn't -/// have a value or the form value's encoding wasn't a signed integer form. -inline int64_t toSigned(const Optional<DWARFFormValue> &V, int64_t Default) { - return toSigned(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract an address. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a address form. -inline Optional<uint64_t> toAddress(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsAddress(); - return None; -} - -inline Optional<object::SectionedAddress> -toSectionedAddress(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsSectionedAddress(); - return None; -} - -/// Take an optional DWARFFormValue and extract a address. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the extracted address value or Default if the V doesn't have a -/// value or the form value's encoding wasn't an address form. -inline uint64_t toAddress(const Optional<DWARFFormValue> &V, uint64_t Default) { - return toAddress(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract an section offset. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a section offset form. -inline Optional<uint64_t> toSectionOffset(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsSectionOffset(); - return None; -} - -/// Take an optional DWARFFormValue and extract a section offset. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \param Default the default value to return in case of failure. -/// \returns the extracted section offset value or Default if the V doesn't -/// have a value or the form value's encoding wasn't a section offset form. -inline uint64_t toSectionOffset(const Optional<DWARFFormValue> &V, - uint64_t Default) { - return toSectionOffset(V).getValueOr(Default); -} - -/// Take an optional DWARFFormValue and try to extract block data. -/// -/// \param V and optional DWARFFormValue to attempt to extract the value from. -/// \returns an optional value that contains a value if the form value -/// was valid and has a block form. -inline Optional<ArrayRef<uint8_t>> toBlock(const Optional<DWARFFormValue> &V) { - if (V) - return V->getAsBlock(); - return None; -} - -} // end namespace dwarf - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFFORMVALUE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS, + DIDumpOptions DumpOpts, uint64_t SectionIndex); + + /// Extracts a value in \p Data at offset \p *OffsetPtr. The information + /// in \p FormParams is needed to interpret some forms. The optional + /// \p Context and \p Unit allows extracting information if the form refers + /// to other sections (e.g., .debug_str). + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + dwarf::FormParams FormParams, + const DWARFContext *Context = nullptr, + const DWARFUnit *Unit = nullptr); + + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, + dwarf::FormParams FormParams, const DWARFUnit *U) { + return extractValue(Data, OffsetPtr, FormParams, nullptr, U); + } + + bool isInlinedCStr() const { + return Value.data != nullptr && Value.data == (const uint8_t *)Value.cstr; + } + + /// getAsFoo functions below return the extracted value as Foo if only + /// DWARFFormValue has form class is suitable for representing Foo. + Optional<uint64_t> getAsReference() const; + struct UnitOffset { + DWARFUnit *Unit; + uint64_t Offset; + }; + Optional<UnitOffset> getAsRelativeReference() const; + Optional<uint64_t> getAsUnsignedConstant() const; + Optional<int64_t> getAsSignedConstant() const; + Optional<const char *> getAsCString() const; + Optional<uint64_t> getAsAddress() const; + Optional<object::SectionedAddress> getAsSectionedAddress() const; + Optional<uint64_t> getAsSectionOffset() const; + Optional<ArrayRef<uint8_t>> getAsBlock() const; + Optional<uint64_t> getAsCStringOffset() const; + Optional<uint64_t> getAsReferenceUVal() const; + + /// Skip a form's value in \p DebugInfoData at the offset specified by + /// \p OffsetPtr. + /// + /// Skips the bytes for the current form and updates the offset. + /// + /// \param DebugInfoData The data where we want to skip the value. + /// \param OffsetPtr A reference to the offset that will be updated. + /// \param Params DWARF parameters to help interpret forms. + /// \returns true on success, false if the form was not skipped. + bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, + const dwarf::FormParams Params) const { + return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params); + } + + /// Skip a form's value in \p DebugInfoData at the offset specified by + /// \p OffsetPtr. + /// + /// Skips the bytes for the specified form and updates the offset. + /// + /// \param Form The DW_FORM enumeration that indicates the form to skip. + /// \param DebugInfoData The data where we want to skip the value. + /// \param OffsetPtr A reference to the offset that will be updated. + /// \param FormParams DWARF parameters to help interpret forms. + /// \returns true on success, false if the form was not skipped. + static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData, + uint64_t *OffsetPtr, + const dwarf::FormParams FormParams); + +private: + void dumpString(raw_ostream &OS) const; +}; + +namespace dwarf { + +/// Take an optional DWARFFormValue and try to extract a string value from it. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and was a string. +inline Optional<const char *> toString(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsCString(); + return None; +} + +/// Take an optional DWARFFormValue and try to extract a string value from it. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and was a string. +inline StringRef toStringRef(const Optional<DWARFFormValue> &V, + StringRef Default = {}) { + if (V) + if (auto S = V->getAsCString()) + return *S; + return Default; +} + +/// Take an optional DWARFFormValue and extract a string value from it. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the string value or Default if the V doesn't have a value or the +/// form value's encoding wasn't a string. +inline const char *toString(const Optional<DWARFFormValue> &V, + const char *Default) { + return toString(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract an unsigned constant. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a unsigned constant form. +inline Optional<uint64_t> toUnsigned(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsUnsignedConstant(); + return None; +} + +/// Take an optional DWARFFormValue and extract a unsigned constant. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the extracted unsigned value or Default if the V doesn't have a +/// value or the form value's encoding wasn't an unsigned constant form. +inline uint64_t toUnsigned(const Optional<DWARFFormValue> &V, + uint64_t Default) { + return toUnsigned(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract an reference. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a reference form. +inline Optional<uint64_t> toReference(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsReference(); + return None; +} + +/// Take an optional DWARFFormValue and extract a reference. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the extracted reference value or Default if the V doesn't have a +/// value or the form value's encoding wasn't a reference form. +inline uint64_t toReference(const Optional<DWARFFormValue> &V, + uint64_t Default) { + return toReference(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract an signed constant. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a signed constant form. +inline Optional<int64_t> toSigned(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsSignedConstant(); + return None; +} + +/// Take an optional DWARFFormValue and extract a signed integer. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the extracted signed integer value or Default if the V doesn't +/// have a value or the form value's encoding wasn't a signed integer form. +inline int64_t toSigned(const Optional<DWARFFormValue> &V, int64_t Default) { + return toSigned(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract an address. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a address form. +inline Optional<uint64_t> toAddress(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsAddress(); + return None; +} + +inline Optional<object::SectionedAddress> +toSectionedAddress(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsSectionedAddress(); + return None; +} + +/// Take an optional DWARFFormValue and extract a address. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the extracted address value or Default if the V doesn't have a +/// value or the form value's encoding wasn't an address form. +inline uint64_t toAddress(const Optional<DWARFFormValue> &V, uint64_t Default) { + return toAddress(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract an section offset. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a section offset form. +inline Optional<uint64_t> toSectionOffset(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsSectionOffset(); + return None; +} + +/// Take an optional DWARFFormValue and extract a section offset. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \param Default the default value to return in case of failure. +/// \returns the extracted section offset value or Default if the V doesn't +/// have a value or the form value's encoding wasn't a section offset form. +inline uint64_t toSectionOffset(const Optional<DWARFFormValue> &V, + uint64_t Default) { + return toSectionOffset(V).getValueOr(Default); +} + +/// Take an optional DWARFFormValue and try to extract block data. +/// +/// \param V and optional DWARFFormValue to attempt to extract the value from. +/// \returns an optional value that contains a value if the form value +/// was valid and has a block form. +inline Optional<ArrayRef<uint8_t>> toBlock(const Optional<DWARFFormValue> &V) { + if (V) + return V->getAsBlock(); + return None; +} + +} // end namespace dwarf + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFFORMVALUE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h index 6a652d4b43..c2792d9807 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFGdbIndex.h @@ -1,93 +1,93 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFGdbIndex.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H -#define LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/DataExtractor.h" -#include <cstdint> -#include <utility> - -namespace llvm { - -class raw_ostream; - -class DWARFGdbIndex { - uint32_t Version; - - uint32_t CuListOffset; - uint32_t TuListOffset; - uint32_t AddressAreaOffset; - uint32_t SymbolTableOffset; - uint32_t ConstantPoolOffset; - - struct CompUnitEntry { - uint64_t Offset; /// Offset of a CU in the .debug_info section. - uint64_t Length; /// Length of that CU. - }; - SmallVector<CompUnitEntry, 0> CuList; - - struct TypeUnitEntry { - uint64_t Offset; - uint64_t TypeOffset; - uint64_t TypeSignature; - }; - SmallVector<TypeUnitEntry, 0> TuList; - - struct AddressEntry { - uint64_t LowAddress; /// The low address. - uint64_t HighAddress; /// The high address. - uint32_t CuIndex; /// The CU index. - }; - SmallVector<AddressEntry, 0> AddressArea; - - struct SymTableEntry { - uint32_t NameOffset; /// Offset of the symbol's name in the constant pool. - uint32_t VecOffset; /// Offset of the CU vector in the constant pool. - }; - SmallVector<SymTableEntry, 0> SymbolTable; - - /// Each value is CU index + attributes. - SmallVector<std::pair<uint32_t, SmallVector<uint32_t, 0>>, 0> - ConstantPoolVectors; - - StringRef ConstantPoolStrings; - uint32_t StringPoolOffset; - - void dumpCUList(raw_ostream &OS) const; - void dumpTUList(raw_ostream &OS) const; - void dumpAddressArea(raw_ostream &OS) const; - void dumpSymbolTable(raw_ostream &OS) const; - void dumpConstantPool(raw_ostream &OS) const; - - bool parseImpl(DataExtractor Data); - -public: - void dump(raw_ostream &OS); - void parse(DataExtractor Data); - - bool HasContent = false; - bool HasError = false; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFGdbIndex.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H +#define LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DataExtractor.h" +#include <cstdint> +#include <utility> + +namespace llvm { + +class raw_ostream; + +class DWARFGdbIndex { + uint32_t Version; + + uint32_t CuListOffset; + uint32_t TuListOffset; + uint32_t AddressAreaOffset; + uint32_t SymbolTableOffset; + uint32_t ConstantPoolOffset; + + struct CompUnitEntry { + uint64_t Offset; /// Offset of a CU in the .debug_info section. + uint64_t Length; /// Length of that CU. + }; + SmallVector<CompUnitEntry, 0> CuList; + + struct TypeUnitEntry { + uint64_t Offset; + uint64_t TypeOffset; + uint64_t TypeSignature; + }; + SmallVector<TypeUnitEntry, 0> TuList; + + struct AddressEntry { + uint64_t LowAddress; /// The low address. + uint64_t HighAddress; /// The high address. + uint32_t CuIndex; /// The CU index. + }; + SmallVector<AddressEntry, 0> AddressArea; + + struct SymTableEntry { + uint32_t NameOffset; /// Offset of the symbol's name in the constant pool. + uint32_t VecOffset; /// Offset of the CU vector in the constant pool. + }; + SmallVector<SymTableEntry, 0> SymbolTable; + + /// Each value is CU index + attributes. + SmallVector<std::pair<uint32_t, SmallVector<uint32_t, 0>>, 0> + ConstantPoolVectors; + + StringRef ConstantPoolStrings; + uint32_t StringPoolOffset; + + void dumpCUList(raw_ostream &OS) const; + void dumpTUList(raw_ostream &OS) const; + void dumpAddressArea(raw_ostream &OS) const; + void dumpSymbolTable(raw_ostream &OS) const; + void dumpConstantPool(raw_ostream &OS) const; + + bool parseImpl(DataExtractor Data); + +public: + void dump(raw_ostream &OS); + void parse(DataExtractor Data); + + bool HasContent = false; + bool HasError = false; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFListTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFListTable.h index eaad7f2d13..a6a761f5f5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -1,122 +1,122 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFListTable.h -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARFLISTTABLE_H -#define LLVM_DEBUGINFO_DWARFLISTTABLE_H - -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" -#include "llvm/Support/Errc.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/Format.h" -#include "llvm/Support/raw_ostream.h" -#include <cstdint> -#include <map> -#include <vector> - -namespace llvm { - -/// A base class for DWARF list entries, such as range or location list -/// entries. -struct DWARFListEntryBase { - /// The offset at which the entry is located in the section. - uint64_t Offset; - /// The DWARF encoding (DW_RLE_* or DW_LLE_*). - uint8_t EntryKind; - /// The index of the section this entry belongs to. - uint64_t SectionIndex; -}; - -/// A base class for lists of entries that are extracted from a particular -/// section, such as range lists or location lists. -template <typename ListEntryType> class DWARFListType { - using EntryType = ListEntryType; - using ListEntries = std::vector<EntryType>; - -protected: - ListEntries Entries; - -public: - const ListEntries &getEntries() const { return Entries; } - bool empty() const { return Entries.empty(); } - void clear() { Entries.clear(); } +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFListTable.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARFLISTTABLE_H +#define LLVM_DEBUGINFO_DWARFLISTTABLE_H + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/Support/Errc.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" +#include <cstdint> +#include <map> +#include <vector> + +namespace llvm { + +/// A base class for DWARF list entries, such as range or location list +/// entries. +struct DWARFListEntryBase { + /// The offset at which the entry is located in the section. + uint64_t Offset; + /// The DWARF encoding (DW_RLE_* or DW_LLE_*). + uint8_t EntryKind; + /// The index of the section this entry belongs to. + uint64_t SectionIndex; +}; + +/// A base class for lists of entries that are extracted from a particular +/// section, such as range lists or location lists. +template <typename ListEntryType> class DWARFListType { + using EntryType = ListEntryType; + using ListEntries = std::vector<EntryType>; + +protected: + ListEntries Entries; + +public: + const ListEntries &getEntries() const { return Entries; } + bool empty() const { return Entries.empty(); } + void clear() { Entries.clear(); } Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, - uint64_t *OffsetPtr, StringRef SectionName, - StringRef ListStringName); -}; - -/// A class representing the header of a list table such as the range list -/// table in the .debug_rnglists section. -class DWARFListTableHeader { - struct Header { - /// The total length of the entries for this table, not including the length - /// field itself. - uint64_t Length = 0; - /// The DWARF version number. - uint16_t Version; - /// The size in bytes of an address on the target architecture. For - /// segmented addressing, this is the size of the offset portion of the - /// address. - uint8_t AddrSize; - /// The size in bytes of a segment selector on the target architecture. - /// If the target system uses a flat address space, this value is 0. - uint8_t SegSize; - /// The number of offsets that follow the header before the range lists. - uint32_t OffsetEntryCount; - }; - - Header HeaderData; - /// The table's format, either DWARF32 or DWARF64. - dwarf::DwarfFormat Format; - /// The offset at which the header (and hence the table) is located within - /// its section. - uint64_t HeaderOffset; - /// The name of the section the list is located in. - StringRef SectionName; - /// A characterization of the list for dumping purposes, e.g. "range" or - /// "location". - StringRef ListTypeString; - -public: - DWARFListTableHeader(StringRef SectionName, StringRef ListTypeString) - : SectionName(SectionName), ListTypeString(ListTypeString) {} - - void clear() { - HeaderData = {}; - } - uint64_t getHeaderOffset() const { return HeaderOffset; } - uint8_t getAddrSize() const { return HeaderData.AddrSize; } - uint64_t getLength() const { return HeaderData.Length; } - uint16_t getVersion() const { return HeaderData.Version; } - StringRef getSectionName() const { return SectionName; } - StringRef getListTypeString() const { return ListTypeString; } - dwarf::DwarfFormat getFormat() const { return Format; } - - /// Return the size of the table header including the length but not including - /// the offsets. - static uint8_t getHeaderSize(dwarf::DwarfFormat Format) { - switch (Format) { - case dwarf::DwarfFormat::DWARF32: - return 12; - case dwarf::DwarfFormat::DWARF64: - return 20; - } - llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64"); - } - + uint64_t *OffsetPtr, StringRef SectionName, + StringRef ListStringName); +}; + +/// A class representing the header of a list table such as the range list +/// table in the .debug_rnglists section. +class DWARFListTableHeader { + struct Header { + /// The total length of the entries for this table, not including the length + /// field itself. + uint64_t Length = 0; + /// The DWARF version number. + uint16_t Version; + /// The size in bytes of an address on the target architecture. For + /// segmented addressing, this is the size of the offset portion of the + /// address. + uint8_t AddrSize; + /// The size in bytes of a segment selector on the target architecture. + /// If the target system uses a flat address space, this value is 0. + uint8_t SegSize; + /// The number of offsets that follow the header before the range lists. + uint32_t OffsetEntryCount; + }; + + Header HeaderData; + /// The table's format, either DWARF32 or DWARF64. + dwarf::DwarfFormat Format; + /// The offset at which the header (and hence the table) is located within + /// its section. + uint64_t HeaderOffset; + /// The name of the section the list is located in. + StringRef SectionName; + /// A characterization of the list for dumping purposes, e.g. "range" or + /// "location". + StringRef ListTypeString; + +public: + DWARFListTableHeader(StringRef SectionName, StringRef ListTypeString) + : SectionName(SectionName), ListTypeString(ListTypeString) {} + + void clear() { + HeaderData = {}; + } + uint64_t getHeaderOffset() const { return HeaderOffset; } + uint8_t getAddrSize() const { return HeaderData.AddrSize; } + uint64_t getLength() const { return HeaderData.Length; } + uint16_t getVersion() const { return HeaderData.Version; } + StringRef getSectionName() const { return SectionName; } + StringRef getListTypeString() const { return ListTypeString; } + dwarf::DwarfFormat getFormat() const { return Format; } + + /// Return the size of the table header including the length but not including + /// the offsets. + static uint8_t getHeaderSize(dwarf::DwarfFormat Format) { + switch (Format) { + case dwarf::DwarfFormat::DWARF32: + return 12; + case dwarf::DwarfFormat::DWARF64: + return 20; + } + llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64"); + } + void dump(DataExtractor Data, raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const { @@ -124,8 +124,8 @@ public: return None; return getOffsetEntry(Data, getHeaderOffset() + getHeaderSize(Format), Format, Index); - } - + } + static Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint64_t OffsetTableOffset, dwarf::DwarfFormat Format, @@ -136,168 +136,168 @@ public: return R; } - /// Extract the table header and the array of offsets. - Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); - - /// Returns the length of the table, including the length field, or 0 if the - /// length has not been determined (e.g. because the table has not yet been - /// parsed, or there was a problem in parsing). - uint64_t length() const; -}; - -/// A class representing a table of lists as specified in the DWARF v5 -/// standard for location lists and range lists. The table consists of a header -/// followed by an array of offsets into a DWARF section, followed by zero or -/// more list entries. The list entries are kept in a map where the keys are -/// the lists' section offsets. -template <typename DWARFListType> class DWARFListTableBase { - DWARFListTableHeader Header; - /// A mapping between file offsets and lists. It is used to find a particular - /// list based on an offset (obtained from DW_AT_ranges, for example). - std::map<uint64_t, DWARFListType> ListMap; - /// This string is displayed as a heading before the list is dumped - /// (e.g. "ranges:"). - StringRef HeaderString; - -protected: - DWARFListTableBase(StringRef SectionName, StringRef HeaderString, - StringRef ListTypeString) - : Header(SectionName, ListTypeString), HeaderString(HeaderString) {} - -public: - void clear() { - Header.clear(); - ListMap.clear(); - } - /// Extract the table header and the array of offsets. - Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr) { - return Header.extract(Data, OffsetPtr); - } - /// Extract an entire table, including all list entries. - Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); - /// Look up a list based on a given offset. Extract it and enter it into the - /// list map if necessary. - Expected<DWARFListType> findList(DWARFDataExtractor Data, uint64_t Offset); - - uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); } - uint8_t getAddrSize() const { return Header.getAddrSize(); } - dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } - + /// Extract the table header and the array of offsets. + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); + + /// Returns the length of the table, including the length field, or 0 if the + /// length has not been determined (e.g. because the table has not yet been + /// parsed, or there was a problem in parsing). + uint64_t length() const; +}; + +/// A class representing a table of lists as specified in the DWARF v5 +/// standard for location lists and range lists. The table consists of a header +/// followed by an array of offsets into a DWARF section, followed by zero or +/// more list entries. The list entries are kept in a map where the keys are +/// the lists' section offsets. +template <typename DWARFListType> class DWARFListTableBase { + DWARFListTableHeader Header; + /// A mapping between file offsets and lists. It is used to find a particular + /// list based on an offset (obtained from DW_AT_ranges, for example). + std::map<uint64_t, DWARFListType> ListMap; + /// This string is displayed as a heading before the list is dumped + /// (e.g. "ranges:"). + StringRef HeaderString; + +protected: + DWARFListTableBase(StringRef SectionName, StringRef HeaderString, + StringRef ListTypeString) + : Header(SectionName, ListTypeString), HeaderString(HeaderString) {} + +public: + void clear() { + Header.clear(); + ListMap.clear(); + } + /// Extract the table header and the array of offsets. + Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr) { + return Header.extract(Data, OffsetPtr); + } + /// Extract an entire table, including all list entries. + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); + /// Look up a list based on a given offset. Extract it and enter it into the + /// list map if necessary. + Expected<DWARFListType> findList(DWARFDataExtractor Data, uint64_t Offset); + + uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); } + uint8_t getAddrSize() const { return Header.getAddrSize(); } + dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } + void dump(DWARFDataExtractor Data, raw_ostream &OS, - llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> - LookupPooledAddress, - DIDumpOptions DumpOpts = {}) const; - - /// Return the contents of the offset entry designated by a given index. + llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> + LookupPooledAddress, + DIDumpOptions DumpOpts = {}) const; + + /// Return the contents of the offset entry designated by a given index. Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const { return Header.getOffsetEntry(Data, Index); - } - /// Return the size of the table header including the length but not including - /// the offsets. This is dependent on the table format, which is unambiguously - /// derived from parsing the table. - uint8_t getHeaderSize() const { - return DWARFListTableHeader::getHeaderSize(getFormat()); - } - - uint64_t length() { return Header.length(); } -}; - -template <typename DWARFListType> -Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, - uint64_t *OffsetPtr) { - clear(); - if (Error E = extractHeaderAndOffsets(Data, OffsetPtr)) - return E; - - Data.setAddressSize(Header.getAddrSize()); + } + /// Return the size of the table header including the length but not including + /// the offsets. This is dependent on the table format, which is unambiguously + /// derived from parsing the table. + uint8_t getHeaderSize() const { + return DWARFListTableHeader::getHeaderSize(getFormat()); + } + + uint64_t length() { return Header.length(); } +}; + +template <typename DWARFListType> +Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, + uint64_t *OffsetPtr) { + clear(); + if (Error E = extractHeaderAndOffsets(Data, OffsetPtr)) + return E; + + Data.setAddressSize(Header.getAddrSize()); Data = DWARFDataExtractor(Data, getHeaderOffset() + Header.length()); while (Data.isValidOffset(*OffsetPtr)) { - DWARFListType CurrentList; - uint64_t Off = *OffsetPtr; + DWARFListType CurrentList; + uint64_t Off = *OffsetPtr; if (Error E = CurrentList.extract(Data, getHeaderOffset(), OffsetPtr, - Header.getSectionName(), - Header.getListTypeString())) - return E; - ListMap[Off] = CurrentList; - } - + Header.getSectionName(), + Header.getListTypeString())) + return E; + ListMap[Off] = CurrentList; + } + assert(*OffsetPtr == Data.size() && - "mismatch between expected length of table and length " - "of extracted data"); - return Error::success(); -} - -template <typename ListEntryType> -Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, + "mismatch between expected length of table and length " + "of extracted data"); + return Error::success(); +} + +template <typename ListEntryType> +Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, uint64_t HeaderOffset, - uint64_t *OffsetPtr, - StringRef SectionName, - StringRef ListTypeString) { + uint64_t *OffsetPtr, + StringRef SectionName, + StringRef ListTypeString) { if (*OffsetPtr < HeaderOffset || *OffsetPtr >= Data.size()) - return createStringError(errc::invalid_argument, - "invalid %s list offset 0x%" PRIx64, - ListTypeString.data(), *OffsetPtr); - Entries.clear(); + return createStringError(errc::invalid_argument, + "invalid %s list offset 0x%" PRIx64, + ListTypeString.data(), *OffsetPtr); + Entries.clear(); while (Data.isValidOffset(*OffsetPtr)) { - ListEntryType Entry; + ListEntryType Entry; if (Error E = Entry.extract(Data, OffsetPtr)) - return E; - Entries.push_back(Entry); - if (Entry.isSentinel()) - return Error::success(); - } - return createStringError(errc::illegal_byte_sequence, - "no end of list marker detected at end of %s table " - "starting at offset 0x%" PRIx64, - SectionName.data(), HeaderOffset); -} - -template <typename DWARFListType> -void DWARFListTableBase<DWARFListType>::dump( + return E; + Entries.push_back(Entry); + if (Entry.isSentinel()) + return Error::success(); + } + return createStringError(errc::illegal_byte_sequence, + "no end of list marker detected at end of %s table " + "starting at offset 0x%" PRIx64, + SectionName.data(), HeaderOffset); +} + +template <typename DWARFListType> +void DWARFListTableBase<DWARFListType>::dump( DWARFDataExtractor Data, raw_ostream &OS, - llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> - LookupPooledAddress, - DIDumpOptions DumpOpts) const { + llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> + LookupPooledAddress, + DIDumpOptions DumpOpts) const { Header.dump(Data, OS, DumpOpts); - OS << HeaderString << "\n"; - - // Determine the length of the longest encoding string we have in the table, - // so we can align the output properly. We only need this in verbose mode. - size_t MaxEncodingStringLength = 0; - if (DumpOpts.Verbose) { - for (const auto &List : ListMap) - for (const auto &Entry : List.second.getEntries()) - MaxEncodingStringLength = - std::max(MaxEncodingStringLength, - dwarf::RangeListEncodingString(Entry.EntryKind).size()); - } - - uint64_t CurrentBase = 0; - for (const auto &List : ListMap) - for (const auto &Entry : List.second.getEntries()) - Entry.dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase, - DumpOpts, LookupPooledAddress); -} - -template <typename DWARFListType> -Expected<DWARFListType> -DWARFListTableBase<DWARFListType>::findList(DWARFDataExtractor Data, - uint64_t Offset) { - // Extract the list from the section and enter it into the list map. - DWARFListType List; + OS << HeaderString << "\n"; + + // Determine the length of the longest encoding string we have in the table, + // so we can align the output properly. We only need this in verbose mode. + size_t MaxEncodingStringLength = 0; + if (DumpOpts.Verbose) { + for (const auto &List : ListMap) + for (const auto &Entry : List.second.getEntries()) + MaxEncodingStringLength = + std::max(MaxEncodingStringLength, + dwarf::RangeListEncodingString(Entry.EntryKind).size()); + } + + uint64_t CurrentBase = 0; + for (const auto &List : ListMap) + for (const auto &Entry : List.second.getEntries()) + Entry.dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase, + DumpOpts, LookupPooledAddress); +} + +template <typename DWARFListType> +Expected<DWARFListType> +DWARFListTableBase<DWARFListType>::findList(DWARFDataExtractor Data, + uint64_t Offset) { + // Extract the list from the section and enter it into the list map. + DWARFListType List; if (Header.length()) Data = DWARFDataExtractor(Data, getHeaderOffset() + Header.length()); - if (Error E = + if (Error E = List.extract(Data, Header.length() ? getHeaderOffset() : 0, &Offset, - Header.getSectionName(), Header.getListTypeString())) - return std::move(E); - return List; -} - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARFLISTTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + Header.getSectionName(), Header.getListTypeString())) + return std::move(E); + return List; +} + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARFLISTTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h index c500a2baf0..931e7f7c99 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFLocationExpression.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFLocationExpression.h --------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H -#define LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" - -namespace llvm { - -class raw_ostream; - -/// Represents a single DWARF expression, whose value is location-dependent. -/// Typically used in DW_AT_location attributes to describe the location of -/// objects. -struct DWARFLocationExpression { - /// The address range in which this expression is valid. None denotes a - /// default entry which is valid in addresses not covered by other location - /// expressions, or everywhere if there are no other expressions. - Optional<DWARFAddressRange> Range; - - /// The expression itself. - SmallVector<uint8_t, 4> Expr; -}; - -inline bool operator==(const DWARFLocationExpression &L, - const DWARFLocationExpression &R) { - return L.Range == R.Range && L.Expr == R.Expr; -} - -inline bool operator!=(const DWARFLocationExpression &L, - const DWARFLocationExpression &R) { - return !(L == R); -} - -raw_ostream &operator<<(raw_ostream &OS, const DWARFLocationExpression &Loc); - -/// Represents a set of absolute location expressions. -using DWARFLocationExpressionsVector = std::vector<DWARFLocationExpression>; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFLocationExpression.h --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H +#define LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" + +namespace llvm { + +class raw_ostream; + +/// Represents a single DWARF expression, whose value is location-dependent. +/// Typically used in DW_AT_location attributes to describe the location of +/// objects. +struct DWARFLocationExpression { + /// The address range in which this expression is valid. None denotes a + /// default entry which is valid in addresses not covered by other location + /// expressions, or everywhere if there are no other expressions. + Optional<DWARFAddressRange> Range; + + /// The expression itself. + SmallVector<uint8_t, 4> Expr; +}; + +inline bool operator==(const DWARFLocationExpression &L, + const DWARFLocationExpression &R) { + return L.Range == R.Range && L.Expr == R.Expr; +} + +inline bool operator!=(const DWARFLocationExpression &L, + const DWARFLocationExpression &R) { + return !(L == R); +} + +raw_ostream &operator<<(raw_ostream &OS, const DWARFLocationExpression &Loc); + +/// Represents a set of absolute location expressions. +using DWARFLocationExpressionsVector = std::vector<DWARFLocationExpression>; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFObject.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFObject.h index 1044421791..6f0cc586c6 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFObject.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFObject.h @@ -1,100 +1,100 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFObject.h --------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===-----------------------------------------------------------------------===/ - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H -#define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H - -#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" -#include "llvm/DebugInfo/DWARF/DWARFSection.h" -#include "llvm/Object/ObjectFile.h" - -namespace llvm { -// This is responsible for low level access to the object file. It -// knows how to find the required sections and compute relocated -// values. -// The default implementations of the get<Section> methods return dummy values. -// This is to allow clients that only need some of those to implement just the -// ones they need. We can't use unreachable for as many cases because the parser -// implementation is eager and will call some of these methods even if the -// result is not used. -class DWARFObject { - DWARFSection Dummy; - -public: - virtual ~DWARFObject() = default; - virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); } - virtual const object::ObjectFile *getFile() const { return nullptr; } - virtual ArrayRef<SectionName> getSectionNames() const { return {}; } - virtual bool isLittleEndian() const = 0; - virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); } - virtual void - forEachInfoSections(function_ref<void(const DWARFSection &)> F) const {} - virtual void - forEachTypesSections(function_ref<void(const DWARFSection &)> F) const {} - virtual StringRef getAbbrevSection() const { return ""; } - virtual const DWARFSection &getLocSection() const { return Dummy; } - virtual const DWARFSection &getLoclistsSection() const { return Dummy; } - virtual StringRef getArangesSection() const { return ""; } - virtual const DWARFSection &getFrameSection() const { return Dummy; } - virtual const DWARFSection &getEHFrameSection() const { return Dummy; } - virtual const DWARFSection &getLineSection() const { return Dummy; } - virtual StringRef getLineStrSection() const { return ""; } - virtual StringRef getStrSection() const { return ""; } - virtual const DWARFSection &getRangesSection() const { return Dummy; } - virtual const DWARFSection &getRnglistsSection() const { return Dummy; } - virtual const DWARFSection &getMacroSection() const { return Dummy; } - virtual StringRef getMacroDWOSection() const { return ""; } - virtual StringRef getMacinfoSection() const { return ""; } - virtual StringRef getMacinfoDWOSection() const { return ""; } - virtual const DWARFSection &getPubnamesSection() const { return Dummy; } - virtual const DWARFSection &getPubtypesSection() const { return Dummy; } - virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; } - virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; } - virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; } - virtual void - forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {} - virtual void - forEachTypesDWOSections(function_ref<void(const DWARFSection &)> F) const {} - virtual StringRef getAbbrevDWOSection() const { return ""; } - virtual const DWARFSection &getLineDWOSection() const { return Dummy; } - virtual const DWARFSection &getLocDWOSection() const { return Dummy; } - virtual const DWARFSection &getLoclistsDWOSection() const { return Dummy; } - virtual StringRef getStrDWOSection() const { return ""; } - virtual const DWARFSection &getStrOffsetsDWOSection() const { - return Dummy; - } - virtual const DWARFSection &getRangesDWOSection() const { return Dummy; } - virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; } - virtual const DWARFSection &getAddrSection() const { return Dummy; } - virtual const DWARFSection &getAppleNamesSection() const { return Dummy; } - virtual const DWARFSection &getAppleTypesSection() const { return Dummy; } - virtual const DWARFSection &getAppleNamespacesSection() const { - return Dummy; - } - virtual const DWARFSection &getNamesSection() const { return Dummy; } - virtual const DWARFSection &getAppleObjCSection() const { return Dummy; } - virtual StringRef getCUIndexSection() const { return ""; } - virtual StringRef getGdbIndexSection() const { return ""; } - virtual StringRef getTUIndexSection() const { return ""; } - virtual Optional<RelocAddrEntry> find(const DWARFSection &Sec, - uint64_t Pos) const = 0; -}; - -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFObject.h --------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===-----------------------------------------------------------------------===/ + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H +#define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H + +#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include "llvm/DebugInfo/DWARF/DWARFSection.h" +#include "llvm/Object/ObjectFile.h" + +namespace llvm { +// This is responsible for low level access to the object file. It +// knows how to find the required sections and compute relocated +// values. +// The default implementations of the get<Section> methods return dummy values. +// This is to allow clients that only need some of those to implement just the +// ones they need. We can't use unreachable for as many cases because the parser +// implementation is eager and will call some of these methods even if the +// result is not used. +class DWARFObject { + DWARFSection Dummy; + +public: + virtual ~DWARFObject() = default; + virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); } + virtual const object::ObjectFile *getFile() const { return nullptr; } + virtual ArrayRef<SectionName> getSectionNames() const { return {}; } + virtual bool isLittleEndian() const = 0; + virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); } + virtual void + forEachInfoSections(function_ref<void(const DWARFSection &)> F) const {} + virtual void + forEachTypesSections(function_ref<void(const DWARFSection &)> F) const {} + virtual StringRef getAbbrevSection() const { return ""; } + virtual const DWARFSection &getLocSection() const { return Dummy; } + virtual const DWARFSection &getLoclistsSection() const { return Dummy; } + virtual StringRef getArangesSection() const { return ""; } + virtual const DWARFSection &getFrameSection() const { return Dummy; } + virtual const DWARFSection &getEHFrameSection() const { return Dummy; } + virtual const DWARFSection &getLineSection() const { return Dummy; } + virtual StringRef getLineStrSection() const { return ""; } + virtual StringRef getStrSection() const { return ""; } + virtual const DWARFSection &getRangesSection() const { return Dummy; } + virtual const DWARFSection &getRnglistsSection() const { return Dummy; } + virtual const DWARFSection &getMacroSection() const { return Dummy; } + virtual StringRef getMacroDWOSection() const { return ""; } + virtual StringRef getMacinfoSection() const { return ""; } + virtual StringRef getMacinfoDWOSection() const { return ""; } + virtual const DWARFSection &getPubnamesSection() const { return Dummy; } + virtual const DWARFSection &getPubtypesSection() const { return Dummy; } + virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; } + virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; } + virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; } + virtual void + forEachInfoDWOSections(function_ref<void(const DWARFSection &)> F) const {} + virtual void + forEachTypesDWOSections(function_ref<void(const DWARFSection &)> F) const {} + virtual StringRef getAbbrevDWOSection() const { return ""; } + virtual const DWARFSection &getLineDWOSection() const { return Dummy; } + virtual const DWARFSection &getLocDWOSection() const { return Dummy; } + virtual const DWARFSection &getLoclistsDWOSection() const { return Dummy; } + virtual StringRef getStrDWOSection() const { return ""; } + virtual const DWARFSection &getStrOffsetsDWOSection() const { + return Dummy; + } + virtual const DWARFSection &getRangesDWOSection() const { return Dummy; } + virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; } + virtual const DWARFSection &getAddrSection() const { return Dummy; } + virtual const DWARFSection &getAppleNamesSection() const { return Dummy; } + virtual const DWARFSection &getAppleTypesSection() const { return Dummy; } + virtual const DWARFSection &getAppleNamespacesSection() const { + return Dummy; + } + virtual const DWARFSection &getNamesSection() const { return Dummy; } + virtual const DWARFSection &getAppleObjCSection() const { return Dummy; } + virtual StringRef getCUIndexSection() const { return ""; } + virtual StringRef getGdbIndexSection() const { return ""; } + virtual StringRef getTUIndexSection() const { return ""; } + virtual Optional<RelocAddrEntry> find(const DWARFSection &Sec, + uint64_t Pos) const = 0; +}; + +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h index adaaf20e5f..4cbb7d12b4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h @@ -1,49 +1,49 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFRelocMap.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H -#define LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/Object/RelocationResolver.h" -#include <cstdint> - -namespace llvm { - -/// RelocAddrEntry contains relocated value and section index. -/// Section index is -1LL if relocation points to absolute symbol. -struct RelocAddrEntry { - uint64_t SectionIndex; - object::RelocationRef Reloc; - uint64_t SymbolValue; - Optional<object::RelocationRef> Reloc2; - uint64_t SymbolValue2; - object::RelocationResolver Resolver; -}; - -/// In place of applying the relocations to the data we've read from disk we use -/// a separate mapping table to the side and checking that at locations in 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 -/// entire size of the debug info sections. -using RelocAddrMap = DenseMap<uint64_t, RelocAddrEntry>; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFRelocMap.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H +#define LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/Object/RelocationResolver.h" +#include <cstdint> + +namespace llvm { + +/// RelocAddrEntry contains relocated value and section index. +/// Section index is -1LL if relocation points to absolute symbol. +struct RelocAddrEntry { + uint64_t SectionIndex; + object::RelocationRef Reloc; + uint64_t SymbolValue; + Optional<object::RelocationRef> Reloc2; + uint64_t SymbolValue2; + object::RelocationResolver Resolver; +}; + +/// In place of applying the relocations to the data we've read from disk we use +/// a separate mapping table to the side and checking that at locations in 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 +/// entire size of the debug info sections. +using RelocAddrMap = DenseMap<uint64_t, RelocAddrEntry>; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFRELOCMAP_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFSection.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFSection.h index d164b452a6..8631d082b7 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFSection.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFSection.h @@ -1,38 +1,38 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFSection.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFSECTION_H -#define LLVM_DEBUGINFO_DWARF_DWARFSECTION_H - -#include "llvm/ADT/StringRef.h" - -namespace llvm { - -struct DWARFSection { - StringRef Data; -}; - -struct SectionName { - StringRef Name; - bool IsNameUnique; -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFSECTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFSection.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFSECTION_H +#define LLVM_DEBUGINFO_DWARF_DWARFSECTION_H + +#include "llvm/ADT/StringRef.h" + +namespace llvm { + +struct DWARFSection { + StringRef Data; +}; + +struct SectionName { + StringRef Name; + bool IsNameUnique; +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFSECTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h index b02ad36294..38d0937d35 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h @@ -1,57 +1,57 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFTypeUnit.h ------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H -#define LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/DWARF/DWARFUnit.h" -#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" -#include "llvm/Support/DataExtractor.h" -#include <cstdint> - -namespace llvm { - -class DWARFContext; -class DWARFDebugAbbrev; -struct DWARFSection; -class raw_ostream; - -class DWARFTypeUnit : public DWARFUnit { -public: - DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, - const DWARFSection *RS, const DWARFSection *LocSection, - StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, - const DWARFSection &LS, bool LE, bool IsDWO, - const DWARFUnitVector &UnitVector) - : DWARFUnit(Context, Section, Header, DA, RS, LocSection, SS, SOS, AOS, - LS, LE, IsDWO, UnitVector) {} - - uint64_t getTypeHash() const { return getHeader().getTypeHash(); } - uint64_t getTypeOffset() const { return getHeader().getTypeOffset(); } - - void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; - // Enable LLVM-style RTTI. - static bool classof(const DWARFUnit *U) { return U->isTypeUnit(); } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFTypeUnit.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H +#define LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" +#include "llvm/Support/DataExtractor.h" +#include <cstdint> + +namespace llvm { + +class DWARFContext; +class DWARFDebugAbbrev; +struct DWARFSection; +class raw_ostream; + +class DWARFTypeUnit : public DWARFUnit { +public: + DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, const DWARFSection *LocSection, + StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, + const DWARFSection &LS, bool LE, bool IsDWO, + const DWARFUnitVector &UnitVector) + : DWARFUnit(Context, Section, Header, DA, RS, LocSection, SS, SOS, AOS, + LS, LE, IsDWO, UnitVector) {} + + uint64_t getTypeHash() const { return getHeader().getTypeHash(); } + uint64_t getTypeOffset() const { return getHeader().getTypeOffset(); } + + void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; + // Enable LLVM-style RTTI. + static bool classof(const DWARFUnit *U) { return U->isTypeUnit(); } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFTYPEUNIT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 00cc27bf58..e8d37922b7 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -1,534 +1,534 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFUnit.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H -#define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/BinaryFormat/Dwarf.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" -#include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h" -#include "llvm/DebugInfo/DWARF/DWARFDie.h" -#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" -#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" -#include "llvm/DebugInfo/DWARF/DWARFSection.h" -#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" -#include "llvm/Support/DataExtractor.h" -#include <algorithm> -#include <cassert> -#include <cstddef> -#include <cstdint> -#include <map> -#include <memory> -#include <utility> -#include <vector> - -namespace llvm { - -class DWARFAbbreviationDeclarationSet; -class DWARFContext; -class DWARFDebugAbbrev; -class DWARFUnit; - -/// Base class describing the header of any kind of "unit." Some information -/// is specific to certain unit types. We separate this class out so we can -/// parse the header before deciding what specific kind of unit to construct. -class DWARFUnitHeader { - // Offset within section. - uint64_t Offset = 0; - // Version, address size, and DWARF format. - dwarf::FormParams FormParams; - uint64_t Length = 0; - uint64_t AbbrOffset = 0; - - // For DWO units only. - const DWARFUnitIndex::Entry *IndexEntry = nullptr; - - // For type units only. - uint64_t TypeHash = 0; - uint64_t TypeOffset = 0; - - // For v5 split or skeleton compile units only. - Optional<uint64_t> DWOId; - - // Unit type as parsed, or derived from the section kind. - uint8_t UnitType = 0; - - // Size as parsed. uint8_t for compactness. - uint8_t Size = 0; - -public: - /// Parse a unit header from \p debug_info starting at \p offset_ptr. - /// Note that \p SectionKind is used as a hint to guess the unit type - /// for DWARF formats prior to DWARFv5. In DWARFv5 the unit type is - /// explicitly defined in the header and the hint is ignored. - bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, - uint64_t *offset_ptr, DWARFSectionKind SectionKind); - // For units in DWARF Package File, remember the index entry and update - // the abbreviation offset read by extract(). - bool applyIndexEntry(const DWARFUnitIndex::Entry *Entry); - uint64_t getOffset() const { return Offset; } - const dwarf::FormParams &getFormParams() const { return FormParams; } - uint16_t getVersion() const { return FormParams.Version; } - dwarf::DwarfFormat getFormat() const { return FormParams.Format; } - uint8_t getAddressByteSize() const { return FormParams.AddrSize; } - uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); } - uint8_t getDwarfOffsetByteSize() const { - return FormParams.getDwarfOffsetByteSize(); - } - uint64_t getLength() const { return Length; } - uint64_t getAbbrOffset() const { return AbbrOffset; } - Optional<uint64_t> getDWOId() const { return DWOId; } - void setDWOId(uint64_t Id) { - assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value"); - DWOId = Id; - } - const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; } - uint64_t getTypeHash() const { return TypeHash; } - uint64_t getTypeOffset() const { return TypeOffset; } - uint8_t getUnitType() const { return UnitType; } - bool isTypeUnit() const { - return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; - } - uint8_t getSize() const { return Size; } - uint8_t getUnitLengthFieldByteSize() const { - return dwarf::getUnitLengthFieldByteSize(FormParams.Format); - } - uint64_t getNextUnitOffset() const { - return Offset + Length + getUnitLengthFieldByteSize(); - } -}; - -const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, - DWARFSectionKind Kind); - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFUnit.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H +#define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h" +#include "llvm/DebugInfo/DWARF/DWARFDie.h" +#include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include "llvm/DebugInfo/DWARF/DWARFSection.h" +#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" +#include "llvm/Support/DataExtractor.h" +#include <algorithm> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <map> +#include <memory> +#include <utility> +#include <vector> + +namespace llvm { + +class DWARFAbbreviationDeclarationSet; +class DWARFContext; +class DWARFDebugAbbrev; +class DWARFUnit; + +/// Base class describing the header of any kind of "unit." Some information +/// is specific to certain unit types. We separate this class out so we can +/// parse the header before deciding what specific kind of unit to construct. +class DWARFUnitHeader { + // Offset within section. + uint64_t Offset = 0; + // Version, address size, and DWARF format. + dwarf::FormParams FormParams; + uint64_t Length = 0; + uint64_t AbbrOffset = 0; + + // For DWO units only. + const DWARFUnitIndex::Entry *IndexEntry = nullptr; + + // For type units only. + uint64_t TypeHash = 0; + uint64_t TypeOffset = 0; + + // For v5 split or skeleton compile units only. + Optional<uint64_t> DWOId; + + // Unit type as parsed, or derived from the section kind. + uint8_t UnitType = 0; + + // Size as parsed. uint8_t for compactness. + uint8_t Size = 0; + +public: + /// Parse a unit header from \p debug_info starting at \p offset_ptr. + /// Note that \p SectionKind is used as a hint to guess the unit type + /// for DWARF formats prior to DWARFv5. In DWARFv5 the unit type is + /// explicitly defined in the header and the hint is ignored. + bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, + uint64_t *offset_ptr, DWARFSectionKind SectionKind); + // For units in DWARF Package File, remember the index entry and update + // the abbreviation offset read by extract(). + bool applyIndexEntry(const DWARFUnitIndex::Entry *Entry); + uint64_t getOffset() const { return Offset; } + const dwarf::FormParams &getFormParams() const { return FormParams; } + uint16_t getVersion() const { return FormParams.Version; } + dwarf::DwarfFormat getFormat() const { return FormParams.Format; } + uint8_t getAddressByteSize() const { return FormParams.AddrSize; } + uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); } + uint8_t getDwarfOffsetByteSize() const { + return FormParams.getDwarfOffsetByteSize(); + } + uint64_t getLength() const { return Length; } + uint64_t getAbbrOffset() const { return AbbrOffset; } + Optional<uint64_t> getDWOId() const { return DWOId; } + void setDWOId(uint64_t Id) { + assert((!DWOId || *DWOId == Id) && "setting DWOId to a different value"); + DWOId = Id; + } + const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; } + uint64_t getTypeHash() const { return TypeHash; } + uint64_t getTypeOffset() const { return TypeOffset; } + uint8_t getUnitType() const { return UnitType; } + bool isTypeUnit() const { + return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; + } + uint8_t getSize() const { return Size; } + uint8_t getUnitLengthFieldByteSize() const { + return dwarf::getUnitLengthFieldByteSize(FormParams.Format); + } + uint64_t getNextUnitOffset() const { + return Offset + Length + getUnitLengthFieldByteSize(); + } +}; + +const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, + DWARFSectionKind Kind); + bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U); -/// Describe a collection of units. Intended to hold all units either from -/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. -class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> { - std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind, - const DWARFSection *, - const DWARFUnitIndex::Entry *)> - Parser; - int NumInfoUnits = -1; - -public: - using UnitVector = SmallVectorImpl<std::unique_ptr<DWARFUnit>>; - using iterator = typename UnitVector::iterator; - using iterator_range = llvm::iterator_range<typename UnitVector::iterator>; - +/// Describe a collection of units. Intended to hold all units either from +/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. +class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> { + std::function<std::unique_ptr<DWARFUnit>(uint64_t, DWARFSectionKind, + const DWARFSection *, + const DWARFUnitIndex::Entry *)> + Parser; + int NumInfoUnits = -1; + +public: + using UnitVector = SmallVectorImpl<std::unique_ptr<DWARFUnit>>; + using iterator = typename UnitVector::iterator; + using iterator_range = llvm::iterator_range<typename UnitVector::iterator>; + using compile_unit_range = decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit)); - DWARFUnit *getUnitForOffset(uint64_t Offset) const; - DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); - - /// Read units from a .debug_info or .debug_types section. Calls made - /// before finishedInfoUnits() are assumed to be for .debug_info sections, - /// calls after finishedInfoUnits() are for .debug_types sections. Caller - /// must not mix calls to addUnitsForSection and addUnitsForDWOSection. - void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, - DWARFSectionKind SectionKind); - /// Read units from a .debug_info.dwo or .debug_types.dwo section. Calls - /// made before finishedInfoUnits() are assumed to be for .debug_info.dwo - /// sections, calls after finishedInfoUnits() are for .debug_types.dwo - /// sections. Caller must not mix calls to addUnitsForSection and - /// addUnitsForDWOSection. - void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, - DWARFSectionKind SectionKind, bool Lazy = false); - - /// Add an existing DWARFUnit to this UnitVector. This is used by the DWARF - /// verifier to process unit separately. - DWARFUnit *addUnit(std::unique_ptr<DWARFUnit> Unit); - - /// Returns number of all units held by this instance. - unsigned getNumUnits() const { return size(); } - /// Returns number of units from all .debug_info[.dwo] sections. - unsigned getNumInfoUnits() const { - return NumInfoUnits == -1 ? size() : NumInfoUnits; - } - /// Returns number of units from all .debug_types[.dwo] sections. - unsigned getNumTypesUnits() const { return size() - NumInfoUnits; } - /// Indicate that parsing .debug_info[.dwo] is done, and remaining units - /// will be from .debug_types[.dwo]. - void finishedInfoUnits() { NumInfoUnits = size(); } - -private: - void addUnitsImpl(DWARFContext &Context, const DWARFObject &Obj, - const DWARFSection &Section, const DWARFDebugAbbrev *DA, - const DWARFSection *RS, const DWARFSection *LocSection, - StringRef SS, const DWARFSection &SOS, - const DWARFSection *AOS, const DWARFSection &LS, bool LE, - bool IsDWO, bool Lazy, DWARFSectionKind SectionKind); -}; - -/// Represents base address of the CU. -/// Represents a unit's contribution to the string offsets table. -struct StrOffsetsContributionDescriptor { - uint64_t Base = 0; - /// The contribution size not including the header. - uint64_t Size = 0; - /// Format and version. - dwarf::FormParams FormParams = {0, 0, dwarf::DwarfFormat::DWARF32}; - - StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, - uint8_t Version, dwarf::DwarfFormat Format) - : Base(Base), Size(Size), FormParams({Version, 0, Format}) {} - StrOffsetsContributionDescriptor() = default; - - uint8_t getVersion() const { return FormParams.Version; } - dwarf::DwarfFormat getFormat() const { return FormParams.Format; } - uint8_t getDwarfOffsetByteSize() const { - return FormParams.getDwarfOffsetByteSize(); - } - /// Determine whether a contribution to the string offsets table is - /// consistent with the relevant section size and that its length is - /// a multiple of the size of one of its entries. - Expected<StrOffsetsContributionDescriptor> - validateContributionSize(DWARFDataExtractor &DA); -}; - -class DWARFUnit { - DWARFContext &Context; - /// Section containing this DWARFUnit. - const DWARFSection &InfoSection; - - DWARFUnitHeader Header; - const DWARFDebugAbbrev *Abbrev; - const DWARFSection *RangeSection; - uint64_t RangeSectionBase; - uint64_t LocSectionBase; - - /// Location table of this unit. - std::unique_ptr<DWARFLocationTable> LocTable; - - const DWARFSection &LineSection; - StringRef StringSection; - const DWARFSection &StringOffsetSection; - const DWARFSection *AddrOffsetSection; - Optional<uint64_t> AddrOffsetSectionBase; - bool isLittleEndian; - bool IsDWO; - const DWARFUnitVector &UnitVector; - - /// Start, length, and DWARF format of the unit's contribution to the string - /// offsets table (DWARF v5). - Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution; - - mutable const DWARFAbbreviationDeclarationSet *Abbrevs; - llvm::Optional<object::SectionedAddress> BaseAddr; - /// The compile unit debug information entry items. - std::vector<DWARFDebugInfoEntry> DieArray; - - /// Map from range's start address to end address and corresponding DIE. - /// IntervalMap does not support range removal, as a result, we use the - /// std::map::upper_bound for address range lookup. - std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap; - - using die_iterator_range = - iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>; - - std::shared_ptr<DWARFUnit> DWO; - - uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) { - auto First = DieArray.data(); - assert(Die >= First && Die < First + DieArray.size()); - return Die - First; - } - -protected: - const DWARFUnitHeader &getHeader() const { return Header; } - - /// Size in bytes of the parsed unit header. - uint32_t getHeaderSize() const { return Header.getSize(); } - - /// Find the unit's contribution to the string offsets table and determine its - /// length and form. The given offset is expected to be derived from the unit - /// DIE's DW_AT_str_offsets_base attribute. - Expected<Optional<StrOffsetsContributionDescriptor>> - determineStringOffsetsTableContribution(DWARFDataExtractor &DA); - - /// Find the unit's contribution to the string offsets table and determine its - /// length and form. The given offset is expected to be 0 in a dwo file or, - /// in a dwp file, the start of the unit's contribution to the string offsets - /// table section (as determined by the index table). - Expected<Optional<StrOffsetsContributionDescriptor>> - determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA); - -public: - DWARFUnit(DWARFContext &Context, const DWARFSection &Section, - const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, - const DWARFSection *RS, const DWARFSection *LocSection, - StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, - const DWARFSection &LS, bool LE, bool IsDWO, - const DWARFUnitVector &UnitVector); - - virtual ~DWARFUnit(); - - bool isDWOUnit() const { return IsDWO; } - DWARFContext& getContext() const { return Context; } - const DWARFSection &getInfoSection() const { return InfoSection; } - uint64_t getOffset() const { return Header.getOffset(); } - const dwarf::FormParams &getFormParams() const { - return Header.getFormParams(); - } - uint16_t getVersion() const { return Header.getVersion(); } - uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); } - uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); } - uint8_t getDwarfOffsetByteSize() const { - return Header.getDwarfOffsetByteSize(); - } - uint64_t getLength() const { return Header.getLength(); } - dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } - uint8_t getUnitType() const { return Header.getUnitType(); } - bool isTypeUnit() const { return Header.isTypeUnit(); } + DWARFUnit *getUnitForOffset(uint64_t Offset) const; + DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); + + /// Read units from a .debug_info or .debug_types section. Calls made + /// before finishedInfoUnits() are assumed to be for .debug_info sections, + /// calls after finishedInfoUnits() are for .debug_types sections. Caller + /// must not mix calls to addUnitsForSection and addUnitsForDWOSection. + void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, + DWARFSectionKind SectionKind); + /// Read units from a .debug_info.dwo or .debug_types.dwo section. Calls + /// made before finishedInfoUnits() are assumed to be for .debug_info.dwo + /// sections, calls after finishedInfoUnits() are for .debug_types.dwo + /// sections. Caller must not mix calls to addUnitsForSection and + /// addUnitsForDWOSection. + void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, + DWARFSectionKind SectionKind, bool Lazy = false); + + /// Add an existing DWARFUnit to this UnitVector. This is used by the DWARF + /// verifier to process unit separately. + DWARFUnit *addUnit(std::unique_ptr<DWARFUnit> Unit); + + /// Returns number of all units held by this instance. + unsigned getNumUnits() const { return size(); } + /// Returns number of units from all .debug_info[.dwo] sections. + unsigned getNumInfoUnits() const { + return NumInfoUnits == -1 ? size() : NumInfoUnits; + } + /// Returns number of units from all .debug_types[.dwo] sections. + unsigned getNumTypesUnits() const { return size() - NumInfoUnits; } + /// Indicate that parsing .debug_info[.dwo] is done, and remaining units + /// will be from .debug_types[.dwo]. + void finishedInfoUnits() { NumInfoUnits = size(); } + +private: + void addUnitsImpl(DWARFContext &Context, const DWARFObject &Obj, + const DWARFSection &Section, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, const DWARFSection *LocSection, + StringRef SS, const DWARFSection &SOS, + const DWARFSection *AOS, const DWARFSection &LS, bool LE, + bool IsDWO, bool Lazy, DWARFSectionKind SectionKind); +}; + +/// Represents base address of the CU. +/// Represents a unit's contribution to the string offsets table. +struct StrOffsetsContributionDescriptor { + uint64_t Base = 0; + /// The contribution size not including the header. + uint64_t Size = 0; + /// Format and version. + dwarf::FormParams FormParams = {0, 0, dwarf::DwarfFormat::DWARF32}; + + StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, + uint8_t Version, dwarf::DwarfFormat Format) + : Base(Base), Size(Size), FormParams({Version, 0, Format}) {} + StrOffsetsContributionDescriptor() = default; + + uint8_t getVersion() const { return FormParams.Version; } + dwarf::DwarfFormat getFormat() const { return FormParams.Format; } + uint8_t getDwarfOffsetByteSize() const { + return FormParams.getDwarfOffsetByteSize(); + } + /// Determine whether a contribution to the string offsets table is + /// consistent with the relevant section size and that its length is + /// a multiple of the size of one of its entries. + Expected<StrOffsetsContributionDescriptor> + validateContributionSize(DWARFDataExtractor &DA); +}; + +class DWARFUnit { + DWARFContext &Context; + /// Section containing this DWARFUnit. + const DWARFSection &InfoSection; + + DWARFUnitHeader Header; + const DWARFDebugAbbrev *Abbrev; + const DWARFSection *RangeSection; + uint64_t RangeSectionBase; + uint64_t LocSectionBase; + + /// Location table of this unit. + std::unique_ptr<DWARFLocationTable> LocTable; + + const DWARFSection &LineSection; + StringRef StringSection; + const DWARFSection &StringOffsetSection; + const DWARFSection *AddrOffsetSection; + Optional<uint64_t> AddrOffsetSectionBase; + bool isLittleEndian; + bool IsDWO; + const DWARFUnitVector &UnitVector; + + /// Start, length, and DWARF format of the unit's contribution to the string + /// offsets table (DWARF v5). + Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution; + + mutable const DWARFAbbreviationDeclarationSet *Abbrevs; + llvm::Optional<object::SectionedAddress> BaseAddr; + /// The compile unit debug information entry items. + std::vector<DWARFDebugInfoEntry> DieArray; + + /// Map from range's start address to end address and corresponding DIE. + /// IntervalMap does not support range removal, as a result, we use the + /// std::map::upper_bound for address range lookup. + std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap; + + using die_iterator_range = + iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>; + + std::shared_ptr<DWARFUnit> DWO; + + uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) { + auto First = DieArray.data(); + assert(Die >= First && Die < First + DieArray.size()); + return Die - First; + } + +protected: + const DWARFUnitHeader &getHeader() const { return Header; } + + /// Size in bytes of the parsed unit header. + uint32_t getHeaderSize() const { return Header.getSize(); } + + /// Find the unit's contribution to the string offsets table and determine its + /// length and form. The given offset is expected to be derived from the unit + /// DIE's DW_AT_str_offsets_base attribute. + Expected<Optional<StrOffsetsContributionDescriptor>> + determineStringOffsetsTableContribution(DWARFDataExtractor &DA); + + /// Find the unit's contribution to the string offsets table and determine its + /// length and form. The given offset is expected to be 0 in a dwo file or, + /// in a dwp file, the start of the unit's contribution to the string offsets + /// table section (as determined by the index table). + Expected<Optional<StrOffsetsContributionDescriptor>> + determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA); + +public: + DWARFUnit(DWARFContext &Context, const DWARFSection &Section, + const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, const DWARFSection *LocSection, + StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, + const DWARFSection &LS, bool LE, bool IsDWO, + const DWARFUnitVector &UnitVector); + + virtual ~DWARFUnit(); + + bool isDWOUnit() const { return IsDWO; } + DWARFContext& getContext() const { return Context; } + const DWARFSection &getInfoSection() const { return InfoSection; } + uint64_t getOffset() const { return Header.getOffset(); } + const dwarf::FormParams &getFormParams() const { + return Header.getFormParams(); + } + uint16_t getVersion() const { return Header.getVersion(); } + uint8_t getAddressByteSize() const { return Header.getAddressByteSize(); } + uint8_t getRefAddrByteSize() const { return Header.getRefAddrByteSize(); } + uint8_t getDwarfOffsetByteSize() const { + return Header.getDwarfOffsetByteSize(); + } + uint64_t getLength() const { return Header.getLength(); } + dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } + uint8_t getUnitType() const { return Header.getUnitType(); } + bool isTypeUnit() const { return Header.isTypeUnit(); } uint64_t getAbbrOffset() const { return Header.getAbbrOffset(); } - uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } - const DWARFSection &getLineSection() const { return LineSection; } - StringRef getStringSection() const { return StringSection; } - const DWARFSection &getStringOffsetSection() const { - return StringOffsetSection; - } - - void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base) { - AddrOffsetSection = AOS; - AddrOffsetSectionBase = Base; - } - - /// Recursively update address to Die map. - void updateAddressDieMap(DWARFDie Die); - - void setRangesSection(const DWARFSection *RS, uint64_t Base) { - RangeSection = RS; - RangeSectionBase = Base; - } - - uint64_t getLocSectionBase() const { - return LocSectionBase; - } - - Optional<object::SectionedAddress> - getAddrOffsetSectionItem(uint32_t Index) const; - Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const; - - DWARFDataExtractor getDebugInfoExtractor() const; - - DataExtractor getStringExtractor() const { - return DataExtractor(StringSection, false, 0); - } - - const DWARFLocationTable &getLocationTable() { return *LocTable; } - - /// Extract the range list referenced by this compile unit from the - /// .debug_ranges section. If the extraction is unsuccessful, an error - /// is returned. Successful extraction requires that the compile unit - /// has already been extracted. - Error extractRangeList(uint64_t RangeListOffset, - DWARFDebugRangeList &RangeList) const; - void clear(); - - const Optional<StrOffsetsContributionDescriptor> & - getStringOffsetsTableContribution() const { - return StringOffsetsTableContribution; - } - - uint8_t getDwarfStringOffsetsByteSize() const { - assert(StringOffsetsTableContribution); - return StringOffsetsTableContribution->getDwarfOffsetByteSize(); - } - - uint64_t getStringOffsetsBase() const { - assert(StringOffsetsTableContribution); - return StringOffsetsTableContribution->Base; - } - - const DWARFAbbreviationDeclarationSet *getAbbreviations() const; - - static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) { - switch (UnitType) { - case dwarf::DW_UT_compile: - return Tag == dwarf::DW_TAG_compile_unit; - case dwarf::DW_UT_type: - return Tag == dwarf::DW_TAG_type_unit; - case dwarf::DW_UT_partial: - return Tag == dwarf::DW_TAG_partial_unit; - case dwarf::DW_UT_skeleton: - return Tag == dwarf::DW_TAG_skeleton_unit; - case dwarf::DW_UT_split_compile: - case dwarf::DW_UT_split_type: - return dwarf::isUnitType(Tag); - } - return false; - } - - llvm::Optional<object::SectionedAddress> getBaseAddress(); - - DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) { - extractDIEsIfNeeded(ExtractUnitDIEOnly); - if (DieArray.empty()) - return DWARFDie(); - return DWARFDie(this, &DieArray[0]); - } - - DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true) { - parseDWO(); - if (DWO) - return DWO->getUnitDIE(ExtractUnitDIEOnly); - return getUnitDIE(ExtractUnitDIEOnly); - } - - const char *getCompilationDir(); - Optional<uint64_t> getDWOId() { - extractDIEsIfNeeded(/*CUDieOnly*/ true); - return getHeader().getDWOId(); - } - void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); } - - /// Return a vector of address ranges resulting from a (possibly encoded) - /// range list starting at a given offset in the appropriate ranges section. - Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint64_t Offset); - - /// Return a vector of address ranges retrieved from an encoded range - /// list whose offset is found via a table lookup given an index (DWARF v5 - /// and later). - Expected<DWARFAddressRangesVector> findRnglistFromIndex(uint32_t Index); - - /// Return a rangelist's offset based on an index. The index designates - /// an entry in the rangelist table's offset array and is supplied by - /// DW_FORM_rnglistx. + uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } + const DWARFSection &getLineSection() const { return LineSection; } + StringRef getStringSection() const { return StringSection; } + const DWARFSection &getStringOffsetSection() const { + return StringOffsetSection; + } + + void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base) { + AddrOffsetSection = AOS; + AddrOffsetSectionBase = Base; + } + + /// Recursively update address to Die map. + void updateAddressDieMap(DWARFDie Die); + + void setRangesSection(const DWARFSection *RS, uint64_t Base) { + RangeSection = RS; + RangeSectionBase = Base; + } + + uint64_t getLocSectionBase() const { + return LocSectionBase; + } + + Optional<object::SectionedAddress> + getAddrOffsetSectionItem(uint32_t Index) const; + Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const; + + DWARFDataExtractor getDebugInfoExtractor() const; + + DataExtractor getStringExtractor() const { + return DataExtractor(StringSection, false, 0); + } + + const DWARFLocationTable &getLocationTable() { return *LocTable; } + + /// Extract the range list referenced by this compile unit from the + /// .debug_ranges section. If the extraction is unsuccessful, an error + /// is returned. Successful extraction requires that the compile unit + /// has already been extracted. + Error extractRangeList(uint64_t RangeListOffset, + DWARFDebugRangeList &RangeList) const; + void clear(); + + const Optional<StrOffsetsContributionDescriptor> & + getStringOffsetsTableContribution() const { + return StringOffsetsTableContribution; + } + + uint8_t getDwarfStringOffsetsByteSize() const { + assert(StringOffsetsTableContribution); + return StringOffsetsTableContribution->getDwarfOffsetByteSize(); + } + + uint64_t getStringOffsetsBase() const { + assert(StringOffsetsTableContribution); + return StringOffsetsTableContribution->Base; + } + + const DWARFAbbreviationDeclarationSet *getAbbreviations() const; + + static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag) { + switch (UnitType) { + case dwarf::DW_UT_compile: + return Tag == dwarf::DW_TAG_compile_unit; + case dwarf::DW_UT_type: + return Tag == dwarf::DW_TAG_type_unit; + case dwarf::DW_UT_partial: + return Tag == dwarf::DW_TAG_partial_unit; + case dwarf::DW_UT_skeleton: + return Tag == dwarf::DW_TAG_skeleton_unit; + case dwarf::DW_UT_split_compile: + case dwarf::DW_UT_split_type: + return dwarf::isUnitType(Tag); + } + return false; + } + + llvm::Optional<object::SectionedAddress> getBaseAddress(); + + DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) { + extractDIEsIfNeeded(ExtractUnitDIEOnly); + if (DieArray.empty()) + return DWARFDie(); + return DWARFDie(this, &DieArray[0]); + } + + DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly = true) { + parseDWO(); + if (DWO) + return DWO->getUnitDIE(ExtractUnitDIEOnly); + return getUnitDIE(ExtractUnitDIEOnly); + } + + const char *getCompilationDir(); + Optional<uint64_t> getDWOId() { + extractDIEsIfNeeded(/*CUDieOnly*/ true); + return getHeader().getDWOId(); + } + void setDWOId(uint64_t NewID) { Header.setDWOId(NewID); } + + /// Return a vector of address ranges resulting from a (possibly encoded) + /// range list starting at a given offset in the appropriate ranges section. + Expected<DWARFAddressRangesVector> findRnglistFromOffset(uint64_t Offset); + + /// Return a vector of address ranges retrieved from an encoded range + /// list whose offset is found via a table lookup given an index (DWARF v5 + /// and later). + Expected<DWARFAddressRangesVector> findRnglistFromIndex(uint32_t Index); + + /// Return a rangelist's offset based on an index. The index designates + /// an entry in the rangelist table's offset array and is supplied by + /// DW_FORM_rnglistx. Optional<uint64_t> getRnglistOffset(uint32_t Index); - + Optional<uint64_t> getLoclistOffset(uint32_t Index); - Expected<DWARFAddressRangesVector> collectAddressRanges(); - - Expected<DWARFLocationExpressionsVector> - findLoclistFromOffset(uint64_t Offset); - - /// Returns subprogram DIE with address range encompassing the provided - /// address. The pointer is alive as long as parsed compile unit DIEs are not - /// cleared. - DWARFDie getSubroutineForAddress(uint64_t Address); - - /// getInlinedChainForAddress - fetches inlined chain for a given address. - /// Returns empty chain if there is no subprogram containing address. The - /// chain is valid as long as parsed compile unit DIEs are not cleared. - void getInlinedChainForAddress(uint64_t Address, - SmallVectorImpl<DWARFDie> &InlinedChain); - - /// Return the DWARFUnitVector containing this unit. - const DWARFUnitVector &getUnitVector() const { return UnitVector; } - - /// Returns the number of DIEs in the unit. Parses the unit - /// if necessary. - unsigned getNumDIEs() { - extractDIEsIfNeeded(false); - return DieArray.size(); - } - - /// Return the index of a DIE inside the unit's DIE vector. - /// - /// It is illegal to call this method with a DIE that hasn't be - /// created by this unit. In other word, it's illegal to call this - /// method on a DIE that isn't accessible by following - /// children/sibling links starting from this unit's getUnitDIE(). - uint32_t getDIEIndex(const DWARFDie &D) { - return getDIEIndex(D.getDebugInfoEntry()); - } - - /// Return the DIE object at the given index. - DWARFDie getDIEAtIndex(unsigned Index) { - assert(Index < DieArray.size()); - return DWARFDie(this, &DieArray[Index]); - } - - DWARFDie getParent(const DWARFDebugInfoEntry *Die); - DWARFDie getSibling(const DWARFDebugInfoEntry *Die); - DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die); - DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die); - DWARFDie getLastChild(const DWARFDebugInfoEntry *Die); - - /// Return the DIE object for a given offset inside the - /// unit's DIE vector. - /// - /// The unit needs to have its DIEs extracted for this method to work. - DWARFDie getDIEForOffset(uint64_t Offset) { - extractDIEsIfNeeded(false); - auto It = - llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) { - return DIE.getOffset() < Offset; - }); - if (It != DieArray.end() && It->getOffset() == Offset) - return DWARFDie(this, &*It); - return DWARFDie(); - } - - uint32_t getLineTableOffset() const { - if (auto IndexEntry = Header.getIndexEntry()) - if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE)) - return Contrib->Offset; - return 0; - } - - die_iterator_range dies() { - extractDIEsIfNeeded(false); - return die_iterator_range(DieArray.begin(), DieArray.end()); - } - - virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; - - Error tryExtractDIEsIfNeeded(bool CUDieOnly); - -private: - /// Size in bytes of the .debug_info data associated with this compile unit. - size_t getDebugInfoSize() const { - return Header.getLength() + Header.getUnitLengthFieldByteSize() - - getHeaderSize(); - } - - /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it - /// hasn't already been done - void extractDIEsIfNeeded(bool CUDieOnly); - - /// extractDIEsToVector - Appends all parsed DIEs to a vector. - void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs, - std::vector<DWARFDebugInfoEntry> &DIEs) const; - - /// clearDIEs - Clear parsed DIEs to keep memory usage low. - void clearDIEs(bool KeepCUDie); - - /// parseDWO - Parses .dwo file for current compile unit. Returns true if - /// it was actually constructed. - bool parseDWO(); -}; - + Expected<DWARFAddressRangesVector> collectAddressRanges(); + + Expected<DWARFLocationExpressionsVector> + findLoclistFromOffset(uint64_t Offset); + + /// Returns subprogram DIE with address range encompassing the provided + /// address. The pointer is alive as long as parsed compile unit DIEs are not + /// cleared. + DWARFDie getSubroutineForAddress(uint64_t Address); + + /// getInlinedChainForAddress - fetches inlined chain for a given address. + /// Returns empty chain if there is no subprogram containing address. The + /// chain is valid as long as parsed compile unit DIEs are not cleared. + void getInlinedChainForAddress(uint64_t Address, + SmallVectorImpl<DWARFDie> &InlinedChain); + + /// Return the DWARFUnitVector containing this unit. + const DWARFUnitVector &getUnitVector() const { return UnitVector; } + + /// Returns the number of DIEs in the unit. Parses the unit + /// if necessary. + unsigned getNumDIEs() { + extractDIEsIfNeeded(false); + return DieArray.size(); + } + + /// Return the index of a DIE inside the unit's DIE vector. + /// + /// It is illegal to call this method with a DIE that hasn't be + /// created by this unit. In other word, it's illegal to call this + /// method on a DIE that isn't accessible by following + /// children/sibling links starting from this unit's getUnitDIE(). + uint32_t getDIEIndex(const DWARFDie &D) { + return getDIEIndex(D.getDebugInfoEntry()); + } + + /// Return the DIE object at the given index. + DWARFDie getDIEAtIndex(unsigned Index) { + assert(Index < DieArray.size()); + return DWARFDie(this, &DieArray[Index]); + } + + DWARFDie getParent(const DWARFDebugInfoEntry *Die); + DWARFDie getSibling(const DWARFDebugInfoEntry *Die); + DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die); + DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die); + DWARFDie getLastChild(const DWARFDebugInfoEntry *Die); + + /// Return the DIE object for a given offset inside the + /// unit's DIE vector. + /// + /// The unit needs to have its DIEs extracted for this method to work. + DWARFDie getDIEForOffset(uint64_t Offset) { + extractDIEsIfNeeded(false); + auto It = + llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) { + return DIE.getOffset() < Offset; + }); + if (It != DieArray.end() && It->getOffset() == Offset) + return DWARFDie(this, &*It); + return DWARFDie(); + } + + uint32_t getLineTableOffset() const { + if (auto IndexEntry = Header.getIndexEntry()) + if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE)) + return Contrib->Offset; + return 0; + } + + die_iterator_range dies() { + extractDIEsIfNeeded(false); + return die_iterator_range(DieArray.begin(), DieArray.end()); + } + + virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; + + Error tryExtractDIEsIfNeeded(bool CUDieOnly); + +private: + /// Size in bytes of the .debug_info data associated with this compile unit. + size_t getDebugInfoSize() const { + return Header.getLength() + Header.getUnitLengthFieldByteSize() - + getHeaderSize(); + } + + /// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it + /// hasn't already been done + void extractDIEsIfNeeded(bool CUDieOnly); + + /// extractDIEsToVector - Appends all parsed DIEs to a vector. + void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs, + std::vector<DWARFDebugInfoEntry> &DIEs) const; + + /// clearDIEs - Clear parsed DIEs to keep memory usage low. + void clearDIEs(bool KeepCUDie); + + /// parseDWO - Parses .dwo file for current compile unit. Returns true if + /// it was actually constructed. + bool parseDWO(); +}; + inline bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U) { return !U->isTypeUnit(); } -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h index b6613ea12b..24047ba1a3 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -1,169 +1,169 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFUnitIndex.h -----------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H -#define LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/DataExtractor.h" -#include <cstdint> -#include <memory> - -namespace llvm { - -class raw_ostream; - -/// The enum of section identifiers to be used in internal interfaces. -/// -/// Pre-standard implementation of package files defined a number of section -/// identifiers with values that clash definitions in the DWARFv5 standard. -/// See https://gcc.gnu.org/wiki/DebugFissionDWP and Section 7.3.5.3 in DWARFv5. -/// -/// The following identifiers are the same in the proposal and in DWARFv5: -/// - DW_SECT_INFO = 1 (.debug_info.dwo) -/// - DW_SECT_ABBREV = 3 (.debug_abbrev.dwo) -/// - DW_SECT_LINE = 4 (.debug_line.dwo) -/// - DW_SECT_STR_OFFSETS = 6 (.debug_str_offsets.dwo) -/// -/// The following identifiers are defined only in DWARFv5: -/// - DW_SECT_LOCLISTS = 5 (.debug_loclists.dwo) -/// - DW_SECT_RNGLISTS = 8 (.debug_rnglists.dwo) -/// -/// The following identifiers are defined only in the GNU proposal: -/// - DW_SECT_TYPES = 2 (.debug_types.dwo) -/// - DW_SECT_LOC = 5 (.debug_loc.dwo) -/// - DW_SECT_MACINFO = 7 (.debug_macinfo.dwo) -/// -/// DW_SECT_MACRO for the .debug_macro.dwo section is defined in both standards, -/// but with different values, 8 in GNU and 7 in DWARFv5. -/// -/// This enum defines constants to represent the identifiers of both sets. -/// For DWARFv5 ones, the values are the same as defined in the standard. -/// For pre-standard ones that correspond to sections being deprecated in -/// DWARFv5, the values are chosen arbitrary and a tag "_EXT_" is added to -/// the names. -/// -/// The enum is for internal use only. The user should not expect the values -/// to correspond to any input/output constants. Special conversion functions, -/// serializeSectionKind() and deserializeSectionKind(), should be used for -/// the translation. -enum DWARFSectionKind { - /// Denotes a value read from an index section that does not correspond - /// to any of the supported standards. - DW_SECT_EXT_unknown = 0, -#define HANDLE_DW_SECT(ID, NAME) DW_SECT_##NAME = ID, -#include "llvm/BinaryFormat/Dwarf.def" - DW_SECT_EXT_TYPES = 2, - DW_SECT_EXT_LOC = 9, - DW_SECT_EXT_MACINFO = 10, -}; - -/// Convert the internal value for a section kind to an on-disk value. -/// -/// The conversion depends on the version of the index section. -/// IndexVersion is expected to be either 2 for pre-standard GNU proposal -/// or 5 for DWARFv5 package file. -uint32_t serializeSectionKind(DWARFSectionKind Kind, unsigned IndexVersion); - -/// Convert a value read from an index section to the internal representation. -/// -/// The conversion depends on the index section version, which is expected -/// to be either 2 for pre-standard GNU proposal or 5 for DWARFv5 package file. -DWARFSectionKind deserializeSectionKind(uint32_t Value, unsigned IndexVersion); - -class DWARFUnitIndex { - struct Header { - uint32_t Version; - uint32_t NumColumns; - uint32_t NumUnits; - uint32_t NumBuckets = 0; - - bool parse(DataExtractor IndexData, uint64_t *OffsetPtr); - void dump(raw_ostream &OS) const; - }; - -public: - class Entry { - public: - struct SectionContribution { - uint32_t Offset; - uint32_t Length; - }; - - private: - const DWARFUnitIndex *Index; - uint64_t Signature; - std::unique_ptr<SectionContribution[]> Contributions; - friend class DWARFUnitIndex; - - public: - const SectionContribution *getContribution(DWARFSectionKind Sec) const; - const SectionContribution *getContribution() const; - - const SectionContribution *getContributions() const { - return Contributions.get(); - } - - uint64_t getSignature() const { return Signature; } - }; - -private: - struct Header Header; - - DWARFSectionKind InfoColumnKind; - int InfoColumn = -1; - std::unique_ptr<DWARFSectionKind[]> ColumnKinds; - // This is a parallel array of section identifiers as they read from the input - // file. The mapping from raw values to DWARFSectionKind is not revertable in - // case of unknown identifiers, so we keep them here. - std::unique_ptr<uint32_t[]> RawSectionIds; - std::unique_ptr<Entry[]> Rows; - mutable std::vector<Entry *> OffsetLookup; - - static StringRef getColumnHeader(DWARFSectionKind DS); - - bool parseImpl(DataExtractor IndexData); - -public: - DWARFUnitIndex(DWARFSectionKind InfoColumnKind) - : InfoColumnKind(InfoColumnKind) {} - - explicit operator bool() const { return Header.NumBuckets; } - - bool parse(DataExtractor IndexData); - void dump(raw_ostream &OS) const; - - uint32_t getVersion() const { return Header.Version; } - - const Entry *getFromOffset(uint32_t Offset) const; - const Entry *getFromHash(uint64_t Offset) const; - - ArrayRef<DWARFSectionKind> getColumnKinds() const { - return makeArrayRef(ColumnKinds.get(), Header.NumColumns); - } - - ArrayRef<Entry> getRows() const { - return makeArrayRef(Rows.get(), Header.NumBuckets); - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFUnitIndex.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H +#define LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DataExtractor.h" +#include <cstdint> +#include <memory> + +namespace llvm { + +class raw_ostream; + +/// The enum of section identifiers to be used in internal interfaces. +/// +/// Pre-standard implementation of package files defined a number of section +/// identifiers with values that clash definitions in the DWARFv5 standard. +/// See https://gcc.gnu.org/wiki/DebugFissionDWP and Section 7.3.5.3 in DWARFv5. +/// +/// The following identifiers are the same in the proposal and in DWARFv5: +/// - DW_SECT_INFO = 1 (.debug_info.dwo) +/// - DW_SECT_ABBREV = 3 (.debug_abbrev.dwo) +/// - DW_SECT_LINE = 4 (.debug_line.dwo) +/// - DW_SECT_STR_OFFSETS = 6 (.debug_str_offsets.dwo) +/// +/// The following identifiers are defined only in DWARFv5: +/// - DW_SECT_LOCLISTS = 5 (.debug_loclists.dwo) +/// - DW_SECT_RNGLISTS = 8 (.debug_rnglists.dwo) +/// +/// The following identifiers are defined only in the GNU proposal: +/// - DW_SECT_TYPES = 2 (.debug_types.dwo) +/// - DW_SECT_LOC = 5 (.debug_loc.dwo) +/// - DW_SECT_MACINFO = 7 (.debug_macinfo.dwo) +/// +/// DW_SECT_MACRO for the .debug_macro.dwo section is defined in both standards, +/// but with different values, 8 in GNU and 7 in DWARFv5. +/// +/// This enum defines constants to represent the identifiers of both sets. +/// For DWARFv5 ones, the values are the same as defined in the standard. +/// For pre-standard ones that correspond to sections being deprecated in +/// DWARFv5, the values are chosen arbitrary and a tag "_EXT_" is added to +/// the names. +/// +/// The enum is for internal use only. The user should not expect the values +/// to correspond to any input/output constants. Special conversion functions, +/// serializeSectionKind() and deserializeSectionKind(), should be used for +/// the translation. +enum DWARFSectionKind { + /// Denotes a value read from an index section that does not correspond + /// to any of the supported standards. + DW_SECT_EXT_unknown = 0, +#define HANDLE_DW_SECT(ID, NAME) DW_SECT_##NAME = ID, +#include "llvm/BinaryFormat/Dwarf.def" + DW_SECT_EXT_TYPES = 2, + DW_SECT_EXT_LOC = 9, + DW_SECT_EXT_MACINFO = 10, +}; + +/// Convert the internal value for a section kind to an on-disk value. +/// +/// The conversion depends on the version of the index section. +/// IndexVersion is expected to be either 2 for pre-standard GNU proposal +/// or 5 for DWARFv5 package file. +uint32_t serializeSectionKind(DWARFSectionKind Kind, unsigned IndexVersion); + +/// Convert a value read from an index section to the internal representation. +/// +/// The conversion depends on the index section version, which is expected +/// to be either 2 for pre-standard GNU proposal or 5 for DWARFv5 package file. +DWARFSectionKind deserializeSectionKind(uint32_t Value, unsigned IndexVersion); + +class DWARFUnitIndex { + struct Header { + uint32_t Version; + uint32_t NumColumns; + uint32_t NumUnits; + uint32_t NumBuckets = 0; + + bool parse(DataExtractor IndexData, uint64_t *OffsetPtr); + void dump(raw_ostream &OS) const; + }; + +public: + class Entry { + public: + struct SectionContribution { + uint32_t Offset; + uint32_t Length; + }; + + private: + const DWARFUnitIndex *Index; + uint64_t Signature; + std::unique_ptr<SectionContribution[]> Contributions; + friend class DWARFUnitIndex; + + public: + const SectionContribution *getContribution(DWARFSectionKind Sec) const; + const SectionContribution *getContribution() const; + + const SectionContribution *getContributions() const { + return Contributions.get(); + } + + uint64_t getSignature() const { return Signature; } + }; + +private: + struct Header Header; + + DWARFSectionKind InfoColumnKind; + int InfoColumn = -1; + std::unique_ptr<DWARFSectionKind[]> ColumnKinds; + // This is a parallel array of section identifiers as they read from the input + // file. The mapping from raw values to DWARFSectionKind is not revertable in + // case of unknown identifiers, so we keep them here. + std::unique_ptr<uint32_t[]> RawSectionIds; + std::unique_ptr<Entry[]> Rows; + mutable std::vector<Entry *> OffsetLookup; + + static StringRef getColumnHeader(DWARFSectionKind DS); + + bool parseImpl(DataExtractor IndexData); + +public: + DWARFUnitIndex(DWARFSectionKind InfoColumnKind) + : InfoColumnKind(InfoColumnKind) {} + + explicit operator bool() const { return Header.NumBuckets; } + + bool parse(DataExtractor IndexData); + void dump(raw_ostream &OS) const; + + uint32_t getVersion() const { return Header.Version; } + + const Entry *getFromOffset(uint32_t Offset) const; + const Entry *getFromHash(uint64_t Offset) const; + + ArrayRef<DWARFSectionKind> getColumnKinds() const { + return makeArrayRef(ColumnKinds.get(), Header.NumColumns); + } + + ArrayRef<Entry> getRows() const { + return makeArrayRef(Rows.get(), Header.NumBuckets); + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFUNITINDEX_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFVerifier.h b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFVerifier.h index 5f8a35a710..2bc2b954c1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -1,347 +1,347 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DWARFVerifier.h ----------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H -#define LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" -#include "llvm/DebugInfo/DWARF/DWARFDie.h" -#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" -#include <cstdint> -#include <map> -#include <set> - -namespace llvm { -class raw_ostream; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DWARFVerifier.h ----------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H +#define LLVM_DEBUGINFO_DWARF_DWARFVERIFIER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" +#include "llvm/DebugInfo/DWARF/DWARFDie.h" +#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" +#include <cstdint> +#include <map> +#include <set> + +namespace llvm { +class raw_ostream; struct DWARFAddressRange; -struct DWARFAttribute; -class DWARFContext; -class DWARFDataExtractor; -class DWARFDebugAbbrev; -class DataExtractor; -struct DWARFSection; +struct DWARFAttribute; +class DWARFContext; +class DWARFDataExtractor; +class DWARFDebugAbbrev; +class DataExtractor; +struct DWARFSection; class DWARFUnit; - -/// A class that verifies DWARF debug information given a DWARF Context. -class DWARFVerifier { -public: - /// A class that keeps the address range information for a single DIE. - struct DieRangeInfo { - DWARFDie Die; - - /// Sorted DWARFAddressRanges. - std::vector<DWARFAddressRange> Ranges; - - /// Sorted DWARFAddressRangeInfo. - std::set<DieRangeInfo> Children; - - DieRangeInfo() = default; - DieRangeInfo(DWARFDie Die) : Die(Die) {} - - /// Used for unit testing. - DieRangeInfo(std::vector<DWARFAddressRange> Ranges) - : Ranges(std::move(Ranges)) {} - - typedef std::vector<DWARFAddressRange>::const_iterator - address_range_iterator; - typedef std::set<DieRangeInfo>::const_iterator die_range_info_iterator; - - /// Inserts the address range. If the range overlaps with an existing - /// range, the range that it overlaps with will be returned and the two - /// address ranges will be unioned together in "Ranges". - /// - /// This is used for finding overlapping ranges in the DW_AT_ranges - /// attribute of a DIE. It is also used as a set of address ranges that - /// children address ranges must all be contained in. - Optional<DWARFAddressRange> insert(const DWARFAddressRange &R); - - /// Finds an address range in the sorted vector of ranges. - address_range_iterator findRange(const DWARFAddressRange &R) const { - auto Begin = Ranges.begin(); - auto End = Ranges.end(); - auto Iter = std::upper_bound(Begin, End, R); - if (Iter != Begin) - --Iter; - return Iter; - } - - /// Inserts the address range info. If any of its ranges overlaps with a - /// range in an existing range info, the range info is *not* added and an - /// iterator to the overlapping range info. - /// - /// This is used for finding overlapping children of the same DIE. - die_range_info_iterator insert(const DieRangeInfo &RI); - - /// Return true if ranges in this object contains all ranges within RHS. - bool contains(const DieRangeInfo &RHS) const; - - /// Return true if any range in this object intersects with any range in - /// RHS. - bool intersects(const DieRangeInfo &RHS) const; - }; - -private: - raw_ostream &OS; - DWARFContext &DCtx; - DIDumpOptions DumpOpts; - /// A map that tracks all references (converted absolute references) so we - /// can verify each reference points to a valid DIE and not an offset that - /// lies between to valid DIEs. - std::map<uint64_t, std::set<uint64_t>> ReferenceToDIEOffsets; - uint32_t NumDebugLineErrors = 0; - // Used to relax some checks that do not currently work portably - bool IsObjectFile; - bool IsMachOObject; - - raw_ostream &error() const; - raw_ostream &warn() const; - raw_ostream ¬e() const; - raw_ostream &dump(const DWARFDie &Die, unsigned indent = 0) const; - - /// Verifies the abbreviations section. - /// - /// This function currently checks that: - /// --No abbreviation declaration has more than one attributes with the same - /// name. - /// - /// \param Abbrev Pointer to the abbreviations section we are verifying - /// Abbrev can be a pointer to either .debug_abbrev or debug_abbrev.dwo. - /// - /// \returns The number of errors that occurred during verification. - unsigned verifyAbbrevSection(const DWARFDebugAbbrev *Abbrev); - - /// Verifies the header of a unit in a .debug_info or .debug_types section. - /// - /// This function currently checks for: - /// - Unit is in 32-bit DWARF format. The function can be modified to - /// support 64-bit format. - /// - The DWARF version is valid - /// - The unit type is valid (if unit is in version >=5) - /// - The unit doesn't extend beyond the containing section - /// - The address size is valid - /// - The offset in the .debug_abbrev section is valid - /// - /// \param DebugInfoData The section data - /// \param Offset A reference to the offset start of the unit. The offset will - /// be updated to point to the next unit in the section - /// \param UnitIndex The index of the unit to be verified - /// \param UnitType A reference to the type of the unit - /// \param isUnitDWARF64 A reference to a flag that shows whether the unit is - /// in 64-bit format. - /// - /// \returns true if the header is verified successfully, false otherwise. - bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData, - uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, - bool &isUnitDWARF64); - - /// Verifies the header of a unit in a .debug_info or .debug_types section. - /// - /// This function currently verifies: - /// - The debug info attributes. - /// - The debug info form=s. - /// - The presence of a root DIE. - /// - That the root DIE is a unit DIE. - /// - If a unit type is provided, that the unit DIE matches the unit type. - /// - The DIE ranges. - /// - That call site entries are only nested within subprograms with a - /// DW_AT_call attribute. - /// - /// \param Unit The DWARF Unit to verify. - /// - /// \returns The number of errors that occurred during verification. - unsigned verifyUnitContents(DWARFUnit &Unit); - - /// Verifies the unit headers and contents in a .debug_info or .debug_types - /// section. - /// - /// \param S The DWARF Section to verify. - /// \param SectionKind The object-file section kind that S comes from. - /// - /// \returns The number of errors that occurred during verification. - unsigned verifyUnitSection(const DWARFSection &S, - DWARFSectionKind SectionKind); - - /// Verifies that a call site entry is nested within a subprogram with a - /// DW_AT_call attribute. - /// - /// \returns Number of errors that occurred during verification. - unsigned verifyDebugInfoCallSite(const DWARFDie &Die); - - /// Verify that all Die ranges are valid. - /// - /// This function currently checks for: - /// - cases in which lowPC >= highPC - /// - /// \returns Number of errors that occurred during verification. - unsigned verifyDieRanges(const DWARFDie &Die, DieRangeInfo &ParentRI); - - /// Verifies the attribute's DWARF attribute and its value. - /// - /// This function currently checks for: - /// - DW_AT_ranges values is a valid .debug_ranges offset - /// - DW_AT_stmt_list is a valid .debug_line offset - /// - /// \param Die The DWARF DIE that owns the attribute value - /// \param AttrValue The DWARF attribute value to check - /// - /// \returns NumErrors The number of errors occurred during verification of - /// attributes' values in a unit - unsigned verifyDebugInfoAttribute(const DWARFDie &Die, - DWARFAttribute &AttrValue); - - /// Verifies the attribute's DWARF form. - /// - /// This function currently checks for: - /// - All DW_FORM_ref values that are CU relative have valid CU offsets - /// - All DW_FORM_ref_addr values have valid section offsets - /// - All DW_FORM_strp values have valid .debug_str offsets - /// - /// \param Die The DWARF DIE that owns the attribute value - /// \param AttrValue The DWARF attribute value to check - /// - /// \returns NumErrors The number of errors occurred during verification of - /// attributes' forms in a unit - unsigned verifyDebugInfoForm(const DWARFDie &Die, DWARFAttribute &AttrValue); - - /// Verifies the all valid references that were found when iterating through - /// all of the DIE attributes. - /// - /// This function will verify that all references point to DIEs whose DIE - /// offset matches. This helps to ensure if a DWARF link phase moved things - /// around, that it doesn't create invalid references by failing to relocate - /// CU relative and absolute references. - /// - /// \returns NumErrors The number of errors occurred during verification of - /// references for the .debug_info and .debug_types sections - unsigned verifyDebugInfoReferences(); - - /// Verify the DW_AT_stmt_list encoding and value and ensure that no - /// compile units that have the same DW_AT_stmt_list value. - void verifyDebugLineStmtOffsets(); - - /// Verify that all of the rows in the line table are valid. - /// - /// This function currently checks for: - /// - addresses within a sequence that decrease in value - /// - invalid file indexes - void verifyDebugLineRows(); - - /// Verify that an Apple-style accelerator table is valid. - /// - /// This function currently checks that: - /// - The fixed part of the header fits in the section - /// - The size of the section is as large as what the header describes - /// - There is at least one atom - /// - The form for each atom is valid - /// - The tag for each DIE in the table is valid - /// - The buckets have a valid index, or they are empty - /// - Each hashdata offset is valid - /// - Each DIE is valid - /// - /// \param AccelSection pointer to the section containing the acceleration table - /// \param StrData pointer to the string section - /// \param SectionName the name of the table we're verifying - /// - /// \returns The number of errors occurred during verification - unsigned verifyAppleAccelTable(const DWARFSection *AccelSection, - DataExtractor *StrData, - const char *SectionName); - - unsigned verifyDebugNamesCULists(const DWARFDebugNames &AccelTable); - unsigned verifyNameIndexBuckets(const DWARFDebugNames::NameIndex &NI, - const DataExtractor &StrData); - unsigned verifyNameIndexAbbrevs(const DWARFDebugNames::NameIndex &NI); - unsigned verifyNameIndexAttribute(const DWARFDebugNames::NameIndex &NI, - const DWARFDebugNames::Abbrev &Abbr, - DWARFDebugNames::AttributeEncoding AttrEnc); - unsigned verifyNameIndexEntries(const DWARFDebugNames::NameIndex &NI, - const DWARFDebugNames::NameTableEntry &NTE); - unsigned verifyNameIndexCompleteness(const DWARFDie &Die, - const DWARFDebugNames::NameIndex &NI); - - /// Verify that the DWARF v5 accelerator table is valid. - /// - /// This function currently checks that: - /// - Headers individual Name Indices fit into the section and can be parsed. - /// - Abbreviation tables can be parsed and contain valid index attributes - /// with correct form encodings. - /// - The CU lists reference existing compile units. - /// - The buckets have a valid index, or they are empty. - /// - All names are reachable via the hash table (they have the correct hash, - /// and the hash is in the correct bucket). - /// - Information in the index entries is complete (all required entries are - /// present) and consistent with the debug_info section DIEs. - /// - /// \param AccelSection section containing the acceleration table - /// \param StrData string section - /// - /// \returns The number of errors occurred during verification - unsigned verifyDebugNames(const DWARFSection &AccelSection, - const DataExtractor &StrData); - -public: - DWARFVerifier(raw_ostream &S, DWARFContext &D, - DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE()); - - /// Verify the information in any of the following sections, if available: - /// .debug_abbrev, debug_abbrev.dwo - /// - /// Any errors are reported to the stream that was this object was - /// constructed with. - /// - /// \returns true if .debug_abbrev and .debug_abbrev.dwo verify successfully, - /// false otherwise. - bool handleDebugAbbrev(); - - /// Verify the information in the .debug_info and .debug_types sections. - /// - /// Any errors are reported to the stream that this object was - /// constructed with. - /// - /// \returns true if all sections verify successfully, false otherwise. - bool handleDebugInfo(); - - /// Verify the information in the .debug_line section. - /// - /// Any errors are reported to the stream that was this object was - /// constructed with. - /// - /// \returns true if the .debug_line verifies successfully, false otherwise. - bool handleDebugLine(); - - /// Verify the information in accelerator tables, if they exist. - /// - /// Any errors are reported to the stream that was this object was - /// constructed with. - /// - /// \returns true if the existing Apple-style accelerator tables verify - /// successfully, false otherwise. - bool handleAccelTables(); -}; - -static inline bool operator<(const DWARFVerifier::DieRangeInfo &LHS, - const DWARFVerifier::DieRangeInfo &RHS) { - return std::tie(LHS.Ranges, LHS.Die) < std::tie(RHS.Ranges, RHS.Die); -} - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + +/// A class that verifies DWARF debug information given a DWARF Context. +class DWARFVerifier { +public: + /// A class that keeps the address range information for a single DIE. + struct DieRangeInfo { + DWARFDie Die; + + /// Sorted DWARFAddressRanges. + std::vector<DWARFAddressRange> Ranges; + + /// Sorted DWARFAddressRangeInfo. + std::set<DieRangeInfo> Children; + + DieRangeInfo() = default; + DieRangeInfo(DWARFDie Die) : Die(Die) {} + + /// Used for unit testing. + DieRangeInfo(std::vector<DWARFAddressRange> Ranges) + : Ranges(std::move(Ranges)) {} + + typedef std::vector<DWARFAddressRange>::const_iterator + address_range_iterator; + typedef std::set<DieRangeInfo>::const_iterator die_range_info_iterator; + + /// Inserts the address range. If the range overlaps with an existing + /// range, the range that it overlaps with will be returned and the two + /// address ranges will be unioned together in "Ranges". + /// + /// This is used for finding overlapping ranges in the DW_AT_ranges + /// attribute of a DIE. It is also used as a set of address ranges that + /// children address ranges must all be contained in. + Optional<DWARFAddressRange> insert(const DWARFAddressRange &R); + + /// Finds an address range in the sorted vector of ranges. + address_range_iterator findRange(const DWARFAddressRange &R) const { + auto Begin = Ranges.begin(); + auto End = Ranges.end(); + auto Iter = std::upper_bound(Begin, End, R); + if (Iter != Begin) + --Iter; + return Iter; + } + + /// Inserts the address range info. If any of its ranges overlaps with a + /// range in an existing range info, the range info is *not* added and an + /// iterator to the overlapping range info. + /// + /// This is used for finding overlapping children of the same DIE. + die_range_info_iterator insert(const DieRangeInfo &RI); + + /// Return true if ranges in this object contains all ranges within RHS. + bool contains(const DieRangeInfo &RHS) const; + + /// Return true if any range in this object intersects with any range in + /// RHS. + bool intersects(const DieRangeInfo &RHS) const; + }; + +private: + raw_ostream &OS; + DWARFContext &DCtx; + DIDumpOptions DumpOpts; + /// A map that tracks all references (converted absolute references) so we + /// can verify each reference points to a valid DIE and not an offset that + /// lies between to valid DIEs. + std::map<uint64_t, std::set<uint64_t>> ReferenceToDIEOffsets; + uint32_t NumDebugLineErrors = 0; + // Used to relax some checks that do not currently work portably + bool IsObjectFile; + bool IsMachOObject; + + raw_ostream &error() const; + raw_ostream &warn() const; + raw_ostream ¬e() const; + raw_ostream &dump(const DWARFDie &Die, unsigned indent = 0) const; + + /// Verifies the abbreviations section. + /// + /// This function currently checks that: + /// --No abbreviation declaration has more than one attributes with the same + /// name. + /// + /// \param Abbrev Pointer to the abbreviations section we are verifying + /// Abbrev can be a pointer to either .debug_abbrev or debug_abbrev.dwo. + /// + /// \returns The number of errors that occurred during verification. + unsigned verifyAbbrevSection(const DWARFDebugAbbrev *Abbrev); + + /// Verifies the header of a unit in a .debug_info or .debug_types section. + /// + /// This function currently checks for: + /// - Unit is in 32-bit DWARF format. The function can be modified to + /// support 64-bit format. + /// - The DWARF version is valid + /// - The unit type is valid (if unit is in version >=5) + /// - The unit doesn't extend beyond the containing section + /// - The address size is valid + /// - The offset in the .debug_abbrev section is valid + /// + /// \param DebugInfoData The section data + /// \param Offset A reference to the offset start of the unit. The offset will + /// be updated to point to the next unit in the section + /// \param UnitIndex The index of the unit to be verified + /// \param UnitType A reference to the type of the unit + /// \param isUnitDWARF64 A reference to a flag that shows whether the unit is + /// in 64-bit format. + /// + /// \returns true if the header is verified successfully, false otherwise. + bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData, + uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, + bool &isUnitDWARF64); + + /// Verifies the header of a unit in a .debug_info or .debug_types section. + /// + /// This function currently verifies: + /// - The debug info attributes. + /// - The debug info form=s. + /// - The presence of a root DIE. + /// - That the root DIE is a unit DIE. + /// - If a unit type is provided, that the unit DIE matches the unit type. + /// - The DIE ranges. + /// - That call site entries are only nested within subprograms with a + /// DW_AT_call attribute. + /// + /// \param Unit The DWARF Unit to verify. + /// + /// \returns The number of errors that occurred during verification. + unsigned verifyUnitContents(DWARFUnit &Unit); + + /// Verifies the unit headers and contents in a .debug_info or .debug_types + /// section. + /// + /// \param S The DWARF Section to verify. + /// \param SectionKind The object-file section kind that S comes from. + /// + /// \returns The number of errors that occurred during verification. + unsigned verifyUnitSection(const DWARFSection &S, + DWARFSectionKind SectionKind); + + /// Verifies that a call site entry is nested within a subprogram with a + /// DW_AT_call attribute. + /// + /// \returns Number of errors that occurred during verification. + unsigned verifyDebugInfoCallSite(const DWARFDie &Die); + + /// Verify that all Die ranges are valid. + /// + /// This function currently checks for: + /// - cases in which lowPC >= highPC + /// + /// \returns Number of errors that occurred during verification. + unsigned verifyDieRanges(const DWARFDie &Die, DieRangeInfo &ParentRI); + + /// Verifies the attribute's DWARF attribute and its value. + /// + /// This function currently checks for: + /// - DW_AT_ranges values is a valid .debug_ranges offset + /// - DW_AT_stmt_list is a valid .debug_line offset + /// + /// \param Die The DWARF DIE that owns the attribute value + /// \param AttrValue The DWARF attribute value to check + /// + /// \returns NumErrors The number of errors occurred during verification of + /// attributes' values in a unit + unsigned verifyDebugInfoAttribute(const DWARFDie &Die, + DWARFAttribute &AttrValue); + + /// Verifies the attribute's DWARF form. + /// + /// This function currently checks for: + /// - All DW_FORM_ref values that are CU relative have valid CU offsets + /// - All DW_FORM_ref_addr values have valid section offsets + /// - All DW_FORM_strp values have valid .debug_str offsets + /// + /// \param Die The DWARF DIE that owns the attribute value + /// \param AttrValue The DWARF attribute value to check + /// + /// \returns NumErrors The number of errors occurred during verification of + /// attributes' forms in a unit + unsigned verifyDebugInfoForm(const DWARFDie &Die, DWARFAttribute &AttrValue); + + /// Verifies the all valid references that were found when iterating through + /// all of the DIE attributes. + /// + /// This function will verify that all references point to DIEs whose DIE + /// offset matches. This helps to ensure if a DWARF link phase moved things + /// around, that it doesn't create invalid references by failing to relocate + /// CU relative and absolute references. + /// + /// \returns NumErrors The number of errors occurred during verification of + /// references for the .debug_info and .debug_types sections + unsigned verifyDebugInfoReferences(); + + /// Verify the DW_AT_stmt_list encoding and value and ensure that no + /// compile units that have the same DW_AT_stmt_list value. + void verifyDebugLineStmtOffsets(); + + /// Verify that all of the rows in the line table are valid. + /// + /// This function currently checks for: + /// - addresses within a sequence that decrease in value + /// - invalid file indexes + void verifyDebugLineRows(); + + /// Verify that an Apple-style accelerator table is valid. + /// + /// This function currently checks that: + /// - The fixed part of the header fits in the section + /// - The size of the section is as large as what the header describes + /// - There is at least one atom + /// - The form for each atom is valid + /// - The tag for each DIE in the table is valid + /// - The buckets have a valid index, or they are empty + /// - Each hashdata offset is valid + /// - Each DIE is valid + /// + /// \param AccelSection pointer to the section containing the acceleration table + /// \param StrData pointer to the string section + /// \param SectionName the name of the table we're verifying + /// + /// \returns The number of errors occurred during verification + unsigned verifyAppleAccelTable(const DWARFSection *AccelSection, + DataExtractor *StrData, + const char *SectionName); + + unsigned verifyDebugNamesCULists(const DWARFDebugNames &AccelTable); + unsigned verifyNameIndexBuckets(const DWARFDebugNames::NameIndex &NI, + const DataExtractor &StrData); + unsigned verifyNameIndexAbbrevs(const DWARFDebugNames::NameIndex &NI); + unsigned verifyNameIndexAttribute(const DWARFDebugNames::NameIndex &NI, + const DWARFDebugNames::Abbrev &Abbr, + DWARFDebugNames::AttributeEncoding AttrEnc); + unsigned verifyNameIndexEntries(const DWARFDebugNames::NameIndex &NI, + const DWARFDebugNames::NameTableEntry &NTE); + unsigned verifyNameIndexCompleteness(const DWARFDie &Die, + const DWARFDebugNames::NameIndex &NI); + + /// Verify that the DWARF v5 accelerator table is valid. + /// + /// This function currently checks that: + /// - Headers individual Name Indices fit into the section and can be parsed. + /// - Abbreviation tables can be parsed and contain valid index attributes + /// with correct form encodings. + /// - The CU lists reference existing compile units. + /// - The buckets have a valid index, or they are empty. + /// - All names are reachable via the hash table (they have the correct hash, + /// and the hash is in the correct bucket). + /// - Information in the index entries is complete (all required entries are + /// present) and consistent with the debug_info section DIEs. + /// + /// \param AccelSection section containing the acceleration table + /// \param StrData string section + /// + /// \returns The number of errors occurred during verification + unsigned verifyDebugNames(const DWARFSection &AccelSection, + const DataExtractor &StrData); + +public: + DWARFVerifier(raw_ostream &S, DWARFContext &D, + DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE()); + + /// Verify the information in any of the following sections, if available: + /// .debug_abbrev, debug_abbrev.dwo + /// + /// Any errors are reported to the stream that was this object was + /// constructed with. + /// + /// \returns true if .debug_abbrev and .debug_abbrev.dwo verify successfully, + /// false otherwise. + bool handleDebugAbbrev(); + + /// Verify the information in the .debug_info and .debug_types sections. + /// + /// Any errors are reported to the stream that this object was + /// constructed with. + /// + /// \returns true if all sections verify successfully, false otherwise. + bool handleDebugInfo(); + + /// Verify the information in the .debug_line section. + /// + /// Any errors are reported to the stream that was this object was + /// constructed with. + /// + /// \returns true if the .debug_line verifies successfully, false otherwise. + bool handleDebugLine(); + + /// Verify the information in accelerator tables, if they exist. + /// + /// Any errors are reported to the stream that was this object was + /// constructed with. + /// + /// \returns true if the existing Apple-style accelerator tables verify + /// successfully, false otherwise. + bool handleAccelTables(); +}; + +static inline bool operator<(const DWARFVerifier::DieRangeInfo &LHS, + const DWARFVerifier::DieRangeInfo &RHS) { + return std::tie(LHS.Ranges, LHS.Die) < std::tie(RHS.Ranges, RHS.Die); +} + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/DwarfTransformer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/DwarfTransformer.h index 2a17d41e90..3b091c5919 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/DwarfTransformer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/DwarfTransformer.h @@ -1,102 +1,102 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DwarfTransformer.h ---------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H -#define LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/GSYM/Range.h" -#include "llvm/Support/Error.h" - -namespace llvm { - -class raw_ostream; - -namespace gsym { - -struct CUInfo; -struct FunctionInfo; -class GsymCreator; - -/// A class that transforms the DWARF in a DWARFContext into GSYM information -/// by populating the GsymCreator object that it is constructed with. This -/// class supports converting all DW_TAG_subprogram DIEs into -/// gsym::FunctionInfo objects that includes line table information and inline -/// function information. Creating a separate class to transform this data -/// allows this class to be unit tested. -class DwarfTransformer { -public: - - /// Create a DWARF transformer. - /// - /// \param D The DWARF to use when converting to GSYM. - /// - /// \param OS The stream to log warnings and non fatal issues to. - /// - /// \param G The GSYM creator to populate with the function information - /// from the debug info. - DwarfTransformer(DWARFContext &D, raw_ostream &OS, GsymCreator &G) : - DICtx(D), Log(OS), Gsym(G) {} - - /// Extract the DWARF from the supplied object file and convert it into the - /// Gsym format in the GsymCreator object that is passed in. Returns an - /// error if something fatal is encountered. - /// - /// \returns An error indicating any fatal issues that happen when parsing - /// the DWARF, or Error::success() if all goes well. - llvm::Error convert(uint32_t NumThreads); - - llvm::Error verify(StringRef GsymPath); - - -private: - - /// Parse the DWARF in the object file and convert it into the GsymCreator. - Error parse(); - - /// Handle any DIE (debug info entry) from the DWARF. - /// - /// This function will find all DW_TAG_subprogram DIEs that convert them into - /// GSYM FuntionInfo objects and add them to the GsymCreator supplied during - /// construction. The DIE and all its children will be recursively parsed - /// with calls to this function. - /// - /// \param Strm The thread specific log stream for any non fatal errors and - /// warnings. Once a thread has finished parsing an entire compile unit, all - /// information in this temporary stream will be forwarded to the member - /// variable log. This keeps logging thread safe. - /// - /// \param CUI The compile unit specific information that contains the DWARF - /// line table, cached file list, and other compile unit specific - /// information. - /// - /// \param Die The DWARF debug info entry to parse. - void handleDie(raw_ostream &Strm, CUInfo &CUI, DWARFDie Die); - - DWARFContext &DICtx; - raw_ostream &Log; - GsymCreator &Gsym; - - friend class DwarfTransformerTest; -}; - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DwarfTransformer.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H +#define LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/GSYM/Range.h" +#include "llvm/Support/Error.h" + +namespace llvm { + +class raw_ostream; + +namespace gsym { + +struct CUInfo; +struct FunctionInfo; +class GsymCreator; + +/// A class that transforms the DWARF in a DWARFContext into GSYM information +/// by populating the GsymCreator object that it is constructed with. This +/// class supports converting all DW_TAG_subprogram DIEs into +/// gsym::FunctionInfo objects that includes line table information and inline +/// function information. Creating a separate class to transform this data +/// allows this class to be unit tested. +class DwarfTransformer { +public: + + /// Create a DWARF transformer. + /// + /// \param D The DWARF to use when converting to GSYM. + /// + /// \param OS The stream to log warnings and non fatal issues to. + /// + /// \param G The GSYM creator to populate with the function information + /// from the debug info. + DwarfTransformer(DWARFContext &D, raw_ostream &OS, GsymCreator &G) : + DICtx(D), Log(OS), Gsym(G) {} + + /// Extract the DWARF from the supplied object file and convert it into the + /// Gsym format in the GsymCreator object that is passed in. Returns an + /// error if something fatal is encountered. + /// + /// \returns An error indicating any fatal issues that happen when parsing + /// the DWARF, or Error::success() if all goes well. + llvm::Error convert(uint32_t NumThreads); + + llvm::Error verify(StringRef GsymPath); + + +private: + + /// Parse the DWARF in the object file and convert it into the GsymCreator. + Error parse(); + + /// Handle any DIE (debug info entry) from the DWARF. + /// + /// This function will find all DW_TAG_subprogram DIEs that convert them into + /// GSYM FuntionInfo objects and add them to the GsymCreator supplied during + /// construction. The DIE and all its children will be recursively parsed + /// with calls to this function. + /// + /// \param Strm The thread specific log stream for any non fatal errors and + /// warnings. Once a thread has finished parsing an entire compile unit, all + /// information in this temporary stream will be forwarded to the member + /// variable log. This keeps logging thread safe. + /// + /// \param CUI The compile unit specific information that contains the DWARF + /// line table, cached file list, and other compile unit specific + /// information. + /// + /// \param Die The DWARF debug info entry to parse. + void handleDie(raw_ostream &Strm, CUInfo &CUI, DWARFDie Die); + + DWARFContext &DICtx; + raw_ostream &Log; + GsymCreator &Gsym; + + friend class DwarfTransformerTest; +}; + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_DWARFTRANSFORMER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileEntry.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileEntry.h index 298a895dc8..ae9185b54b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileEntry.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileEntry.h @@ -1,78 +1,78 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- FileEntry.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H -#define LLVM_DEBUGINFO_GSYM_FILEENTRY_H - -#include "llvm/ADT/DenseMapInfo.h" -#include "llvm/ADT/Hashing.h" -#include <functional> -#include <stdint.h> -#include <utility> - -namespace llvm { -namespace gsym { - -/// Files in GSYM are contained in FileEntry structs where we split the -/// directory and basename into two different strings in the string -/// table. This allows paths to shared commont directory and filename -/// strings and saves space. -struct FileEntry { - - /// Offsets in the string table. - /// @{ - uint32_t Dir = 0; - uint32_t Base = 0; - /// @} - - FileEntry() = default; - FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {} - - // Implement operator== so that FileEntry can be used as key in - // unordered containers. - bool operator==(const FileEntry &RHS) const { - return Base == RHS.Base && Dir == RHS.Dir; - }; - bool operator!=(const FileEntry &RHS) const { - return Base != RHS.Base || Dir != RHS.Dir; - }; -}; - -} // namespace gsym - -template <> struct DenseMapInfo<gsym::FileEntry> { - static inline gsym::FileEntry getEmptyKey() { - uint32_t key = DenseMapInfo<uint32_t>::getEmptyKey(); - return gsym::FileEntry(key, key); - } - static inline gsym::FileEntry getTombstoneKey() { - uint32_t key = DenseMapInfo<uint32_t>::getTombstoneKey(); - return gsym::FileEntry(key, key); - } - static unsigned getHashValue(const gsym::FileEntry &Val) { - return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir), - DenseMapInfo<uint32_t>::getHashValue(Val.Base)); - } - static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) { - return LHS == RHS; - } -}; - -} // namespace llvm -#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- FileEntry.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H +#define LLVM_DEBUGINFO_GSYM_FILEENTRY_H + +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/Hashing.h" +#include <functional> +#include <stdint.h> +#include <utility> + +namespace llvm { +namespace gsym { + +/// Files in GSYM are contained in FileEntry structs where we split the +/// directory and basename into two different strings in the string +/// table. This allows paths to shared commont directory and filename +/// strings and saves space. +struct FileEntry { + + /// Offsets in the string table. + /// @{ + uint32_t Dir = 0; + uint32_t Base = 0; + /// @} + + FileEntry() = default; + FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {} + + // Implement operator== so that FileEntry can be used as key in + // unordered containers. + bool operator==(const FileEntry &RHS) const { + return Base == RHS.Base && Dir == RHS.Dir; + }; + bool operator!=(const FileEntry &RHS) const { + return Base != RHS.Base || Dir != RHS.Dir; + }; +}; + +} // namespace gsym + +template <> struct DenseMapInfo<gsym::FileEntry> { + static inline gsym::FileEntry getEmptyKey() { + uint32_t key = DenseMapInfo<uint32_t>::getEmptyKey(); + return gsym::FileEntry(key, key); + } + static inline gsym::FileEntry getTombstoneKey() { + uint32_t key = DenseMapInfo<uint32_t>::getTombstoneKey(); + return gsym::FileEntry(key, key); + } + static unsigned getHashValue(const gsym::FileEntry &Val) { + return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir), + DenseMapInfo<uint32_t>::getHashValue(Val.Base)); + } + static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) { + return LHS == RHS; + } +}; + +} // namespace llvm +#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileWriter.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileWriter.h index 9de83a9e56..e66020f220 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileWriter.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FileWriter.h @@ -1,135 +1,135 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- FileWriter.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_FILEWRITER_H -#define LLVM_DEBUGINFO_GSYM_FILEWRITER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/Endian.h" - -#include <stddef.h> -#include <stdint.h> -#include <sys/types.h> - -namespace llvm { -class raw_pwrite_stream; - -namespace gsym { - -/// A simplified binary data writer class that doesn't require targets, target -/// definitions, architectures, or require any other optional compile time -/// libraries to be enabled via the build process. This class needs the ability -/// to seek to different spots in the binary stream that is produces to fixup -/// offsets and sizes. -class FileWriter { - llvm::raw_pwrite_stream &OS; - llvm::support::endianness ByteOrder; -public: - FileWriter(llvm::raw_pwrite_stream &S, llvm::support::endianness B) - : OS(S), ByteOrder(B) {} - ~FileWriter(); - /// Write a single uint8_t value into the stream at the current file - /// position. - /// - /// \param Value The value to write into the stream. - void writeU8(uint8_t Value); - - /// Write a single uint16_t value into the stream at the current file - /// position. The value will be byte swapped if needed to match the byte - /// order specified during construction. - /// - /// \param Value The value to write into the stream. - void writeU16(uint16_t Value); - - /// Write a single uint32_t value into the stream at the current file - /// position. The value will be byte swapped if needed to match the byte - /// order specified during construction. - /// - /// \param Value The value to write into the stream. - void writeU32(uint32_t Value); - - /// Write a single uint64_t value into the stream at the current file - /// position. The value will be byte swapped if needed to match the byte - /// order specified during construction. - /// - /// \param Value The value to write into the stream. - void writeU64(uint64_t Value); - - /// Write the value into the stream encoded using signed LEB128 at the - /// current file position. - /// - /// \param Value The value to write into the stream. - void writeSLEB(int64_t Value); - - /// Write the value into the stream encoded using unsigned LEB128 at the - /// current file position. - /// - /// \param Value The value to write into the stream. - void writeULEB(uint64_t Value); - - /// Write an array of uint8_t values into the stream at the current file - /// position. - /// - /// \param Data An array of values to write into the stream. - void writeData(llvm::ArrayRef<uint8_t> Data); - - /// Write a NULL terminated C string into the stream at the current file - /// position. The entire contents of Str will be written into the steam at - /// the current file position and then an extra NULL termation byte will be - /// written. It is up to the user to ensure that Str doesn't contain any NULL - /// characters unless the additional NULL characters are desired. - /// - /// \param Str The value to write into the stream. - void writeNullTerminated(llvm::StringRef Str); - - /// Fixup a uint32_t value at the specified offset in the stream. This - /// function will save the current file position, seek to the specified - /// offset, overwrite the data using Value, and then restore the file - /// position to the previous file position. - /// - /// \param Value The value to write into the stream. - /// \param Offset The offset at which to write the Value within the stream. - void fixup32(uint32_t Value, uint64_t Offset); - - /// Pad with zeroes at the current file position until the current file - /// position matches the specified alignment. - /// - /// \param Align An integer speciying the desired alignment. This does not - /// need to be a power of two. - void alignTo(size_t Align); - - /// Return the current offset within the file. - /// - /// \return The unsigned offset from the start of the file of the current - /// file position. - uint64_t tell(); - - llvm::raw_pwrite_stream &get_stream() { - return OS; - } - -private: - FileWriter(const FileWriter &rhs) = delete; - void operator=(const FileWriter &rhs) = delete; -}; - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEWRITER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- FileWriter.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_FILEWRITER_H +#define LLVM_DEBUGINFO_GSYM_FILEWRITER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Endian.h" + +#include <stddef.h> +#include <stdint.h> +#include <sys/types.h> + +namespace llvm { +class raw_pwrite_stream; + +namespace gsym { + +/// A simplified binary data writer class that doesn't require targets, target +/// definitions, architectures, or require any other optional compile time +/// libraries to be enabled via the build process. This class needs the ability +/// to seek to different spots in the binary stream that is produces to fixup +/// offsets and sizes. +class FileWriter { + llvm::raw_pwrite_stream &OS; + llvm::support::endianness ByteOrder; +public: + FileWriter(llvm::raw_pwrite_stream &S, llvm::support::endianness B) + : OS(S), ByteOrder(B) {} + ~FileWriter(); + /// Write a single uint8_t value into the stream at the current file + /// position. + /// + /// \param Value The value to write into the stream. + void writeU8(uint8_t Value); + + /// Write a single uint16_t value into the stream at the current file + /// position. The value will be byte swapped if needed to match the byte + /// order specified during construction. + /// + /// \param Value The value to write into the stream. + void writeU16(uint16_t Value); + + /// Write a single uint32_t value into the stream at the current file + /// position. The value will be byte swapped if needed to match the byte + /// order specified during construction. + /// + /// \param Value The value to write into the stream. + void writeU32(uint32_t Value); + + /// Write a single uint64_t value into the stream at the current file + /// position. The value will be byte swapped if needed to match the byte + /// order specified during construction. + /// + /// \param Value The value to write into the stream. + void writeU64(uint64_t Value); + + /// Write the value into the stream encoded using signed LEB128 at the + /// current file position. + /// + /// \param Value The value to write into the stream. + void writeSLEB(int64_t Value); + + /// Write the value into the stream encoded using unsigned LEB128 at the + /// current file position. + /// + /// \param Value The value to write into the stream. + void writeULEB(uint64_t Value); + + /// Write an array of uint8_t values into the stream at the current file + /// position. + /// + /// \param Data An array of values to write into the stream. + void writeData(llvm::ArrayRef<uint8_t> Data); + + /// Write a NULL terminated C string into the stream at the current file + /// position. The entire contents of Str will be written into the steam at + /// the current file position and then an extra NULL termation byte will be + /// written. It is up to the user to ensure that Str doesn't contain any NULL + /// characters unless the additional NULL characters are desired. + /// + /// \param Str The value to write into the stream. + void writeNullTerminated(llvm::StringRef Str); + + /// Fixup a uint32_t value at the specified offset in the stream. This + /// function will save the current file position, seek to the specified + /// offset, overwrite the data using Value, and then restore the file + /// position to the previous file position. + /// + /// \param Value The value to write into the stream. + /// \param Offset The offset at which to write the Value within the stream. + void fixup32(uint32_t Value, uint64_t Offset); + + /// Pad with zeroes at the current file position until the current file + /// position matches the specified alignment. + /// + /// \param Align An integer speciying the desired alignment. This does not + /// need to be a power of two. + void alignTo(size_t Align); + + /// Return the current offset within the file. + /// + /// \return The unsigned offset from the start of the file of the current + /// file position. + uint64_t tell(); + + llvm::raw_pwrite_stream &get_stream() { + return OS; + } + +private: + FileWriter(const FileWriter &rhs) = delete; + void operator=(const FileWriter &rhs) = delete; +}; + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEWRITER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FunctionInfo.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FunctionInfo.h index 3bb28221fe..1efb9036eb 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FunctionInfo.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/FunctionInfo.h @@ -1,227 +1,227 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- FunctionInfo.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H -#define LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/GSYM/InlineInfo.h" -#include "llvm/DebugInfo/GSYM/LineTable.h" -#include "llvm/DebugInfo/GSYM/LookupResult.h" -#include "llvm/DebugInfo/GSYM/Range.h" -#include "llvm/DebugInfo/GSYM/StringTable.h" -#include <tuple> -#include <vector> - -namespace llvm { -class raw_ostream; -namespace gsym { - -class GsymReader; -/// Function information in GSYM files encodes information for one contiguous -/// address range. If a function has discontiguous address ranges, they will -/// need to be encoded using multiple FunctionInfo objects. -/// -/// ENCODING -/// -/// The function information gets the function start address as an argument -/// to the FunctionInfo::decode(...) function. This information is calculated -/// from the GSYM header and an address offset from the GSYM address offsets -/// table. The encoded FunctionInfo information must be aligned to a 4 byte -/// boundary. -/// -/// The encoded data for a FunctionInfo starts with fixed data that all -/// function info objects have: -/// -/// ENCODING NAME DESCRIPTION -/// ========= =========== ==================================================== -/// uint32_t Size The size in bytes of this function. -/// uint32_t Name The string table offset of the function name. -/// -/// The optional data in a FunctionInfo object follows this fixed information -/// and consists of a stream of tuples that consist of: -/// -/// ENCODING NAME DESCRIPTION -/// ========= =========== ==================================================== -/// uint32_t InfoType An "InfoType" enumeration that describes the type -/// of optional data that is encoded. -/// uint32_t InfoLength The size in bytes of the encoded data that -/// immediately follows this length if this value is -/// greater than zero. -/// uint8_t[] InfoData Encoded bytes that represent the data for the -/// "InfoType". These bytes are only present if -/// "InfoLength" is greater than zero. -/// -/// The "InfoType" is an enumeration: -/// -/// enum InfoType { -/// EndOfList = 0u, -/// LineTableInfo = 1u, -/// InlineInfo = 2u -/// }; -/// -/// This stream of tuples is terminated by a "InfoType" whose value is -/// InfoType::EndOfList and a zero for "InfoLength". This signifies the end of -/// the optional information list. This format allows us to add new optional -/// information data to a FunctionInfo object over time and allows older -/// clients to still parse the format and skip over any data that they don't -/// understand or want to parse. -/// -/// So the function information encoding essientially looks like: -/// -/// struct { -/// uint32_t Size; -/// uint32_t Name; -/// struct { -/// uint32_t InfoType; -/// uint32_t InfoLength; -/// uint8_t InfoData[InfoLength]; -/// }[N]; -/// } -/// -/// Where "N" is the number of tuples. -struct FunctionInfo { - AddressRange Range; - uint32_t Name; ///< String table offset in the string table. - llvm::Optional<LineTable> OptLineTable; - llvm::Optional<InlineInfo> Inline; - - FunctionInfo(uint64_t Addr = 0, uint64_t Size = 0, uint32_t N = 0) - : Range(Addr, Addr + Size), Name(N) {} - - /// Query if a FunctionInfo has rich debug info. - /// - /// \returns A bool that indicates if this object has something else than - /// range and name. When converting information from a symbol table and from - /// debug info, we might end up with multiple FunctionInfo objects for the - /// same range and we need to be able to tell which one is the better object - /// to use. - bool hasRichInfo() const { - return OptLineTable.hasValue() || Inline.hasValue(); - } - - /// Query if a FunctionInfo object is valid. - /// - /// Address and size can be zero and there can be no line entries for a - /// symbol so the only indication this entry is valid is if the name is - /// not zero. This can happen when extracting information from symbol - /// tables that do not encode symbol sizes. In that case only the - /// address and name will be filled in. - /// - /// \returns A boolean indicating if this FunctionInfo is valid. - bool isValid() const { - return Name != 0; - } - - /// Decode an object from a binary data stream. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param BaseAddr The FunctionInfo's start address and will be used as the - /// base address when decoding any contained information like the line table - /// and the inline info. - /// - /// \returns An FunctionInfo or an error describing the issue that was - /// encountered during decoding. - static llvm::Expected<FunctionInfo> decode(DataExtractor &Data, - uint64_t BaseAddr); - - /// Encode this object into FileWriter stream. - /// - /// \param O The binary stream to write the data to at the current file - /// position. - /// - /// \returns An error object that indicates failure or the offset of the - /// function info that was successfully written into the stream. - llvm::Expected<uint64_t> encode(FileWriter &O) const; - - - /// Lookup an address within a FunctionInfo object's data stream. - /// - /// Instead of decoding an entire FunctionInfo object when doing lookups, - /// we can decode only the information we need from the FunctionInfo's data - /// for the specific address. The lookup result information is returned as - /// a LookupResult. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param GR The GSYM reader that contains the string and file table that - /// will be used to fill in information in the returned result. - /// - /// \param FuncAddr The function start address decoded from the GsymReader. - /// - /// \param Addr The address to lookup. - /// - /// \returns An LookupResult or an error describing the issue that was - /// encountered during decoding. An error should only be returned if the - /// address is not contained in the FunctionInfo or if the data is corrupted. - static llvm::Expected<LookupResult> lookup(DataExtractor &Data, - const GsymReader &GR, - uint64_t FuncAddr, - uint64_t Addr); - - uint64_t startAddress() const { return Range.Start; } - uint64_t endAddress() const { return Range.End; } - uint64_t size() const { return Range.size(); } - void setStartAddress(uint64_t Addr) { Range.Start = Addr; } - void setEndAddress(uint64_t Addr) { Range.End = Addr; } - void setSize(uint64_t Size) { Range.End = Range.Start + Size; } - - void clear() { - Range = {0, 0}; - Name = 0; - OptLineTable = None; - Inline = None; - } -}; - -inline bool operator==(const FunctionInfo &LHS, const FunctionInfo &RHS) { - return LHS.Range == RHS.Range && LHS.Name == RHS.Name && - LHS.OptLineTable == RHS.OptLineTable && LHS.Inline == RHS.Inline; -} -inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) { - return !(LHS == RHS); -} -/// This sorting will order things consistently by address range first, but then -/// followed by inlining being valid and line tables. We might end up with a -/// FunctionInfo from debug info that will have the same range as one from the -/// symbol table, but we want to quickly be able to sort and use the best version -/// when creating the final GSYM file. -inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) { - // First sort by address range - if (LHS.Range != RHS.Range) - return LHS.Range < RHS.Range; - - // Then sort by inline - if (LHS.Inline.hasValue() != RHS.Inline.hasValue()) - return RHS.Inline.hasValue(); - - return LHS.OptLineTable < RHS.OptLineTable; -} - -raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- FunctionInfo.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H +#define LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/GSYM/InlineInfo.h" +#include "llvm/DebugInfo/GSYM/LineTable.h" +#include "llvm/DebugInfo/GSYM/LookupResult.h" +#include "llvm/DebugInfo/GSYM/Range.h" +#include "llvm/DebugInfo/GSYM/StringTable.h" +#include <tuple> +#include <vector> + +namespace llvm { +class raw_ostream; +namespace gsym { + +class GsymReader; +/// Function information in GSYM files encodes information for one contiguous +/// address range. If a function has discontiguous address ranges, they will +/// need to be encoded using multiple FunctionInfo objects. +/// +/// ENCODING +/// +/// The function information gets the function start address as an argument +/// to the FunctionInfo::decode(...) function. This information is calculated +/// from the GSYM header and an address offset from the GSYM address offsets +/// table. The encoded FunctionInfo information must be aligned to a 4 byte +/// boundary. +/// +/// The encoded data for a FunctionInfo starts with fixed data that all +/// function info objects have: +/// +/// ENCODING NAME DESCRIPTION +/// ========= =========== ==================================================== +/// uint32_t Size The size in bytes of this function. +/// uint32_t Name The string table offset of the function name. +/// +/// The optional data in a FunctionInfo object follows this fixed information +/// and consists of a stream of tuples that consist of: +/// +/// ENCODING NAME DESCRIPTION +/// ========= =========== ==================================================== +/// uint32_t InfoType An "InfoType" enumeration that describes the type +/// of optional data that is encoded. +/// uint32_t InfoLength The size in bytes of the encoded data that +/// immediately follows this length if this value is +/// greater than zero. +/// uint8_t[] InfoData Encoded bytes that represent the data for the +/// "InfoType". These bytes are only present if +/// "InfoLength" is greater than zero. +/// +/// The "InfoType" is an enumeration: +/// +/// enum InfoType { +/// EndOfList = 0u, +/// LineTableInfo = 1u, +/// InlineInfo = 2u +/// }; +/// +/// This stream of tuples is terminated by a "InfoType" whose value is +/// InfoType::EndOfList and a zero for "InfoLength". This signifies the end of +/// the optional information list. This format allows us to add new optional +/// information data to a FunctionInfo object over time and allows older +/// clients to still parse the format and skip over any data that they don't +/// understand or want to parse. +/// +/// So the function information encoding essientially looks like: +/// +/// struct { +/// uint32_t Size; +/// uint32_t Name; +/// struct { +/// uint32_t InfoType; +/// uint32_t InfoLength; +/// uint8_t InfoData[InfoLength]; +/// }[N]; +/// } +/// +/// Where "N" is the number of tuples. +struct FunctionInfo { + AddressRange Range; + uint32_t Name; ///< String table offset in the string table. + llvm::Optional<LineTable> OptLineTable; + llvm::Optional<InlineInfo> Inline; + + FunctionInfo(uint64_t Addr = 0, uint64_t Size = 0, uint32_t N = 0) + : Range(Addr, Addr + Size), Name(N) {} + + /// Query if a FunctionInfo has rich debug info. + /// + /// \returns A bool that indicates if this object has something else than + /// range and name. When converting information from a symbol table and from + /// debug info, we might end up with multiple FunctionInfo objects for the + /// same range and we need to be able to tell which one is the better object + /// to use. + bool hasRichInfo() const { + return OptLineTable.hasValue() || Inline.hasValue(); + } + + /// Query if a FunctionInfo object is valid. + /// + /// Address and size can be zero and there can be no line entries for a + /// symbol so the only indication this entry is valid is if the name is + /// not zero. This can happen when extracting information from symbol + /// tables that do not encode symbol sizes. In that case only the + /// address and name will be filled in. + /// + /// \returns A boolean indicating if this FunctionInfo is valid. + bool isValid() const { + return Name != 0; + } + + /// Decode an object from a binary data stream. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param BaseAddr The FunctionInfo's start address and will be used as the + /// base address when decoding any contained information like the line table + /// and the inline info. + /// + /// \returns An FunctionInfo or an error describing the issue that was + /// encountered during decoding. + static llvm::Expected<FunctionInfo> decode(DataExtractor &Data, + uint64_t BaseAddr); + + /// Encode this object into FileWriter stream. + /// + /// \param O The binary stream to write the data to at the current file + /// position. + /// + /// \returns An error object that indicates failure or the offset of the + /// function info that was successfully written into the stream. + llvm::Expected<uint64_t> encode(FileWriter &O) const; + + + /// Lookup an address within a FunctionInfo object's data stream. + /// + /// Instead of decoding an entire FunctionInfo object when doing lookups, + /// we can decode only the information we need from the FunctionInfo's data + /// for the specific address. The lookup result information is returned as + /// a LookupResult. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param GR The GSYM reader that contains the string and file table that + /// will be used to fill in information in the returned result. + /// + /// \param FuncAddr The function start address decoded from the GsymReader. + /// + /// \param Addr The address to lookup. + /// + /// \returns An LookupResult or an error describing the issue that was + /// encountered during decoding. An error should only be returned if the + /// address is not contained in the FunctionInfo or if the data is corrupted. + static llvm::Expected<LookupResult> lookup(DataExtractor &Data, + const GsymReader &GR, + uint64_t FuncAddr, + uint64_t Addr); + + uint64_t startAddress() const { return Range.Start; } + uint64_t endAddress() const { return Range.End; } + uint64_t size() const { return Range.size(); } + void setStartAddress(uint64_t Addr) { Range.Start = Addr; } + void setEndAddress(uint64_t Addr) { Range.End = Addr; } + void setSize(uint64_t Size) { Range.End = Range.Start + Size; } + + void clear() { + Range = {0, 0}; + Name = 0; + OptLineTable = None; + Inline = None; + } +}; + +inline bool operator==(const FunctionInfo &LHS, const FunctionInfo &RHS) { + return LHS.Range == RHS.Range && LHS.Name == RHS.Name && + LHS.OptLineTable == RHS.OptLineTable && LHS.Inline == RHS.Inline; +} +inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) { + return !(LHS == RHS); +} +/// This sorting will order things consistently by address range first, but then +/// followed by inlining being valid and line tables. We might end up with a +/// FunctionInfo from debug info that will have the same range as one from the +/// symbol table, but we want to quickly be able to sort and use the best version +/// when creating the final GSYM file. +inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) { + // First sort by address range + if (LHS.Range != RHS.Range) + return LHS.Range < RHS.Range; + + // Then sort by inline + if (LHS.Inline.hasValue() != RHS.Inline.hasValue()) + return RHS.Inline.hasValue(); + + return LHS.OptLineTable < RHS.OptLineTable; +} + +raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymCreator.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymCreator.h index 3e0c712a89..ef178ab686 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymCreator.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymCreator.h @@ -1,308 +1,308 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GsymCreator.h --------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H -#define LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H - -#include <functional> -#include <memory> -#include <mutex> -#include <string> -#include <thread> - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/DebugInfo/GSYM/FileEntry.h" -#include "llvm/DebugInfo/GSYM/FunctionInfo.h" -#include "llvm/DebugInfo/GSYM/Range.h" -#include "llvm/MC/StringTableBuilder.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/Path.h" - -namespace llvm { - -namespace gsym { -class FileWriter; - -/// GsymCreator is used to emit GSYM data to a stand alone file or section -/// within a file. -/// -/// The GsymCreator is designed to be used in 3 stages: -/// - Create FunctionInfo objects and add them -/// - Finalize the GsymCreator object -/// - Save to file or section -/// -/// The first stage involves creating FunctionInfo objects from another source -/// of information like compiler debug info metadata, DWARF or Breakpad files. -/// Any strings in the FunctionInfo or contained information, like InlineInfo -/// or LineTable objects, should get the string table offsets by calling -/// GsymCreator::insertString(...). Any file indexes that are needed should be -/// obtained by calling GsymCreator::insertFile(...). All of the function calls -/// in GsymCreator are thread safe. This allows multiple threads to create and -/// add FunctionInfo objects while parsing debug information. -/// -/// Once all of the FunctionInfo objects have been added, the -/// GsymCreator::finalize(...) must be called prior to saving. This function -/// will sort the FunctionInfo objects, finalize the string table, and do any -/// other passes on the information needed to prepare the information to be -/// saved. -/// -/// Once the object has been finalized, it can be saved to a file or section. -/// -/// ENCODING -/// -/// GSYM files are designed to be memory mapped into a process as shared, read -/// only data, and used as is. -/// -/// The GSYM file format when in a stand alone file consists of: -/// - Header -/// - Address Table -/// - Function Info Offsets -/// - File Table -/// - String Table -/// - Function Info Data -/// -/// HEADER -/// -/// The header is fully described in "llvm/DebugInfo/GSYM/Header.h". -/// -/// ADDRESS TABLE -/// -/// The address table immediately follows the header in the file and consists -/// of Header.NumAddresses address offsets. These offsets are sorted and can be -/// binary searched for efficient lookups. Addresses in the address table are -/// stored as offsets from a 64 bit base address found in Header.BaseAddress. -/// This allows the address table to contain 8, 16, or 32 offsets. This allows -/// the address table to not require full 64 bit addresses for each address. -/// The resulting GSYM size is smaller and causes fewer pages to be touched -/// during address lookups when the address table is smaller. The size of the -/// address offsets in the address table is specified in the header in -/// Header.AddrOffSize. The first offset in the address table is aligned to -/// Header.AddrOffSize alignment to ensure efficient access when loaded into -/// memory. -/// -/// FUNCTION INFO OFFSETS TABLE -/// -/// The function info offsets table immediately follows the address table and -/// consists of Header.NumAddresses 32 bit file offsets: one for each address -/// in the address table. This data is aligned to a 4 byte boundary. The -/// offsets in this table are the relative offsets from the start offset of the -/// GSYM header and point to the function info data for each address in the -/// address table. Keeping this data separate from the address table helps to -/// reduce the number of pages that are touched when address lookups occur on a -/// GSYM file. -/// -/// FILE TABLE -/// -/// The file table immediately follows the function info offsets table. The -/// encoding of the FileTable is: -/// -/// struct FileTable { -/// uint32_t Count; -/// FileEntry Files[]; -/// }; -/// -/// The file table starts with a 32 bit count of the number of files that are -/// used in all of the function info, followed by that number of FileEntry -/// structures. The file table is aligned to a 4 byte boundary, Each file in -/// the file table is represented with a FileEntry structure. -/// See "llvm/DebugInfo/GSYM/FileEntry.h" for details. -/// -/// STRING TABLE -/// -/// The string table follows the file table in stand alone GSYM files and -/// contains all strings for everything contained in the GSYM file. Any string -/// data should be added to the string table and any references to strings -/// inside GSYM information must be stored as 32 bit string table offsets into -/// this string table. The string table always starts with an empty string at -/// offset zero and is followed by any strings needed by the GSYM information. -/// The start of the string table is not aligned to any boundary. -/// -/// FUNCTION INFO DATA -/// -/// The function info data is the payload that contains information about the -/// address that is being looked up. It contains all of the encoded -/// FunctionInfo objects. Each encoded FunctionInfo's data is pointed to by an -/// entry in the Function Info Offsets Table. For details on the exact encoding -/// of FunctionInfo objects, see "llvm/DebugInfo/GSYM/FunctionInfo.h". -class GsymCreator { - // Private member variables require Mutex protections - mutable std::recursive_mutex Mutex; - std::vector<FunctionInfo> Funcs; - StringTableBuilder StrTab; - StringSet<> StringStorage; - DenseMap<llvm::gsym::FileEntry, uint32_t> FileEntryToIndex; - std::vector<llvm::gsym::FileEntry> Files; - std::vector<uint8_t> UUID; - Optional<AddressRanges> ValidTextRanges; - AddressRanges Ranges; - llvm::Optional<uint64_t> BaseAddress; - bool Finalized = false; - -public: - - GsymCreator(); - - /// Save a GSYM file to a stand alone file. - /// - /// \param Path The file path to save the GSYM file to. - /// \param ByteOrder The endianness to use when saving the file. - /// \returns An error object that indicates success or failure of the save. - llvm::Error save(StringRef Path, llvm::support::endianness ByteOrder) const; - - /// Encode a GSYM into the file writer stream at the current position. - /// - /// \param O The stream to save the binary data to - /// \returns An error object that indicates success or failure of the save. - llvm::Error encode(FileWriter &O) const; - - /// Insert a string into the GSYM string table. - /// - /// All strings used by GSYM files must be uniqued by adding them to this - /// string pool and using the returned offset for any string values. - /// - /// \param S The string to insert into the string table. - /// \param Copy If true, then make a backing copy of the string. If false, - /// the string is owned by another object that will stay around - /// long enough for the GsymCreator to save the GSYM file. - /// \returns The unique 32 bit offset into the string table. - uint32_t insertString(StringRef S, bool Copy = true); - - /// Insert a file into this GSYM creator. - /// - /// Inserts a file by adding a FileEntry into the "Files" member variable if - /// the file has not already been added. The file path is split into - /// directory and filename which are both added to the string table. This - /// allows paths to be stored efficiently by reusing the directories that are - /// common between multiple files. - /// - /// \param Path The path to the file to insert. - /// \param Style The path style for the "Path" parameter. - /// \returns The unique file index for the inserted file. - uint32_t insertFile(StringRef Path, - sys::path::Style Style = sys::path::Style::native); - - /// Add a function info to this GSYM creator. - /// - /// All information in the FunctionInfo object must use the - /// GsymCreator::insertString(...) function when creating string table - /// offsets for names and other strings. - /// - /// \param FI The function info object to emplace into our functions list. - void addFunctionInfo(FunctionInfo &&FI); - - /// Finalize the data in the GSYM creator prior to saving the data out. - /// - /// Finalize must be called after all FunctionInfo objects have been added - /// and before GsymCreator::save() is called. - /// - /// \param OS Output stream to report duplicate function infos, overlapping - /// function infos, and function infos that were merged or removed. - /// \returns An error object that indicates success or failure of the - /// finalize. - llvm::Error finalize(llvm::raw_ostream &OS); - - /// Set the UUID value. - /// - /// \param UUIDBytes The new UUID bytes. - void setUUID(llvm::ArrayRef<uint8_t> UUIDBytes) { - UUID.assign(UUIDBytes.begin(), UUIDBytes.end()); - } - - /// Thread safe iteration over all function infos. - /// - /// \param Callback A callback function that will get called with each - /// FunctionInfo. If the callback returns false, stop iterating. - void forEachFunctionInfo( - std::function<bool(FunctionInfo &)> const &Callback); - - /// Thread safe const iteration over all function infos. - /// - /// \param Callback A callback function that will get called with each - /// FunctionInfo. If the callback returns false, stop iterating. - void forEachFunctionInfo( - std::function<bool(const FunctionInfo &)> const &Callback) const; - - /// Get the current number of FunctionInfo objects contained in this - /// object. - size_t getNumFunctionInfos() const; - - /// Check if an address has already been added as a function info. - /// - /// FunctionInfo data can come from many sources: debug info, symbol tables, - /// exception information, and more. Symbol tables should be added after - /// debug info and can use this function to see if a symbol's start address - /// has already been added to the GsymReader. Calling this before adding - /// a function info from a source other than debug info avoids clients adding - /// many redundant FunctionInfo objects from many sources only for them to be - /// removed during the finalize() call. - bool hasFunctionInfoForAddress(uint64_t Addr) const; - - /// Set valid .text address ranges that all functions must be contained in. - void SetValidTextRanges(AddressRanges &TextRanges) { - ValidTextRanges = TextRanges; - } - - /// Get the valid text ranges. - const Optional<AddressRanges> GetValidTextRanges() const { - return ValidTextRanges; - } - - /// Check if an address is a valid code address. - /// - /// Any functions whose addresses do not exist within these function bounds - /// will not be converted into the final GSYM. This allows the object file - /// to figure out the valid file address ranges of all the code sections - /// and ensure we don't add invalid functions to the final output. Many - /// linkers have issues when dead stripping functions from DWARF debug info - /// where they set the DW_AT_low_pc to zero, but newer DWARF has the - /// DW_AT_high_pc as an offset from the DW_AT_low_pc and these size - /// attributes have no relocations that can be applied. This results in DWARF - /// where many functions have an DW_AT_low_pc of zero and a valid offset size - /// for DW_AT_high_pc. If we extract all valid ranges from an object file - /// that are marked with executable permissions, we can properly ensure that - /// these functions are removed. - /// - /// \param Addr An address to check. - /// - /// \returns True if the address is in the valid text ranges or if no valid - /// text ranges have been set, false otherwise. - bool IsValidTextAddress(uint64_t Addr) const; - - /// Set the base address to use for the GSYM file. - /// - /// Setting the base address to use for the GSYM file. Object files typically - /// get loaded from a base address when the OS loads them into memory. Using - /// GSYM files for symbolication becomes easier if the base address in the - /// GSYM header is the same address as it allows addresses to be easily slid - /// and allows symbolication without needing to find the original base - /// address in the original object file. - /// - /// \param Addr The address to use as the base address of the GSYM file - /// when it is saved to disk. - void setBaseAddress(uint64_t Addr) { - BaseAddress = Addr; - } -}; - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GsymCreator.h --------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H +#define LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H + +#include <functional> +#include <memory> +#include <mutex> +#include <string> +#include <thread> + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/DebugInfo/GSYM/FileEntry.h" +#include "llvm/DebugInfo/GSYM/FunctionInfo.h" +#include "llvm/DebugInfo/GSYM/Range.h" +#include "llvm/MC/StringTableBuilder.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/Path.h" + +namespace llvm { + +namespace gsym { +class FileWriter; + +/// GsymCreator is used to emit GSYM data to a stand alone file or section +/// within a file. +/// +/// The GsymCreator is designed to be used in 3 stages: +/// - Create FunctionInfo objects and add them +/// - Finalize the GsymCreator object +/// - Save to file or section +/// +/// The first stage involves creating FunctionInfo objects from another source +/// of information like compiler debug info metadata, DWARF or Breakpad files. +/// Any strings in the FunctionInfo or contained information, like InlineInfo +/// or LineTable objects, should get the string table offsets by calling +/// GsymCreator::insertString(...). Any file indexes that are needed should be +/// obtained by calling GsymCreator::insertFile(...). All of the function calls +/// in GsymCreator are thread safe. This allows multiple threads to create and +/// add FunctionInfo objects while parsing debug information. +/// +/// Once all of the FunctionInfo objects have been added, the +/// GsymCreator::finalize(...) must be called prior to saving. This function +/// will sort the FunctionInfo objects, finalize the string table, and do any +/// other passes on the information needed to prepare the information to be +/// saved. +/// +/// Once the object has been finalized, it can be saved to a file or section. +/// +/// ENCODING +/// +/// GSYM files are designed to be memory mapped into a process as shared, read +/// only data, and used as is. +/// +/// The GSYM file format when in a stand alone file consists of: +/// - Header +/// - Address Table +/// - Function Info Offsets +/// - File Table +/// - String Table +/// - Function Info Data +/// +/// HEADER +/// +/// The header is fully described in "llvm/DebugInfo/GSYM/Header.h". +/// +/// ADDRESS TABLE +/// +/// The address table immediately follows the header in the file and consists +/// of Header.NumAddresses address offsets. These offsets are sorted and can be +/// binary searched for efficient lookups. Addresses in the address table are +/// stored as offsets from a 64 bit base address found in Header.BaseAddress. +/// This allows the address table to contain 8, 16, or 32 offsets. This allows +/// the address table to not require full 64 bit addresses for each address. +/// The resulting GSYM size is smaller and causes fewer pages to be touched +/// during address lookups when the address table is smaller. The size of the +/// address offsets in the address table is specified in the header in +/// Header.AddrOffSize. The first offset in the address table is aligned to +/// Header.AddrOffSize alignment to ensure efficient access when loaded into +/// memory. +/// +/// FUNCTION INFO OFFSETS TABLE +/// +/// The function info offsets table immediately follows the address table and +/// consists of Header.NumAddresses 32 bit file offsets: one for each address +/// in the address table. This data is aligned to a 4 byte boundary. The +/// offsets in this table are the relative offsets from the start offset of the +/// GSYM header and point to the function info data for each address in the +/// address table. Keeping this data separate from the address table helps to +/// reduce the number of pages that are touched when address lookups occur on a +/// GSYM file. +/// +/// FILE TABLE +/// +/// The file table immediately follows the function info offsets table. The +/// encoding of the FileTable is: +/// +/// struct FileTable { +/// uint32_t Count; +/// FileEntry Files[]; +/// }; +/// +/// The file table starts with a 32 bit count of the number of files that are +/// used in all of the function info, followed by that number of FileEntry +/// structures. The file table is aligned to a 4 byte boundary, Each file in +/// the file table is represented with a FileEntry structure. +/// See "llvm/DebugInfo/GSYM/FileEntry.h" for details. +/// +/// STRING TABLE +/// +/// The string table follows the file table in stand alone GSYM files and +/// contains all strings for everything contained in the GSYM file. Any string +/// data should be added to the string table and any references to strings +/// inside GSYM information must be stored as 32 bit string table offsets into +/// this string table. The string table always starts with an empty string at +/// offset zero and is followed by any strings needed by the GSYM information. +/// The start of the string table is not aligned to any boundary. +/// +/// FUNCTION INFO DATA +/// +/// The function info data is the payload that contains information about the +/// address that is being looked up. It contains all of the encoded +/// FunctionInfo objects. Each encoded FunctionInfo's data is pointed to by an +/// entry in the Function Info Offsets Table. For details on the exact encoding +/// of FunctionInfo objects, see "llvm/DebugInfo/GSYM/FunctionInfo.h". +class GsymCreator { + // Private member variables require Mutex protections + mutable std::recursive_mutex Mutex; + std::vector<FunctionInfo> Funcs; + StringTableBuilder StrTab; + StringSet<> StringStorage; + DenseMap<llvm::gsym::FileEntry, uint32_t> FileEntryToIndex; + std::vector<llvm::gsym::FileEntry> Files; + std::vector<uint8_t> UUID; + Optional<AddressRanges> ValidTextRanges; + AddressRanges Ranges; + llvm::Optional<uint64_t> BaseAddress; + bool Finalized = false; + +public: + + GsymCreator(); + + /// Save a GSYM file to a stand alone file. + /// + /// \param Path The file path to save the GSYM file to. + /// \param ByteOrder The endianness to use when saving the file. + /// \returns An error object that indicates success or failure of the save. + llvm::Error save(StringRef Path, llvm::support::endianness ByteOrder) const; + + /// Encode a GSYM into the file writer stream at the current position. + /// + /// \param O The stream to save the binary data to + /// \returns An error object that indicates success or failure of the save. + llvm::Error encode(FileWriter &O) const; + + /// Insert a string into the GSYM string table. + /// + /// All strings used by GSYM files must be uniqued by adding them to this + /// string pool and using the returned offset for any string values. + /// + /// \param S The string to insert into the string table. + /// \param Copy If true, then make a backing copy of the string. If false, + /// the string is owned by another object that will stay around + /// long enough for the GsymCreator to save the GSYM file. + /// \returns The unique 32 bit offset into the string table. + uint32_t insertString(StringRef S, bool Copy = true); + + /// Insert a file into this GSYM creator. + /// + /// Inserts a file by adding a FileEntry into the "Files" member variable if + /// the file has not already been added. The file path is split into + /// directory and filename which are both added to the string table. This + /// allows paths to be stored efficiently by reusing the directories that are + /// common between multiple files. + /// + /// \param Path The path to the file to insert. + /// \param Style The path style for the "Path" parameter. + /// \returns The unique file index for the inserted file. + uint32_t insertFile(StringRef Path, + sys::path::Style Style = sys::path::Style::native); + + /// Add a function info to this GSYM creator. + /// + /// All information in the FunctionInfo object must use the + /// GsymCreator::insertString(...) function when creating string table + /// offsets for names and other strings. + /// + /// \param FI The function info object to emplace into our functions list. + void addFunctionInfo(FunctionInfo &&FI); + + /// Finalize the data in the GSYM creator prior to saving the data out. + /// + /// Finalize must be called after all FunctionInfo objects have been added + /// and before GsymCreator::save() is called. + /// + /// \param OS Output stream to report duplicate function infos, overlapping + /// function infos, and function infos that were merged or removed. + /// \returns An error object that indicates success or failure of the + /// finalize. + llvm::Error finalize(llvm::raw_ostream &OS); + + /// Set the UUID value. + /// + /// \param UUIDBytes The new UUID bytes. + void setUUID(llvm::ArrayRef<uint8_t> UUIDBytes) { + UUID.assign(UUIDBytes.begin(), UUIDBytes.end()); + } + + /// Thread safe iteration over all function infos. + /// + /// \param Callback A callback function that will get called with each + /// FunctionInfo. If the callback returns false, stop iterating. + void forEachFunctionInfo( + std::function<bool(FunctionInfo &)> const &Callback); + + /// Thread safe const iteration over all function infos. + /// + /// \param Callback A callback function that will get called with each + /// FunctionInfo. If the callback returns false, stop iterating. + void forEachFunctionInfo( + std::function<bool(const FunctionInfo &)> const &Callback) const; + + /// Get the current number of FunctionInfo objects contained in this + /// object. + size_t getNumFunctionInfos() const; + + /// Check if an address has already been added as a function info. + /// + /// FunctionInfo data can come from many sources: debug info, symbol tables, + /// exception information, and more. Symbol tables should be added after + /// debug info and can use this function to see if a symbol's start address + /// has already been added to the GsymReader. Calling this before adding + /// a function info from a source other than debug info avoids clients adding + /// many redundant FunctionInfo objects from many sources only for them to be + /// removed during the finalize() call. + bool hasFunctionInfoForAddress(uint64_t Addr) const; + + /// Set valid .text address ranges that all functions must be contained in. + void SetValidTextRanges(AddressRanges &TextRanges) { + ValidTextRanges = TextRanges; + } + + /// Get the valid text ranges. + const Optional<AddressRanges> GetValidTextRanges() const { + return ValidTextRanges; + } + + /// Check if an address is a valid code address. + /// + /// Any functions whose addresses do not exist within these function bounds + /// will not be converted into the final GSYM. This allows the object file + /// to figure out the valid file address ranges of all the code sections + /// and ensure we don't add invalid functions to the final output. Many + /// linkers have issues when dead stripping functions from DWARF debug info + /// where they set the DW_AT_low_pc to zero, but newer DWARF has the + /// DW_AT_high_pc as an offset from the DW_AT_low_pc and these size + /// attributes have no relocations that can be applied. This results in DWARF + /// where many functions have an DW_AT_low_pc of zero and a valid offset size + /// for DW_AT_high_pc. If we extract all valid ranges from an object file + /// that are marked with executable permissions, we can properly ensure that + /// these functions are removed. + /// + /// \param Addr An address to check. + /// + /// \returns True if the address is in the valid text ranges or if no valid + /// text ranges have been set, false otherwise. + bool IsValidTextAddress(uint64_t Addr) const; + + /// Set the base address to use for the GSYM file. + /// + /// Setting the base address to use for the GSYM file. Object files typically + /// get loaded from a base address when the OS loads them into memory. Using + /// GSYM files for symbolication becomes easier if the base address in the + /// GSYM header is the same address as it allows addresses to be easily slid + /// and allows symbolication without needing to find the original base + /// address in the original object file. + /// + /// \param Addr The address to use as the base address of the GSYM file + /// when it is saved to disk. + void setBaseAddress(uint64_t Addr) { + BaseAddress = Addr; + } +}; + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_GSYMCREATOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymReader.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymReader.h index 4ff742915f..20ddad04f0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymReader.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/GsymReader.h @@ -1,324 +1,324 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GsymReader.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H -#define LLVM_DEBUGINFO_GSYM_GSYMREADER_H - - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/GSYM/FileEntry.h" -#include "llvm/DebugInfo/GSYM/FunctionInfo.h" -#include "llvm/DebugInfo/GSYM/Header.h" -#include "llvm/DebugInfo/GSYM/LineEntry.h" -#include "llvm/DebugInfo/GSYM/StringTable.h" -#include "llvm/Support/DataExtractor.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/ErrorOr.h" - -#include <inttypes.h> -#include <memory> -#include <stdint.h> -#include <string> -#include <vector> - -namespace llvm { -class MemoryBuffer; -class raw_ostream; - -namespace gsym { - -/// GsymReader is used to read GSYM data from a file or buffer. -/// -/// This class is optimized for very quick lookups when the endianness matches -/// the host system. The Header, address table, address info offsets, and file -/// table is designed to be mmap'ed as read only into memory and used without -/// any parsing needed. If the endianness doesn't match, we swap these objects -/// and tables into GsymReader::SwappedData and then point our header and -/// ArrayRefs to this swapped internal data. -/// -/// GsymReader objects must use one of the static functions to create an -/// instance: GsymReader::openFile(...) and GsymReader::copyBuffer(...). - -class GsymReader { - GsymReader(std::unique_ptr<MemoryBuffer> Buffer); - llvm::Error parse(); - - std::unique_ptr<MemoryBuffer> MemBuffer; - StringRef GsymBytes; - llvm::support::endianness Endian; - const Header *Hdr = nullptr; - ArrayRef<uint8_t> AddrOffsets; - ArrayRef<uint32_t> AddrInfoOffsets; - ArrayRef<FileEntry> Files; - StringTable StrTab; - /// When the GSYM file's endianness doesn't match the host system then - /// we must decode all data structures that need to be swapped into - /// local storage and set point the ArrayRef objects above to these swapped - /// copies. - struct SwappedData { - Header Hdr; - std::vector<uint8_t> AddrOffsets; - std::vector<uint32_t> AddrInfoOffsets; - std::vector<FileEntry> Files; - }; - std::unique_ptr<SwappedData> Swap; - -public: - GsymReader(GsymReader &&RHS); - ~GsymReader(); - - /// Construct a GsymReader from a file on disk. - /// - /// \param Path The file path the GSYM file to read. - /// \returns An expected GsymReader that contains the object or an error - /// object that indicates reason for failing to read the GSYM. - static llvm::Expected<GsymReader> openFile(StringRef Path); - - /// Construct a GsymReader from a buffer. - /// - /// \param Bytes A set of bytes that will be copied and owned by the - /// returned object on success. - /// \returns An expected GsymReader that contains the object or an error - /// object that indicates reason for failing to read the GSYM. - static llvm::Expected<GsymReader> copyBuffer(StringRef Bytes); - - /// Access the GSYM header. - /// \returns A native endian version of the GSYM header. - const Header &getHeader() const; - - /// Get the full function info for an address. - /// - /// This should be called when a client will store a copy of the complete - /// FunctionInfo for a given address. For one off lookups, use the lookup() - /// function below. - /// - /// Symbolication server processes might want to parse the entire function - /// info for a given address and cache it if the process stays around to - /// service many symbolication addresses, like for parsing profiling - /// information. - /// - /// \param Addr A virtual address from the orignal object file to lookup. - /// - /// \returns An expected FunctionInfo that contains the function info object - /// or an error object that indicates reason for failing to lookup the - /// address. - llvm::Expected<FunctionInfo> getFunctionInfo(uint64_t Addr) const; - - /// Lookup an address in the a GSYM. - /// - /// Lookup just the information needed for a specific address \a Addr. This - /// function is faster that calling getFunctionInfo() as it will only return - /// information that pertains to \a Addr and allows the parsing to skip any - /// extra information encoded for other addresses. For example the line table - /// parsing can stop when a matching LineEntry has been fouhnd, and the - /// InlineInfo can stop parsing early once a match has been found and also - /// skip information that doesn't match. This avoids memory allocations and - /// is much faster for lookups. - /// - /// \param Addr A virtual address from the orignal object file to lookup. - /// \returns An expected LookupResult that contains only the information - /// needed for the current address, or an error object that indicates reason - /// for failing to lookup the address. - llvm::Expected<LookupResult> lookup(uint64_t Addr) const; - - /// Get a string from the string table. - /// - /// \param Offset The string table offset for the string to retrieve. - /// \returns The string from the strin table. - StringRef getString(uint32_t Offset) const { return StrTab[Offset]; } - - /// Get the a file entry for the suppplied file index. - /// - /// Used to convert any file indexes in the FunctionInfo data back into - /// files. This function can be used for iteration, but is more commonly used - /// for random access when doing lookups. - /// - /// \param Index An index into the file table. - /// \returns An optional FileInfo that will be valid if the file index is - /// valid, or llvm::None if the file index is out of bounds, - Optional<FileEntry> getFile(uint32_t Index) const { - if (Index < Files.size()) - return Files[Index]; - return llvm::None; - } - - /// Dump the entire Gsym data contained in this object. - /// - /// \param OS The output stream to dump to. - void dump(raw_ostream &OS); - - /// Dump a FunctionInfo object. - /// - /// This function will convert any string table indexes and file indexes - /// into human readable format. - /// - /// \param OS The output stream to dump to. - /// - /// \param FI The object to dump. - void dump(raw_ostream &OS, const FunctionInfo &FI); - - /// Dump a LineTable object. - /// - /// This function will convert any string table indexes and file indexes - /// into human readable format. - /// - /// - /// \param OS The output stream to dump to. - /// - /// \param LT The object to dump. - void dump(raw_ostream &OS, const LineTable <); - - /// Dump a InlineInfo object. - /// - /// This function will convert any string table indexes and file indexes - /// into human readable format. - /// - /// \param OS The output stream to dump to. - /// - /// \param II The object to dump. - /// - /// \param Indent The indentation as number of spaces. Used for recurive - /// dumping. - void dump(raw_ostream &OS, const InlineInfo &II, uint32_t Indent = 0); - - /// Dump a FileEntry object. - /// - /// This function will convert any string table indexes into human readable - /// format. - /// - /// \param OS The output stream to dump to. - /// - /// \param FE The object to dump. - void dump(raw_ostream &OS, Optional<FileEntry> FE); - - /// Get the number of addresses in this Gsym file. - uint32_t getNumAddresses() const { - return Hdr->NumAddresses; - } - - /// Gets an address from the address table. - /// - /// Addresses are stored as offsets frrom the gsym::Header::BaseAddress. - /// - /// \param Index A index into the address table. - /// \returns A resolved virtual address for adddress in the address table - /// or llvm::None if Index is out of bounds. - Optional<uint64_t> getAddress(size_t Index) const; - -protected: - - /// Get an appropriate address info offsets array. - /// - /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8 - /// byte offsets from the The gsym::Header::BaseAddress. The table is stored - /// internally as a array of bytes that are in the correct endianness. When - /// we access this table we must get an array that matches those sizes. This - /// templatized helper function is used when accessing address offsets in the - /// AddrOffsets member variable. - /// - /// \returns An ArrayRef of an appropriate address offset size. - template <class T> ArrayRef<T> - getAddrOffsets() const { - return ArrayRef<T>(reinterpret_cast<const T *>(AddrOffsets.data()), - AddrOffsets.size()/sizeof(T)); - } - - /// Get an appropriate address from the address table. - /// - /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8 - /// byte address offsets from the The gsym::Header::BaseAddress. The table is - /// stored internally as a array of bytes that are in the correct endianness. - /// In order to extract an address from the address table we must access the - /// address offset using the correct size and then add it to the BaseAddress - /// in the header. - /// - /// \param Index An index into the AddrOffsets array. - /// \returns An virtual address that matches the original object file for the - /// address as the specified index, or llvm::None if Index is out of bounds. - template <class T> Optional<uint64_t> - addressForIndex(size_t Index) const { - ArrayRef<T> AIO = getAddrOffsets<T>(); - if (Index < AIO.size()) - return AIO[Index] + Hdr->BaseAddress; - return llvm::None; - } - /// Lookup an address offset in the AddrOffsets table. - /// - /// Given an address offset, look it up using a binary search of the - /// AddrOffsets table. - /// - /// \param AddrOffset An address offset, that has already been computed by - /// subtracting the gsym::Header::BaseAddress. - /// \returns The matching address offset index. This index will be used to - /// extract the FunctionInfo data's offset from the AddrInfoOffsets array. - template <class T> - llvm::Optional<uint64_t> getAddressOffsetIndex(const uint64_t AddrOffset) const { - ArrayRef<T> AIO = getAddrOffsets<T>(); - const auto Begin = AIO.begin(); - const auto End = AIO.end(); - auto Iter = std::lower_bound(Begin, End, AddrOffset); - // Watch for addresses that fall between the gsym::Header::BaseAddress and - // the first address offset. - if (Iter == Begin && AddrOffset < *Begin) - return llvm::None; - if (Iter == End || AddrOffset < *Iter) - --Iter; - return std::distance(Begin, Iter); - } - - /// Create a GSYM from a memory buffer. - /// - /// Called by both openFile() and copyBuffer(), this function does all of the - /// work of parsing the GSYM file and returning an error. - /// - /// \param MemBuffer A memory buffer that will transfer ownership into the - /// GsymReader. - /// \returns An expected GsymReader that contains the object or an error - /// object that indicates reason for failing to read the GSYM. - static llvm::Expected<llvm::gsym::GsymReader> - create(std::unique_ptr<MemoryBuffer> &MemBuffer); - - - /// Given an address, find the address index. - /// - /// Binary search the address table and find the matching address index. - /// - /// \param Addr A virtual address that matches the original object file - /// to lookup. - /// \returns An index into the address table. This index can be used to - /// extract the FunctionInfo data's offset from the AddrInfoOffsets array. - /// Returns an error if the address isn't in the GSYM with details of why. - Expected<uint64_t> getAddressIndex(const uint64_t Addr) const; - - /// Given an address index, get the offset for the FunctionInfo. - /// - /// Looking up an address is done by finding the corresponding address - /// index for the address. This index is then used to get the offset of the - /// FunctionInfo data that we will decode using this function. - /// - /// \param Index An index into the address table. - /// \returns An optional GSYM data offset for the offset of the FunctionInfo - /// that needs to be decoded. - Optional<uint64_t> getAddressInfoOffset(size_t Index) const; -}; - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GsymReader.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H +#define LLVM_DEBUGINFO_GSYM_GSYMREADER_H + + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/DebugInfo/GSYM/FileEntry.h" +#include "llvm/DebugInfo/GSYM/FunctionInfo.h" +#include "llvm/DebugInfo/GSYM/Header.h" +#include "llvm/DebugInfo/GSYM/LineEntry.h" +#include "llvm/DebugInfo/GSYM/StringTable.h" +#include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorOr.h" + +#include <inttypes.h> +#include <memory> +#include <stdint.h> +#include <string> +#include <vector> + +namespace llvm { +class MemoryBuffer; +class raw_ostream; + +namespace gsym { + +/// GsymReader is used to read GSYM data from a file or buffer. +/// +/// This class is optimized for very quick lookups when the endianness matches +/// the host system. The Header, address table, address info offsets, and file +/// table is designed to be mmap'ed as read only into memory and used without +/// any parsing needed. If the endianness doesn't match, we swap these objects +/// and tables into GsymReader::SwappedData and then point our header and +/// ArrayRefs to this swapped internal data. +/// +/// GsymReader objects must use one of the static functions to create an +/// instance: GsymReader::openFile(...) and GsymReader::copyBuffer(...). + +class GsymReader { + GsymReader(std::unique_ptr<MemoryBuffer> Buffer); + llvm::Error parse(); + + std::unique_ptr<MemoryBuffer> MemBuffer; + StringRef GsymBytes; + llvm::support::endianness Endian; + const Header *Hdr = nullptr; + ArrayRef<uint8_t> AddrOffsets; + ArrayRef<uint32_t> AddrInfoOffsets; + ArrayRef<FileEntry> Files; + StringTable StrTab; + /// When the GSYM file's endianness doesn't match the host system then + /// we must decode all data structures that need to be swapped into + /// local storage and set point the ArrayRef objects above to these swapped + /// copies. + struct SwappedData { + Header Hdr; + std::vector<uint8_t> AddrOffsets; + std::vector<uint32_t> AddrInfoOffsets; + std::vector<FileEntry> Files; + }; + std::unique_ptr<SwappedData> Swap; + +public: + GsymReader(GsymReader &&RHS); + ~GsymReader(); + + /// Construct a GsymReader from a file on disk. + /// + /// \param Path The file path the GSYM file to read. + /// \returns An expected GsymReader that contains the object or an error + /// object that indicates reason for failing to read the GSYM. + static llvm::Expected<GsymReader> openFile(StringRef Path); + + /// Construct a GsymReader from a buffer. + /// + /// \param Bytes A set of bytes that will be copied and owned by the + /// returned object on success. + /// \returns An expected GsymReader that contains the object or an error + /// object that indicates reason for failing to read the GSYM. + static llvm::Expected<GsymReader> copyBuffer(StringRef Bytes); + + /// Access the GSYM header. + /// \returns A native endian version of the GSYM header. + const Header &getHeader() const; + + /// Get the full function info for an address. + /// + /// This should be called when a client will store a copy of the complete + /// FunctionInfo for a given address. For one off lookups, use the lookup() + /// function below. + /// + /// Symbolication server processes might want to parse the entire function + /// info for a given address and cache it if the process stays around to + /// service many symbolication addresses, like for parsing profiling + /// information. + /// + /// \param Addr A virtual address from the orignal object file to lookup. + /// + /// \returns An expected FunctionInfo that contains the function info object + /// or an error object that indicates reason for failing to lookup the + /// address. + llvm::Expected<FunctionInfo> getFunctionInfo(uint64_t Addr) const; + + /// Lookup an address in the a GSYM. + /// + /// Lookup just the information needed for a specific address \a Addr. This + /// function is faster that calling getFunctionInfo() as it will only return + /// information that pertains to \a Addr and allows the parsing to skip any + /// extra information encoded for other addresses. For example the line table + /// parsing can stop when a matching LineEntry has been fouhnd, and the + /// InlineInfo can stop parsing early once a match has been found and also + /// skip information that doesn't match. This avoids memory allocations and + /// is much faster for lookups. + /// + /// \param Addr A virtual address from the orignal object file to lookup. + /// \returns An expected LookupResult that contains only the information + /// needed for the current address, or an error object that indicates reason + /// for failing to lookup the address. + llvm::Expected<LookupResult> lookup(uint64_t Addr) const; + + /// Get a string from the string table. + /// + /// \param Offset The string table offset for the string to retrieve. + /// \returns The string from the strin table. + StringRef getString(uint32_t Offset) const { return StrTab[Offset]; } + + /// Get the a file entry for the suppplied file index. + /// + /// Used to convert any file indexes in the FunctionInfo data back into + /// files. This function can be used for iteration, but is more commonly used + /// for random access when doing lookups. + /// + /// \param Index An index into the file table. + /// \returns An optional FileInfo that will be valid if the file index is + /// valid, or llvm::None if the file index is out of bounds, + Optional<FileEntry> getFile(uint32_t Index) const { + if (Index < Files.size()) + return Files[Index]; + return llvm::None; + } + + /// Dump the entire Gsym data contained in this object. + /// + /// \param OS The output stream to dump to. + void dump(raw_ostream &OS); + + /// Dump a FunctionInfo object. + /// + /// This function will convert any string table indexes and file indexes + /// into human readable format. + /// + /// \param OS The output stream to dump to. + /// + /// \param FI The object to dump. + void dump(raw_ostream &OS, const FunctionInfo &FI); + + /// Dump a LineTable object. + /// + /// This function will convert any string table indexes and file indexes + /// into human readable format. + /// + /// + /// \param OS The output stream to dump to. + /// + /// \param LT The object to dump. + void dump(raw_ostream &OS, const LineTable <); + + /// Dump a InlineInfo object. + /// + /// This function will convert any string table indexes and file indexes + /// into human readable format. + /// + /// \param OS The output stream to dump to. + /// + /// \param II The object to dump. + /// + /// \param Indent The indentation as number of spaces. Used for recurive + /// dumping. + void dump(raw_ostream &OS, const InlineInfo &II, uint32_t Indent = 0); + + /// Dump a FileEntry object. + /// + /// This function will convert any string table indexes into human readable + /// format. + /// + /// \param OS The output stream to dump to. + /// + /// \param FE The object to dump. + void dump(raw_ostream &OS, Optional<FileEntry> FE); + + /// Get the number of addresses in this Gsym file. + uint32_t getNumAddresses() const { + return Hdr->NumAddresses; + } + + /// Gets an address from the address table. + /// + /// Addresses are stored as offsets frrom the gsym::Header::BaseAddress. + /// + /// \param Index A index into the address table. + /// \returns A resolved virtual address for adddress in the address table + /// or llvm::None if Index is out of bounds. + Optional<uint64_t> getAddress(size_t Index) const; + +protected: + + /// Get an appropriate address info offsets array. + /// + /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8 + /// byte offsets from the The gsym::Header::BaseAddress. The table is stored + /// internally as a array of bytes that are in the correct endianness. When + /// we access this table we must get an array that matches those sizes. This + /// templatized helper function is used when accessing address offsets in the + /// AddrOffsets member variable. + /// + /// \returns An ArrayRef of an appropriate address offset size. + template <class T> ArrayRef<T> + getAddrOffsets() const { + return ArrayRef<T>(reinterpret_cast<const T *>(AddrOffsets.data()), + AddrOffsets.size()/sizeof(T)); + } + + /// Get an appropriate address from the address table. + /// + /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8 + /// byte address offsets from the The gsym::Header::BaseAddress. The table is + /// stored internally as a array of bytes that are in the correct endianness. + /// In order to extract an address from the address table we must access the + /// address offset using the correct size and then add it to the BaseAddress + /// in the header. + /// + /// \param Index An index into the AddrOffsets array. + /// \returns An virtual address that matches the original object file for the + /// address as the specified index, or llvm::None if Index is out of bounds. + template <class T> Optional<uint64_t> + addressForIndex(size_t Index) const { + ArrayRef<T> AIO = getAddrOffsets<T>(); + if (Index < AIO.size()) + return AIO[Index] + Hdr->BaseAddress; + return llvm::None; + } + /// Lookup an address offset in the AddrOffsets table. + /// + /// Given an address offset, look it up using a binary search of the + /// AddrOffsets table. + /// + /// \param AddrOffset An address offset, that has already been computed by + /// subtracting the gsym::Header::BaseAddress. + /// \returns The matching address offset index. This index will be used to + /// extract the FunctionInfo data's offset from the AddrInfoOffsets array. + template <class T> + llvm::Optional<uint64_t> getAddressOffsetIndex(const uint64_t AddrOffset) const { + ArrayRef<T> AIO = getAddrOffsets<T>(); + const auto Begin = AIO.begin(); + const auto End = AIO.end(); + auto Iter = std::lower_bound(Begin, End, AddrOffset); + // Watch for addresses that fall between the gsym::Header::BaseAddress and + // the first address offset. + if (Iter == Begin && AddrOffset < *Begin) + return llvm::None; + if (Iter == End || AddrOffset < *Iter) + --Iter; + return std::distance(Begin, Iter); + } + + /// Create a GSYM from a memory buffer. + /// + /// Called by both openFile() and copyBuffer(), this function does all of the + /// work of parsing the GSYM file and returning an error. + /// + /// \param MemBuffer A memory buffer that will transfer ownership into the + /// GsymReader. + /// \returns An expected GsymReader that contains the object or an error + /// object that indicates reason for failing to read the GSYM. + static llvm::Expected<llvm::gsym::GsymReader> + create(std::unique_ptr<MemoryBuffer> &MemBuffer); + + + /// Given an address, find the address index. + /// + /// Binary search the address table and find the matching address index. + /// + /// \param Addr A virtual address that matches the original object file + /// to lookup. + /// \returns An index into the address table. This index can be used to + /// extract the FunctionInfo data's offset from the AddrInfoOffsets array. + /// Returns an error if the address isn't in the GSYM with details of why. + Expected<uint64_t> getAddressIndex(const uint64_t Addr) const; + + /// Given an address index, get the offset for the FunctionInfo. + /// + /// Looking up an address is done by finding the corresponding address + /// index for the address. This index is then used to get the offset of the + /// FunctionInfo data that we will decode using this function. + /// + /// \param Index An index into the address table. + /// \returns An optional GSYM data offset for the offset of the FunctionInfo + /// that needs to be decoded. + Optional<uint64_t> getAddressInfoOffset(size_t Index) const; +}; + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Header.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Header.h index 10ad757f37..bea16e9f03 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Header.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Header.h @@ -1,140 +1,140 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Header.h -------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_HEADER_H -#define LLVM_DEBUGINFO_GSYM_HEADER_H - -#include "llvm/Support/Error.h" - -#include <cstddef> -#include <cstdint> - -namespace llvm { -class raw_ostream; -class DataExtractor; - -namespace gsym { -class FileWriter; - -constexpr uint32_t GSYM_MAGIC = 0x4753594d; // 'GSYM' -constexpr uint32_t GSYM_CIGAM = 0x4d595347; // 'MYSG' -constexpr uint32_t GSYM_VERSION = 1; -constexpr size_t GSYM_MAX_UUID_SIZE = 20; - -/// The GSYM header. -/// -/// The GSYM header is found at the start of a stand alone GSYM file, or as -/// the first bytes in a section when GSYM is contained in a section of an -/// executable file (ELF, mach-o, COFF). -/// -/// The structure is encoded exactly as it appears in the structure definition -/// with no gaps between members. Alignment should not change from system to -/// system as the members were laid out so that they shouldn't align -/// differently on different architectures. -/// -/// When endianness of the system loading a GSYM file matches, the file can -/// be mmap'ed in and a pointer to the header can be cast to the first bytes -/// of the file (stand alone GSYM file) or section data (GSYM in a section). -/// When endianness is swapped, the Header::decode() function should be used to -/// decode the header. -struct Header { - /// The magic bytes should be set to GSYM_MAGIC. This helps detect if a file - /// is a GSYM file by scanning the first 4 bytes of a file or section. - /// This value might appear byte swapped - uint32_t Magic; - /// The version can number determines how the header is decoded and how each - /// InfoType in FunctionInfo is encoded/decoded. As version numbers increase, - /// "Magic" and "Version" members should always appear at offset zero and 4 - /// respectively to ensure clients figure out if they can parse the format. - uint16_t Version; - /// The size in bytes of each address offset in the address offsets table. - uint8_t AddrOffSize; - /// The size in bytes of the UUID encoded in the "UUID" member. - uint8_t UUIDSize; - /// The 64 bit base address that all address offsets in the address offsets - /// table are relative to. Storing a full 64 bit address allows our address - /// offsets table to be smaller on disk. - uint64_t BaseAddress; - /// The number of addresses stored in the address offsets table. - uint32_t NumAddresses; - /// The file relative offset of the start of the string table for strings - /// contained in the GSYM file. If the GSYM in contained in a stand alone - /// file this will be the file offset of the start of the string table. If - /// the GSYM is contained in a section within an executable file, this can - /// be the offset of the first string used in the GSYM file and can possibly - /// span one or more executable string tables. This allows the strings to - /// share string tables in an ELF or mach-o file. - uint32_t StrtabOffset; - /// The size in bytes of the string table. For a stand alone GSYM file, this - /// will be the exact size in bytes of the string table. When the GSYM data - /// is in a section within an executable file, this size can span one or more - /// sections that contains strings. This allows any strings that are already - /// stored in the executable file to be re-used, and any extra strings could - /// be added to another string table and the string table offset and size - /// can be set to span all needed string tables. - uint32_t StrtabSize; - /// The UUID of the original executable file. This is stored to allow - /// matching a GSYM file to an executable file when symbolication is - /// required. Only the first "UUIDSize" bytes of the UUID are valid. Any - /// bytes in the UUID value that appear after the first UUIDSize bytes should - /// be set to zero. - uint8_t UUID[GSYM_MAX_UUID_SIZE]; - - /// Check if a header is valid and return an error if anything is wrong. - /// - /// This function can be used prior to encoding a header to ensure it is - /// valid, or after decoding a header to ensure it is valid and supported. - /// - /// Check a correctly byte swapped header for errors: - /// - check magic value - /// - check that version number is supported - /// - check that the address offset size is supported - /// - check that the UUID size is valid - /// - /// \returns An error if anything is wrong in the header, or Error::success() - /// if there are no errors. - llvm::Error checkForError() const; - - /// Decode an object from a binary data stream. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \returns A Header or an error describing the issue that was - /// encountered during decoding. - static llvm::Expected<Header> decode(DataExtractor &Data); - - /// Encode this object into FileWriter stream. - /// - /// \param O The binary stream to write the data to at the current file - /// position. - /// - /// \returns An error object that indicates success or failure of the - /// encoding process. - llvm::Error encode(FileWriter &O) const; -}; - -bool operator==(const Header &LHS, const Header &RHS); -raw_ostream &operator<<(raw_ostream &OS, const llvm::gsym::Header &H); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_HEADER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Header.h -------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_HEADER_H +#define LLVM_DEBUGINFO_GSYM_HEADER_H + +#include "llvm/Support/Error.h" + +#include <cstddef> +#include <cstdint> + +namespace llvm { +class raw_ostream; +class DataExtractor; + +namespace gsym { +class FileWriter; + +constexpr uint32_t GSYM_MAGIC = 0x4753594d; // 'GSYM' +constexpr uint32_t GSYM_CIGAM = 0x4d595347; // 'MYSG' +constexpr uint32_t GSYM_VERSION = 1; +constexpr size_t GSYM_MAX_UUID_SIZE = 20; + +/// The GSYM header. +/// +/// The GSYM header is found at the start of a stand alone GSYM file, or as +/// the first bytes in a section when GSYM is contained in a section of an +/// executable file (ELF, mach-o, COFF). +/// +/// The structure is encoded exactly as it appears in the structure definition +/// with no gaps between members. Alignment should not change from system to +/// system as the members were laid out so that they shouldn't align +/// differently on different architectures. +/// +/// When endianness of the system loading a GSYM file matches, the file can +/// be mmap'ed in and a pointer to the header can be cast to the first bytes +/// of the file (stand alone GSYM file) or section data (GSYM in a section). +/// When endianness is swapped, the Header::decode() function should be used to +/// decode the header. +struct Header { + /// The magic bytes should be set to GSYM_MAGIC. This helps detect if a file + /// is a GSYM file by scanning the first 4 bytes of a file or section. + /// This value might appear byte swapped + uint32_t Magic; + /// The version can number determines how the header is decoded and how each + /// InfoType in FunctionInfo is encoded/decoded. As version numbers increase, + /// "Magic" and "Version" members should always appear at offset zero and 4 + /// respectively to ensure clients figure out if they can parse the format. + uint16_t Version; + /// The size in bytes of each address offset in the address offsets table. + uint8_t AddrOffSize; + /// The size in bytes of the UUID encoded in the "UUID" member. + uint8_t UUIDSize; + /// The 64 bit base address that all address offsets in the address offsets + /// table are relative to. Storing a full 64 bit address allows our address + /// offsets table to be smaller on disk. + uint64_t BaseAddress; + /// The number of addresses stored in the address offsets table. + uint32_t NumAddresses; + /// The file relative offset of the start of the string table for strings + /// contained in the GSYM file. If the GSYM in contained in a stand alone + /// file this will be the file offset of the start of the string table. If + /// the GSYM is contained in a section within an executable file, this can + /// be the offset of the first string used in the GSYM file and can possibly + /// span one or more executable string tables. This allows the strings to + /// share string tables in an ELF or mach-o file. + uint32_t StrtabOffset; + /// The size in bytes of the string table. For a stand alone GSYM file, this + /// will be the exact size in bytes of the string table. When the GSYM data + /// is in a section within an executable file, this size can span one or more + /// sections that contains strings. This allows any strings that are already + /// stored in the executable file to be re-used, and any extra strings could + /// be added to another string table and the string table offset and size + /// can be set to span all needed string tables. + uint32_t StrtabSize; + /// The UUID of the original executable file. This is stored to allow + /// matching a GSYM file to an executable file when symbolication is + /// required. Only the first "UUIDSize" bytes of the UUID are valid. Any + /// bytes in the UUID value that appear after the first UUIDSize bytes should + /// be set to zero. + uint8_t UUID[GSYM_MAX_UUID_SIZE]; + + /// Check if a header is valid and return an error if anything is wrong. + /// + /// This function can be used prior to encoding a header to ensure it is + /// valid, or after decoding a header to ensure it is valid and supported. + /// + /// Check a correctly byte swapped header for errors: + /// - check magic value + /// - check that version number is supported + /// - check that the address offset size is supported + /// - check that the UUID size is valid + /// + /// \returns An error if anything is wrong in the header, or Error::success() + /// if there are no errors. + llvm::Error checkForError() const; + + /// Decode an object from a binary data stream. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \returns A Header or an error describing the issue that was + /// encountered during decoding. + static llvm::Expected<Header> decode(DataExtractor &Data); + + /// Encode this object into FileWriter stream. + /// + /// \param O The binary stream to write the data to at the current file + /// position. + /// + /// \returns An error object that indicates success or failure of the + /// encoding process. + llvm::Error encode(FileWriter &O) const; +}; + +bool operator==(const Header &LHS, const Header &RHS); +raw_ostream &operator<<(raw_ostream &OS, const llvm::gsym::Header &H); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_HEADER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/InlineInfo.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/InlineInfo.h index 941a5b6d45..f5faf4583d 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/InlineInfo.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/InlineInfo.h @@ -1,193 +1,193 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InlineInfo.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H -#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/GSYM/LineEntry.h" -#include "llvm/DebugInfo/GSYM/LookupResult.h" -#include "llvm/DebugInfo/GSYM/Range.h" -#include "llvm/Support/Error.h" -#include <stdint.h> -#include <vector> - - -namespace llvm { -class raw_ostream; - -namespace gsym { - -class GsymReader; -/// Inline information stores the name of the inline function along with -/// an array of address ranges. It also stores the call file and call line -/// that called this inline function. This allows us to unwind inline call -/// stacks back to the inline or concrete function that called this -/// function. Inlined functions contained in this function are stored in the -/// "Children" variable. All address ranges must be sorted and all address -/// ranges of all children must be contained in the ranges of this function. -/// Any clients that encode information will need to ensure the ranges are -/// all contined correctly or lookups could fail. Add ranges in these objects -/// must be contained in the top level FunctionInfo address ranges as well. -/// -/// ENCODING -/// -/// When saved to disk, the inline info encodes all ranges to be relative to -/// a parent address range. This will be the FunctionInfo's start address if -/// the InlineInfo is directly contained in a FunctionInfo, or a the start -/// address of the containing parent InlineInfo's first "Ranges" member. This -/// allows address ranges to be efficiently encoded using ULEB128 encodings as -/// we encode the offset and size of each range instead of full addresses. This -/// also makes any encoded addresses easy to relocate as we just need to -/// relocate the FunctionInfo's start address. -/// -/// - The AddressRanges member "Ranges" is encoded using an appropriate base -/// address as described above. -/// - UINT8 boolean value that specifies if the InlineInfo object has children. -/// - UINT32 string table offset that points to the name of the inline -/// function. -/// - ULEB128 integer that specifies the file of the call site that called -/// this function. -/// - ULEB128 integer that specifies the source line of the call site that -/// called this function. -/// - if this object has children, enocode each child InlineInfo using the -/// the first address range's start address as the base address. -/// -struct InlineInfo { - - uint32_t Name; ///< String table offset in the string table. - uint32_t CallFile; ///< 1 based file index in the file table. - uint32_t CallLine; ///< Source line number. - AddressRanges Ranges; - std::vector<InlineInfo> Children; - InlineInfo() : Name(0), CallFile(0), CallLine(0) {} - void clear() { - Name = 0; - CallFile = 0; - CallLine = 0; - Ranges.clear(); - Children.clear(); - } - bool isValid() const { return !Ranges.empty(); } - - using InlineArray = std::vector<const InlineInfo *>; - - /// Lookup a single address within the inline info data. - /// - /// Clients have the option to decode an entire InlineInfo object (using - /// InlineInfo::decode() ) or just find the matching inline info using this - /// function. The benefit of using this function is that only the information - /// needed for the lookup will be extracted, other info can be skipped and - /// parsing can stop as soon as the deepest match is found. This allows - /// symbolication tools to be fast and efficient and avoid allocation costs - /// when doing lookups. - /// - /// This function will augment the SourceLocations array \a SrcLocs with any - /// inline information that pertains to \a Addr. If no inline information - /// exists for \a Addr, then \a SrcLocs will be left untouched. If there is - /// inline information for \a Addr, then \a SrcLocs will be modifiied to - /// contain the deepest most inline function's SourceLocation at index zero - /// in the array and proceed up the the concrete function source file and - /// line at the end of the array. - /// - /// \param GR The GSYM reader that contains the string and file table that - /// will be used to fill in the source locations. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the LineTable object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param BaseAddr The base address to use when decoding the line table. - /// This will be the FunctionInfo's start address and will be used to - /// decode the correct addresses for the inline information. - /// - /// \param Addr The address to lookup. - /// - /// \param SrcLocs The inline source locations that matches \a Addr. This - /// array must be initialized with the matching line entry - /// from the line table upon entry. The name of the concrete - /// function must be supplied since it will get pushed to - /// the last SourceLocation entry and the inline information - /// will fill in the source file and line from the inline - /// information. - /// - /// \returns An error if the inline information is corrupt, or - /// Error::success() for all other cases, even when no information - /// is added to \a SrcLocs. - static llvm::Error lookup(const GsymReader &GR, DataExtractor &Data, - uint64_t BaseAddr, uint64_t Addr, - SourceLocations &SrcLocs); - - /// Lookup an address in the InlineInfo object - /// - /// This function is used to symbolicate an inline call stack and can - /// turn one address in the program into one or more inline call stacks - /// and have the stack trace show the original call site from - /// non-inlined code. - /// - /// \param Addr the address to lookup - /// - /// \returns optional vector of InlineInfo objects that describe the - /// inline call stack for a given address, false otherwise. - llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const; - - /// Decode an InlineInfo object from a binary data stream. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the InlineInfo object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param BaseAddr The base address to use when decoding all address ranges. - /// This will be the FunctionInfo's start address if this object is directly - /// contained in a FunctionInfo object, or the start address of the first - /// address range in an InlineInfo object of this object is a child of - /// another InlineInfo object. - /// \returns An InlineInfo or an error describing the issue that was - /// encountered during decoding. - static llvm::Expected<InlineInfo> decode(DataExtractor &Data, - uint64_t BaseAddr); - - /// Encode this InlineInfo object into FileWriter stream. - /// - /// \param O The binary stream to write the data to at the current file - /// position. - /// - /// \param BaseAddr The base address to use when encoding all address ranges. - /// This will be the FunctionInfo's start address if this object is directly - /// contained in a FunctionInfo object, or the start address of the first - /// address range in an InlineInfo object of this object is a child of - /// another InlineInfo object. - /// - /// \returns An error object that indicates success or failure or the - /// encoding process. - llvm::Error encode(FileWriter &O, uint64_t BaseAddr) const; -}; - -inline bool operator==(const InlineInfo &LHS, const InlineInfo &RHS) { - return LHS.Name == RHS.Name && LHS.CallFile == RHS.CallFile && - LHS.CallLine == RHS.CallLine && LHS.Ranges == RHS.Ranges && - LHS.Children == RHS.Children; -} - -raw_ostream &operator<<(raw_ostream &OS, const InlineInfo &FI); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InlineInfo.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H +#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/GSYM/LineEntry.h" +#include "llvm/DebugInfo/GSYM/LookupResult.h" +#include "llvm/DebugInfo/GSYM/Range.h" +#include "llvm/Support/Error.h" +#include <stdint.h> +#include <vector> + + +namespace llvm { +class raw_ostream; + +namespace gsym { + +class GsymReader; +/// Inline information stores the name of the inline function along with +/// an array of address ranges. It also stores the call file and call line +/// that called this inline function. This allows us to unwind inline call +/// stacks back to the inline or concrete function that called this +/// function. Inlined functions contained in this function are stored in the +/// "Children" variable. All address ranges must be sorted and all address +/// ranges of all children must be contained in the ranges of this function. +/// Any clients that encode information will need to ensure the ranges are +/// all contined correctly or lookups could fail. Add ranges in these objects +/// must be contained in the top level FunctionInfo address ranges as well. +/// +/// ENCODING +/// +/// When saved to disk, the inline info encodes all ranges to be relative to +/// a parent address range. This will be the FunctionInfo's start address if +/// the InlineInfo is directly contained in a FunctionInfo, or a the start +/// address of the containing parent InlineInfo's first "Ranges" member. This +/// allows address ranges to be efficiently encoded using ULEB128 encodings as +/// we encode the offset and size of each range instead of full addresses. This +/// also makes any encoded addresses easy to relocate as we just need to +/// relocate the FunctionInfo's start address. +/// +/// - The AddressRanges member "Ranges" is encoded using an appropriate base +/// address as described above. +/// - UINT8 boolean value that specifies if the InlineInfo object has children. +/// - UINT32 string table offset that points to the name of the inline +/// function. +/// - ULEB128 integer that specifies the file of the call site that called +/// this function. +/// - ULEB128 integer that specifies the source line of the call site that +/// called this function. +/// - if this object has children, enocode each child InlineInfo using the +/// the first address range's start address as the base address. +/// +struct InlineInfo { + + uint32_t Name; ///< String table offset in the string table. + uint32_t CallFile; ///< 1 based file index in the file table. + uint32_t CallLine; ///< Source line number. + AddressRanges Ranges; + std::vector<InlineInfo> Children; + InlineInfo() : Name(0), CallFile(0), CallLine(0) {} + void clear() { + Name = 0; + CallFile = 0; + CallLine = 0; + Ranges.clear(); + Children.clear(); + } + bool isValid() const { return !Ranges.empty(); } + + using InlineArray = std::vector<const InlineInfo *>; + + /// Lookup a single address within the inline info data. + /// + /// Clients have the option to decode an entire InlineInfo object (using + /// InlineInfo::decode() ) or just find the matching inline info using this + /// function. The benefit of using this function is that only the information + /// needed for the lookup will be extracted, other info can be skipped and + /// parsing can stop as soon as the deepest match is found. This allows + /// symbolication tools to be fast and efficient and avoid allocation costs + /// when doing lookups. + /// + /// This function will augment the SourceLocations array \a SrcLocs with any + /// inline information that pertains to \a Addr. If no inline information + /// exists for \a Addr, then \a SrcLocs will be left untouched. If there is + /// inline information for \a Addr, then \a SrcLocs will be modifiied to + /// contain the deepest most inline function's SourceLocation at index zero + /// in the array and proceed up the the concrete function source file and + /// line at the end of the array. + /// + /// \param GR The GSYM reader that contains the string and file table that + /// will be used to fill in the source locations. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the LineTable object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param BaseAddr The base address to use when decoding the line table. + /// This will be the FunctionInfo's start address and will be used to + /// decode the correct addresses for the inline information. + /// + /// \param Addr The address to lookup. + /// + /// \param SrcLocs The inline source locations that matches \a Addr. This + /// array must be initialized with the matching line entry + /// from the line table upon entry. The name of the concrete + /// function must be supplied since it will get pushed to + /// the last SourceLocation entry and the inline information + /// will fill in the source file and line from the inline + /// information. + /// + /// \returns An error if the inline information is corrupt, or + /// Error::success() for all other cases, even when no information + /// is added to \a SrcLocs. + static llvm::Error lookup(const GsymReader &GR, DataExtractor &Data, + uint64_t BaseAddr, uint64_t Addr, + SourceLocations &SrcLocs); + + /// Lookup an address in the InlineInfo object + /// + /// This function is used to symbolicate an inline call stack and can + /// turn one address in the program into one or more inline call stacks + /// and have the stack trace show the original call site from + /// non-inlined code. + /// + /// \param Addr the address to lookup + /// + /// \returns optional vector of InlineInfo objects that describe the + /// inline call stack for a given address, false otherwise. + llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const; + + /// Decode an InlineInfo object from a binary data stream. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the InlineInfo object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param BaseAddr The base address to use when decoding all address ranges. + /// This will be the FunctionInfo's start address if this object is directly + /// contained in a FunctionInfo object, or the start address of the first + /// address range in an InlineInfo object of this object is a child of + /// another InlineInfo object. + /// \returns An InlineInfo or an error describing the issue that was + /// encountered during decoding. + static llvm::Expected<InlineInfo> decode(DataExtractor &Data, + uint64_t BaseAddr); + + /// Encode this InlineInfo object into FileWriter stream. + /// + /// \param O The binary stream to write the data to at the current file + /// position. + /// + /// \param BaseAddr The base address to use when encoding all address ranges. + /// This will be the FunctionInfo's start address if this object is directly + /// contained in a FunctionInfo object, or the start address of the first + /// address range in an InlineInfo object of this object is a child of + /// another InlineInfo object. + /// + /// \returns An error object that indicates success or failure or the + /// encoding process. + llvm::Error encode(FileWriter &O, uint64_t BaseAddr) const; +}; + +inline bool operator==(const InlineInfo &LHS, const InlineInfo &RHS) { + return LHS.Name == RHS.Name && LHS.CallFile == RHS.CallFile && + LHS.CallLine == RHS.CallLine && LHS.Ranges == RHS.Ranges && + LHS.Children == RHS.Children; +} + +raw_ostream &operator<<(raw_ostream &OS, const InlineInfo &FI); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineEntry.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineEntry.h index c2d26c02d9..87e9f46b14 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineEntry.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineEntry.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- LineEntry.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H -#define LLVM_DEBUGINFO_GSYM_LINEENTRY_H - -#include "llvm/DebugInfo/GSYM/Range.h" - -namespace llvm { -namespace gsym { - -/// Line entries are used to encode the line tables in FunctionInfo objects. -/// They are stored as a sorted vector of these objects and store the -/// address, file and line of the line table row for a given address. The -/// size of a line table entry is calculated by looking at the next entry -/// in the FunctionInfo's vector of entries. -struct LineEntry { - uint64_t Addr; ///< Start address of this line entry. - uint32_t File; ///< 1 based index of file in FileTable - uint32_t Line; ///< Source line number. - LineEntry(uint64_t A = 0, uint32_t F = 0, uint32_t L = 0) - : Addr(A), File(F), Line(L) {} - bool isValid() { return File != 0; } -}; - -inline raw_ostream &operator<<(raw_ostream &OS, const LineEntry &LE) { - return OS << "addr=" << HEX64(LE.Addr) << ", file=" << format("%3u", LE.File) - << ", line=" << format("%3u", LE.Line); -} - -inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) { - return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line; -} -inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) { - return !(LHS == RHS); -} -inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) { - return LHS.Addr < RHS.Addr; -} -} // namespace gsym -} // namespace llvm -#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- LineEntry.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H +#define LLVM_DEBUGINFO_GSYM_LINEENTRY_H + +#include "llvm/DebugInfo/GSYM/Range.h" + +namespace llvm { +namespace gsym { + +/// Line entries are used to encode the line tables in FunctionInfo objects. +/// They are stored as a sorted vector of these objects and store the +/// address, file and line of the line table row for a given address. The +/// size of a line table entry is calculated by looking at the next entry +/// in the FunctionInfo's vector of entries. +struct LineEntry { + uint64_t Addr; ///< Start address of this line entry. + uint32_t File; ///< 1 based index of file in FileTable + uint32_t Line; ///< Source line number. + LineEntry(uint64_t A = 0, uint32_t F = 0, uint32_t L = 0) + : Addr(A), File(F), Line(L) {} + bool isValid() { return File != 0; } +}; + +inline raw_ostream &operator<<(raw_ostream &OS, const LineEntry &LE) { + return OS << "addr=" << HEX64(LE.Addr) << ", file=" << format("%3u", LE.File) + << ", line=" << format("%3u", LE.Line); +} + +inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) { + return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line; +} +inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) { + return !(LHS == RHS); +} +inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) { + return LHS.Addr < RHS.Addr; +} +} // namespace gsym +} // namespace llvm +#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineTable.h index 79f0c0e066..9be35eedb2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LineTable.h @@ -1,244 +1,244 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- LineTable.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_LINETABLE_H -#define LLVM_DEBUGINFO_GSYM_LINETABLE_H - -#include "llvm/DebugInfo/GSYM/LineEntry.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace gsym { - -struct FunctionInfo; -class FileWriter; - -/// LineTable class contains deserialized versions of line tables for each -/// function's address ranges. -/// -/// When saved to disk, the line table is encoded using a modified version of -/// the DWARF line tables that only tracks address to source file and line. -/// -/// ENCODING -/// -/// The line table starts with a small prolog that contains the following -/// values: -/// -/// ENCODING NAME DESCRIPTION -/// ======== =========== ==================================================== -/// SLEB MinDelta The min line delta for special opcodes that advance -/// the address and line number. -/// SLEB MaxDelta The max line delta for single byte opcodes that -/// advance the address and line number. -/// ULEB FirstLine The value of the first source line number to -/// initialize the LineEntry with. -/// -/// Once these prolog items are read, we initialize a LineEntry struct with -/// the start address of the function from the FunctionInfo's address range, -/// a default file index of 1, and the line number set to "FirstLine" from -/// the prolog above: -/// -/// LineEntry Row(BaseAddr, 1, FirstLine); -/// -/// The line table state machine is now initialized and ready to be parsed. -/// The stream that follows this encodes the line entries in a compact -/// form. Some opcodes cause "Row" to be modified and some opcodes may also -/// push "Row" onto the end of the "LineTable.Lines" vector. The end result -/// is a vector of LineEntry structs that is sorted in ascending address -/// order. -/// -/// NORMAL OPCODES -/// -/// The opcodes 0 through 3 are normal in opcodes. Their encoding and -/// descriptions are listed below: -/// -/// ENCODING ENUMERATION VALUE DESCRIPTION -/// ======== ================ ===== ======================================== -/// LTOC_EndSequence 0x00 Parsing is done. -/// ULEB LTOC_SetFile 0x01 Row.File = ULEB -/// ULEB LTOC_AdvancePC 0x02 Row.Addr += ULEB, push "Row". -/// SLEB LTOC_AdvanceLine 0x03 Row.Line += SLEB -/// LTOC_FirstSpecial 0x04 First special opcode (see SPECIAL -/// OPCODES below). -/// -/// SPECIAL OPCODES -/// -/// Opcodes LTOC_FirstSpecial through 255 are special opcodes that always -/// increment both the Row.Addr and Row.Line and push "Row" onto the -/// LineEntry.Lines array. They do this by using some of the bits to -/// increment/decrement the source line number, and some of the bits to -/// increment the address. Line numbers can go up or down when making line -/// tables, where addresses always only increase since line tables are sorted -/// by address. -/// -/// In order to calculate the amount to increment the line and address for -/// these special opcodes, we calculate the number of values reserved for the -/// line increment/decrement using the "MinDelta" and "MaxDelta" from the -/// prolog: -/// -/// const int64_t LineRange = MaxDelta - MinDelta + 1; -/// -/// Then we can adjust the opcode to not include any of the normal opcodes: -/// -/// const uint8_t AdjustedOp = Opcode - LTOC_FirstSpecial; -/// -/// And we can calculate the line offset, and address offset: -/// -/// const int64_t LineDelta = MinDelta + (AdjustedOp % LineRange); -/// const uint64_t AddrDelta = (AdjustedOp / LineRange); -/// -/// And use these to modify our "Row": -/// -/// Row.Line += LineDelta; -/// Row.Addr += AddrDelta; -/// -/// And push a row onto the line table: -/// -/// Lines.push_back(Row); -/// -/// This is verify similar to the way that DWARF encodes its line tables. The -/// only difference is the DWARF line tables have more normal opcodes and the -/// "Row" contains more members, like source column number, bools for end of -/// prologue, beginnging of epilogue, is statement and many others. There are -/// also more complex rules that happen for the extra normal opcodes. By -/// leaving these extra opcodes out, we leave more bits for the special -/// opcodes that allows us to encode line tables in fewer bytes than standard -/// DWARF encodings. -/// -/// Opcodes that will push "Row" onto the LineEntry.Lines include the -/// LTOC_AdvancePC opcode and all special opcodes. All other opcodes -/// only modify the current "Row", or cause the line table to end. -class LineTable { - typedef std::vector<gsym::LineEntry> Collection; - Collection Lines; ///< All line entries in the line table. -public: - /// Lookup a single address within a line table's data. - /// - /// Clients have the option to decode an entire line table using - /// LineTable::decode() or just find a single matching entry using this - /// function. The benefit of using this function is that parsed LineEntry - /// objects that do not match will not be stored in an array. This will avoid - /// memory allocation costs and parsing can stop once a match has been found. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the LineTable object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param BaseAddr The base address to use when decoding the line table. - /// This will be the FunctionInfo's start address and will be used to - /// initialize the line table row prior to parsing any opcodes. - /// - /// \returns An LineEntry object if a match is found, error otherwise. - static Expected<LineEntry> lookup(DataExtractor &Data, uint64_t BaseAddr, - uint64_t Addr); - - /// Decode an LineTable object from a binary data stream. - /// - /// \param Data The binary stream to read the data from. This object must - /// have the data for the LineTable object starting at offset zero. The data - /// can contain more data than needed. - /// - /// \param BaseAddr The base address to use when decoding the line table. - /// This will be the FunctionInfo's start address and will be used to - /// initialize the line table row prior to parsing any opcodes. - /// - /// \returns An LineTable or an error describing the issue that was - /// encountered during decoding. - static llvm::Expected<LineTable> decode(DataExtractor &Data, - uint64_t BaseAddr); - /// Encode this LineTable object into FileWriter stream. - /// - /// \param O The binary stream to write the data to at the current file - /// position. - /// - /// \param BaseAddr The base address to use when decoding the line table. - /// This will be the FunctionInfo's start address. - /// - /// \returns An error object that indicates success or failure or the - /// encoding process. - llvm::Error encode(FileWriter &O, uint64_t BaseAddr) const; - bool empty() const { return Lines.empty(); } - void clear() { Lines.clear(); } - /// Return the first line entry if the line table isn't empty. - /// - /// \returns An optional line entry with the first line entry if the line - /// table isn't empty, or llvm::None if the line table is emtpy. - Optional<LineEntry> first() const { - if (Lines.empty()) - return llvm::None; - return Lines.front(); - } - /// Return the last line entry if the line table isn't empty. - /// - /// \returns An optional line entry with the last line entry if the line - /// table isn't empty, or llvm::None if the line table is emtpy. - Optional<LineEntry> last() const { - if (Lines.empty()) - return llvm::None; - return Lines.back(); - } - void push(const LineEntry &LE) { - Lines.push_back(LE); - } - size_t isValid() const { - return !Lines.empty(); - } - size_t size() const { - return Lines.size(); - } - LineEntry &get(size_t i) { - assert(i < Lines.size()); - return Lines[i]; - } - const LineEntry &get(size_t i) const { - assert(i < Lines.size()); - return Lines[i]; - } - LineEntry &operator[](size_t i) { - return get(i); - } - const LineEntry &operator[](size_t i) const { - return get(i); - } - bool operator==(const LineTable &RHS) const { - return Lines == RHS.Lines; - } - bool operator!=(const LineTable &RHS) const { - return Lines != RHS.Lines; - } - bool operator<(const LineTable &RHS) const { - const auto LHSSize = Lines.size(); - const auto RHSSize = RHS.Lines.size(); - if (LHSSize == RHSSize) - return Lines < RHS.Lines; - return LHSSize < RHSSize; - } - Collection::const_iterator begin() const { return Lines.begin(); } - Collection::const_iterator end() const { return Lines.end(); } - -}; - -raw_ostream &operator<<(raw_ostream &OS, const gsym::LineTable <); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINETABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- LineTable.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_LINETABLE_H +#define LLVM_DEBUGINFO_GSYM_LINETABLE_H + +#include "llvm/DebugInfo/GSYM/LineEntry.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace gsym { + +struct FunctionInfo; +class FileWriter; + +/// LineTable class contains deserialized versions of line tables for each +/// function's address ranges. +/// +/// When saved to disk, the line table is encoded using a modified version of +/// the DWARF line tables that only tracks address to source file and line. +/// +/// ENCODING +/// +/// The line table starts with a small prolog that contains the following +/// values: +/// +/// ENCODING NAME DESCRIPTION +/// ======== =========== ==================================================== +/// SLEB MinDelta The min line delta for special opcodes that advance +/// the address and line number. +/// SLEB MaxDelta The max line delta for single byte opcodes that +/// advance the address and line number. +/// ULEB FirstLine The value of the first source line number to +/// initialize the LineEntry with. +/// +/// Once these prolog items are read, we initialize a LineEntry struct with +/// the start address of the function from the FunctionInfo's address range, +/// a default file index of 1, and the line number set to "FirstLine" from +/// the prolog above: +/// +/// LineEntry Row(BaseAddr, 1, FirstLine); +/// +/// The line table state machine is now initialized and ready to be parsed. +/// The stream that follows this encodes the line entries in a compact +/// form. Some opcodes cause "Row" to be modified and some opcodes may also +/// push "Row" onto the end of the "LineTable.Lines" vector. The end result +/// is a vector of LineEntry structs that is sorted in ascending address +/// order. +/// +/// NORMAL OPCODES +/// +/// The opcodes 0 through 3 are normal in opcodes. Their encoding and +/// descriptions are listed below: +/// +/// ENCODING ENUMERATION VALUE DESCRIPTION +/// ======== ================ ===== ======================================== +/// LTOC_EndSequence 0x00 Parsing is done. +/// ULEB LTOC_SetFile 0x01 Row.File = ULEB +/// ULEB LTOC_AdvancePC 0x02 Row.Addr += ULEB, push "Row". +/// SLEB LTOC_AdvanceLine 0x03 Row.Line += SLEB +/// LTOC_FirstSpecial 0x04 First special opcode (see SPECIAL +/// OPCODES below). +/// +/// SPECIAL OPCODES +/// +/// Opcodes LTOC_FirstSpecial through 255 are special opcodes that always +/// increment both the Row.Addr and Row.Line and push "Row" onto the +/// LineEntry.Lines array. They do this by using some of the bits to +/// increment/decrement the source line number, and some of the bits to +/// increment the address. Line numbers can go up or down when making line +/// tables, where addresses always only increase since line tables are sorted +/// by address. +/// +/// In order to calculate the amount to increment the line and address for +/// these special opcodes, we calculate the number of values reserved for the +/// line increment/decrement using the "MinDelta" and "MaxDelta" from the +/// prolog: +/// +/// const int64_t LineRange = MaxDelta - MinDelta + 1; +/// +/// Then we can adjust the opcode to not include any of the normal opcodes: +/// +/// const uint8_t AdjustedOp = Opcode - LTOC_FirstSpecial; +/// +/// And we can calculate the line offset, and address offset: +/// +/// const int64_t LineDelta = MinDelta + (AdjustedOp % LineRange); +/// const uint64_t AddrDelta = (AdjustedOp / LineRange); +/// +/// And use these to modify our "Row": +/// +/// Row.Line += LineDelta; +/// Row.Addr += AddrDelta; +/// +/// And push a row onto the line table: +/// +/// Lines.push_back(Row); +/// +/// This is verify similar to the way that DWARF encodes its line tables. The +/// only difference is the DWARF line tables have more normal opcodes and the +/// "Row" contains more members, like source column number, bools for end of +/// prologue, beginnging of epilogue, is statement and many others. There are +/// also more complex rules that happen for the extra normal opcodes. By +/// leaving these extra opcodes out, we leave more bits for the special +/// opcodes that allows us to encode line tables in fewer bytes than standard +/// DWARF encodings. +/// +/// Opcodes that will push "Row" onto the LineEntry.Lines include the +/// LTOC_AdvancePC opcode and all special opcodes. All other opcodes +/// only modify the current "Row", or cause the line table to end. +class LineTable { + typedef std::vector<gsym::LineEntry> Collection; + Collection Lines; ///< All line entries in the line table. +public: + /// Lookup a single address within a line table's data. + /// + /// Clients have the option to decode an entire line table using + /// LineTable::decode() or just find a single matching entry using this + /// function. The benefit of using this function is that parsed LineEntry + /// objects that do not match will not be stored in an array. This will avoid + /// memory allocation costs and parsing can stop once a match has been found. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the LineTable object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param BaseAddr The base address to use when decoding the line table. + /// This will be the FunctionInfo's start address and will be used to + /// initialize the line table row prior to parsing any opcodes. + /// + /// \returns An LineEntry object if a match is found, error otherwise. + static Expected<LineEntry> lookup(DataExtractor &Data, uint64_t BaseAddr, + uint64_t Addr); + + /// Decode an LineTable object from a binary data stream. + /// + /// \param Data The binary stream to read the data from. This object must + /// have the data for the LineTable object starting at offset zero. The data + /// can contain more data than needed. + /// + /// \param BaseAddr The base address to use when decoding the line table. + /// This will be the FunctionInfo's start address and will be used to + /// initialize the line table row prior to parsing any opcodes. + /// + /// \returns An LineTable or an error describing the issue that was + /// encountered during decoding. + static llvm::Expected<LineTable> decode(DataExtractor &Data, + uint64_t BaseAddr); + /// Encode this LineTable object into FileWriter stream. + /// + /// \param O The binary stream to write the data to at the current file + /// position. + /// + /// \param BaseAddr The base address to use when decoding the line table. + /// This will be the FunctionInfo's start address. + /// + /// \returns An error object that indicates success or failure or the + /// encoding process. + llvm::Error encode(FileWriter &O, uint64_t BaseAddr) const; + bool empty() const { return Lines.empty(); } + void clear() { Lines.clear(); } + /// Return the first line entry if the line table isn't empty. + /// + /// \returns An optional line entry with the first line entry if the line + /// table isn't empty, or llvm::None if the line table is emtpy. + Optional<LineEntry> first() const { + if (Lines.empty()) + return llvm::None; + return Lines.front(); + } + /// Return the last line entry if the line table isn't empty. + /// + /// \returns An optional line entry with the last line entry if the line + /// table isn't empty, or llvm::None if the line table is emtpy. + Optional<LineEntry> last() const { + if (Lines.empty()) + return llvm::None; + return Lines.back(); + } + void push(const LineEntry &LE) { + Lines.push_back(LE); + } + size_t isValid() const { + return !Lines.empty(); + } + size_t size() const { + return Lines.size(); + } + LineEntry &get(size_t i) { + assert(i < Lines.size()); + return Lines[i]; + } + const LineEntry &get(size_t i) const { + assert(i < Lines.size()); + return Lines[i]; + } + LineEntry &operator[](size_t i) { + return get(i); + } + const LineEntry &operator[](size_t i) const { + return get(i); + } + bool operator==(const LineTable &RHS) const { + return Lines == RHS.Lines; + } + bool operator!=(const LineTable &RHS) const { + return Lines != RHS.Lines; + } + bool operator<(const LineTable &RHS) const { + const auto LHSSize = Lines.size(); + const auto RHSSize = RHS.Lines.size(); + if (LHSSize == RHSSize) + return Lines < RHS.Lines; + return LHSSize < RHSSize; + } + Collection::const_iterator begin() const { return Lines.begin(); } + Collection::const_iterator end() const { return Lines.end(); } + +}; + +raw_ostream &operator<<(raw_ostream &OS, const gsym::LineTable <); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINETABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LookupResult.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LookupResult.h index e909783875..085d20810d 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LookupResult.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/LookupResult.h @@ -1,74 +1,74 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- LookupResult.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H -#define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H - -#include "llvm/DebugInfo/GSYM/Range.h" -#include "llvm/ADT/StringRef.h" -#include <inttypes.h> -#include <vector> - -namespace llvm { -class raw_ostream; -namespace gsym { -struct FileEntry; - -struct SourceLocation { - StringRef Name; ///< Function or symbol name. - StringRef Dir; ///< Line entry source file directory path. - StringRef Base; ///< Line entry source file basename. - uint32_t Line = 0; ///< Source file line number. - uint32_t Offset = 0; ///< Byte size offset within the named function. -}; - -inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) { - return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && - LHS.Base == RHS.Base && LHS.Line == RHS.Line && - LHS.Offset == RHS.Offset; -} - -raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R); - -using SourceLocations = std::vector<SourceLocation>; - - -struct LookupResult { - uint64_t LookupAddr = 0; ///< The address that this lookup pertains to. - AddressRange FuncRange; ///< The concrete function address range. - StringRef FuncName; ///< The concrete function name that contains LookupAddr. - /// The source locations that match this address. This information will only - /// be filled in if the FunctionInfo contains a line table. If an address is - /// for a concrete function with no inlined functions, this array will have - /// one entry. If an address points to an inline function, there will be one - /// SourceLocation for each inlined function with the last entry pointing to - /// the concrete function itself. This allows one address to generate - /// multiple locations and allows unwinding of inline call stacks. The - /// deepest inline function will appear at index zero in the source locations - /// array, and the concrete function will appear at the end of the array. - SourceLocations Locations; - std::string getSourceFile(uint32_t Index) const; -}; - -raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- LookupResult.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H +#define LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H + +#include "llvm/DebugInfo/GSYM/Range.h" +#include "llvm/ADT/StringRef.h" +#include <inttypes.h> +#include <vector> + +namespace llvm { +class raw_ostream; +namespace gsym { +struct FileEntry; + +struct SourceLocation { + StringRef Name; ///< Function or symbol name. + StringRef Dir; ///< Line entry source file directory path. + StringRef Base; ///< Line entry source file basename. + uint32_t Line = 0; ///< Source file line number. + uint32_t Offset = 0; ///< Byte size offset within the named function. +}; + +inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) { + return LHS.Name == RHS.Name && LHS.Dir == RHS.Dir && + LHS.Base == RHS.Base && LHS.Line == RHS.Line && + LHS.Offset == RHS.Offset; +} + +raw_ostream &operator<<(raw_ostream &OS, const SourceLocation &R); + +using SourceLocations = std::vector<SourceLocation>; + + +struct LookupResult { + uint64_t LookupAddr = 0; ///< The address that this lookup pertains to. + AddressRange FuncRange; ///< The concrete function address range. + StringRef FuncName; ///< The concrete function name that contains LookupAddr. + /// The source locations that match this address. This information will only + /// be filled in if the FunctionInfo contains a line table. If an address is + /// for a concrete function with no inlined functions, this array will have + /// one entry. If an address points to an inline function, there will be one + /// SourceLocation for each inlined function with the last entry pointing to + /// the concrete function itself. This allows one address to generate + /// multiple locations and allows unwinding of inline call stacks. The + /// deepest inline function will appear at index zero in the source locations + /// array, and the concrete function will appear at the end of the array. + SourceLocations Locations; + std::string getSourceFile(uint32_t Index) const; +}; + +raw_ostream &operator<<(raw_ostream &OS, const LookupResult &R); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_LOOKUPRESULT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/ObjectFileTransformer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/ObjectFileTransformer.h index 6919af9c37..79ed0dcd2e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/ObjectFileTransformer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/ObjectFileTransformer.h @@ -1,62 +1,62 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- ObjectFileTransformer.h ----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H -#define LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H - -#include "llvm/Support/Error.h" - -namespace llvm { - -class raw_ostream; - -namespace object { -class ObjectFile; -} - -namespace gsym { - -struct CUInfo; -class GsymCreator; - -class ObjectFileTransformer { -public: - /// Extract any object file data that is needed by the GsymCreator. - /// - /// The extracted information includes the UUID of the binary and converting - /// all function symbols from any symbol tables into FunctionInfo objects. - /// - /// \param Obj The object file that contains the DWARF debug info. - /// - /// \param Log The stream to log warnings and non fatal issues to. - /// - /// \param Gsym The GSYM creator to populate with the function information - /// from the debug info. - /// - /// \returns An error indicating any fatal issues that happen when parsing - /// the DWARF, or Error::success() if all goes well. - static llvm::Error convert(const object::ObjectFile &Obj, - raw_ostream &Log, - GsymCreator &Gsym); -}; - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- ObjectFileTransformer.h ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H +#define LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H + +#include "llvm/Support/Error.h" + +namespace llvm { + +class raw_ostream; + +namespace object { +class ObjectFile; +} + +namespace gsym { + +struct CUInfo; +class GsymCreator; + +class ObjectFileTransformer { +public: + /// Extract any object file data that is needed by the GsymCreator. + /// + /// The extracted information includes the UUID of the binary and converting + /// all function symbols from any symbol tables into FunctionInfo objects. + /// + /// \param Obj The object file that contains the DWARF debug info. + /// + /// \param Log The stream to log warnings and non fatal issues to. + /// + /// \param Gsym The GSYM creator to populate with the function information + /// from the debug info. + /// + /// \returns An error indicating any fatal issues that happen when parsing + /// the DWARF, or Error::success() if all goes well. + static llvm::Error convert(const object::ObjectFile &Obj, + raw_ostream &Log, + GsymCreator &Gsym); +}; + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_OBJECTFILETRANSFORMER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Range.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Range.h index 566e1f950a..93c57777f5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Range.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/Range.h @@ -1,141 +1,141 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Range.h --------------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_RANGE_H -#define LLVM_DEBUGINFO_GSYM_RANGE_H - -#include "llvm/ADT/Optional.h" -#include "llvm/Support/Format.h" -#include "llvm/Support/raw_ostream.h" -#include <stdint.h> -#include <vector> - -#define HEX8(v) llvm::format_hex(v, 4) -#define HEX16(v) llvm::format_hex(v, 6) -#define HEX32(v) llvm::format_hex(v, 10) -#define HEX64(v) llvm::format_hex(v, 18) - -namespace llvm { -class DataExtractor; -class raw_ostream; - -namespace gsym { - -class FileWriter; - -/// A class that represents an address range. The range is specified using -/// a start and an end address. -struct AddressRange { - uint64_t Start; - uint64_t End; - AddressRange() : Start(0), End(0) {} - AddressRange(uint64_t S, uint64_t E) : Start(S), End(E) {} - uint64_t size() const { return End - Start; } - bool contains(uint64_t Addr) const { return Start <= Addr && Addr < End; } - bool intersects(const AddressRange &R) const { - return Start < R.End && R.Start < End; - } - - bool operator==(const AddressRange &R) const { - return Start == R.Start && End == R.End; - } - bool operator!=(const AddressRange &R) const { - return !(*this == R); - } - bool operator<(const AddressRange &R) const { - return std::make_pair(Start, End) < std::make_pair(R.Start, R.End); - } - /// AddressRange objects are encoded and decoded to be relative to a base - /// address. This will be the FunctionInfo's start address if the AddressRange - /// is directly contained in a FunctionInfo, or a base address of the - /// containing parent AddressRange or AddressRanges. This allows address - /// ranges to be efficiently encoded using ULEB128 encodings as we encode the - /// offset and size of each range instead of full addresses. This also makes - /// encoded addresses easy to relocate as we just need to relocate one base - /// address. - /// @{ - void decode(DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset); - void encode(FileWriter &O, uint64_t BaseAddr) const; - /// @} - - /// Skip an address range object in the specified data a the specified - /// offset. - /// - /// \param Data The binary stream to read the data from. - /// - /// \param Offset The byte offset within \a Data. - static void skip(DataExtractor &Data, uint64_t &Offset); -}; - -raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R); - -/// The AddressRanges class helps normalize address range collections. -/// This class keeps a sorted vector of AddressRange objects and can perform -/// insertions and searches efficiently. The address ranges are always sorted -/// and never contain any invalid or empty address ranges. This allows us to -/// emit address ranges into the GSYM file efficiently. Intersecting address -/// ranges are combined during insertion so that we can emit the most compact -/// representation for address ranges when writing to disk. -class AddressRanges { -protected: - using Collection = std::vector<AddressRange>; - Collection Ranges; -public: - void clear() { Ranges.clear(); } - bool empty() const { return Ranges.empty(); } - bool contains(uint64_t Addr) const; - bool contains(AddressRange Range) const; - Optional<AddressRange> getRangeThatContains(uint64_t Addr) const; - void insert(AddressRange Range); - size_t size() const { return Ranges.size(); } - bool operator==(const AddressRanges &RHS) const { - return Ranges == RHS.Ranges; - } - const AddressRange &operator[](size_t i) const { - assert(i < Ranges.size()); - return Ranges[i]; - } - Collection::const_iterator begin() const { return Ranges.begin(); } - Collection::const_iterator end() const { return Ranges.end(); } - - /// Address ranges are decoded and encoded to be relative to a base address. - /// See the AddressRange comment for the encode and decode methods for full - /// details. - /// @{ - void decode(DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset); - void encode(FileWriter &O, uint64_t BaseAddr) const; - /// @} - - /// Skip an address range object in the specified data a the specified - /// offset. - /// - /// \param Data The binary stream to read the data from. - /// - /// \param Offset The byte offset within \a Data. - /// - /// \returns The number of address ranges that were skipped. - static uint64_t skip(DataExtractor &Data, uint64_t &Offset); -}; - -raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR); - -} // namespace gsym -} // namespace llvm - -#endif // #ifndef LLVM_DEBUGINFO_GSYM_RANGE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Range.h --------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_RANGE_H +#define LLVM_DEBUGINFO_GSYM_RANGE_H + +#include "llvm/ADT/Optional.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" +#include <stdint.h> +#include <vector> + +#define HEX8(v) llvm::format_hex(v, 4) +#define HEX16(v) llvm::format_hex(v, 6) +#define HEX32(v) llvm::format_hex(v, 10) +#define HEX64(v) llvm::format_hex(v, 18) + +namespace llvm { +class DataExtractor; +class raw_ostream; + +namespace gsym { + +class FileWriter; + +/// A class that represents an address range. The range is specified using +/// a start and an end address. +struct AddressRange { + uint64_t Start; + uint64_t End; + AddressRange() : Start(0), End(0) {} + AddressRange(uint64_t S, uint64_t E) : Start(S), End(E) {} + uint64_t size() const { return End - Start; } + bool contains(uint64_t Addr) const { return Start <= Addr && Addr < End; } + bool intersects(const AddressRange &R) const { + return Start < R.End && R.Start < End; + } + + bool operator==(const AddressRange &R) const { + return Start == R.Start && End == R.End; + } + bool operator!=(const AddressRange &R) const { + return !(*this == R); + } + bool operator<(const AddressRange &R) const { + return std::make_pair(Start, End) < std::make_pair(R.Start, R.End); + } + /// AddressRange objects are encoded and decoded to be relative to a base + /// address. This will be the FunctionInfo's start address if the AddressRange + /// is directly contained in a FunctionInfo, or a base address of the + /// containing parent AddressRange or AddressRanges. This allows address + /// ranges to be efficiently encoded using ULEB128 encodings as we encode the + /// offset and size of each range instead of full addresses. This also makes + /// encoded addresses easy to relocate as we just need to relocate one base + /// address. + /// @{ + void decode(DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset); + void encode(FileWriter &O, uint64_t BaseAddr) const; + /// @} + + /// Skip an address range object in the specified data a the specified + /// offset. + /// + /// \param Data The binary stream to read the data from. + /// + /// \param Offset The byte offset within \a Data. + static void skip(DataExtractor &Data, uint64_t &Offset); +}; + +raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R); + +/// The AddressRanges class helps normalize address range collections. +/// This class keeps a sorted vector of AddressRange objects and can perform +/// insertions and searches efficiently. The address ranges are always sorted +/// and never contain any invalid or empty address ranges. This allows us to +/// emit address ranges into the GSYM file efficiently. Intersecting address +/// ranges are combined during insertion so that we can emit the most compact +/// representation for address ranges when writing to disk. +class AddressRanges { +protected: + using Collection = std::vector<AddressRange>; + Collection Ranges; +public: + void clear() { Ranges.clear(); } + bool empty() const { return Ranges.empty(); } + bool contains(uint64_t Addr) const; + bool contains(AddressRange Range) const; + Optional<AddressRange> getRangeThatContains(uint64_t Addr) const; + void insert(AddressRange Range); + size_t size() const { return Ranges.size(); } + bool operator==(const AddressRanges &RHS) const { + return Ranges == RHS.Ranges; + } + const AddressRange &operator[](size_t i) const { + assert(i < Ranges.size()); + return Ranges[i]; + } + Collection::const_iterator begin() const { return Ranges.begin(); } + Collection::const_iterator end() const { return Ranges.end(); } + + /// Address ranges are decoded and encoded to be relative to a base address. + /// See the AddressRange comment for the encode and decode methods for full + /// details. + /// @{ + void decode(DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset); + void encode(FileWriter &O, uint64_t BaseAddr) const; + /// @} + + /// Skip an address range object in the specified data a the specified + /// offset. + /// + /// \param Data The binary stream to read the data from. + /// + /// \param Offset The byte offset within \a Data. + /// + /// \returns The number of address ranges that were skipped. + static uint64_t skip(DataExtractor &Data, uint64_t &Offset); +}; + +raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR); + +} // namespace gsym +} // namespace llvm + +#endif // #ifndef LLVM_DEBUGINFO_GSYM_RANGE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/StringTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/StringTable.h index 12d71c2a88..8a86344f3b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/StringTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/GSYM/StringTable.h @@ -1,64 +1,64 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- StringTable.h --------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H -#define LLVM_DEBUGINFO_GSYM_STRINGTABLE_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/GSYM/Range.h" -#include <stdint.h> -#include <string> - - -namespace llvm { -namespace gsym { - -/// String tables in GSYM files are required to start with an empty -/// string at offset zero. Strings must be UTF8 NULL terminated strings. -struct StringTable { - StringRef Data; - StringTable() : Data() {} - StringTable(StringRef D) : Data(D) {} - StringRef operator[](size_t Offset) const { return getString(Offset); } - StringRef getString(uint32_t Offset) const { - if (Offset < Data.size()) { - auto End = Data.find('\0', Offset); - return Data.substr(Offset, End - Offset); - } - return StringRef(); - } - void clear() { Data = StringRef(); } -}; - -inline raw_ostream &operator<<(raw_ostream &OS, const StringTable &S) { - OS << "String table:\n"; - uint32_t Offset = 0; - const size_t Size = S.Data.size(); - while (Offset < Size) { - StringRef Str = S.getString(Offset); - OS << HEX32(Offset) << ": \"" << Str << "\"\n"; - Offset += Str.size() + 1; - } - return OS; -} - -} // namespace gsym -} // namespace llvm -#endif // #ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- StringTable.h --------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H +#define LLVM_DEBUGINFO_GSYM_STRINGTABLE_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/GSYM/Range.h" +#include <stdint.h> +#include <string> + + +namespace llvm { +namespace gsym { + +/// String tables in GSYM files are required to start with an empty +/// string at offset zero. Strings must be UTF8 NULL terminated strings. +struct StringTable { + StringRef Data; + StringTable() : Data() {} + StringTable(StringRef D) : Data(D) {} + StringRef operator[](size_t Offset) const { return getString(Offset); } + StringRef getString(uint32_t Offset) const { + if (Offset < Data.size()) { + auto End = Data.find('\0', Offset); + return Data.substr(Offset, End - Offset); + } + return StringRef(); + } + void clear() { Data = StringRef(); } +}; + +inline raw_ostream &operator<<(raw_ostream &OS, const StringTable &S) { + OS << "String table:\n"; + uint32_t Offset = 0; + const size_t Size = S.Data.size(); + while (Offset < Size) { + StringRef Str = S.getString(Offset); + OS << HEX32(Offset) << ": \"" << Str << "\"\n"; + Offset += Str.size() + 1; + } + return OS; +} + +} // namespace gsym +} // namespace llvm +#endif // #ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/IMSFFile.h b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/IMSFFile.h index 5af0a3a572..5e598b1998 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/IMSFFile.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/IMSFFile.h @@ -1,52 +1,52 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IMSFFile.h - Abstract base class for an MSF file ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_MSF_IMSFFILE_H -#define LLVM_DEBUGINFO_MSF_IMSFFILE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> - -namespace llvm { -namespace msf { - -class IMSFFile { -public: - virtual ~IMSFFile() = default; - - virtual uint32_t getBlockSize() const = 0; - virtual uint32_t getBlockCount() const = 0; - - virtual uint32_t getNumStreams() const = 0; - virtual uint32_t getStreamByteSize(uint32_t StreamIndex) const = 0; - virtual ArrayRef<support::ulittle32_t> - getStreamBlockList(uint32_t StreamIndex) const = 0; - - virtual Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex, - uint32_t NumBytes) const = 0; - virtual Error setBlockData(uint32_t BlockIndex, uint32_t Offset, - ArrayRef<uint8_t> Data) const = 0; -}; - -} // end namespace msf -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_MSF_IMSFFILE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IMSFFile.h - Abstract base class for an MSF file ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_MSF_IMSFFILE_H +#define LLVM_DEBUGINFO_MSF_IMSFFILE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> + +namespace llvm { +namespace msf { + +class IMSFFile { +public: + virtual ~IMSFFile() = default; + + virtual uint32_t getBlockSize() const = 0; + virtual uint32_t getBlockCount() const = 0; + + virtual uint32_t getNumStreams() const = 0; + virtual uint32_t getStreamByteSize(uint32_t StreamIndex) const = 0; + virtual ArrayRef<support::ulittle32_t> + getStreamBlockList(uint32_t StreamIndex) const = 0; + + virtual Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex, + uint32_t NumBytes) const = 0; + virtual Error setBlockData(uint32_t BlockIndex, uint32_t Offset, + ArrayRef<uint8_t> Data) const = 0; +}; + +} // end namespace msf +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_IMSFFILE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFBuilder.h index 7365677db5..d41217132a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFBuilder.h @@ -1,155 +1,155 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MSFBuilder.h - MSF Directory & Metadata Builder ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_MSF_MSFBUILDER_H -#define LLVM_DEBUGINFO_MSF_MSFBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/BitVector.h" -#include "llvm/DebugInfo/MSF/MSFCommon.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <utility> -#include <vector> - -namespace llvm { -class FileBufferByteStream; -class WritableBinaryStream; -namespace msf { - -class MSFBuilder { -public: - /// Create a new `MSFBuilder`. - /// - /// \param BlockSize The internal block size used by the PDB file. See - /// isValidBlockSize() for a list of valid block sizes. - /// - /// \param MinBlockCount Causes the builder to reserve up front space for - /// at least `MinBlockCount` blocks. This is useful when using `MSFBuilder` - /// to read an existing MSF that you want to write back out later. The - /// original MSF file's SuperBlock contains the exact number of blocks used - /// by the file, so is a good hint as to how many blocks the new MSF file - /// will contain. Furthermore, it is actually necessary in this case. To - /// preserve stability of the file's layout, it is helpful to try to keep - /// all streams mapped to their original block numbers. To ensure that this - /// is possible, space for all blocks must be allocated beforehand so that - /// streams can be assigned to them. - /// - /// \param CanGrow If true, any operation which results in an attempt to - /// locate a free block when all available blocks have been exhausted will - /// allocate a new block, thereby growing the size of the final MSF file. - /// When false, any such attempt will result in an error. This is especially - /// useful in testing scenarios when you know your test isn't going to do - /// anything to increase the size of the file, so having an Error returned if - /// it were to happen would catch a programming error - /// - /// \returns an llvm::Error representing whether the operation succeeded or - /// failed. Currently the only way this can fail is if an invalid block size - /// is specified, or `MinBlockCount` does not leave enough room for the - /// mandatory reserved blocks required by an MSF file. - static Expected<MSFBuilder> create(BumpPtrAllocator &Allocator, - uint32_t BlockSize, - uint32_t MinBlockCount = 0, - bool CanGrow = true); - - /// Request the block map to be at a specific block address. This is useful - /// when editing a MSF and you want the layout to be as stable as possible. - Error setBlockMapAddr(uint32_t Addr); - Error setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks); - void setFreePageMap(uint32_t Fpm); - void setUnknown1(uint32_t Unk1); - - /// Add a stream to the MSF file with the given size, occupying the given - /// list of blocks. This is useful when reading a MSF file and you want a - /// particular stream to occupy the original set of blocks. If the given - /// blocks are already allocated, or if the number of blocks specified is - /// incorrect for the given stream size, this function will return an Error. - Expected<uint32_t> addStream(uint32_t Size, ArrayRef<uint32_t> Blocks); - - /// Add a stream to the MSF file with the given size, occupying any available - /// blocks that the builder decides to use. This is useful when building a - /// new PDB file from scratch and you don't care what blocks a stream occupies - /// but you just want it to work. - Expected<uint32_t> addStream(uint32_t Size); - - /// Update the size of an existing stream. This will allocate or deallocate - /// blocks as needed to match the requested size. This can fail if `CanGrow` - /// was set to false when initializing the `MSFBuilder`. - Error setStreamSize(uint32_t Idx, uint32_t Size); - - /// Get the total number of streams in the MSF layout. This should return 1 - /// for every call to `addStream`. - uint32_t getNumStreams() const; - - /// Get the size of a stream by index. - uint32_t getStreamSize(uint32_t StreamIdx) const; - - /// Get the list of blocks allocated to a particular stream. - ArrayRef<uint32_t> getStreamBlocks(uint32_t StreamIdx) const; - - /// Get the total number of blocks that will be allocated to actual data in - /// this MSF file. - uint32_t getNumUsedBlocks() const; - - /// Get the total number of blocks that exist in the MSF file but are not - /// allocated to any valid data. - uint32_t getNumFreeBlocks() const; - - /// Get the total number of blocks in the MSF file. In practice this is equal - /// to `getNumUsedBlocks() + getNumFreeBlocks()`. - uint32_t getTotalBlockCount() const; - - /// Check whether a particular block is allocated or free. - bool isBlockFree(uint32_t Idx) const; - - /// Finalize the layout and build the headers and structures that describe the - /// MSF layout and can be written directly to the MSF file. - Expected<MSFLayout> generateLayout(); - - /// Write the MSF layout to the underlying file. - Expected<FileBufferByteStream> commit(StringRef Path, MSFLayout &Layout); - - BumpPtrAllocator &getAllocator() { return Allocator; } - -private: - MSFBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, - BumpPtrAllocator &Allocator); - - Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks); - uint32_t computeDirectoryByteSize() const; - - using BlockList = std::vector<uint32_t>; - - BumpPtrAllocator &Allocator; - - bool IsGrowable; - uint32_t FreePageMap; - uint32_t Unknown1 = 0; - uint32_t BlockSize; - uint32_t BlockMapAddr; - BitVector FreeBlocks; - std::vector<uint32_t> DirectoryBlocks; - std::vector<std::pair<uint32_t, BlockList>> StreamData; -}; - -} // end namespace msf -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MSFBuilder.h - MSF Directory & Metadata Builder ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_MSF_MSFBUILDER_H +#define LLVM_DEBUGINFO_MSF_MSFBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/DebugInfo/MSF/MSFCommon.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <utility> +#include <vector> + +namespace llvm { +class FileBufferByteStream; +class WritableBinaryStream; +namespace msf { + +class MSFBuilder { +public: + /// Create a new `MSFBuilder`. + /// + /// \param BlockSize The internal block size used by the PDB file. See + /// isValidBlockSize() for a list of valid block sizes. + /// + /// \param MinBlockCount Causes the builder to reserve up front space for + /// at least `MinBlockCount` blocks. This is useful when using `MSFBuilder` + /// to read an existing MSF that you want to write back out later. The + /// original MSF file's SuperBlock contains the exact number of blocks used + /// by the file, so is a good hint as to how many blocks the new MSF file + /// will contain. Furthermore, it is actually necessary in this case. To + /// preserve stability of the file's layout, it is helpful to try to keep + /// all streams mapped to their original block numbers. To ensure that this + /// is possible, space for all blocks must be allocated beforehand so that + /// streams can be assigned to them. + /// + /// \param CanGrow If true, any operation which results in an attempt to + /// locate a free block when all available blocks have been exhausted will + /// allocate a new block, thereby growing the size of the final MSF file. + /// When false, any such attempt will result in an error. This is especially + /// useful in testing scenarios when you know your test isn't going to do + /// anything to increase the size of the file, so having an Error returned if + /// it were to happen would catch a programming error + /// + /// \returns an llvm::Error representing whether the operation succeeded or + /// failed. Currently the only way this can fail is if an invalid block size + /// is specified, or `MinBlockCount` does not leave enough room for the + /// mandatory reserved blocks required by an MSF file. + static Expected<MSFBuilder> create(BumpPtrAllocator &Allocator, + uint32_t BlockSize, + uint32_t MinBlockCount = 0, + bool CanGrow = true); + + /// Request the block map to be at a specific block address. This is useful + /// when editing a MSF and you want the layout to be as stable as possible. + Error setBlockMapAddr(uint32_t Addr); + Error setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks); + void setFreePageMap(uint32_t Fpm); + void setUnknown1(uint32_t Unk1); + + /// Add a stream to the MSF file with the given size, occupying the given + /// list of blocks. This is useful when reading a MSF file and you want a + /// particular stream to occupy the original set of blocks. If the given + /// blocks are already allocated, or if the number of blocks specified is + /// incorrect for the given stream size, this function will return an Error. + Expected<uint32_t> addStream(uint32_t Size, ArrayRef<uint32_t> Blocks); + + /// Add a stream to the MSF file with the given size, occupying any available + /// blocks that the builder decides to use. This is useful when building a + /// new PDB file from scratch and you don't care what blocks a stream occupies + /// but you just want it to work. + Expected<uint32_t> addStream(uint32_t Size); + + /// Update the size of an existing stream. This will allocate or deallocate + /// blocks as needed to match the requested size. This can fail if `CanGrow` + /// was set to false when initializing the `MSFBuilder`. + Error setStreamSize(uint32_t Idx, uint32_t Size); + + /// Get the total number of streams in the MSF layout. This should return 1 + /// for every call to `addStream`. + uint32_t getNumStreams() const; + + /// Get the size of a stream by index. + uint32_t getStreamSize(uint32_t StreamIdx) const; + + /// Get the list of blocks allocated to a particular stream. + ArrayRef<uint32_t> getStreamBlocks(uint32_t StreamIdx) const; + + /// Get the total number of blocks that will be allocated to actual data in + /// this MSF file. + uint32_t getNumUsedBlocks() const; + + /// Get the total number of blocks that exist in the MSF file but are not + /// allocated to any valid data. + uint32_t getNumFreeBlocks() const; + + /// Get the total number of blocks in the MSF file. In practice this is equal + /// to `getNumUsedBlocks() + getNumFreeBlocks()`. + uint32_t getTotalBlockCount() const; + + /// Check whether a particular block is allocated or free. + bool isBlockFree(uint32_t Idx) const; + + /// Finalize the layout and build the headers and structures that describe the + /// MSF layout and can be written directly to the MSF file. + Expected<MSFLayout> generateLayout(); + + /// Write the MSF layout to the underlying file. + Expected<FileBufferByteStream> commit(StringRef Path, MSFLayout &Layout); + + BumpPtrAllocator &getAllocator() { return Allocator; } + +private: + MSFBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, + BumpPtrAllocator &Allocator); + + Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks); + uint32_t computeDirectoryByteSize() const; + + using BlockList = std::vector<uint32_t>; + + BumpPtrAllocator &Allocator; + + bool IsGrowable; + uint32_t FreePageMap; + uint32_t Unknown1 = 0; + uint32_t BlockSize; + uint32_t BlockMapAddr; + BitVector FreeBlocks; + std::vector<uint32_t> DirectoryBlocks; + std::vector<std::pair<uint32_t, BlockList>> StreamData; +}; + +} // end namespace msf +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFCommon.h b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFCommon.h index f0c5525f05..737d3dc20a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFCommon.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFCommon.h @@ -1,172 +1,172 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MSFCommon.h - Common types and functions for MSF files ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_MSF_MSFCOMMON_H -#define LLVM_DEBUGINFO_MSF_MSFCOMMON_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/BitVector.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/MathExtras.h" -#include <cstdint> -#include <vector> - -namespace llvm { -namespace msf { - -static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', - 't', ' ', 'C', '/', 'C', '+', '+', ' ', - 'M', 'S', 'F', ' ', '7', '.', '0', '0', - '\r', '\n', '\x1a', 'D', 'S', '\0', '\0', '\0'}; - -// The superblock is overlaid at the beginning of the file (offset 0). -// It starts with a magic header and is followed by information which -// describes the layout of the file system. -struct SuperBlock { - char MagicBytes[sizeof(Magic)]; - // The file system is split into a variable number of fixed size elements. - // These elements are referred to as blocks. The size of a block may vary - // from system to system. - support::ulittle32_t BlockSize; - // The index of the free block map. - support::ulittle32_t FreeBlockMapBlock; - // This contains the number of blocks resident in the file system. In - // practice, NumBlocks * BlockSize is equivalent to the size of the MSF - // file. - support::ulittle32_t NumBlocks; - // This contains the number of bytes which make up the directory. - support::ulittle32_t NumDirectoryBytes; - // This field's purpose is not yet known. - support::ulittle32_t Unknown1; - // This contains the block # of the block map. - support::ulittle32_t BlockMapAddr; -}; - -struct MSFLayout { - MSFLayout() = default; - - uint32_t mainFpmBlock() const { - assert(SB->FreeBlockMapBlock == 1 || SB->FreeBlockMapBlock == 2); - return SB->FreeBlockMapBlock; - } - - uint32_t alternateFpmBlock() const { - // If mainFpmBlock is 1, this is 2. If mainFpmBlock is 2, this is 1. - return 3U - mainFpmBlock(); - } - - const SuperBlock *SB = nullptr; - BitVector FreePageMap; - ArrayRef<support::ulittle32_t> DirectoryBlocks; - ArrayRef<support::ulittle32_t> StreamSizes; - std::vector<ArrayRef<support::ulittle32_t>> StreamMap; -}; - -/// Describes the layout of a stream in an MSF layout. A "stream" here -/// is defined as any logical unit of data which may be arranged inside the MSF -/// file as a sequence of (possibly discontiguous) blocks. When we want to read -/// from a particular MSF Stream, we fill out a stream layout structure and the -/// reader uses it to determine which blocks in the underlying MSF file contain -/// the data, so that it can be pieced together in the right order. -class MSFStreamLayout { -public: - uint32_t Length; - std::vector<support::ulittle32_t> Blocks; -}; - -/// Determine the layout of the FPM stream, given the MSF layout. An FPM -/// stream spans 1 or more blocks, each at equally spaced intervals throughout -/// the file. -MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, - bool IncludeUnusedFpmData = false, - bool AltFpm = false); - -inline bool isValidBlockSize(uint32_t Size) { - switch (Size) { - case 512: - case 1024: - case 2048: - case 4096: - return true; - } - return false; -} - -// Super Block, Fpm0, Fpm1, and Block Map -inline uint32_t getMinimumBlockCount() { return 4; } - -// Super Block, Fpm0, and Fpm1 are reserved. The Block Map, although required -// need not be at block 3. -inline uint32_t getFirstUnreservedBlock() { return 3; } - -inline uint64_t bytesToBlocks(uint64_t NumBytes, uint64_t BlockSize) { - return divideCeil(NumBytes, BlockSize); -} - -inline uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize) { - return BlockNumber * BlockSize; -} - -inline uint32_t getFpmIntervalLength(const MSFLayout &L) { - return L.SB->BlockSize; -} - -/// Given an MSF with the specified block size and number of blocks, determine -/// how many pieces the specified Fpm is split into. -/// \p BlockSize - the block size of the MSF -/// \p NumBlocks - the total number of blocks in the MSF -/// \p IncludeUnusedFpmData - When true, this will count every block that is -/// both in the file and matches the form of an FPM block, even if some of -/// those FPM blocks are unused (a single FPM block can describe the -/// allocation status of up to 32,767 blocks, although one appears only -/// every 4,096 blocks). So there are 8x as many blocks that match the -/// form as there are blocks that are necessary to describe the allocation -/// status of the file. When this parameter is false, these extraneous -/// trailing blocks are not counted. -inline uint32_t getNumFpmIntervals(uint32_t BlockSize, uint32_t NumBlocks, - bool IncludeUnusedFpmData, int FpmNumber) { - assert(FpmNumber == 1 || FpmNumber == 2); - if (IncludeUnusedFpmData) { - // This calculation determines how many times a number of the form - // BlockSize * k + N appears in the range [0, NumBlocks). We only need to - // do this when unused data is included, since the number of blocks dwarfs - // the number of fpm blocks. - return divideCeil(NumBlocks - FpmNumber, BlockSize); - } - - // We want the minimum number of intervals required, where each interval can - // represent BlockSize * 8 blocks. - return divideCeil(NumBlocks, 8 * BlockSize); -} - -inline uint32_t getNumFpmIntervals(const MSFLayout &L, - bool IncludeUnusedFpmData = false, - bool AltFpm = false) { - return getNumFpmIntervals(L.SB->BlockSize, L.SB->NumBlocks, - IncludeUnusedFpmData, - AltFpm ? L.alternateFpmBlock() : L.mainFpmBlock()); -} - -Error validateSuperBlock(const SuperBlock &SB); - -} // end namespace msf -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MSFCommon.h - Common types and functions for MSF files ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_MSF_MSFCOMMON_H +#define LLVM_DEBUGINFO_MSF_MSFCOMMON_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" +#include <cstdint> +#include <vector> + +namespace llvm { +namespace msf { + +static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', + 't', ' ', 'C', '/', 'C', '+', '+', ' ', + 'M', 'S', 'F', ' ', '7', '.', '0', '0', + '\r', '\n', '\x1a', 'D', 'S', '\0', '\0', '\0'}; + +// The superblock is overlaid at the beginning of the file (offset 0). +// It starts with a magic header and is followed by information which +// describes the layout of the file system. +struct SuperBlock { + char MagicBytes[sizeof(Magic)]; + // The file system is split into a variable number of fixed size elements. + // These elements are referred to as blocks. The size of a block may vary + // from system to system. + support::ulittle32_t BlockSize; + // The index of the free block map. + support::ulittle32_t FreeBlockMapBlock; + // This contains the number of blocks resident in the file system. In + // practice, NumBlocks * BlockSize is equivalent to the size of the MSF + // file. + support::ulittle32_t NumBlocks; + // This contains the number of bytes which make up the directory. + support::ulittle32_t NumDirectoryBytes; + // This field's purpose is not yet known. + support::ulittle32_t Unknown1; + // This contains the block # of the block map. + support::ulittle32_t BlockMapAddr; +}; + +struct MSFLayout { + MSFLayout() = default; + + uint32_t mainFpmBlock() const { + assert(SB->FreeBlockMapBlock == 1 || SB->FreeBlockMapBlock == 2); + return SB->FreeBlockMapBlock; + } + + uint32_t alternateFpmBlock() const { + // If mainFpmBlock is 1, this is 2. If mainFpmBlock is 2, this is 1. + return 3U - mainFpmBlock(); + } + + const SuperBlock *SB = nullptr; + BitVector FreePageMap; + ArrayRef<support::ulittle32_t> DirectoryBlocks; + ArrayRef<support::ulittle32_t> StreamSizes; + std::vector<ArrayRef<support::ulittle32_t>> StreamMap; +}; + +/// Describes the layout of a stream in an MSF layout. A "stream" here +/// is defined as any logical unit of data which may be arranged inside the MSF +/// file as a sequence of (possibly discontiguous) blocks. When we want to read +/// from a particular MSF Stream, we fill out a stream layout structure and the +/// reader uses it to determine which blocks in the underlying MSF file contain +/// the data, so that it can be pieced together in the right order. +class MSFStreamLayout { +public: + uint32_t Length; + std::vector<support::ulittle32_t> Blocks; +}; + +/// Determine the layout of the FPM stream, given the MSF layout. An FPM +/// stream spans 1 or more blocks, each at equally spaced intervals throughout +/// the file. +MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, + bool IncludeUnusedFpmData = false, + bool AltFpm = false); + +inline bool isValidBlockSize(uint32_t Size) { + switch (Size) { + case 512: + case 1024: + case 2048: + case 4096: + return true; + } + return false; +} + +// Super Block, Fpm0, Fpm1, and Block Map +inline uint32_t getMinimumBlockCount() { return 4; } + +// Super Block, Fpm0, and Fpm1 are reserved. The Block Map, although required +// need not be at block 3. +inline uint32_t getFirstUnreservedBlock() { return 3; } + +inline uint64_t bytesToBlocks(uint64_t NumBytes, uint64_t BlockSize) { + return divideCeil(NumBytes, BlockSize); +} + +inline uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize) { + return BlockNumber * BlockSize; +} + +inline uint32_t getFpmIntervalLength(const MSFLayout &L) { + return L.SB->BlockSize; +} + +/// Given an MSF with the specified block size and number of blocks, determine +/// how many pieces the specified Fpm is split into. +/// \p BlockSize - the block size of the MSF +/// \p NumBlocks - the total number of blocks in the MSF +/// \p IncludeUnusedFpmData - When true, this will count every block that is +/// both in the file and matches the form of an FPM block, even if some of +/// those FPM blocks are unused (a single FPM block can describe the +/// allocation status of up to 32,767 blocks, although one appears only +/// every 4,096 blocks). So there are 8x as many blocks that match the +/// form as there are blocks that are necessary to describe the allocation +/// status of the file. When this parameter is false, these extraneous +/// trailing blocks are not counted. +inline uint32_t getNumFpmIntervals(uint32_t BlockSize, uint32_t NumBlocks, + bool IncludeUnusedFpmData, int FpmNumber) { + assert(FpmNumber == 1 || FpmNumber == 2); + if (IncludeUnusedFpmData) { + // This calculation determines how many times a number of the form + // BlockSize * k + N appears in the range [0, NumBlocks). We only need to + // do this when unused data is included, since the number of blocks dwarfs + // the number of fpm blocks. + return divideCeil(NumBlocks - FpmNumber, BlockSize); + } + + // We want the minimum number of intervals required, where each interval can + // represent BlockSize * 8 blocks. + return divideCeil(NumBlocks, 8 * BlockSize); +} + +inline uint32_t getNumFpmIntervals(const MSFLayout &L, + bool IncludeUnusedFpmData = false, + bool AltFpm = false) { + return getNumFpmIntervals(L.SB->BlockSize, L.SB->NumBlocks, + IncludeUnusedFpmData, + AltFpm ? L.alternateFpmBlock() : L.mainFpmBlock()); +} + +Error validateSuperBlock(const SuperBlock &SB); + +} // end namespace msf +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFError.h b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFError.h index 71e3fc291d..49bb10586c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFError.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MSFError.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MSFError.h - Error extensions for MSF Files --------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_MSF_MSFERROR_H -#define LLVM_DEBUGINFO_MSF_MSFERROR_H - -#include "llvm/Support/Error.h" - -#include <string> - -namespace llvm { -namespace msf { -enum class msf_error_code { - unspecified = 1, - insufficient_buffer, - not_writable, - no_stream, - invalid_format, - block_in_use -}; -} // namespace msf -} // namespace llvm - -namespace std { -template <> -struct is_error_code_enum<llvm::msf::msf_error_code> : std::true_type {}; -} // namespace std - -namespace llvm { -namespace msf { -const std::error_category &MSFErrCategory(); - -inline std::error_code make_error_code(msf_error_code E) { - return std::error_code(static_cast<int>(E), MSFErrCategory()); -} - -/// Base class for errors originating when parsing raw PDB files -class MSFError : public ErrorInfo<MSFError, StringError> { -public: - using ErrorInfo<MSFError, StringError>::ErrorInfo; // inherit constructors - MSFError(const Twine &S) : ErrorInfo(S, msf_error_code::unspecified) {} - static char ID; -}; -} // namespace msf -} // namespace llvm - -#endif // LLVM_DEBUGINFO_MSF_MSFERROR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MSFError.h - Error extensions for MSF Files --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_MSF_MSFERROR_H +#define LLVM_DEBUGINFO_MSF_MSFERROR_H + +#include "llvm/Support/Error.h" + +#include <string> + +namespace llvm { +namespace msf { +enum class msf_error_code { + unspecified = 1, + insufficient_buffer, + not_writable, + no_stream, + invalid_format, + block_in_use +}; +} // namespace msf +} // namespace llvm + +namespace std { +template <> +struct is_error_code_enum<llvm::msf::msf_error_code> : std::true_type {}; +} // namespace std + +namespace llvm { +namespace msf { +const std::error_category &MSFErrCategory(); + +inline std::error_code make_error_code(msf_error_code E) { + return std::error_code(static_cast<int>(E), MSFErrCategory()); +} + +/// Base class for errors originating when parsing raw PDB files +class MSFError : public ErrorInfo<MSFError, StringError> { +public: + using ErrorInfo<MSFError, StringError>::ErrorInfo; // inherit constructors + MSFError(const Twine &S) : ErrorInfo(S, msf_error_code::unspecified) {} + static char ID; +}; +} // namespace msf +} // namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_MSFERROR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MappedBlockStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MappedBlockStream.h index 0aa3d887cd..6f48fae6f1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MappedBlockStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/MSF/MappedBlockStream.h @@ -1,171 +1,171 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- MappedBlockStream.h - Discontiguous stream data in an MSF --*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H -#define LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/DebugInfo/MSF/MSFCommon.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryStream.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <memory> -#include <vector> - -namespace llvm { -namespace msf { - -/// MappedBlockStream represents data stored in an MSF file into chunks of a -/// particular size (called the Block Size), and whose chunks may not be -/// necessarily contiguous. The arrangement of these chunks MSF the file -/// is described by some other metadata contained within the MSF file. In -/// the case of a standard MSF Stream, the layout of the stream's blocks -/// is described by the MSF "directory", but in the case of the directory -/// itself, the layout is described by an array at a fixed location within -/// the MSF. MappedBlockStream provides methods for reading from and writing -/// to one of these streams transparently, as if it were a contiguous sequence -/// of bytes. -class MappedBlockStream : public BinaryStream { - friend class WritableMappedBlockStream; - -public: - static std::unique_ptr<MappedBlockStream> - createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, - BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - - static std::unique_ptr<MappedBlockStream> - createIndexedStream(const MSFLayout &Layout, BinaryStreamRef MsfData, - uint32_t StreamIndex, BumpPtrAllocator &Allocator); - - static std::unique_ptr<MappedBlockStream> - createFpmStream(const MSFLayout &Layout, BinaryStreamRef MsfData, - BumpPtrAllocator &Allocator); - - static std::unique_ptr<MappedBlockStream> - createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, - BumpPtrAllocator &Allocator); - - support::endianness getEndian() const override { - return support::little; - } - - Error readBytes(uint32_t Offset, uint32_t Size, - ArrayRef<uint8_t> &Buffer) override; - Error readLongestContiguousChunk(uint32_t Offset, - ArrayRef<uint8_t> &Buffer) override; - - uint32_t getLength() override; - - BumpPtrAllocator &getAllocator() { return Allocator; } - - void invalidateCache(); - - uint32_t getBlockSize() const { return BlockSize; } - uint32_t getNumBlocks() const { return StreamLayout.Blocks.size(); } - uint32_t getStreamLength() const { return StreamLayout.Length; } - -protected: - MappedBlockStream(uint32_t BlockSize, const MSFStreamLayout &StreamLayout, - BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - -private: - const MSFStreamLayout &getStreamLayout() const { return StreamLayout; } - void fixCacheAfterWrite(uint32_t Offset, ArrayRef<uint8_t> Data) const; - - Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer); - bool tryReadContiguously(uint32_t Offset, uint32_t Size, - ArrayRef<uint8_t> &Buffer); - - const uint32_t BlockSize; - const MSFStreamLayout StreamLayout; - BinaryStreamRef MsfData; - - using CacheEntry = MutableArrayRef<uint8_t>; - - // We just store the allocator by reference. We use this to allocate - // contiguous memory for things like arrays or strings that cross a block - // boundary, and this memory is expected to outlive the stream. For example, - // someone could create a stream, read some stuff, then close the stream, and - // we would like outstanding references to fields to remain valid since the - // entire file is mapped anyway. Because of that, the user must supply the - // allocator to allocate broken records from. - BumpPtrAllocator &Allocator; - DenseMap<uint32_t, std::vector<CacheEntry>> CacheMap; -}; - -class WritableMappedBlockStream : public WritableBinaryStream { -public: - static std::unique_ptr<WritableMappedBlockStream> - createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, - WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - - static std::unique_ptr<WritableMappedBlockStream> - createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, - uint32_t StreamIndex, BumpPtrAllocator &Allocator); - - static std::unique_ptr<WritableMappedBlockStream> - createDirectoryStream(const MSFLayout &Layout, - WritableBinaryStreamRef MsfData, - BumpPtrAllocator &Allocator); - - static std::unique_ptr<WritableMappedBlockStream> - createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, - BumpPtrAllocator &Allocator, bool AltFpm = false); - - support::endianness getEndian() const override { - return support::little; - } - - Error readBytes(uint32_t Offset, uint32_t Size, - ArrayRef<uint8_t> &Buffer) override; - Error readLongestContiguousChunk(uint32_t Offset, - ArrayRef<uint8_t> &Buffer) override; - uint32_t getLength() override; - - Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) override; - - Error commit() override; - - const MSFStreamLayout &getStreamLayout() const { - return ReadInterface.getStreamLayout(); - } - - uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); } - uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); } - uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); } - -protected: - WritableMappedBlockStream(uint32_t BlockSize, - const MSFStreamLayout &StreamLayout, - WritableBinaryStreamRef MsfData, - BumpPtrAllocator &Allocator); - -private: - MappedBlockStream ReadInterface; - WritableBinaryStreamRef WriteInterface; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- MappedBlockStream.h - Discontiguous stream data in an MSF --*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H +#define LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/DebugInfo/MSF/MSFCommon.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryStream.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { +namespace msf { + +/// MappedBlockStream represents data stored in an MSF file into chunks of a +/// particular size (called the Block Size), and whose chunks may not be +/// necessarily contiguous. The arrangement of these chunks MSF the file +/// is described by some other metadata contained within the MSF file. In +/// the case of a standard MSF Stream, the layout of the stream's blocks +/// is described by the MSF "directory", but in the case of the directory +/// itself, the layout is described by an array at a fixed location within +/// the MSF. MappedBlockStream provides methods for reading from and writing +/// to one of these streams transparently, as if it were a contiguous sequence +/// of bytes. +class MappedBlockStream : public BinaryStream { + friend class WritableMappedBlockStream; + +public: + static std::unique_ptr<MappedBlockStream> + createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, + BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); + + static std::unique_ptr<MappedBlockStream> + createIndexedStream(const MSFLayout &Layout, BinaryStreamRef MsfData, + uint32_t StreamIndex, BumpPtrAllocator &Allocator); + + static std::unique_ptr<MappedBlockStream> + createFpmStream(const MSFLayout &Layout, BinaryStreamRef MsfData, + BumpPtrAllocator &Allocator); + + static std::unique_ptr<MappedBlockStream> + createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, + BumpPtrAllocator &Allocator); + + support::endianness getEndian() const override { + return support::little; + } + + Error readBytes(uint32_t Offset, uint32_t Size, + ArrayRef<uint8_t> &Buffer) override; + Error readLongestContiguousChunk(uint32_t Offset, + ArrayRef<uint8_t> &Buffer) override; + + uint32_t getLength() override; + + BumpPtrAllocator &getAllocator() { return Allocator; } + + void invalidateCache(); + + uint32_t getBlockSize() const { return BlockSize; } + uint32_t getNumBlocks() const { return StreamLayout.Blocks.size(); } + uint32_t getStreamLength() const { return StreamLayout.Length; } + +protected: + MappedBlockStream(uint32_t BlockSize, const MSFStreamLayout &StreamLayout, + BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); + +private: + const MSFStreamLayout &getStreamLayout() const { return StreamLayout; } + void fixCacheAfterWrite(uint32_t Offset, ArrayRef<uint8_t> Data) const; + + Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer); + bool tryReadContiguously(uint32_t Offset, uint32_t Size, + ArrayRef<uint8_t> &Buffer); + + const uint32_t BlockSize; + const MSFStreamLayout StreamLayout; + BinaryStreamRef MsfData; + + using CacheEntry = MutableArrayRef<uint8_t>; + + // We just store the allocator by reference. We use this to allocate + // contiguous memory for things like arrays or strings that cross a block + // boundary, and this memory is expected to outlive the stream. For example, + // someone could create a stream, read some stuff, then close the stream, and + // we would like outstanding references to fields to remain valid since the + // entire file is mapped anyway. Because of that, the user must supply the + // allocator to allocate broken records from. + BumpPtrAllocator &Allocator; + DenseMap<uint32_t, std::vector<CacheEntry>> CacheMap; +}; + +class WritableMappedBlockStream : public WritableBinaryStream { +public: + static std::unique_ptr<WritableMappedBlockStream> + createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, + WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator); + + static std::unique_ptr<WritableMappedBlockStream> + createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, + uint32_t StreamIndex, BumpPtrAllocator &Allocator); + + static std::unique_ptr<WritableMappedBlockStream> + createDirectoryStream(const MSFLayout &Layout, + WritableBinaryStreamRef MsfData, + BumpPtrAllocator &Allocator); + + static std::unique_ptr<WritableMappedBlockStream> + createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, + BumpPtrAllocator &Allocator, bool AltFpm = false); + + support::endianness getEndian() const override { + return support::little; + } + + Error readBytes(uint32_t Offset, uint32_t Size, + ArrayRef<uint8_t> &Buffer) override; + Error readLongestContiguousChunk(uint32_t Offset, + ArrayRef<uint8_t> &Buffer) override; + uint32_t getLength() override; + + Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) override; + + Error commit() override; + + const MSFStreamLayout &getStreamLayout() const { + return ReadInterface.getStreamLayout(); + } + + uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); } + uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); } + uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); } + +protected: + WritableMappedBlockStream(uint32_t BlockSize, + const MSFStreamLayout &StreamLayout, + WritableBinaryStreamRef MsfData, + BumpPtrAllocator &Allocator); + +private: + MappedBlockStream ReadInterface; + WritableBinaryStreamRef WriteInterface; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h index f45c094c69..4947b3ae40 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h @@ -1,64 +1,64 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- ConcreteSymbolEnumerator.h -------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H -#define LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H - -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/Casting.h" -#include <algorithm> -#include <cstdint> -#include <memory> - -namespace llvm { -namespace pdb { - -template <typename ChildType> -class ConcreteSymbolEnumerator : public IPDBEnumChildren<ChildType> { -public: - ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator) - : Enumerator(std::move(SymbolEnumerator)) {} - - ~ConcreteSymbolEnumerator() override = default; - - uint32_t getChildCount() const override { - return Enumerator->getChildCount(); - } - - std::unique_ptr<ChildType> getChildAtIndex(uint32_t Index) const override { - std::unique_ptr<PDBSymbol> Child = Enumerator->getChildAtIndex(Index); - return unique_dyn_cast_or_null<ChildType>(Child); - } - - std::unique_ptr<ChildType> getNext() override { - return unique_dyn_cast_or_null<ChildType>(Enumerator->getNext()); - } - - void reset() override { Enumerator->reset(); } - -private: - - std::unique_ptr<IPDBEnumSymbols> Enumerator; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- ConcreteSymbolEnumerator.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H +#define LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H + +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/Casting.h" +#include <algorithm> +#include <cstdint> +#include <memory> + +namespace llvm { +namespace pdb { + +template <typename ChildType> +class ConcreteSymbolEnumerator : public IPDBEnumChildren<ChildType> { +public: + ConcreteSymbolEnumerator(std::unique_ptr<IPDBEnumSymbols> SymbolEnumerator) + : Enumerator(std::move(SymbolEnumerator)) {} + + ~ConcreteSymbolEnumerator() override = default; + + uint32_t getChildCount() const override { + return Enumerator->getChildCount(); + } + + std::unique_ptr<ChildType> getChildAtIndex(uint32_t Index) const override { + std::unique_ptr<PDBSymbol> Child = Enumerator->getChildAtIndex(Index); + return unique_dyn_cast_or_null<ChildType>(Child); + } + + std::unique_ptr<ChildType> getNext() override { + return unique_dyn_cast_or_null<ChildType>(Enumerator->getNext()); + } + + void reset() override { Enumerator->reset(); } + +private: + + std::unique_ptr<IPDBEnumSymbols> Enumerator; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_CONCRETESYMBOLENUMERATOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h index 4e89678162..f9a0fe9433 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIADataStream.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIADataStream.h - DIA implementation of IPDBDataStream ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIADATASTREAM_H -#define LLVM_DEBUGINFO_PDB_DIA_DIADATASTREAM_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBDataStream.h" - -namespace llvm { -namespace pdb { -class DIADataStream : public IPDBDataStream { -public: - explicit DIADataStream(CComPtr<IDiaEnumDebugStreamData> DiaStreamData); - - uint32_t getRecordCount() const override; - std::string getName() const override; - llvm::Optional<RecordType> getItemAtIndex(uint32_t Index) const override; - bool getNext(RecordType &Record) override; - void reset() override; - -private: - CComPtr<IDiaEnumDebugStreamData> StreamData; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIADataStream.h - DIA implementation of IPDBDataStream ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIADATASTREAM_H +#define LLVM_DEBUGINFO_PDB_DIA_DIADATASTREAM_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBDataStream.h" + +namespace llvm { +namespace pdb { +class DIADataStream : public IPDBDataStream { +public: + explicit DIADataStream(CComPtr<IDiaEnumDebugStreamData> DiaStreamData); + + uint32_t getRecordCount() const override; + std::string getName() const override; + llvm::Optional<RecordType> getItemAtIndex(uint32_t Index) const override; + bool getNext(RecordType &Record) override; + void reset() override; + +private: + CComPtr<IDiaEnumDebugStreamData> StreamData; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h index bb82abc709..7b0bdd2384 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h @@ -1,47 +1,47 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumDebugStreams.h - DIA Debug Stream Enumerator impl ---*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMDEBUGSTREAMS_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMDEBUGSTREAMS_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBDataStream.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" - -namespace llvm { -namespace pdb { - -class IPDBDataStream; - -class DIAEnumDebugStreams : public IPDBEnumChildren<IPDBDataStream> { -public: - explicit DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - CComPtr<IDiaEnumDebugStreams> Enumerator; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumDebugStreams.h - DIA Debug Stream Enumerator impl ---*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMDEBUGSTREAMS_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMDEBUGSTREAMS_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBDataStream.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" + +namespace llvm { +namespace pdb { + +class IPDBDataStream; + +class DIAEnumDebugStreams : public IPDBEnumChildren<IPDBDataStream> { +public: + explicit DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + CComPtr<IDiaEnumDebugStreams> Enumerator; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h index 64606a091b..ccaccaa887 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumFrameData.h --------------------------------------- -*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBFrameData.h" - -namespace llvm { -namespace pdb { - -class DIAEnumFrameData : public IPDBEnumChildren<IPDBFrameData> { -public: - explicit DIAEnumFrameData(CComPtr<IDiaEnumFrameData> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - CComPtr<IDiaEnumFrameData> Enumerator; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumFrameData.h --------------------------------------- -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMFRAMEDATA_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBFrameData.h" + +namespace llvm { +namespace pdb { + +class DIAEnumFrameData : public IPDBEnumChildren<IPDBFrameData> { +public: + explicit DIAEnumFrameData(CComPtr<IDiaEnumFrameData> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + CComPtr<IDiaEnumFrameData> Enumerator; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h index 1545936ce1..4776d02f47 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumInjectedSources.h - DIA Injected Sources Enumerator -*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" - -namespace llvm { -namespace pdb { - -class DIAEnumInjectedSources : public IPDBEnumChildren<IPDBInjectedSource> { -public: - explicit DIAEnumInjectedSources( - CComPtr<IDiaEnumInjectedSources> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - CComPtr<IDiaEnumInjectedSources> Enumerator; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumInjectedSources.h - DIA Injected Sources Enumerator -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" + +namespace llvm { +namespace pdb { + +class DIAEnumInjectedSources : public IPDBEnumChildren<IPDBInjectedSource> { +public: + explicit DIAEnumInjectedSources( + CComPtr<IDiaEnumInjectedSources> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + CComPtr<IDiaEnumInjectedSources> Enumerator; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMINJECTEDSOURCES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h index b46349fdc8..21dbc4b127 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumLineNumbers.h - DIA Line Number Enumerator impl -----*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMLINENUMBERS_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMLINENUMBERS_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" - -namespace llvm { -namespace pdb { -class IPDBLineNumber; - -class DIAEnumLineNumbers : public IPDBEnumChildren<IPDBLineNumber> { -public: - explicit DIAEnumLineNumbers(CComPtr<IDiaEnumLineNumbers> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - CComPtr<IDiaEnumLineNumbers> Enumerator; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumLineNumbers.h - DIA Line Number Enumerator impl -----*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMLINENUMBERS_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMLINENUMBERS_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" + +namespace llvm { +namespace pdb { +class IPDBLineNumber; + +class DIAEnumLineNumbers : public IPDBEnumChildren<IPDBLineNumber> { +public: + explicit DIAEnumLineNumbers(CComPtr<IDiaEnumLineNumbers> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + CComPtr<IDiaEnumLineNumbers> Enumerator; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h index 1a7bdcf0ff..2e44bb48ac 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h @@ -1,49 +1,49 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumSectionContribs.h --------------------------------- -*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBSectionContrib.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIAEnumSectionContribs : public IPDBEnumChildren<IPDBSectionContrib> { -public: - explicit DIAEnumSectionContribs( - const DIASession &PDBSession, - CComPtr<IDiaEnumSectionContribs> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - const DIASession &Session; - CComPtr<IDiaEnumSectionContribs> Enumerator; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumSectionContribs.h --------------------------------- -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBSectionContrib.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIAEnumSectionContribs : public IPDBEnumChildren<IPDBSectionContrib> { +public: + explicit DIAEnumSectionContribs( + const DIASession &PDBSession, + CComPtr<IDiaEnumSectionContribs> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + const DIASession &Session; + CComPtr<IDiaEnumSectionContribs> Enumerator; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMSECTIONCONTRIBS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h index 940d5c877e..43ea2df383 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumSourceFiles.h - DIA Source File Enumerator impl -----*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSOURCEFILES_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSOURCEFILES_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIAEnumSourceFiles : public IPDBEnumChildren<IPDBSourceFile> { -public: - explicit DIAEnumSourceFiles(const DIASession &PDBSession, - CComPtr<IDiaEnumSourceFiles> DiaEnumerator); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - const DIASession &Session; - CComPtr<IDiaEnumSourceFiles> Enumerator; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumSourceFiles.h - DIA Source File Enumerator impl -----*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSOURCEFILES_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSOURCEFILES_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIAEnumSourceFiles : public IPDBEnumChildren<IPDBSourceFile> { +public: + explicit DIAEnumSourceFiles(const DIASession &PDBSession, + CComPtr<IDiaEnumSourceFiles> DiaEnumerator); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + const DIASession &Session; + CComPtr<IDiaEnumSourceFiles> Enumerator; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h index 3fb995ce5e..d8df677665 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- DIAEnumSymbols.h - DIA Symbol Enumerator impl --------------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSYMBOLS_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSYMBOLS_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIAEnumSymbols : public IPDBEnumChildren<PDBSymbol> { -public: - explicit DIAEnumSymbols(const DIASession &Session, - CComPtr<IDiaEnumSymbols> DiaEnumerator); - - uint32_t getChildCount() const override; - std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<PDBSymbol> getNext() override; - void reset() override; - -private: - const DIASession &Session; - CComPtr<IDiaEnumSymbols> Enumerator; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- DIAEnumSymbols.h - DIA Symbol Enumerator impl --------------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMSYMBOLS_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMSYMBOLS_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIAEnumSymbols : public IPDBEnumChildren<PDBSymbol> { +public: + explicit DIAEnumSymbols(const DIASession &Session, + CComPtr<IDiaEnumSymbols> DiaEnumerator); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + +private: + const DIASession &Session; + CComPtr<IDiaEnumSymbols> Enumerator; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h index 24579ae7cc..b4d41eb392 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIAEnumTables.h - DIA Tables Enumerator Impl -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBTable.h" - -namespace llvm { -namespace pdb { -class IPDBTable; - -class DIAEnumTables : public IPDBEnumChildren<IPDBTable> { -public: - explicit DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator); - - uint32_t getChildCount() const override; - std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<IPDBTable> getNext() override; - void reset() override; - -private: - CComPtr<IDiaEnumTables> Enumerator; -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIAEnumTables.h - DIA Tables Enumerator Impl -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBTable.h" + +namespace llvm { +namespace pdb { +class IPDBTable; + +class DIAEnumTables : public IPDBEnumChildren<IPDBTable> { +public: + explicit DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator); + + uint32_t getChildCount() const override; + std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<IPDBTable> getNext() override; + void reset() override; + +private: + CComPtr<IDiaEnumTables> Enumerator; +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAError.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAError.h index b69324fbc0..0c3342967e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAError.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAError.h @@ -1,61 +1,61 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIAError.h - Error extensions for PDB DIA implementation -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAERROR_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAERROR_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { -enum class dia_error_code { - unspecified = 1, - could_not_create_impl, - invalid_file_format, - invalid_parameter, - already_loaded, - debug_info_mismatch, -}; -} // namespace pdb -} // namespace llvm - -namespace std { -template <> -struct is_error_code_enum<llvm::pdb::dia_error_code> : std::true_type {}; -} // namespace std - -namespace llvm { -namespace pdb { -const std::error_category &DIAErrCategory(); - -inline std::error_code make_error_code(dia_error_code E) { - return std::error_code(static_cast<int>(E), DIAErrCategory()); -} - -/// Base class for errors originating in DIA SDK, e.g. COM calls -class DIAError : public ErrorInfo<DIAError, StringError> { -public: - using ErrorInfo<DIAError, StringError>::ErrorInfo; - DIAError(const Twine &S) : ErrorInfo(S, dia_error_code::unspecified) {} - static char ID; -}; -} // namespace pdb -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIAError.h - Error extensions for PDB DIA implementation -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAERROR_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAERROR_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { +enum class dia_error_code { + unspecified = 1, + could_not_create_impl, + invalid_file_format, + invalid_parameter, + already_loaded, + debug_info_mismatch, +}; +} // namespace pdb +} // namespace llvm + +namespace std { +template <> +struct is_error_code_enum<llvm::pdb::dia_error_code> : std::true_type {}; +} // namespace std + +namespace llvm { +namespace pdb { +const std::error_category &DIAErrCategory(); + +inline std::error_code make_error_code(dia_error_code E) { + return std::error_code(static_cast<int>(E), DIAErrCategory()); +} + +/// Base class for errors originating in DIA SDK, e.g. COM calls +class DIAError : public ErrorInfo<DIAError, StringError> { +public: + using ErrorInfo<DIAError, StringError>::ErrorInfo; + DIAError(const Twine &S) : ErrorInfo(S, dia_error_code::unspecified) {} + static char ID; +}; +} // namespace pdb +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h index 5ef18c2801..104017577f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAFrameData.h @@ -1,49 +1,49 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIAFrameData.h - DIA Impl. of IPDBFrameData ---------------- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBFrameData.h" - -namespace llvm { -namespace pdb { - -class DIASession; - -class DIAFrameData : public IPDBFrameData { -public: - explicit DIAFrameData(CComPtr<IDiaFrameData> DiaFrameData); - - uint32_t getAddressOffset() const override; - uint32_t getAddressSection() const override; - uint32_t getLengthBlock() const override; - std::string getProgram() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; - -private: - CComPtr<IDiaFrameData> FrameData; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIAFrameData.h - DIA Impl. of IPDBFrameData ---------------- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAFRAMEDATA_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBFrameData.h" + +namespace llvm { +namespace pdb { + +class DIASession; + +class DIAFrameData : public IPDBFrameData { +public: + explicit DIAFrameData(CComPtr<IDiaFrameData> DiaFrameData); + + uint32_t getAddressOffset() const override; + uint32_t getAddressSection() const override; + uint32_t getLengthBlock() const override; + std::string getProgram() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; + +private: + CComPtr<IDiaFrameData> FrameData; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h index 0c16b053c7..fd1732f811 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIAInjectedSource.h - DIA impl for IPDBInjectedSource ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIAInjectedSource : public IPDBInjectedSource { -public: - explicit DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile); - - uint32_t getCrc32() const override; - uint64_t getCodeByteSize() const override; - std::string getFileName() const override; - std::string getObjectFileName() const override; - std::string getVirtualFileName() const override; - uint32_t getCompression() const override; - std::string getCode() const override; - -private: - CComPtr<IDiaInjectedSource> SourceFile; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIAInjectedSource.h - DIA impl for IPDBInjectedSource ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIAInjectedSource : public IPDBInjectedSource { +public: + explicit DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile); + + uint32_t getCrc32() const override; + uint64_t getCodeByteSize() const override; + std::string getFileName() const override; + std::string getObjectFileName() const override; + std::string getVirtualFileName() const override; + uint32_t getCompression() const override; + std::string getCode() const override; + +private: + CComPtr<IDiaInjectedSource> SourceFile; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIAINJECTEDSOURCE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIALineNumber.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIALineNumber.h index e4342e4543..42db84a6ea 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIALineNumber.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIALineNumber.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIALineNumber.h - DIA implementation of IPDBLineNumber ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIALINENUMBER_H -#define LLVM_DEBUGINFO_PDB_DIA_DIALINENUMBER_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" - -namespace llvm { -namespace pdb { -class DIALineNumber : public IPDBLineNumber { -public: - explicit DIALineNumber(CComPtr<IDiaLineNumber> DiaLineNumber); - - uint32_t getLineNumber() const override; - uint32_t getLineNumberEnd() const override; - uint32_t getColumnNumber() const override; - uint32_t getColumnNumberEnd() const override; - uint32_t getAddressSection() const override; - uint32_t getAddressOffset() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; - uint32_t getLength() const override; - uint32_t getSourceFileId() const override; - uint32_t getCompilandId() const override; - bool isStatement() const override; - -private: - CComPtr<IDiaLineNumber> LineNumber; -}; -} -} -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIALineNumber.h - DIA implementation of IPDBLineNumber ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIALINENUMBER_H +#define LLVM_DEBUGINFO_PDB_DIA_DIALINENUMBER_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" + +namespace llvm { +namespace pdb { +class DIALineNumber : public IPDBLineNumber { +public: + explicit DIALineNumber(CComPtr<IDiaLineNumber> DiaLineNumber); + + uint32_t getLineNumber() const override; + uint32_t getLineNumberEnd() const override; + uint32_t getColumnNumber() const override; + uint32_t getColumnNumberEnd() const override; + uint32_t getAddressSection() const override; + uint32_t getAddressOffset() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; + uint32_t getLength() const override; + uint32_t getSourceFileId() const override; + uint32_t getCompilandId() const override; + bool isStatement() const override; + +private: + CComPtr<IDiaLineNumber> LineNumber; +}; +} +} +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h index 5a194051b3..0b3c91431b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h @@ -1,244 +1,244 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIARawSymbol.h - DIA implementation of IPDBRawSymbol ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIARAWSYMBOL_H -#define LLVM_DEBUGINFO_PDB_DIA_DIARAWSYMBOL_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" - -namespace llvm { -namespace pdb { -class DIASession; -class DIARawSymbol : public IPDBRawSymbol { -public: - DIARawSymbol(const DIASession &PDBSession, CComPtr<IDiaSymbol> DiaSymbol); - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - CComPtr<IDiaSymbol> getDiaSymbol() const { return Symbol; } - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByAddr(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags, - uint32_t Section, uint32_t Offset) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint64_t VA) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint32_t RVA) const override; - - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const override; - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByRVA(uint32_t RVA) const override; - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByVA(uint64_t VA) const override; - - std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, - uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override; - - void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const override; - void getFrontEndVersion(VersionInfo &Version) const override; - void getBackEndVersion(VersionInfo &Version) const override; - PDB_MemberAccess getAccess() const override; - uint32_t getAddressOffset() const override; - uint32_t getAddressSection() const override; - uint32_t getAge() const override; - SymIndexId getArrayIndexTypeId() const override; - uint32_t getBaseDataOffset() const override; - uint32_t getBaseDataSlot() const override; - SymIndexId getBaseSymbolId() const override; - PDB_BuiltinType getBuiltinType() const override; - uint32_t getBitPosition() const override; - PDB_CallingConv getCallingConvention() const override; - SymIndexId getClassParentId() const override; - std::string getCompilerName() const override; - uint32_t getCount() const override; - uint32_t getCountLiveRanges() const override; - PDB_Lang getLanguage() const override; - SymIndexId getLexicalParentId() const override; - std::string getLibraryName() const override; - uint32_t getLiveRangeStartAddressOffset() const override; - uint32_t getLiveRangeStartAddressSection() const override; - uint32_t getLiveRangeStartRelativeVirtualAddress() const override; - codeview::RegisterId getLocalBasePointerRegisterId() const override; - SymIndexId getLowerBoundId() const override; - uint32_t getMemorySpaceKind() const override; - std::string getName() const override; - uint32_t getNumberOfAcceleratorPointerTags() const override; - uint32_t getNumberOfColumns() const override; - uint32_t getNumberOfModifiers() const override; - uint32_t getNumberOfRegisterIndices() const override; - uint32_t getNumberOfRows() const override; - std::string getObjectFileName() const override; - uint32_t getOemId() const override; - SymIndexId getOemSymbolId() const override; - uint32_t getOffsetInUdt() const override; - PDB_Cpu getPlatform() const override; - uint32_t getRank() const override; - codeview::RegisterId getRegisterId() const override; - uint32_t getRegisterType() const override; - uint32_t getRelativeVirtualAddress() const override; - uint32_t getSamplerSlot() const override; - uint32_t getSignature() const override; - uint32_t getSizeInUdt() const override; - uint32_t getSlot() const override; - std::string getSourceFileName() const override; - std::unique_ptr<IPDBLineNumber> getSrcLineOnTypeDefn() const override; - uint32_t getStride() const override; - SymIndexId getSubTypeId() const override; - std::string getSymbolsFileName() const override; - SymIndexId getSymIndexId() const override; - uint32_t getTargetOffset() const override; - uint32_t getTargetRelativeVirtualAddress() const override; - uint64_t getTargetVirtualAddress() const override; - uint32_t getTargetSection() const override; - uint32_t getTextureSlot() const override; - uint32_t getTimeStamp() const override; - uint32_t getToken() const override; - SymIndexId getTypeId() const override; - uint32_t getUavSlot() const override; - std::string getUndecoratedName() const override; - std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override; - SymIndexId getUnmodifiedTypeId() const override; - SymIndexId getUpperBoundId() const override; - Variant getValue() const override; - uint32_t getVirtualBaseDispIndex() const override; - uint32_t getVirtualBaseOffset() const override; - SymIndexId getVirtualTableShapeId() const override; - std::unique_ptr<PDBSymbolTypeBuiltin> - getVirtualBaseTableType() const override; - PDB_DataKind getDataKind() const override; - PDB_SymType getSymTag() const override; - codeview::GUID getGuid() const override; - int32_t getOffset() const override; - int32_t getThisAdjust() const override; - int32_t getVirtualBasePointerOffset() const override; - PDB_LocType getLocationType() const override; - PDB_Machine getMachineType() const override; - codeview::ThunkOrdinal getThunkOrdinal() const override; - uint64_t getLength() const override; - uint64_t getLiveRangeLength() const override; - uint64_t getVirtualAddress() const override; - PDB_UdtType getUdtKind() const override; - bool hasConstructor() const override; - bool hasCustomCallingConvention() const override; - bool hasFarReturn() const override; - bool isCode() const override; - bool isCompilerGenerated() const override; - bool isConstType() const override; - bool isEditAndContinueEnabled() const override; - bool isFunction() const override; - bool getAddressTaken() const override; - bool getNoStackOrdering() const override; - bool hasAlloca() const override; - bool hasAssignmentOperator() const override; - bool hasCTypes() const override; - bool hasCastOperator() const override; - bool hasDebugInfo() const override; - bool hasEH() const override; - bool hasEHa() const override; - bool hasInlAsm() const override; - bool hasInlineAttribute() const override; - bool hasInterruptReturn() const override; - bool hasFramePointer() const override; - bool hasLongJump() const override; - bool hasManagedCode() const override; - bool hasNestedTypes() const override; - bool hasNoInlineAttribute() const override; - bool hasNoReturnAttribute() const override; - bool hasOptimizedCodeDebugInfo() const override; - bool hasOverloadedOperator() const override; - bool hasSEH() const override; - bool hasSecurityChecks() const override; - bool hasSetJump() const override; - bool hasStrictGSCheck() const override; - bool isAcceleratorGroupSharedLocal() const override; - bool isAcceleratorPointerTagLiveRange() const override; - bool isAcceleratorStubFunction() const override; - bool isAggregated() const override; - bool isIntroVirtualFunction() const override; - bool isCVTCIL() const override; - bool isConstructorVirtualBase() const override; - bool isCxxReturnUdt() const override; - bool isDataAligned() const override; - bool isHLSLData() const override; - bool isHotpatchable() const override; - bool isIndirectVirtualBaseClass() const override; - bool isInterfaceUdt() const override; - bool isIntrinsic() const override; - bool isLTCG() const override; - bool isLocationControlFlowDependent() const override; - bool isMSILNetmodule() const override; - bool isMatrixRowMajor() const override; - bool isManagedCode() const override; - bool isMSILCode() const override; - bool isMultipleInheritance() const override; - bool isNaked() const override; - bool isNested() const override; - bool isOptimizedAway() const override; - bool isPacked() const override; - bool isPointerBasedOnSymbolValue() const override; - bool isPointerToDataMember() const override; - bool isPointerToMemberFunction() const override; - bool isPureVirtual() const override; - bool isRValueReference() const override; - bool isRefUdt() const override; - bool isReference() const override; - bool isRestrictedType() const override; - bool isReturnValue() const override; - bool isSafeBuffers() const override; - bool isScoped() const override; - bool isSdl() const override; - bool isSingleInheritance() const override; - bool isSplitted() const override; - bool isStatic() const override; - bool hasPrivateSymbols() const override; - bool isUnalignedType() const override; - bool isUnreached() const override; - bool isValueUdt() const override; - bool isVirtual() const override; - bool isVirtualBaseClass() const override; - bool isVirtualInheritance() const override; - bool isVolatileType() const override; - bool wasInlined() const override; - std::string getUnused() const override; - -private: - const DIASession &Session; - CComPtr<IDiaSymbol> Symbol; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIARawSymbol.h - DIA implementation of IPDBRawSymbol ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIARAWSYMBOL_H +#define LLVM_DEBUGINFO_PDB_DIA_DIARAWSYMBOL_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" + +namespace llvm { +namespace pdb { +class DIASession; +class DIARawSymbol : public IPDBRawSymbol { +public: + DIARawSymbol(const DIASession &PDBSession, CComPtr<IDiaSymbol> DiaSymbol); + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + CComPtr<IDiaSymbol> getDiaSymbol() const { return Symbol; } + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByAddr(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags, + uint32_t Section, uint32_t Offset) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint64_t VA) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint32_t RVA) const override; + + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const override; + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByRVA(uint32_t RVA) const override; + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByVA(uint64_t VA) const override; + + std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, + uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override; + + void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const override; + void getFrontEndVersion(VersionInfo &Version) const override; + void getBackEndVersion(VersionInfo &Version) const override; + PDB_MemberAccess getAccess() const override; + uint32_t getAddressOffset() const override; + uint32_t getAddressSection() const override; + uint32_t getAge() const override; + SymIndexId getArrayIndexTypeId() const override; + uint32_t getBaseDataOffset() const override; + uint32_t getBaseDataSlot() const override; + SymIndexId getBaseSymbolId() const override; + PDB_BuiltinType getBuiltinType() const override; + uint32_t getBitPosition() const override; + PDB_CallingConv getCallingConvention() const override; + SymIndexId getClassParentId() const override; + std::string getCompilerName() const override; + uint32_t getCount() const override; + uint32_t getCountLiveRanges() const override; + PDB_Lang getLanguage() const override; + SymIndexId getLexicalParentId() const override; + std::string getLibraryName() const override; + uint32_t getLiveRangeStartAddressOffset() const override; + uint32_t getLiveRangeStartAddressSection() const override; + uint32_t getLiveRangeStartRelativeVirtualAddress() const override; + codeview::RegisterId getLocalBasePointerRegisterId() const override; + SymIndexId getLowerBoundId() const override; + uint32_t getMemorySpaceKind() const override; + std::string getName() const override; + uint32_t getNumberOfAcceleratorPointerTags() const override; + uint32_t getNumberOfColumns() const override; + uint32_t getNumberOfModifiers() const override; + uint32_t getNumberOfRegisterIndices() const override; + uint32_t getNumberOfRows() const override; + std::string getObjectFileName() const override; + uint32_t getOemId() const override; + SymIndexId getOemSymbolId() const override; + uint32_t getOffsetInUdt() const override; + PDB_Cpu getPlatform() const override; + uint32_t getRank() const override; + codeview::RegisterId getRegisterId() const override; + uint32_t getRegisterType() const override; + uint32_t getRelativeVirtualAddress() const override; + uint32_t getSamplerSlot() const override; + uint32_t getSignature() const override; + uint32_t getSizeInUdt() const override; + uint32_t getSlot() const override; + std::string getSourceFileName() const override; + std::unique_ptr<IPDBLineNumber> getSrcLineOnTypeDefn() const override; + uint32_t getStride() const override; + SymIndexId getSubTypeId() const override; + std::string getSymbolsFileName() const override; + SymIndexId getSymIndexId() const override; + uint32_t getTargetOffset() const override; + uint32_t getTargetRelativeVirtualAddress() const override; + uint64_t getTargetVirtualAddress() const override; + uint32_t getTargetSection() const override; + uint32_t getTextureSlot() const override; + uint32_t getTimeStamp() const override; + uint32_t getToken() const override; + SymIndexId getTypeId() const override; + uint32_t getUavSlot() const override; + std::string getUndecoratedName() const override; + std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override; + SymIndexId getUnmodifiedTypeId() const override; + SymIndexId getUpperBoundId() const override; + Variant getValue() const override; + uint32_t getVirtualBaseDispIndex() const override; + uint32_t getVirtualBaseOffset() const override; + SymIndexId getVirtualTableShapeId() const override; + std::unique_ptr<PDBSymbolTypeBuiltin> + getVirtualBaseTableType() const override; + PDB_DataKind getDataKind() const override; + PDB_SymType getSymTag() const override; + codeview::GUID getGuid() const override; + int32_t getOffset() const override; + int32_t getThisAdjust() const override; + int32_t getVirtualBasePointerOffset() const override; + PDB_LocType getLocationType() const override; + PDB_Machine getMachineType() const override; + codeview::ThunkOrdinal getThunkOrdinal() const override; + uint64_t getLength() const override; + uint64_t getLiveRangeLength() const override; + uint64_t getVirtualAddress() const override; + PDB_UdtType getUdtKind() const override; + bool hasConstructor() const override; + bool hasCustomCallingConvention() const override; + bool hasFarReturn() const override; + bool isCode() const override; + bool isCompilerGenerated() const override; + bool isConstType() const override; + bool isEditAndContinueEnabled() const override; + bool isFunction() const override; + bool getAddressTaken() const override; + bool getNoStackOrdering() const override; + bool hasAlloca() const override; + bool hasAssignmentOperator() const override; + bool hasCTypes() const override; + bool hasCastOperator() const override; + bool hasDebugInfo() const override; + bool hasEH() const override; + bool hasEHa() const override; + bool hasInlAsm() const override; + bool hasInlineAttribute() const override; + bool hasInterruptReturn() const override; + bool hasFramePointer() const override; + bool hasLongJump() const override; + bool hasManagedCode() const override; + bool hasNestedTypes() const override; + bool hasNoInlineAttribute() const override; + bool hasNoReturnAttribute() const override; + bool hasOptimizedCodeDebugInfo() const override; + bool hasOverloadedOperator() const override; + bool hasSEH() const override; + bool hasSecurityChecks() const override; + bool hasSetJump() const override; + bool hasStrictGSCheck() const override; + bool isAcceleratorGroupSharedLocal() const override; + bool isAcceleratorPointerTagLiveRange() const override; + bool isAcceleratorStubFunction() const override; + bool isAggregated() const override; + bool isIntroVirtualFunction() const override; + bool isCVTCIL() const override; + bool isConstructorVirtualBase() const override; + bool isCxxReturnUdt() const override; + bool isDataAligned() const override; + bool isHLSLData() const override; + bool isHotpatchable() const override; + bool isIndirectVirtualBaseClass() const override; + bool isInterfaceUdt() const override; + bool isIntrinsic() const override; + bool isLTCG() const override; + bool isLocationControlFlowDependent() const override; + bool isMSILNetmodule() const override; + bool isMatrixRowMajor() const override; + bool isManagedCode() const override; + bool isMSILCode() const override; + bool isMultipleInheritance() const override; + bool isNaked() const override; + bool isNested() const override; + bool isOptimizedAway() const override; + bool isPacked() const override; + bool isPointerBasedOnSymbolValue() const override; + bool isPointerToDataMember() const override; + bool isPointerToMemberFunction() const override; + bool isPureVirtual() const override; + bool isRValueReference() const override; + bool isRefUdt() const override; + bool isReference() const override; + bool isRestrictedType() const override; + bool isReturnValue() const override; + bool isSafeBuffers() const override; + bool isScoped() const override; + bool isSdl() const override; + bool isSingleInheritance() const override; + bool isSplitted() const override; + bool isStatic() const override; + bool hasPrivateSymbols() const override; + bool isUnalignedType() const override; + bool isUnreached() const override; + bool isValueUdt() const override; + bool isVirtual() const override; + bool isVirtualBaseClass() const override; + bool isVirtualInheritance() const override; + bool isVolatileType() const override; + bool wasInlined() const override; + std::string getUnused() const override; + +private: + const DIASession &Session; + CComPtr<IDiaSymbol> Symbol; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASectionContrib.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASectionContrib.h index 519a2aa245..af2d7b788a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASectionContrib.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASectionContrib.h @@ -1,65 +1,65 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIASectionContrib.h - DIA Impl. of IPDBSectionContrib ------ C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H -#define LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBSectionContrib.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIASectionContrib : public IPDBSectionContrib { -public: - explicit DIASectionContrib(const DIASession &PDBSession, - CComPtr<IDiaSectionContrib> DiaSection); - - std::unique_ptr<PDBSymbolCompiland> getCompiland() const override; - uint32_t getAddressSection() const override; - uint32_t getAddressOffset() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; - uint32_t getLength() const override; - bool isNotPaged() const override; - bool hasCode() const override; - bool hasCode16Bit() const override; - bool hasInitializedData() const override; - bool hasUninitializedData() const override; - bool isRemoved() const override; - bool hasComdat() const override; - bool isDiscardable() const override; - bool isNotCached() const override; - bool isShared() const override; - bool isExecutable() const override; - bool isReadable() const override; - bool isWritable() const override; - uint32_t getDataCrc32() const override; - uint32_t getRelocationsCrc32() const override; - uint32_t getCompilandId() const override; - -private: - const DIASession &Session; - CComPtr<IDiaSectionContrib> Section; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIASectionContrib.h - DIA Impl. of IPDBSectionContrib ------ C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H +#define LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBSectionContrib.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIASectionContrib : public IPDBSectionContrib { +public: + explicit DIASectionContrib(const DIASession &PDBSession, + CComPtr<IDiaSectionContrib> DiaSection); + + std::unique_ptr<PDBSymbolCompiland> getCompiland() const override; + uint32_t getAddressSection() const override; + uint32_t getAddressOffset() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; + uint32_t getLength() const override; + bool isNotPaged() const override; + bool hasCode() const override; + bool hasCode16Bit() const override; + bool hasInitializedData() const override; + bool hasUninitializedData() const override; + bool isRemoved() const override; + bool hasComdat() const override; + bool isDiscardable() const override; + bool isNotCached() const override; + bool isShared() const override; + bool isExecutable() const override; + bool isReadable() const override; + bool isWritable() const override; + uint32_t getDataCrc32() const override; + uint32_t getRelocationsCrc32() const override; + uint32_t getCompilandId() const override; + +private: + const DIASession &Session; + CComPtr<IDiaSectionContrib> Section; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIASECTIONCONTRIB_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASourceFile.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASourceFile.h index fc71ec74af..46e1a2b96c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASourceFile.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASourceFile.h @@ -1,51 +1,51 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIASourceFile.h - DIA implementation of IPDBSourceFile ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASOURCEFILE_H -#define LLVM_DEBUGINFO_PDB_DIA_DIASOURCEFILE_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" - -namespace llvm { -namespace pdb { -class DIASession; - -class DIASourceFile : public IPDBSourceFile { -public: - explicit DIASourceFile(const DIASession &Session, - CComPtr<IDiaSourceFile> DiaSourceFile); - - std::string getFileName() const override; - uint32_t getUniqueId() const override; - std::string getChecksum() const override; - PDB_Checksum getChecksumType() const override; - std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> - getCompilands() const override; - - CComPtr<IDiaSourceFile> getDiaFile() const { return SourceFile; } - -private: - const DIASession &Session; - CComPtr<IDiaSourceFile> SourceFile; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIASourceFile.h - DIA implementation of IPDBSourceFile ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASOURCEFILE_H +#define LLVM_DEBUGINFO_PDB_DIA_DIASOURCEFILE_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" + +namespace llvm { +namespace pdb { +class DIASession; + +class DIASourceFile : public IPDBSourceFile { +public: + explicit DIASourceFile(const DIASession &Session, + CComPtr<IDiaSourceFile> DiaSourceFile); + + std::string getFileName() const override; + uint32_t getUniqueId() const override; + std::string getChecksum() const override; + PDB_Checksum getChecksumType() const override; + std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> + getCompilands() const override; + + CComPtr<IDiaSourceFile> getDiaFile() const { return SourceFile; } + +private: + const DIASession &Session; + CComPtr<IDiaSourceFile> SourceFile; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASupport.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASupport.h index a942da8c2d..c04f407038 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASupport.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIASupport.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIASupport.h - Common header includes for DIA ------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// Common defines and header includes for all LLVMDebugInfoPDBDIA. The -// definitions here configure the necessary #defines and include system headers -// in the proper order for using DIA. -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H -#define LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H - -// Require at least Vista -#define NTDDI_VERSION NTDDI_VISTA -#define _WIN32_WINNT _WIN32_WINNT_VISTA -#define WINVER _WIN32_WINNT_VISTA -#ifndef NOMINMAX -#define NOMINMAX -#endif - -// atlbase.h has to come before windows.h -#include <atlbase.h> -#include <windows.h> - -// DIA headers must come after windows headers. -#include <cvconst.h> -#include <dia2.h> -#include <diacreate.h> - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIASupport.h - Common header includes for DIA ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// Common defines and header includes for all LLVMDebugInfoPDBDIA. The +// definitions here configure the necessary #defines and include system headers +// in the proper order for using DIA. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H +#define LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H + +// Require at least Vista +#define NTDDI_VERSION NTDDI_VISTA +#define _WIN32_WINNT _WIN32_WINNT_VISTA +#define WINVER _WIN32_WINNT_VISTA +#ifndef NOMINMAX +#define NOMINMAX +#endif + +// atlbase.h has to come before windows.h +#include <atlbase.h> +#include <windows.h> + +// DIA headers must come after windows headers. +#include <cvconst.h> +#include <dia2.h> +#include <diacreate.h> + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIASUPPORT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIATable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIATable.h index 67302839ed..97085ae5c9 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIATable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIATable.h @@ -1,42 +1,42 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIATable.h - DIA implementation of IPDBTable -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H -#define LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H - -#include "DIASupport.h" -#include "llvm/DebugInfo/PDB/IPDBTable.h" - -namespace llvm { -namespace pdb { -class DIATable : public IPDBTable { -public: - explicit DIATable(CComPtr<IDiaTable> DiaTable); - - uint32_t getItemCount() const override; - std::string getName() const override; - PDB_TableType getTableType() const override; - -private: - CComPtr<IDiaTable> Table; -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIATable.h - DIA implementation of IPDBTable -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H +#define LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H + +#include "DIASupport.h" +#include "llvm/DebugInfo/PDB/IPDBTable.h" + +namespace llvm { +namespace pdb { +class DIATable : public IPDBTable { +public: + explicit DIATable(CComPtr<IDiaTable> DiaTable); + + uint32_t getItemCount() const override; + std::string getName() const override; + PDB_TableType getTableType() const override; + +private: + CComPtr<IDiaTable> Table; +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAUtils.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAUtils.h index 65ff176aef..fe0bd1b612 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAUtils.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/DIA/DIAUtils.h @@ -1,41 +1,41 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DIAUtils.h - Utility functions for working with DIA ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H -#define LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/ConvertUTF.h" - -template <typename Obj> -std::string invokeBstrMethod(Obj &Object, - HRESULT (__stdcall Obj::*Func)(BSTR *)) { - CComBSTR Str16; - HRESULT Result = (Object.*Func)(&Str16); - if (S_OK != Result) - return std::string(); - - std::string Str8; - llvm::ArrayRef<char> StrBytes(reinterpret_cast<char *>(Str16.m_str), - Str16.ByteLength()); - llvm::convertUTF16ToUTF8String(StrBytes, Str8); - return Str8; -} - -#endif // LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DIAUtils.h - Utility functions for working with DIA ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H +#define LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/ConvertUTF.h" + +template <typename Obj> +std::string invokeBstrMethod(Obj &Object, + HRESULT (__stdcall Obj::*Func)(BSTR *)) { + CComBSTR Str16; + HRESULT Result = (Object.*Func)(&Str16); + if (S_OK != Result) + return std::string(); + + std::string Str8; + llvm::ArrayRef<char> StrBytes(reinterpret_cast<char *>(Str16.m_str), + Str16.ByteLength()); + llvm::convertUTF16ToUTF8String(StrBytes, Str8); + return Str8; +} + +#endif // LLVM_DEBUGINFO_PDB_DIA_DIAUTILS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/GenericError.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/GenericError.h index 3435a631cd..4168bbd8d4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/GenericError.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/GenericError.h @@ -1,61 +1,61 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GenericError.h - system_error extensions for PDB ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_ERROR_H -#define LLVM_DEBUGINFO_PDB_ERROR_H - -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { - -enum class pdb_error_code { - invalid_utf8_path = 1, - dia_sdk_not_present, - dia_failed_loading, - signature_out_of_date, - no_matching_pch, - unspecified, -}; -} // namespace pdb -} // namespace llvm - -namespace std { -template <> -struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {}; -} // namespace std - -namespace llvm { -namespace pdb { -const std::error_category &PDBErrCategory(); - -inline std::error_code make_error_code(pdb_error_code E) { - return std::error_code(static_cast<int>(E), PDBErrCategory()); -} - -/// Base class for errors originating when parsing raw PDB files -class PDBError : public ErrorInfo<PDBError, StringError> { -public: - using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors - PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {} - static char ID; -}; -} // namespace pdb -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GenericError.h - system_error extensions for PDB ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_ERROR_H +#define LLVM_DEBUGINFO_PDB_ERROR_H + +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { + +enum class pdb_error_code { + invalid_utf8_path = 1, + dia_sdk_not_present, + dia_failed_loading, + signature_out_of_date, + no_matching_pch, + unspecified, +}; +} // namespace pdb +} // namespace llvm + +namespace std { +template <> +struct is_error_code_enum<llvm::pdb::pdb_error_code> : std::true_type {}; +} // namespace std + +namespace llvm { +namespace pdb { +const std::error_category &PDBErrCategory(); + +inline std::error_code make_error_code(pdb_error_code E) { + return std::error_code(static_cast<int>(E), PDBErrCategory()); +} + +/// Base class for errors originating when parsing raw PDB files +class PDBError : public ErrorInfo<PDBError, StringError> { +public: + using ErrorInfo<PDBError, StringError>::ErrorInfo; // inherit constructors + PDBError(const Twine &S) : ErrorInfo(S, pdb_error_code::unspecified) {} + static char ID; +}; +} // namespace pdb +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBDataStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBDataStream.h index 255fbebbf7..649683ca4f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBDataStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBDataStream.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBDataStream.h - base interface for child enumerator ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H -#define LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include <cstdint> -#include <string> - -namespace llvm { -namespace pdb { - -/// IPDBDataStream defines an interface used to represent a stream consisting -/// of a name and a series of records whose formats depend on the particular -/// stream type. -class IPDBDataStream { -public: - using RecordType = SmallVector<uint8_t, 32>; - - virtual ~IPDBDataStream(); - - virtual uint32_t getRecordCount() const = 0; - virtual std::string getName() const = 0; - virtual Optional<RecordType> getItemAtIndex(uint32_t Index) const = 0; - virtual bool getNext(RecordType &Record) = 0; - virtual void reset() = 0; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBDataStream.h - base interface for child enumerator ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H +#define LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include <cstdint> +#include <string> + +namespace llvm { +namespace pdb { + +/// IPDBDataStream defines an interface used to represent a stream consisting +/// of a name and a series of records whose formats depend on the particular +/// stream type. +class IPDBDataStream { +public: + using RecordType = SmallVector<uint8_t, 32>; + + virtual ~IPDBDataStream(); + + virtual uint32_t getRecordCount() const = 0; + virtual std::string getName() const = 0; + virtual Optional<RecordType> getItemAtIndex(uint32_t Index) const = 0; + virtual bool getNext(RecordType &Record) = 0; + virtual void reset() = 0; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_IPDBDATASTREAM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBEnumChildren.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBEnumChildren.h index 0710d2ba96..79eebee0d1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBEnumChildren.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBEnumChildren.h @@ -1,59 +1,59 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBEnumChildren.h - base interface for child enumerator -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H -#define LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H - -#include <cassert> -#include <cstdint> -#include <memory> - -namespace llvm { -namespace pdb { - -template <typename ChildType> class IPDBEnumChildren { -public: - using ChildTypePtr = std::unique_ptr<ChildType>; - using MyType = IPDBEnumChildren<ChildType>; - - virtual ~IPDBEnumChildren() = default; - - virtual uint32_t getChildCount() const = 0; - virtual ChildTypePtr getChildAtIndex(uint32_t Index) const = 0; - virtual ChildTypePtr getNext() = 0; - virtual void reset() = 0; -}; - -template <typename ChildType> -class NullEnumerator : public IPDBEnumChildren<ChildType> { - virtual uint32_t getChildCount() const override { return 0; } - virtual std::unique_ptr<ChildType> - getChildAtIndex(uint32_t Index) const override { - return nullptr; - } - virtual std::unique_ptr<ChildType> getNext() override { - return nullptr; - } - virtual void reset() override {} -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBEnumChildren.h - base interface for child enumerator -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H +#define LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H + +#include <cassert> +#include <cstdint> +#include <memory> + +namespace llvm { +namespace pdb { + +template <typename ChildType> class IPDBEnumChildren { +public: + using ChildTypePtr = std::unique_ptr<ChildType>; + using MyType = IPDBEnumChildren<ChildType>; + + virtual ~IPDBEnumChildren() = default; + + virtual uint32_t getChildCount() const = 0; + virtual ChildTypePtr getChildAtIndex(uint32_t Index) const = 0; + virtual ChildTypePtr getNext() = 0; + virtual void reset() = 0; +}; + +template <typename ChildType> +class NullEnumerator : public IPDBEnumChildren<ChildType> { + virtual uint32_t getChildCount() const override { return 0; } + virtual std::unique_ptr<ChildType> + getChildAtIndex(uint32_t Index) const override { + return nullptr; + } + virtual std::unique_ptr<ChildType> getNext() override { + return nullptr; + } + virtual void reset() override {} +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_IPDBENUMCHILDREN_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBFrameData.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBFrameData.h index 565bea9403..5a2d1dc91a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBFrameData.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBFrameData.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBFrameData.h - base interface for frame data ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H -#define LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H - -#include <cstdint> -#include <string> - -namespace llvm { -namespace pdb { - -/// IPDBFrameData defines an interface used to represent a frame data of some -/// code block. -class IPDBFrameData { -public: - virtual ~IPDBFrameData(); - - virtual uint32_t getAddressOffset() const = 0; - virtual uint32_t getAddressSection() const = 0; - virtual uint32_t getLengthBlock() const = 0; - virtual std::string getProgram() const = 0; - virtual uint32_t getRelativeVirtualAddress() const = 0; - virtual uint64_t getVirtualAddress() const = 0; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBFrameData.h - base interface for frame data ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H +#define LLVM_DEBUGINFO_PDB_IPDBFRAMEDATA_H + +#include <cstdint> +#include <string> + +namespace llvm { +namespace pdb { + +/// IPDBFrameData defines an interface used to represent a frame data of some +/// code block. +class IPDBFrameData { +public: + virtual ~IPDBFrameData(); + + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getLengthBlock() const = 0; + virtual std::string getProgram() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint64_t getVirtualAddress() const = 0; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBInjectedSource.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBInjectedSource.h index 327b340c94..3a65dfd1ac 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBInjectedSource.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBInjectedSource.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBInjectedSource.h - base class for PDB injected file --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H -#define LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H - -#include <cstdint> -#include <string> - -namespace llvm { -namespace pdb { -/// IPDBInjectedSource defines an interface used to represent source files -/// which were injected directly into the PDB file during the compilation -/// process. This is used, for example, to add natvis files to a PDB, but -/// in theory could be used to add arbitrary source code. -class IPDBInjectedSource { -public: - virtual ~IPDBInjectedSource(); - - virtual uint32_t getCrc32() const = 0; - virtual uint64_t getCodeByteSize() const = 0; - virtual std::string getFileName() const = 0; - virtual std::string getObjectFileName() const = 0; - virtual std::string getVirtualFileName() const = 0; - // The returned value depends on the PDB producer, - // but 0 is guaranteed to mean "no compression". - // The enum PDB_SourceCompression lists known return values. - virtual uint32_t getCompression() const = 0; - virtual std::string getCode() const = 0; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBInjectedSource.h - base class for PDB injected file --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H +#define LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H + +#include <cstdint> +#include <string> + +namespace llvm { +namespace pdb { +/// IPDBInjectedSource defines an interface used to represent source files +/// which were injected directly into the PDB file during the compilation +/// process. This is used, for example, to add natvis files to a PDB, but +/// in theory could be used to add arbitrary source code. +class IPDBInjectedSource { +public: + virtual ~IPDBInjectedSource(); + + virtual uint32_t getCrc32() const = 0; + virtual uint64_t getCodeByteSize() const = 0; + virtual std::string getFileName() const = 0; + virtual std::string getObjectFileName() const = 0; + virtual std::string getVirtualFileName() const = 0; + // The returned value depends on the PDB producer, + // but 0 is guaranteed to mean "no compression". + // The enum PDB_SourceCompression lists known return values. + virtual uint32_t getCompression() const = 0; + virtual std::string getCode() const = 0; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_IPDBINJECTEDSOURCE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBLineNumber.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBLineNumber.h index 975ba87a63..5390f3169b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBLineNumber.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBLineNumber.h @@ -1,47 +1,47 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBLineNumber.h - base interface for PDB line no. info ---*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBLINENUMBER_H -#define LLVM_DEBUGINFO_PDB_IPDBLINENUMBER_H - -#include <cstdint> - -namespace llvm { -namespace pdb { -class IPDBLineNumber { -public: - virtual ~IPDBLineNumber(); - - virtual uint32_t getLineNumber() const = 0; - virtual uint32_t getLineNumberEnd() const = 0; - virtual uint32_t getColumnNumber() const = 0; - virtual uint32_t getColumnNumberEnd() const = 0; - virtual uint32_t getAddressSection() const = 0; - virtual uint32_t getAddressOffset() const = 0; - virtual uint32_t getRelativeVirtualAddress() const = 0; - virtual uint64_t getVirtualAddress() const = 0; - virtual uint32_t getLength() const = 0; - virtual uint32_t getSourceFileId() const = 0; - virtual uint32_t getCompilandId() const = 0; - virtual bool isStatement() const = 0; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBLineNumber.h - base interface for PDB line no. info ---*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBLINENUMBER_H +#define LLVM_DEBUGINFO_PDB_IPDBLINENUMBER_H + +#include <cstdint> + +namespace llvm { +namespace pdb { +class IPDBLineNumber { +public: + virtual ~IPDBLineNumber(); + + virtual uint32_t getLineNumber() const = 0; + virtual uint32_t getLineNumberEnd() const = 0; + virtual uint32_t getColumnNumber() const = 0; + virtual uint32_t getColumnNumberEnd() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint64_t getVirtualAddress() const = 0; + virtual uint32_t getLength() const = 0; + virtual uint32_t getSourceFileId() const = 0; + virtual uint32_t getCompilandId() const = 0; + virtual bool isStatement() const = 0; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h index 4ca7e7319c..d5f34e7d05 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h @@ -1,270 +1,270 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBRawSymbol.h - base interface for PDB symbol types ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H -#define LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H - -#include "PDBTypes.h" -#include "llvm/ADT/BitmaskEnum.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include <memory> - -namespace llvm { -class raw_ostream; -class StringRef; - -namespace pdb { - -enum class PdbSymbolIdField : uint32_t { - None = 0, - SymIndexId = 1 << 0, - LexicalParent = 1 << 1, - ClassParent = 1 << 2, - Type = 1 << 3, - UnmodifiedType = 1 << 4, - All = 0xFFFFFFFF, - LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) -}; - -void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, - int Indent, const IPDBSession &Session, - PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, - PdbSymbolIdField RecurseFlags); - -/// IPDBRawSymbol defines an interface used to represent an arbitrary symbol. -/// It exposes a monolithic interface consisting of accessors for the union of -/// all properties that are valid for any symbol type. This interface is then -/// wrapped by a concrete class which exposes only those set of methods valid -/// for this particular symbol type. See PDBSymbol.h for more details. -class IPDBRawSymbol { -public: - virtual ~IPDBRawSymbol(); - - virtual void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const = 0; - - virtual std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const = 0; - - virtual std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags) const = 0; - virtual std::unique_ptr<IPDBEnumSymbols> - findChildrenByAddr(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags, - uint32_t Section, uint32_t Offset) const = 0; - virtual std::unique_ptr<IPDBEnumSymbols> - findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint64_t VA) const = 0; - virtual std::unique_ptr<IPDBEnumSymbols> - findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint32_t RVA) const = 0; - - virtual std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const = 0; - virtual std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByRVA(uint32_t RVA) const = 0; - virtual std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByVA(uint64_t VA) const = 0; - - virtual std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, - uint32_t Length) const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByVA(uint64_t VA, uint32_t Length) const = 0; - - virtual void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const = 0; - virtual void getBackEndVersion(VersionInfo &Version) const = 0; - virtual PDB_MemberAccess getAccess() const = 0; - virtual uint32_t getAddressOffset() const = 0; - virtual uint32_t getAddressSection() const = 0; - virtual uint32_t getAge() const = 0; - virtual SymIndexId getArrayIndexTypeId() const = 0; - virtual uint32_t getBaseDataOffset() const = 0; - virtual uint32_t getBaseDataSlot() const = 0; - virtual SymIndexId getBaseSymbolId() const = 0; - virtual PDB_BuiltinType getBuiltinType() const = 0; - virtual uint32_t getBitPosition() const = 0; - virtual PDB_CallingConv getCallingConvention() const = 0; - virtual SymIndexId getClassParentId() const = 0; - virtual std::string getCompilerName() const = 0; - virtual uint32_t getCount() const = 0; - virtual uint32_t getCountLiveRanges() const = 0; - virtual void getFrontEndVersion(VersionInfo &Version) const = 0; - virtual PDB_Lang getLanguage() const = 0; - virtual SymIndexId getLexicalParentId() const = 0; - virtual std::string getLibraryName() const = 0; - virtual uint32_t getLiveRangeStartAddressOffset() const = 0; - virtual uint32_t getLiveRangeStartAddressSection() const = 0; - virtual uint32_t getLiveRangeStartRelativeVirtualAddress() const = 0; - virtual codeview::RegisterId getLocalBasePointerRegisterId() const = 0; - virtual SymIndexId getLowerBoundId() const = 0; - virtual uint32_t getMemorySpaceKind() const = 0; - virtual std::string getName() const = 0; - virtual uint32_t getNumberOfAcceleratorPointerTags() const = 0; - virtual uint32_t getNumberOfColumns() const = 0; - virtual uint32_t getNumberOfModifiers() const = 0; - virtual uint32_t getNumberOfRegisterIndices() const = 0; - virtual uint32_t getNumberOfRows() const = 0; - virtual std::string getObjectFileName() const = 0; - virtual uint32_t getOemId() const = 0; - virtual SymIndexId getOemSymbolId() const = 0; - virtual uint32_t getOffsetInUdt() const = 0; - virtual PDB_Cpu getPlatform() const = 0; - virtual uint32_t getRank() const = 0; - virtual codeview::RegisterId getRegisterId() const = 0; - virtual uint32_t getRegisterType() const = 0; - virtual uint32_t getRelativeVirtualAddress() const = 0; - virtual uint32_t getSamplerSlot() const = 0; - virtual uint32_t getSignature() const = 0; - virtual uint32_t getSizeInUdt() const = 0; - virtual uint32_t getSlot() const = 0; - virtual std::string getSourceFileName() const = 0; - virtual std::unique_ptr<IPDBLineNumber> - getSrcLineOnTypeDefn() const = 0; - virtual uint32_t getStride() const = 0; - virtual SymIndexId getSubTypeId() const = 0; - virtual std::string getSymbolsFileName() const = 0; - virtual SymIndexId getSymIndexId() const = 0; - virtual uint32_t getTargetOffset() const = 0; - virtual uint32_t getTargetRelativeVirtualAddress() const = 0; - virtual uint64_t getTargetVirtualAddress() const = 0; - virtual uint32_t getTargetSection() const = 0; - virtual uint32_t getTextureSlot() const = 0; - virtual uint32_t getTimeStamp() const = 0; - virtual uint32_t getToken() const = 0; - virtual SymIndexId getTypeId() const = 0; - virtual uint32_t getUavSlot() const = 0; - virtual std::string getUndecoratedName() const = 0; - virtual std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const = 0; - virtual SymIndexId getUnmodifiedTypeId() const = 0; - virtual SymIndexId getUpperBoundId() const = 0; - virtual Variant getValue() const = 0; - virtual uint32_t getVirtualBaseDispIndex() const = 0; - virtual uint32_t getVirtualBaseOffset() const = 0; - virtual std::unique_ptr<PDBSymbolTypeBuiltin> - getVirtualBaseTableType() const = 0; - virtual SymIndexId getVirtualTableShapeId() const = 0; - virtual PDB_DataKind getDataKind() const = 0; - virtual PDB_SymType getSymTag() const = 0; - virtual codeview::GUID getGuid() const = 0; - virtual int32_t getOffset() const = 0; - virtual int32_t getThisAdjust() const = 0; - virtual int32_t getVirtualBasePointerOffset() const = 0; - virtual PDB_LocType getLocationType() const = 0; - virtual PDB_Machine getMachineType() const = 0; - virtual codeview::ThunkOrdinal getThunkOrdinal() const = 0; - virtual uint64_t getLength() const = 0; - virtual uint64_t getLiveRangeLength() const = 0; - virtual uint64_t getVirtualAddress() const = 0; - virtual PDB_UdtType getUdtKind() const = 0; - virtual bool hasConstructor() const = 0; - virtual bool hasCustomCallingConvention() const = 0; - virtual bool hasFarReturn() const = 0; - virtual bool isCode() const = 0; - virtual bool isCompilerGenerated() const = 0; - virtual bool isConstType() const = 0; - virtual bool isEditAndContinueEnabled() const = 0; - virtual bool isFunction() const = 0; - virtual bool getAddressTaken() const = 0; - virtual bool getNoStackOrdering() const = 0; - virtual bool hasAlloca() const = 0; - virtual bool hasAssignmentOperator() const = 0; - virtual bool hasCTypes() const = 0; - virtual bool hasCastOperator() const = 0; - virtual bool hasDebugInfo() const = 0; - virtual bool hasEH() const = 0; - virtual bool hasEHa() const = 0; - virtual bool hasFramePointer() const = 0; - virtual bool hasInlAsm() const = 0; - virtual bool hasInlineAttribute() const = 0; - virtual bool hasInterruptReturn() const = 0; - virtual bool hasLongJump() const = 0; - virtual bool hasManagedCode() const = 0; - virtual bool hasNestedTypes() const = 0; - virtual bool hasNoInlineAttribute() const = 0; - virtual bool hasNoReturnAttribute() const = 0; - virtual bool hasOptimizedCodeDebugInfo() const = 0; - virtual bool hasOverloadedOperator() const = 0; - virtual bool hasSEH() const = 0; - virtual bool hasSecurityChecks() const = 0; - virtual bool hasSetJump() const = 0; - virtual bool hasStrictGSCheck() const = 0; - virtual bool isAcceleratorGroupSharedLocal() const = 0; - virtual bool isAcceleratorPointerTagLiveRange() const = 0; - virtual bool isAcceleratorStubFunction() const = 0; - virtual bool isAggregated() const = 0; - virtual bool isIntroVirtualFunction() const = 0; - virtual bool isCVTCIL() const = 0; - virtual bool isConstructorVirtualBase() const = 0; - virtual bool isCxxReturnUdt() const = 0; - virtual bool isDataAligned() const = 0; - virtual bool isHLSLData() const = 0; - virtual bool isHotpatchable() const = 0; - virtual bool isIndirectVirtualBaseClass() const = 0; - virtual bool isInterfaceUdt() const = 0; - virtual bool isIntrinsic() const = 0; - virtual bool isLTCG() const = 0; - virtual bool isLocationControlFlowDependent() const = 0; - virtual bool isMSILNetmodule() const = 0; - virtual bool isMatrixRowMajor() const = 0; - virtual bool isManagedCode() const = 0; - virtual bool isMSILCode() const = 0; - virtual bool isMultipleInheritance() const = 0; - virtual bool isNaked() const = 0; - virtual bool isNested() const = 0; - virtual bool isOptimizedAway() const = 0; - virtual bool isPacked() const = 0; - virtual bool isPointerBasedOnSymbolValue() const = 0; - virtual bool isPointerToDataMember() const = 0; - virtual bool isPointerToMemberFunction() const = 0; - virtual bool isPureVirtual() const = 0; - virtual bool isRValueReference() const = 0; - virtual bool isRefUdt() const = 0; - virtual bool isReference() const = 0; - virtual bool isRestrictedType() const = 0; - virtual bool isReturnValue() const = 0; - virtual bool isSafeBuffers() const = 0; - virtual bool isScoped() const = 0; - virtual bool isSdl() const = 0; - virtual bool isSingleInheritance() const = 0; - virtual bool isSplitted() const = 0; - virtual bool isStatic() const = 0; - virtual bool hasPrivateSymbols() const = 0; - virtual bool isUnalignedType() const = 0; - virtual bool isUnreached() const = 0; - virtual bool isValueUdt() const = 0; - virtual bool isVirtual() const = 0; - virtual bool isVirtualBaseClass() const = 0; - virtual bool isVirtualInheritance() const = 0; - virtual bool isVolatileType() const = 0; - virtual bool wasInlined() const = 0; - virtual std::string getUnused() const = 0; -}; - -LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBRawSymbol.h - base interface for PDB symbol types ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H +#define LLVM_DEBUGINFO_PDB_IPDBRAWSYMBOL_H + +#include "PDBTypes.h" +#include "llvm/ADT/BitmaskEnum.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include <memory> + +namespace llvm { +class raw_ostream; +class StringRef; + +namespace pdb { + +enum class PdbSymbolIdField : uint32_t { + None = 0, + SymIndexId = 1 << 0, + LexicalParent = 1 << 1, + ClassParent = 1 << 2, + Type = 1 << 3, + UnmodifiedType = 1 << 4, + All = 0xFFFFFFFF, + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ All) +}; + +void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, + int Indent, const IPDBSession &Session, + PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, + PdbSymbolIdField RecurseFlags); + +/// IPDBRawSymbol defines an interface used to represent an arbitrary symbol. +/// It exposes a monolithic interface consisting of accessors for the union of +/// all properties that are valid for any symbol type. This interface is then +/// wrapped by a concrete class which exposes only those set of methods valid +/// for this particular symbol type. See PDBSymbol.h for more details. +class IPDBRawSymbol { +public: + virtual ~IPDBRawSymbol(); + + virtual void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const = 0; + + virtual std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const = 0; + + virtual std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const = 0; + virtual std::unique_ptr<IPDBEnumSymbols> + findChildrenByAddr(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags, + uint32_t Section, uint32_t Offset) const = 0; + virtual std::unique_ptr<IPDBEnumSymbols> + findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint64_t VA) const = 0; + virtual std::unique_ptr<IPDBEnumSymbols> + findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint32_t RVA) const = 0; + + virtual std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const = 0; + virtual std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByRVA(uint32_t RVA) const = 0; + virtual std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByVA(uint64_t VA) const = 0; + + virtual std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, + uint32_t Length) const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByVA(uint64_t VA, uint32_t Length) const = 0; + + virtual void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const = 0; + virtual void getBackEndVersion(VersionInfo &Version) const = 0; + virtual PDB_MemberAccess getAccess() const = 0; + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getAge() const = 0; + virtual SymIndexId getArrayIndexTypeId() const = 0; + virtual uint32_t getBaseDataOffset() const = 0; + virtual uint32_t getBaseDataSlot() const = 0; + virtual SymIndexId getBaseSymbolId() const = 0; + virtual PDB_BuiltinType getBuiltinType() const = 0; + virtual uint32_t getBitPosition() const = 0; + virtual PDB_CallingConv getCallingConvention() const = 0; + virtual SymIndexId getClassParentId() const = 0; + virtual std::string getCompilerName() const = 0; + virtual uint32_t getCount() const = 0; + virtual uint32_t getCountLiveRanges() const = 0; + virtual void getFrontEndVersion(VersionInfo &Version) const = 0; + virtual PDB_Lang getLanguage() const = 0; + virtual SymIndexId getLexicalParentId() const = 0; + virtual std::string getLibraryName() const = 0; + virtual uint32_t getLiveRangeStartAddressOffset() const = 0; + virtual uint32_t getLiveRangeStartAddressSection() const = 0; + virtual uint32_t getLiveRangeStartRelativeVirtualAddress() const = 0; + virtual codeview::RegisterId getLocalBasePointerRegisterId() const = 0; + virtual SymIndexId getLowerBoundId() const = 0; + virtual uint32_t getMemorySpaceKind() const = 0; + virtual std::string getName() const = 0; + virtual uint32_t getNumberOfAcceleratorPointerTags() const = 0; + virtual uint32_t getNumberOfColumns() const = 0; + virtual uint32_t getNumberOfModifiers() const = 0; + virtual uint32_t getNumberOfRegisterIndices() const = 0; + virtual uint32_t getNumberOfRows() const = 0; + virtual std::string getObjectFileName() const = 0; + virtual uint32_t getOemId() const = 0; + virtual SymIndexId getOemSymbolId() const = 0; + virtual uint32_t getOffsetInUdt() const = 0; + virtual PDB_Cpu getPlatform() const = 0; + virtual uint32_t getRank() const = 0; + virtual codeview::RegisterId getRegisterId() const = 0; + virtual uint32_t getRegisterType() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint32_t getSamplerSlot() const = 0; + virtual uint32_t getSignature() const = 0; + virtual uint32_t getSizeInUdt() const = 0; + virtual uint32_t getSlot() const = 0; + virtual std::string getSourceFileName() const = 0; + virtual std::unique_ptr<IPDBLineNumber> + getSrcLineOnTypeDefn() const = 0; + virtual uint32_t getStride() const = 0; + virtual SymIndexId getSubTypeId() const = 0; + virtual std::string getSymbolsFileName() const = 0; + virtual SymIndexId getSymIndexId() const = 0; + virtual uint32_t getTargetOffset() const = 0; + virtual uint32_t getTargetRelativeVirtualAddress() const = 0; + virtual uint64_t getTargetVirtualAddress() const = 0; + virtual uint32_t getTargetSection() const = 0; + virtual uint32_t getTextureSlot() const = 0; + virtual uint32_t getTimeStamp() const = 0; + virtual uint32_t getToken() const = 0; + virtual SymIndexId getTypeId() const = 0; + virtual uint32_t getUavSlot() const = 0; + virtual std::string getUndecoratedName() const = 0; + virtual std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const = 0; + virtual SymIndexId getUnmodifiedTypeId() const = 0; + virtual SymIndexId getUpperBoundId() const = 0; + virtual Variant getValue() const = 0; + virtual uint32_t getVirtualBaseDispIndex() const = 0; + virtual uint32_t getVirtualBaseOffset() const = 0; + virtual std::unique_ptr<PDBSymbolTypeBuiltin> + getVirtualBaseTableType() const = 0; + virtual SymIndexId getVirtualTableShapeId() const = 0; + virtual PDB_DataKind getDataKind() const = 0; + virtual PDB_SymType getSymTag() const = 0; + virtual codeview::GUID getGuid() const = 0; + virtual int32_t getOffset() const = 0; + virtual int32_t getThisAdjust() const = 0; + virtual int32_t getVirtualBasePointerOffset() const = 0; + virtual PDB_LocType getLocationType() const = 0; + virtual PDB_Machine getMachineType() const = 0; + virtual codeview::ThunkOrdinal getThunkOrdinal() const = 0; + virtual uint64_t getLength() const = 0; + virtual uint64_t getLiveRangeLength() const = 0; + virtual uint64_t getVirtualAddress() const = 0; + virtual PDB_UdtType getUdtKind() const = 0; + virtual bool hasConstructor() const = 0; + virtual bool hasCustomCallingConvention() const = 0; + virtual bool hasFarReturn() const = 0; + virtual bool isCode() const = 0; + virtual bool isCompilerGenerated() const = 0; + virtual bool isConstType() const = 0; + virtual bool isEditAndContinueEnabled() const = 0; + virtual bool isFunction() const = 0; + virtual bool getAddressTaken() const = 0; + virtual bool getNoStackOrdering() const = 0; + virtual bool hasAlloca() const = 0; + virtual bool hasAssignmentOperator() const = 0; + virtual bool hasCTypes() const = 0; + virtual bool hasCastOperator() const = 0; + virtual bool hasDebugInfo() const = 0; + virtual bool hasEH() const = 0; + virtual bool hasEHa() const = 0; + virtual bool hasFramePointer() const = 0; + virtual bool hasInlAsm() const = 0; + virtual bool hasInlineAttribute() const = 0; + virtual bool hasInterruptReturn() const = 0; + virtual bool hasLongJump() const = 0; + virtual bool hasManagedCode() const = 0; + virtual bool hasNestedTypes() const = 0; + virtual bool hasNoInlineAttribute() const = 0; + virtual bool hasNoReturnAttribute() const = 0; + virtual bool hasOptimizedCodeDebugInfo() const = 0; + virtual bool hasOverloadedOperator() const = 0; + virtual bool hasSEH() const = 0; + virtual bool hasSecurityChecks() const = 0; + virtual bool hasSetJump() const = 0; + virtual bool hasStrictGSCheck() const = 0; + virtual bool isAcceleratorGroupSharedLocal() const = 0; + virtual bool isAcceleratorPointerTagLiveRange() const = 0; + virtual bool isAcceleratorStubFunction() const = 0; + virtual bool isAggregated() const = 0; + virtual bool isIntroVirtualFunction() const = 0; + virtual bool isCVTCIL() const = 0; + virtual bool isConstructorVirtualBase() const = 0; + virtual bool isCxxReturnUdt() const = 0; + virtual bool isDataAligned() const = 0; + virtual bool isHLSLData() const = 0; + virtual bool isHotpatchable() const = 0; + virtual bool isIndirectVirtualBaseClass() const = 0; + virtual bool isInterfaceUdt() const = 0; + virtual bool isIntrinsic() const = 0; + virtual bool isLTCG() const = 0; + virtual bool isLocationControlFlowDependent() const = 0; + virtual bool isMSILNetmodule() const = 0; + virtual bool isMatrixRowMajor() const = 0; + virtual bool isManagedCode() const = 0; + virtual bool isMSILCode() const = 0; + virtual bool isMultipleInheritance() const = 0; + virtual bool isNaked() const = 0; + virtual bool isNested() const = 0; + virtual bool isOptimizedAway() const = 0; + virtual bool isPacked() const = 0; + virtual bool isPointerBasedOnSymbolValue() const = 0; + virtual bool isPointerToDataMember() const = 0; + virtual bool isPointerToMemberFunction() const = 0; + virtual bool isPureVirtual() const = 0; + virtual bool isRValueReference() const = 0; + virtual bool isRefUdt() const = 0; + virtual bool isReference() const = 0; + virtual bool isRestrictedType() const = 0; + virtual bool isReturnValue() const = 0; + virtual bool isSafeBuffers() const = 0; + virtual bool isScoped() const = 0; + virtual bool isSdl() const = 0; + virtual bool isSingleInheritance() const = 0; + virtual bool isSplitted() const = 0; + virtual bool isStatic() const = 0; + virtual bool hasPrivateSymbols() const = 0; + virtual bool isUnalignedType() const = 0; + virtual bool isUnreached() const = 0; + virtual bool isValueUdt() const = 0; + virtual bool isVirtual() const = 0; + virtual bool isVirtualBaseClass() const = 0; + virtual bool isVirtualInheritance() const = 0; + virtual bool isVolatileType() const = 0; + virtual bool wasInlined() const = 0; + virtual std::string getUnused() const = 0; +}; + +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSectionContrib.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSectionContrib.h index d521fbbb0b..232baf2619 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSectionContrib.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSectionContrib.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- IPDBSectionContrib.h - Interfaces for PDB SectionContribs --*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H -#define LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H - -#include "PDBTypes.h" - -namespace llvm { -namespace pdb { - -/// IPDBSectionContrib defines an interface used to represent section -/// contributions whose information are stored in the PDB. -class IPDBSectionContrib { -public: - virtual ~IPDBSectionContrib(); - - virtual std::unique_ptr<PDBSymbolCompiland> getCompiland() const = 0; - virtual uint32_t getAddressSection() const = 0; - virtual uint32_t getAddressOffset() const = 0; - virtual uint32_t getRelativeVirtualAddress() const = 0; - virtual uint64_t getVirtualAddress() const = 0; - virtual uint32_t getLength() const = 0; - virtual bool isNotPaged() const = 0; - virtual bool hasCode() const = 0; - virtual bool hasCode16Bit() const = 0; - virtual bool hasInitializedData() const = 0; - virtual bool hasUninitializedData() const = 0; - virtual bool isRemoved() const = 0; - virtual bool hasComdat() const = 0; - virtual bool isDiscardable() const = 0; - virtual bool isNotCached() const = 0; - virtual bool isShared() const = 0; - virtual bool isExecutable() const = 0; - virtual bool isReadable() const = 0; - virtual bool isWritable() const = 0; - virtual uint32_t getDataCrc32() const = 0; - virtual uint32_t getRelocationsCrc32() const = 0; - virtual uint32_t getCompilandId() const = 0; -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- IPDBSectionContrib.h - Interfaces for PDB SectionContribs --*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H +#define LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H + +#include "PDBTypes.h" + +namespace llvm { +namespace pdb { + +/// IPDBSectionContrib defines an interface used to represent section +/// contributions whose information are stored in the PDB. +class IPDBSectionContrib { +public: + virtual ~IPDBSectionContrib(); + + virtual std::unique_ptr<PDBSymbolCompiland> getCompiland() const = 0; + virtual uint32_t getAddressSection() const = 0; + virtual uint32_t getAddressOffset() const = 0; + virtual uint32_t getRelativeVirtualAddress() const = 0; + virtual uint64_t getVirtualAddress() const = 0; + virtual uint32_t getLength() const = 0; + virtual bool isNotPaged() const = 0; + virtual bool hasCode() const = 0; + virtual bool hasCode16Bit() const = 0; + virtual bool hasInitializedData() const = 0; + virtual bool hasUninitializedData() const = 0; + virtual bool isRemoved() const = 0; + virtual bool hasComdat() const = 0; + virtual bool isDiscardable() const = 0; + virtual bool isNotCached() const = 0; + virtual bool isShared() const = 0; + virtual bool isExecutable() const = 0; + virtual bool isReadable() const = 0; + virtual bool isWritable() const = 0; + virtual uint32_t getDataCrc32() const = 0; + virtual uint32_t getRelocationsCrc32() const = 0; + virtual uint32_t getCompilandId() const = 0; +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_IPDBSECTIONCONTRIB_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSession.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSession.h index 6b5e5ffcce..1de6d510b6 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSession.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSession.h @@ -1,110 +1,110 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBSession.h - base interface for a PDB symbol context --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBSESSION_H -#define LLVM_DEBUGINFO_PDB_IPDBSESSION_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Casting.h" -#include <memory> - -namespace llvm { -namespace pdb { -class PDBSymbolCompiland; -class PDBSymbolExe; - -/// IPDBSession defines an interface used to provide a context for querying -/// debug information from a debug data source (for example, a PDB). -class IPDBSession { -public: - virtual ~IPDBSession(); - - virtual uint64_t getLoadAddress() const = 0; - virtual bool setLoadAddress(uint64_t Address) = 0; - virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0; - virtual std::unique_ptr<PDBSymbol> - getSymbolById(SymIndexId SymbolId) const = 0; - - virtual bool addressForVA(uint64_t VA, uint32_t &Section, - uint32_t &Offset) const = 0; - virtual bool addressForRVA(uint32_t RVA, uint32_t &Section, - uint32_t &Offset) const = 0; - - template <typename T> - std::unique_ptr<T> getConcreteSymbolById(SymIndexId SymbolId) const { - return unique_dyn_cast_or_null<T>(getSymbolById(SymbolId)); - } - - virtual std::unique_ptr<PDBSymbol> findSymbolByAddress(uint64_t Address, - PDB_SymType Type) = 0; - virtual std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA, - PDB_SymType Type) = 0; - virtual std::unique_ptr<PDBSymbol> - findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) = 0; - - virtual std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbers(const PDBSymbolCompiland &Compiland, - const IPDBSourceFile &File) const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersByAddress(uint64_t Address, uint32_t Length) const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const = 0; - virtual std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, - uint32_t Length) const = 0; - - virtual std::unique_ptr<IPDBEnumSourceFiles> - findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const = 0; - virtual std::unique_ptr<IPDBSourceFile> - findOneSourceFile(const PDBSymbolCompiland *Compiland, - llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const = 0; - virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> - findCompilandsForSourceFile(llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const = 0; - virtual std::unique_ptr<PDBSymbolCompiland> - findOneCompilandForSourceFile(llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const = 0; - - virtual std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const = 0; - virtual std::unique_ptr<IPDBEnumSourceFiles> - getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0; - virtual std::unique_ptr<IPDBSourceFile> - getSourceFileById(uint32_t FileId) const = 0; - - virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0; - - virtual std::unique_ptr<IPDBEnumTables> getEnumTables() const = 0; - - virtual std::unique_ptr<IPDBEnumInjectedSources> - getInjectedSources() const = 0; - - virtual std::unique_ptr<IPDBEnumSectionContribs> - getSectionContribs() const = 0; - - virtual std::unique_ptr<IPDBEnumFrameData> - getFrameData() const = 0; -}; -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBSession.h - base interface for a PDB symbol context --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBSESSION_H +#define LLVM_DEBUGINFO_PDB_IPDBSESSION_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" +#include <memory> + +namespace llvm { +namespace pdb { +class PDBSymbolCompiland; +class PDBSymbolExe; + +/// IPDBSession defines an interface used to provide a context for querying +/// debug information from a debug data source (for example, a PDB). +class IPDBSession { +public: + virtual ~IPDBSession(); + + virtual uint64_t getLoadAddress() const = 0; + virtual bool setLoadAddress(uint64_t Address) = 0; + virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0; + virtual std::unique_ptr<PDBSymbol> + getSymbolById(SymIndexId SymbolId) const = 0; + + virtual bool addressForVA(uint64_t VA, uint32_t &Section, + uint32_t &Offset) const = 0; + virtual bool addressForRVA(uint32_t RVA, uint32_t &Section, + uint32_t &Offset) const = 0; + + template <typename T> + std::unique_ptr<T> getConcreteSymbolById(SymIndexId SymbolId) const { + return unique_dyn_cast_or_null<T>(getSymbolById(SymbolId)); + } + + virtual std::unique_ptr<PDBSymbol> findSymbolByAddress(uint64_t Address, + PDB_SymType Type) = 0; + virtual std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA, + PDB_SymType Type) = 0; + virtual std::unique_ptr<PDBSymbol> + findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) = 0; + + virtual std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbers(const PDBSymbolCompiland &Compiland, + const IPDBSourceFile &File) const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersByAddress(uint64_t Address, uint32_t Length) const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const = 0; + virtual std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const = 0; + + virtual std::unique_ptr<IPDBEnumSourceFiles> + findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const = 0; + virtual std::unique_ptr<IPDBSourceFile> + findOneSourceFile(const PDBSymbolCompiland *Compiland, + llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const = 0; + virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> + findCompilandsForSourceFile(llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const = 0; + virtual std::unique_ptr<PDBSymbolCompiland> + findOneCompilandForSourceFile(llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const = 0; + + virtual std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const = 0; + virtual std::unique_ptr<IPDBEnumSourceFiles> + getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0; + virtual std::unique_ptr<IPDBSourceFile> + getSourceFileById(uint32_t FileId) const = 0; + + virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0; + + virtual std::unique_ptr<IPDBEnumTables> getEnumTables() const = 0; + + virtual std::unique_ptr<IPDBEnumInjectedSources> + getInjectedSources() const = 0; + + virtual std::unique_ptr<IPDBEnumSectionContribs> + getSectionContribs() const = 0; + + virtual std::unique_ptr<IPDBEnumFrameData> + getFrameData() const = 0; +}; +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSourceFile.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSourceFile.h index 1b6f1185c6..b9d6948857 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSourceFile.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBSourceFile.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBSourceFile.h - base interface for a PDB source file --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H -#define LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H - -#include "PDBTypes.h" -#include <memory> -#include <string> - -namespace llvm { -class raw_ostream; - -namespace pdb { - -/// IPDBSourceFile defines an interface used to represent source files whose -/// information are stored in the PDB. -class IPDBSourceFile { -public: - virtual ~IPDBSourceFile(); - - void dump(raw_ostream &OS, int Indent) const; - - virtual std::string getFileName() const = 0; - virtual uint32_t getUniqueId() const = 0; - virtual std::string getChecksum() const = 0; - virtual PDB_Checksum getChecksumType() const = 0; - virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> - getCompilands() const = 0; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBSourceFile.h - base interface for a PDB source file --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H +#define LLVM_DEBUGINFO_PDB_IPDBSOURCEFILE_H + +#include "PDBTypes.h" +#include <memory> +#include <string> + +namespace llvm { +class raw_ostream; + +namespace pdb { + +/// IPDBSourceFile defines an interface used to represent source files whose +/// information are stored in the PDB. +class IPDBSourceFile { +public: + virtual ~IPDBSourceFile(); + + void dump(raw_ostream &OS, int Indent) const; + + virtual std::string getFileName() const = 0; + virtual uint32_t getUniqueId() const = 0; + virtual std::string getChecksum() const = 0; + virtual PDB_Checksum getChecksumType() const = 0; + virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> + getCompilands() const = 0; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBTable.h index 63cbf8bbb7..424eb6206a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/IPDBTable.h @@ -1,38 +1,38 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- IPDBTable.h - Base Interface for a PDB Symbol Context ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_IPDBTABLE_H -#define LLVM_DEBUGINFO_PDB_IPDBTABLE_H - -#include "PDBTypes.h" - -namespace llvm { -namespace pdb { -class IPDBTable { -public: - virtual ~IPDBTable(); - - virtual std::string getName() const = 0; - virtual uint32_t getItemCount() const = 0; - virtual PDB_TableType getTableType() const = 0; -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_IPDBTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- IPDBTable.h - Base Interface for a PDB Symbol Context ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_IPDBTABLE_H +#define LLVM_DEBUGINFO_PDB_IPDBTABLE_H + +#include "PDBTypes.h" + +namespace llvm { +namespace pdb { +class IPDBTable { +public: + virtual ~IPDBTable(); + + virtual std::string getName() const = 0; + virtual uint32_t getItemCount() const = 0; + virtual PDB_TableType getTableType() const = 0; +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_IPDBTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h index 2698c4f411..e1742c981c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h @@ -1,82 +1,82 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DbiModuleDescriptor.h - PDB module information -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H -#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { - -namespace pdb { - -class DbiModuleDescriptor { - friend class DbiStreamBuilder; - -public: - DbiModuleDescriptor() = default; - DbiModuleDescriptor(const DbiModuleDescriptor &Info) = default; - DbiModuleDescriptor &operator=(const DbiModuleDescriptor &Info) = default; - - static Error initialize(BinaryStreamRef Stream, DbiModuleDescriptor &Info); - - bool hasECInfo() const; - uint16_t getTypeServerIndex() const; - uint16_t getModuleStreamIndex() const; - uint32_t getSymbolDebugInfoByteSize() const; - uint32_t getC11LineInfoByteSize() const; - uint32_t getC13LineInfoByteSize() const; - uint32_t getNumberOfFiles() const; - uint32_t getSourceFileNameIndex() const; - uint32_t getPdbFilePathNameIndex() const; - - StringRef getModuleName() const; - StringRef getObjFileName() const; - - uint32_t getRecordLength() const; - - const SectionContrib &getSectionContrib() const; - -private: - StringRef ModuleName; - StringRef ObjFileName; - const ModuleInfoHeader *Layout = nullptr; -}; - -} // end namespace pdb - -template <> struct VarStreamArrayExtractor<pdb::DbiModuleDescriptor> { - Error operator()(BinaryStreamRef Stream, uint32_t &Length, - pdb::DbiModuleDescriptor &Info) { - if (auto EC = pdb::DbiModuleDescriptor::initialize(Stream, Info)) - return EC; - Length = Info.getRecordLength(); - return Error::success(); - } -}; - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DbiModuleDescriptor.h - PDB module information -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H +#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { + +namespace pdb { + +class DbiModuleDescriptor { + friend class DbiStreamBuilder; + +public: + DbiModuleDescriptor() = default; + DbiModuleDescriptor(const DbiModuleDescriptor &Info) = default; + DbiModuleDescriptor &operator=(const DbiModuleDescriptor &Info) = default; + + static Error initialize(BinaryStreamRef Stream, DbiModuleDescriptor &Info); + + bool hasECInfo() const; + uint16_t getTypeServerIndex() const; + uint16_t getModuleStreamIndex() const; + uint32_t getSymbolDebugInfoByteSize() const; + uint32_t getC11LineInfoByteSize() const; + uint32_t getC13LineInfoByteSize() const; + uint32_t getNumberOfFiles() const; + uint32_t getSourceFileNameIndex() const; + uint32_t getPdbFilePathNameIndex() const; + + StringRef getModuleName() const; + StringRef getObjFileName() const; + + uint32_t getRecordLength() const; + + const SectionContrib &getSectionContrib() const; + +private: + StringRef ModuleName; + StringRef ObjFileName; + const ModuleInfoHeader *Layout = nullptr; +}; + +} // end namespace pdb + +template <> struct VarStreamArrayExtractor<pdb::DbiModuleDescriptor> { + Error operator()(BinaryStreamRef Stream, uint32_t &Length, + pdb::DbiModuleDescriptor &Info) { + if (auto EC = pdb::DbiModuleDescriptor::initialize(Stream, Info)) + return EC; + Length = Info.getRecordLength(); + return Error::success(); + } +}; + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h index 9c8b884edc..3b3598fc27 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DbiModuleDescriptorBuilder.h - PDB module information ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <string> -#include <vector> - -namespace llvm { -class BinaryStreamWriter; - -namespace codeview { -class DebugSubsectionRecordBuilder; -} - -namespace msf { -class MSFBuilder; -struct MSFLayout; -} -namespace pdb { - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DbiModuleDescriptorBuilder.h - PDB module information ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <string> +#include <vector> + +namespace llvm { +class BinaryStreamWriter; + +namespace codeview { +class DebugSubsectionRecordBuilder; +} + +namespace msf { +class MSFBuilder; +struct MSFLayout; +} +namespace pdb { + // Represents merged or unmerged symbols. Merged symbols can be written to the // output file as is, but unmerged symbols must be rewritten first. In either // case, the size must be known up front. @@ -69,20 +69,20 @@ struct StringTableFixup { uint32_t SymOffsetOfReference = 0; }; -class DbiModuleDescriptorBuilder { - friend class DbiStreamBuilder; - -public: - DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, - msf::MSFBuilder &Msf); - ~DbiModuleDescriptorBuilder(); - - DbiModuleDescriptorBuilder(const DbiModuleDescriptorBuilder &) = delete; - DbiModuleDescriptorBuilder & - operator=(const DbiModuleDescriptorBuilder &) = delete; - - void setPdbFilePathNI(uint32_t NI); - void setObjFileName(StringRef Name); +class DbiModuleDescriptorBuilder { + friend class DbiStreamBuilder; + +public: + DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, + msf::MSFBuilder &Msf); + ~DbiModuleDescriptorBuilder(); + + DbiModuleDescriptorBuilder(const DbiModuleDescriptorBuilder &) = delete; + DbiModuleDescriptorBuilder & + operator=(const DbiModuleDescriptorBuilder &) = delete; + + void setPdbFilePathNI(uint32_t NI); + void setObjFileName(StringRef Name); // Callback to merge one source of unmerged symbols. using MergeSymbolsCallback = Error (*)(void *Ctx, void *Symbols, @@ -97,77 +97,77 @@ public: StringTableFixups = std::move(Fixups); } - void setFirstSectionContrib(const SectionContrib &SC); - void addSymbol(codeview::CVSymbol Symbol); - void addSymbolsInBulk(ArrayRef<uint8_t> BulkSymbols); - + void setFirstSectionContrib(const SectionContrib &SC); + void addSymbol(codeview::CVSymbol Symbol); + void addSymbolsInBulk(ArrayRef<uint8_t> BulkSymbols); + // Add symbols of known size which will be merged (rewritten) when committing // the PDB to disk. void addUnmergedSymbols(void *SymSrc, uint32_t SymLength); - void - addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection); - - void - addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents); - - uint16_t getStreamIndex() const; - StringRef getModuleName() const { return ModuleName; } - StringRef getObjFileName() const { return ObjFileName; } - - unsigned getModuleIndex() const { return Layout.Mod; } - - ArrayRef<std::string> source_files() const { - return makeArrayRef(SourceFiles); - } - - uint32_t calculateSerializedLength() const; - - /// Return the offset within the module symbol stream of the next symbol - /// record passed to addSymbol. Add four to account for the signature. - uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; } - - void finalize(); - Error finalizeMsfLayout(); - + void + addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection); + + void + addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents); + + uint16_t getStreamIndex() const; + StringRef getModuleName() const { return ModuleName; } + StringRef getObjFileName() const { return ObjFileName; } + + unsigned getModuleIndex() const { return Layout.Mod; } + + ArrayRef<std::string> source_files() const { + return makeArrayRef(SourceFiles); + } + + uint32_t calculateSerializedLength() const; + + /// Return the offset within the module symbol stream of the next symbol + /// record passed to addSymbol. Add four to account for the signature. + uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; } + + void finalize(); + Error finalizeMsfLayout(); + /// Commit the DBI descriptor to the DBI stream. Error commit(BinaryStreamWriter &ModiWriter); - + /// Commit the accumulated symbols to the module symbol stream. Safe to call /// in parallel on different DbiModuleDescriptorBuilder objects. Only modifies /// the pre-allocated stream in question. Error commitSymbolStream(const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer); -private: - uint32_t calculateC13DebugInfoSize() const; - - void addSourceFile(StringRef Path); - msf::MSFBuilder &MSF; - - uint32_t SymbolByteSize = 0; - uint32_t PdbFilePathNI = 0; - std::string ModuleName; - std::string ObjFileName; - std::vector<std::string> SourceFiles; +private: + uint32_t calculateC13DebugInfoSize() const; + + void addSourceFile(StringRef Path); + msf::MSFBuilder &MSF; + + uint32_t SymbolByteSize = 0; + uint32_t PdbFilePathNI = 0; + std::string ModuleName; + std::string ObjFileName; + std::vector<std::string> SourceFiles; std::vector<SymbolListWrapper> Symbols; - + void *MergeSymsCtx = nullptr; MergeSymbolsCallback MergeSymsCallback = nullptr; std::vector<StringTableFixup> StringTableFixups; - std::vector<codeview::DebugSubsectionRecordBuilder> C13Builders; - - ModuleInfoHeader Layout; -}; - -} // end namespace pdb - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + std::vector<codeview::DebugSubsectionRecordBuilder> C13Builders; + + ModuleInfoHeader Layout; +}; + +} // end namespace pdb + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_DBIMODULEDESCRIPTORBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h index ee5cb6da09..ce12682393 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h @@ -1,129 +1,129 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DbiModuleList.h - PDB module information list ------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H -#define LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstddef> -#include <cstdint> -#include <iterator> -#include <vector> - -namespace llvm { -namespace pdb { - -class DbiModuleList; -struct FileInfoSubstreamHeader; - -class DbiModuleSourceFilesIterator - : public iterator_facade_base<DbiModuleSourceFilesIterator, - std::random_access_iterator_tag, StringRef> { - using BaseType = - iterator_facade_base<DbiModuleSourceFilesIterator, - std::random_access_iterator_tag, StringRef>; - -public: - DbiModuleSourceFilesIterator(const DbiModuleList &Modules, uint32_t Modi, - uint16_t Filei); - DbiModuleSourceFilesIterator() = default; - DbiModuleSourceFilesIterator(const DbiModuleSourceFilesIterator &R) = default; - DbiModuleSourceFilesIterator & - operator=(const DbiModuleSourceFilesIterator &R) = default; - - bool operator==(const DbiModuleSourceFilesIterator &R) const; - - const StringRef &operator*() const { return ThisValue; } - StringRef &operator*() { return ThisValue; } - - bool operator<(const DbiModuleSourceFilesIterator &RHS) const; - std::ptrdiff_t operator-(const DbiModuleSourceFilesIterator &R) const; - DbiModuleSourceFilesIterator &operator+=(std::ptrdiff_t N); - DbiModuleSourceFilesIterator &operator-=(std::ptrdiff_t N); - -private: - void setValue(); - - bool isEnd() const; - bool isCompatible(const DbiModuleSourceFilesIterator &R) const; - bool isUniversalEnd() const; - - StringRef ThisValue; - const DbiModuleList *Modules{nullptr}; - uint32_t Modi{0}; - uint16_t Filei{0}; -}; - -class DbiModuleList { - friend DbiModuleSourceFilesIterator; - -public: - Error initialize(BinaryStreamRef ModInfo, BinaryStreamRef FileInfo); - - Expected<StringRef> getFileName(uint32_t Index) const; - uint32_t getModuleCount() const; - uint32_t getSourceFileCount() const; - uint16_t getSourceFileCount(uint32_t Modi) const; - - iterator_range<DbiModuleSourceFilesIterator> - source_files(uint32_t Modi) const; - - DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const; - -private: - Error initializeModInfo(BinaryStreamRef ModInfo); - Error initializeFileInfo(BinaryStreamRef FileInfo); - - VarStreamArray<DbiModuleDescriptor> Descriptors; - - FixedStreamArray<support::little32_t> FileNameOffsets; - FixedStreamArray<support::ulittle16_t> ModFileCountArray; - - // For each module, there are multiple filenames, which can be obtained by - // knowing the index of the file. Given the index of the file, one can use - // that as an offset into the FileNameOffsets array, which contains the - // absolute offset of the file name in NamesBuffer. Thus, for each module - // we store the first index in the FileNameOffsets array for this module. - // The number of files for the corresponding module is stored in - // ModFileCountArray. - std::vector<uint32_t> ModuleInitialFileIndex; - - // In order to provide random access into the Descriptors array, we iterate it - // once up front to find the offsets of the individual items and store them in - // this array. - std::vector<uint32_t> ModuleDescriptorOffsets; - - const FileInfoSubstreamHeader *FileInfoHeader = nullptr; - - BinaryStreamRef ModInfoSubstream; - BinaryStreamRef FileInfoSubstream; - BinaryStreamRef NamesBuffer; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DbiModuleList.h - PDB module information list ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H +#define LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstddef> +#include <cstdint> +#include <iterator> +#include <vector> + +namespace llvm { +namespace pdb { + +class DbiModuleList; +struct FileInfoSubstreamHeader; + +class DbiModuleSourceFilesIterator + : public iterator_facade_base<DbiModuleSourceFilesIterator, + std::random_access_iterator_tag, StringRef> { + using BaseType = + iterator_facade_base<DbiModuleSourceFilesIterator, + std::random_access_iterator_tag, StringRef>; + +public: + DbiModuleSourceFilesIterator(const DbiModuleList &Modules, uint32_t Modi, + uint16_t Filei); + DbiModuleSourceFilesIterator() = default; + DbiModuleSourceFilesIterator(const DbiModuleSourceFilesIterator &R) = default; + DbiModuleSourceFilesIterator & + operator=(const DbiModuleSourceFilesIterator &R) = default; + + bool operator==(const DbiModuleSourceFilesIterator &R) const; + + const StringRef &operator*() const { return ThisValue; } + StringRef &operator*() { return ThisValue; } + + bool operator<(const DbiModuleSourceFilesIterator &RHS) const; + std::ptrdiff_t operator-(const DbiModuleSourceFilesIterator &R) const; + DbiModuleSourceFilesIterator &operator+=(std::ptrdiff_t N); + DbiModuleSourceFilesIterator &operator-=(std::ptrdiff_t N); + +private: + void setValue(); + + bool isEnd() const; + bool isCompatible(const DbiModuleSourceFilesIterator &R) const; + bool isUniversalEnd() const; + + StringRef ThisValue; + const DbiModuleList *Modules{nullptr}; + uint32_t Modi{0}; + uint16_t Filei{0}; +}; + +class DbiModuleList { + friend DbiModuleSourceFilesIterator; + +public: + Error initialize(BinaryStreamRef ModInfo, BinaryStreamRef FileInfo); + + Expected<StringRef> getFileName(uint32_t Index) const; + uint32_t getModuleCount() const; + uint32_t getSourceFileCount() const; + uint16_t getSourceFileCount(uint32_t Modi) const; + + iterator_range<DbiModuleSourceFilesIterator> + source_files(uint32_t Modi) const; + + DbiModuleDescriptor getModuleDescriptor(uint32_t Modi) const; + +private: + Error initializeModInfo(BinaryStreamRef ModInfo); + Error initializeFileInfo(BinaryStreamRef FileInfo); + + VarStreamArray<DbiModuleDescriptor> Descriptors; + + FixedStreamArray<support::little32_t> FileNameOffsets; + FixedStreamArray<support::ulittle16_t> ModFileCountArray; + + // For each module, there are multiple filenames, which can be obtained by + // knowing the index of the file. Given the index of the file, one can use + // that as an offset into the FileNameOffsets array, which contains the + // absolute offset of the file name in NamesBuffer. Thus, for each module + // we store the first index in the FileNameOffsets array for this module. + // The number of files for the corresponding module is stored in + // ModFileCountArray. + std::vector<uint32_t> ModuleInitialFileIndex; + + // In order to provide random access into the Descriptors array, we iterate it + // once up front to find the offsets of the individual items and store them in + // this array. + std::vector<uint32_t> ModuleDescriptorOffsets; + + const FileInfoSubstreamHeader *FileInfoHeader = nullptr; + + BinaryStreamRef ModInfoSubstream; + BinaryStreamRef FileInfoSubstream; + BinaryStreamRef NamesBuffer; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_DBIMODULELIST_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStream.h index fa437f8ea8..07228dd98e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStream.h @@ -1,149 +1,149 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H - -#include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" -#include "llvm/DebugInfo/MSF/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" -#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h" -#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace object { -struct FpoData; -struct coff_section; -} - -namespace pdb { -class DbiStreamBuilder; -class PDBFile; -class ISectionContribVisitor; - -class DbiStream { - friend class DbiStreamBuilder; - -public: - explicit DbiStream(std::unique_ptr<BinaryStream> Stream); - ~DbiStream(); - Error reload(PDBFile *Pdb); - - PdbRaw_DbiVer getDbiVersion() const; - uint32_t getAge() const; - uint16_t getPublicSymbolStreamIndex() const; - uint16_t getGlobalSymbolStreamIndex() const; - - uint16_t getFlags() const; - bool isIncrementallyLinked() const; - bool hasCTypes() const; - bool isStripped() const; - - uint16_t getBuildNumber() const; - uint16_t getBuildMajorVersion() const; - uint16_t getBuildMinorVersion() const; - - uint16_t getPdbDllRbld() const; - uint32_t getPdbDllVersion() const; - - uint32_t getSymRecordStreamIndex() const; - - PDB_Machine getMachineType() const; - - const DbiStreamHeader *getHeader() const { return Header; } - - BinarySubstreamRef getSectionContributionData() const; - BinarySubstreamRef getSecMapSubstreamData() const; - BinarySubstreamRef getModiSubstreamData() const; - BinarySubstreamRef getFileInfoSubstreamData() const; - BinarySubstreamRef getTypeServerMapSubstreamData() const; - BinarySubstreamRef getECSubstreamData() const; - - /// If the given stream type is present, returns its stream index. If it is - /// not present, returns InvalidStreamIndex. - uint32_t getDebugStreamIndex(DbgHeaderType Type) const; - - const DbiModuleList &modules() const; - - FixedStreamArray<object::coff_section> getSectionHeaders() const; - - bool hasOldFpoRecords() const; - FixedStreamArray<object::FpoData> getOldFpoRecords() const; - bool hasNewFpoRecords() const; - const codeview::DebugFrameDataSubsectionRef &getNewFpoRecords() const; - - FixedStreamArray<SecMapEntry> getSectionMap() const; - void visitSectionContributions(ISectionContribVisitor &Visitor) const; - - Expected<StringRef> getECName(uint32_t NI) const; - -private: - Error initializeSectionContributionData(); - Error initializeSectionHeadersData(PDBFile *Pdb); - Error initializeSectionMapData(); - Error initializeOldFpoRecords(PDBFile *Pdb); - Error initializeNewFpoRecords(PDBFile *Pdb); - - Expected<std::unique_ptr<msf::MappedBlockStream>> - createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const; - - std::unique_ptr<BinaryStream> Stream; - - PDBStringTable ECNames; - - BinarySubstreamRef SecContrSubstream; - BinarySubstreamRef SecMapSubstream; - BinarySubstreamRef ModiSubstream; - BinarySubstreamRef FileInfoSubstream; - BinarySubstreamRef TypeServerMapSubstream; - BinarySubstreamRef ECSubstream; - - DbiModuleList Modules; - - FixedStreamArray<support::ulittle16_t> DbgStreams; - - PdbRaw_DbiSecContribVer SectionContribVersion = - PdbRaw_DbiSecContribVer::DbiSecContribVer60; - FixedStreamArray<SectionContrib> SectionContribs; - FixedStreamArray<SectionContrib2> SectionContribs2; - FixedStreamArray<SecMapEntry> SectionMap; - - std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream; - FixedStreamArray<object::coff_section> SectionHeaders; - - std::unique_ptr<msf::MappedBlockStream> OldFpoStream; - FixedStreamArray<object::FpoData> OldFpoRecords; - - std::unique_ptr<msf::MappedBlockStream> NewFpoStream; - codeview::DebugFrameDataSubsectionRef NewFpoRecords; - - const DbiStreamHeader *Header; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H + +#include "llvm/DebugInfo/CodeView/DebugSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleList.h" +#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace object { +struct FpoData; +struct coff_section; +} + +namespace pdb { +class DbiStreamBuilder; +class PDBFile; +class ISectionContribVisitor; + +class DbiStream { + friend class DbiStreamBuilder; + +public: + explicit DbiStream(std::unique_ptr<BinaryStream> Stream); + ~DbiStream(); + Error reload(PDBFile *Pdb); + + PdbRaw_DbiVer getDbiVersion() const; + uint32_t getAge() const; + uint16_t getPublicSymbolStreamIndex() const; + uint16_t getGlobalSymbolStreamIndex() const; + + uint16_t getFlags() const; + bool isIncrementallyLinked() const; + bool hasCTypes() const; + bool isStripped() const; + + uint16_t getBuildNumber() const; + uint16_t getBuildMajorVersion() const; + uint16_t getBuildMinorVersion() const; + + uint16_t getPdbDllRbld() const; + uint32_t getPdbDllVersion() const; + + uint32_t getSymRecordStreamIndex() const; + + PDB_Machine getMachineType() const; + + const DbiStreamHeader *getHeader() const { return Header; } + + BinarySubstreamRef getSectionContributionData() const; + BinarySubstreamRef getSecMapSubstreamData() const; + BinarySubstreamRef getModiSubstreamData() const; + BinarySubstreamRef getFileInfoSubstreamData() const; + BinarySubstreamRef getTypeServerMapSubstreamData() const; + BinarySubstreamRef getECSubstreamData() const; + + /// If the given stream type is present, returns its stream index. If it is + /// not present, returns InvalidStreamIndex. + uint32_t getDebugStreamIndex(DbgHeaderType Type) const; + + const DbiModuleList &modules() const; + + FixedStreamArray<object::coff_section> getSectionHeaders() const; + + bool hasOldFpoRecords() const; + FixedStreamArray<object::FpoData> getOldFpoRecords() const; + bool hasNewFpoRecords() const; + const codeview::DebugFrameDataSubsectionRef &getNewFpoRecords() const; + + FixedStreamArray<SecMapEntry> getSectionMap() const; + void visitSectionContributions(ISectionContribVisitor &Visitor) const; + + Expected<StringRef> getECName(uint32_t NI) const; + +private: + Error initializeSectionContributionData(); + Error initializeSectionHeadersData(PDBFile *Pdb); + Error initializeSectionMapData(); + Error initializeOldFpoRecords(PDBFile *Pdb); + Error initializeNewFpoRecords(PDBFile *Pdb); + + Expected<std::unique_ptr<msf::MappedBlockStream>> + createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const; + + std::unique_ptr<BinaryStream> Stream; + + PDBStringTable ECNames; + + BinarySubstreamRef SecContrSubstream; + BinarySubstreamRef SecMapSubstream; + BinarySubstreamRef ModiSubstream; + BinarySubstreamRef FileInfoSubstream; + BinarySubstreamRef TypeServerMapSubstream; + BinarySubstreamRef ECSubstream; + + DbiModuleList Modules; + + FixedStreamArray<support::ulittle16_t> DbgStreams; + + PdbRaw_DbiSecContribVer SectionContribVersion = + PdbRaw_DbiSecContribVer::DbiSecContribVer60; + FixedStreamArray<SectionContrib> SectionContribs; + FixedStreamArray<SectionContrib2> SectionContribs2; + FixedStreamArray<SecMapEntry> SectionMap; + + std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream; + FixedStreamArray<object::coff_section> SectionHeaders; + + std::unique_ptr<msf::MappedBlockStream> OldFpoStream; + FixedStreamArray<object::FpoData> OldFpoRecords; + + std::unique_ptr<msf::MappedBlockStream> NewFpoStream; + codeview::DebugFrameDataSubsectionRef NewFpoRecords; + + const DbiStreamHeader *Header; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h index 5830e78070..931c27ca65 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h @@ -1,151 +1,151 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- DbiStreamBuilder.h - PDB Dbi Stream Creation -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAMBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAMBUILDER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/BinaryFormat/COFF.h" -#include "llvm/Support/Error.h" - -#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" -#include "llvm/DebugInfo/PDB/Native/PDBFile.h" -#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" - -namespace llvm { -namespace codeview { -struct FrameData; -} -namespace msf { -class MSFBuilder; -} -namespace object { -struct coff_section; -struct FpoData; -} -namespace pdb { -class DbiStream; -struct DbiStreamHeader; -class DbiModuleDescriptorBuilder; -class PDBFile; - -class DbiStreamBuilder { -public: - DbiStreamBuilder(msf::MSFBuilder &Msf); - ~DbiStreamBuilder(); - - DbiStreamBuilder(const DbiStreamBuilder &) = delete; - DbiStreamBuilder &operator=(const DbiStreamBuilder &) = delete; - - void setVersionHeader(PdbRaw_DbiVer V); - void setAge(uint32_t A); - void setBuildNumber(uint16_t B); - void setBuildNumber(uint8_t Major, uint8_t Minor); - void setPdbDllVersion(uint16_t V); - void setPdbDllRbld(uint16_t R); - void setFlags(uint16_t F); - void setMachineType(PDB_Machine M); - void setMachineType(COFF::MachineTypes M); - - // Add given bytes as a new stream. - Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef<uint8_t> Data); - - uint32_t addECName(StringRef Name); - - uint32_t calculateSerializedLength() const; - - void setGlobalsStreamIndex(uint32_t Index); - void setPublicsStreamIndex(uint32_t Index); - void setSymbolRecordStreamIndex(uint32_t Index); - void addNewFpoData(const codeview::FrameData &FD); - void addOldFpoData(const object::FpoData &Fpo); - - Expected<DbiModuleDescriptorBuilder &> addModuleInfo(StringRef ModuleName); - Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File); - Expected<uint32_t> getSourceFileNameIndex(StringRef FileName); - - Error finalizeMsfLayout(); - - Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer); - - void addSectionContrib(const SectionContrib &SC) { - SectionContribs.emplace_back(SC); - } - - // Populate the Section Map from COFF section headers. - void createSectionMap(ArrayRef<llvm::object::coff_section> SecHdrs); - -private: - struct DebugStream { - std::function<Error(BinaryStreamWriter &)> WriteFn; - uint32_t Size = 0; - uint16_t StreamNumber = kInvalidStreamIndex; - }; - - Error finalize(); - uint32_t calculateModiSubstreamSize() const; - uint32_t calculateNamesOffset() const; - uint32_t calculateSectionContribsStreamSize() const; - uint32_t calculateSectionMapStreamSize() const; - uint32_t calculateFileInfoSubstreamSize() const; - uint32_t calculateNamesBufferSize() const; - uint32_t calculateDbgStreamsSize() const; - - Error generateFileInfoSubstream(); - - msf::MSFBuilder &Msf; - BumpPtrAllocator &Allocator; - - Optional<PdbRaw_DbiVer> VerHeader; - uint32_t Age; - uint16_t BuildNumber; - uint16_t PdbDllVersion; - uint16_t PdbDllRbld; - uint16_t Flags; - PDB_Machine MachineType; - uint32_t GlobalsStreamIndex = kInvalidStreamIndex; - uint32_t PublicsStreamIndex = kInvalidStreamIndex; - uint32_t SymRecordStreamIndex = kInvalidStreamIndex; - - const DbiStreamHeader *Header; - - std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList; - - Optional<codeview::DebugFrameDataSubsection> NewFpoData; - std::vector<object::FpoData> OldFpoData; - - StringMap<uint32_t> SourceFileNames; - - PDBStringTableBuilder ECNamesBuilder; - WritableBinaryStreamRef NamesBuffer; - MutableBinaryByteStream FileInfoBuffer; - std::vector<SectionContrib> SectionContribs; - std::vector<SecMapEntry> SectionMap; - std::array<Optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- DbiStreamBuilder.h - PDB Dbi Stream Creation -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAMBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAMBUILDER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/BinaryFormat/COFF.h" +#include "llvm/Support/Error.h" + +#include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Endian.h" + +namespace llvm { +namespace codeview { +struct FrameData; +} +namespace msf { +class MSFBuilder; +} +namespace object { +struct coff_section; +struct FpoData; +} +namespace pdb { +class DbiStream; +struct DbiStreamHeader; +class DbiModuleDescriptorBuilder; +class PDBFile; + +class DbiStreamBuilder { +public: + DbiStreamBuilder(msf::MSFBuilder &Msf); + ~DbiStreamBuilder(); + + DbiStreamBuilder(const DbiStreamBuilder &) = delete; + DbiStreamBuilder &operator=(const DbiStreamBuilder &) = delete; + + void setVersionHeader(PdbRaw_DbiVer V); + void setAge(uint32_t A); + void setBuildNumber(uint16_t B); + void setBuildNumber(uint8_t Major, uint8_t Minor); + void setPdbDllVersion(uint16_t V); + void setPdbDllRbld(uint16_t R); + void setFlags(uint16_t F); + void setMachineType(PDB_Machine M); + void setMachineType(COFF::MachineTypes M); + + // Add given bytes as a new stream. + Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef<uint8_t> Data); + + uint32_t addECName(StringRef Name); + + uint32_t calculateSerializedLength() const; + + void setGlobalsStreamIndex(uint32_t Index); + void setPublicsStreamIndex(uint32_t Index); + void setSymbolRecordStreamIndex(uint32_t Index); + void addNewFpoData(const codeview::FrameData &FD); + void addOldFpoData(const object::FpoData &Fpo); + + Expected<DbiModuleDescriptorBuilder &> addModuleInfo(StringRef ModuleName); + Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File); + Expected<uint32_t> getSourceFileNameIndex(StringRef FileName); + + Error finalizeMsfLayout(); + + Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer); + + void addSectionContrib(const SectionContrib &SC) { + SectionContribs.emplace_back(SC); + } + + // Populate the Section Map from COFF section headers. + void createSectionMap(ArrayRef<llvm::object::coff_section> SecHdrs); + +private: + struct DebugStream { + std::function<Error(BinaryStreamWriter &)> WriteFn; + uint32_t Size = 0; + uint16_t StreamNumber = kInvalidStreamIndex; + }; + + Error finalize(); + uint32_t calculateModiSubstreamSize() const; + uint32_t calculateNamesOffset() const; + uint32_t calculateSectionContribsStreamSize() const; + uint32_t calculateSectionMapStreamSize() const; + uint32_t calculateFileInfoSubstreamSize() const; + uint32_t calculateNamesBufferSize() const; + uint32_t calculateDbgStreamsSize() const; + + Error generateFileInfoSubstream(); + + msf::MSFBuilder &Msf; + BumpPtrAllocator &Allocator; + + Optional<PdbRaw_DbiVer> VerHeader; + uint32_t Age; + uint16_t BuildNumber; + uint16_t PdbDllVersion; + uint16_t PdbDllRbld; + uint16_t Flags; + PDB_Machine MachineType; + uint32_t GlobalsStreamIndex = kInvalidStreamIndex; + uint32_t PublicsStreamIndex = kInvalidStreamIndex; + uint32_t SymRecordStreamIndex = kInvalidStreamIndex; + + const DbiStreamHeader *Header; + + std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList; + + Optional<codeview::DebugFrameDataSubsection> NewFpoData; + std::vector<object::FpoData> OldFpoData; + + StringMap<uint32_t> SourceFileNames; + + PDBStringTableBuilder ECNamesBuilder; + WritableBinaryStreamRef NamesBuffer; + MutableBinaryByteStream FileInfoBuffer; + std::vector<SectionContrib> SectionContribs; + std::vector<SecMapEntry> SectionMap; + std::array<Optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/EnumTables.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/EnumTables.h index 4633a7cfab..2ec3fac3ca 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/EnumTables.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/EnumTables.h @@ -1,32 +1,32 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- EnumTables.h - Enum to string conversion tables ----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H -#define LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/Support/ScopedPrinter.h" - -namespace llvm { -namespace pdb { -ArrayRef<EnumEntry<uint16_t>> getOMFSegMapDescFlagNames(); -} -} - -#endif // LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- EnumTables.h - Enum to string conversion tables ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H +#define LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/ScopedPrinter.h" + +namespace llvm { +namespace pdb { +ArrayRef<EnumEntry<uint16_t>> getOMFSegMapDescFlagNames(); +} +} + +#endif // LLVM_DEBUGINFO_PDB_RAW_ENUMTABLES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Formatters.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Formatters.h index d2fae99795..d5fd6a83d0 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Formatters.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Formatters.h @@ -1,55 +1,55 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Formatters.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_FORMATTERS_H -#define LLVM_DEBUGINFO_PDB_NATIVE_FORMATTERS_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/Formatters.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/FormatProviders.h" - -#define FORMAT_CASE(Value, Name) \ - case Value: \ - Stream << Name; \ - break; - -namespace llvm { -template <> struct format_provider<pdb::PdbRaw_ImplVer> { - static void format(const pdb::PdbRaw_ImplVer &V, llvm::raw_ostream &Stream, - StringRef Style) { - switch (V) { - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC110, "VC110") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC140, "VC140") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC2, "VC2") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC4, "VC4") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC41, "VC41") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC50, "VC50") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC70, "VC70") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC70Dep, "VC70Dep") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC80, "VC80") - FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC98, "VC98") - } - } -}; -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Formatters.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_FORMATTERS_H +#define LLVM_DEBUGINFO_PDB_NATIVE_FORMATTERS_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/Formatters.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/FormatProviders.h" + +#define FORMAT_CASE(Value, Name) \ + case Value: \ + Stream << Name; \ + break; + +namespace llvm { +template <> struct format_provider<pdb::PdbRaw_ImplVer> { + static void format(const pdb::PdbRaw_ImplVer &V, llvm::raw_ostream &Stream, + StringRef Style) { + switch (V) { + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC110, "VC110") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC140, "VC140") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC2, "VC2") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC4, "VC4") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC41, "VC41") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC50, "VC50") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC70, "VC70") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC70Dep, "VC70Dep") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC80, "VC80") + FORMAT_CASE(pdb::PdbRaw_ImplVer::PdbImplVC98, "VC98") + } + } +}; +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h index abf829f971..03ffca9059 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h @@ -1,159 +1,159 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H - -#include "llvm/ADT/DenseSet.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryItemStream.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" - -namespace llvm { - -template <> struct BinaryItemTraits<codeview::CVSymbol> { - static size_t length(const codeview::CVSymbol &Item) { - return Item.RecordData.size(); - } - static ArrayRef<uint8_t> bytes(const codeview::CVSymbol &Item) { - return Item.RecordData; - } -}; - -namespace msf { -class MSFBuilder; -struct MSFLayout; -} // namespace msf -namespace pdb { -struct GSIHashStreamBuilder; -struct BulkPublic; -struct SymbolDenseMapInfo; - -class GSIStreamBuilder { - -public: - explicit GSIStreamBuilder(msf::MSFBuilder &Msf); - ~GSIStreamBuilder(); - - GSIStreamBuilder(const GSIStreamBuilder &) = delete; - GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete; - - Error finalizeMsfLayout(); - - Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); - - uint32_t getPublicsStreamIndex() const { return PublicsStreamIndex; } - uint32_t getGlobalsStreamIndex() const { return GlobalsStreamIndex; } - uint32_t getRecordStreamIndex() const { return RecordStreamIndex; } - - // Add public symbols in bulk. - void addPublicSymbols(std::vector<BulkPublic> &&PublicsIn); - - void addGlobalSymbol(const codeview::ProcRefSym &Sym); - void addGlobalSymbol(const codeview::DataSym &Sym); - void addGlobalSymbol(const codeview::ConstantSym &Sym); - - // Add a pre-serialized global symbol record. The caller must ensure that the - // symbol data remains alive until the global stream is committed to disk. - void addGlobalSymbol(const codeview::CVSymbol &Sym); - -private: - void finalizePublicBuckets(); - void finalizeGlobalBuckets(uint32_t RecordZeroOffset); - - template <typename T> void serializeAndAddGlobal(const T &Symbol); - - uint32_t calculatePublicsHashStreamSize() const; - uint32_t calculateGlobalsHashStreamSize() const; - Error commitSymbolRecordStream(WritableBinaryStreamRef Stream); - Error commitPublicsHashStream(WritableBinaryStreamRef Stream); - Error commitGlobalsHashStream(WritableBinaryStreamRef Stream); - - uint32_t PublicsStreamIndex = kInvalidStreamIndex; - uint32_t GlobalsStreamIndex = kInvalidStreamIndex; - uint32_t RecordStreamIndex = kInvalidStreamIndex; - msf::MSFBuilder &Msf; - std::unique_ptr<GSIHashStreamBuilder> PSH; - std::unique_ptr<GSIHashStreamBuilder> GSH; - - // List of all of the public records. These are stored unserialized so that we - // can defer copying the names until we are ready to commit the PDB. - std::vector<BulkPublic> Publics; - - // List of all of the global records. - std::vector<codeview::CVSymbol> Globals; - - // Hash table for deduplicating global typedef and constant records. Only used - // for globals. - llvm::DenseSet<codeview::CVSymbol, SymbolDenseMapInfo> GlobalsSeen; -}; - -/// This struct is equivalent to codeview::PublicSym32, but it has been -/// optimized for size to speed up bulk serialization and sorting operations -/// during PDB writing. -struct BulkPublic { - BulkPublic() : Flags(0), BucketIdx(0) {} - - const char *Name = nullptr; - uint32_t NameLen = 0; - - // Offset of the symbol record in the publics stream. - uint32_t SymOffset = 0; - - // Section offset of the symbol in the image. - uint32_t Offset = 0; - - // Section index of the section containing the symbol. - uint16_t Segment = 0; - - // PublicSymFlags. - uint16_t Flags : 4; - - // GSI hash table bucket index. The maximum value is IPHR_HASH. - uint16_t BucketIdx : 12; - static_assert(IPHR_HASH <= 1 << 12, "bitfield too small"); - - void setFlags(codeview::PublicSymFlags F) { - Flags = uint32_t(F); - assert(Flags == uint32_t(F) && "truncated"); - } - - void setBucketIdx(uint16_t B) { - assert(B < IPHR_HASH); - BucketIdx = B; - } - - StringRef getName() const { return StringRef(Name, NameLen); } -}; - -static_assert(sizeof(BulkPublic) <= 24, "unexpected size increase"); -static_assert(std::is_trivially_copyable<BulkPublic>::value, - "should be trivial"); - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H + +#include "llvm/ADT/DenseSet.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryItemStream.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" + +namespace llvm { + +template <> struct BinaryItemTraits<codeview::CVSymbol> { + static size_t length(const codeview::CVSymbol &Item) { + return Item.RecordData.size(); + } + static ArrayRef<uint8_t> bytes(const codeview::CVSymbol &Item) { + return Item.RecordData; + } +}; + +namespace msf { +class MSFBuilder; +struct MSFLayout; +} // namespace msf +namespace pdb { +struct GSIHashStreamBuilder; +struct BulkPublic; +struct SymbolDenseMapInfo; + +class GSIStreamBuilder { + +public: + explicit GSIStreamBuilder(msf::MSFBuilder &Msf); + ~GSIStreamBuilder(); + + GSIStreamBuilder(const GSIStreamBuilder &) = delete; + GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete; + + Error finalizeMsfLayout(); + + Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); + + uint32_t getPublicsStreamIndex() const { return PublicsStreamIndex; } + uint32_t getGlobalsStreamIndex() const { return GlobalsStreamIndex; } + uint32_t getRecordStreamIndex() const { return RecordStreamIndex; } + + // Add public symbols in bulk. + void addPublicSymbols(std::vector<BulkPublic> &&PublicsIn); + + void addGlobalSymbol(const codeview::ProcRefSym &Sym); + void addGlobalSymbol(const codeview::DataSym &Sym); + void addGlobalSymbol(const codeview::ConstantSym &Sym); + + // Add a pre-serialized global symbol record. The caller must ensure that the + // symbol data remains alive until the global stream is committed to disk. + void addGlobalSymbol(const codeview::CVSymbol &Sym); + +private: + void finalizePublicBuckets(); + void finalizeGlobalBuckets(uint32_t RecordZeroOffset); + + template <typename T> void serializeAndAddGlobal(const T &Symbol); + + uint32_t calculatePublicsHashStreamSize() const; + uint32_t calculateGlobalsHashStreamSize() const; + Error commitSymbolRecordStream(WritableBinaryStreamRef Stream); + Error commitPublicsHashStream(WritableBinaryStreamRef Stream); + Error commitGlobalsHashStream(WritableBinaryStreamRef Stream); + + uint32_t PublicsStreamIndex = kInvalidStreamIndex; + uint32_t GlobalsStreamIndex = kInvalidStreamIndex; + uint32_t RecordStreamIndex = kInvalidStreamIndex; + msf::MSFBuilder &Msf; + std::unique_ptr<GSIHashStreamBuilder> PSH; + std::unique_ptr<GSIHashStreamBuilder> GSH; + + // List of all of the public records. These are stored unserialized so that we + // can defer copying the names until we are ready to commit the PDB. + std::vector<BulkPublic> Publics; + + // List of all of the global records. + std::vector<codeview::CVSymbol> Globals; + + // Hash table for deduplicating global typedef and constant records. Only used + // for globals. + llvm::DenseSet<codeview::CVSymbol, SymbolDenseMapInfo> GlobalsSeen; +}; + +/// This struct is equivalent to codeview::PublicSym32, but it has been +/// optimized for size to speed up bulk serialization and sorting operations +/// during PDB writing. +struct BulkPublic { + BulkPublic() : Flags(0), BucketIdx(0) {} + + const char *Name = nullptr; + uint32_t NameLen = 0; + + // Offset of the symbol record in the publics stream. + uint32_t SymOffset = 0; + + // Section offset of the symbol in the image. + uint32_t Offset = 0; + + // Section index of the section containing the symbol. + uint16_t Segment = 0; + + // PublicSymFlags. + uint16_t Flags : 4; + + // GSI hash table bucket index. The maximum value is IPHR_HASH. + uint16_t BucketIdx : 12; + static_assert(IPHR_HASH <= 1 << 12, "bitfield too small"); + + void setFlags(codeview::PublicSymFlags F) { + Flags = uint32_t(F); + assert(Flags == uint32_t(F) && "truncated"); + } + + void setBucketIdx(uint16_t B) { + assert(B < IPHR_HASH); + BucketIdx = B; + } + + StringRef getName() const { return StringRef(Name, NameLen); } +}; + +static_assert(sizeof(BulkPublic) <= 24, "unexpected size increase"); +static_assert(std::is_trivially_copyable<BulkPublic>::value, + "should be trivial"); + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h index d84632769a..511b12e58f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h @@ -1,98 +1,98 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- GlobalsStream.h - PDB Index of Symbols by Name -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H - -#include "llvm/ADT/iterator.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/MSF/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { -class DbiStream; -class PDBFile; -class SymbolStream; - -/// Iterator over hash records producing symbol record offsets. Abstracts away -/// the fact that symbol record offsets on disk are off-by-one. -class GSIHashIterator - : public iterator_adaptor_base< - GSIHashIterator, FixedStreamArrayIterator<PSHashRecord>, - std::random_access_iterator_tag, const uint32_t> { -public: - template <typename T> - GSIHashIterator(T &&v) - : GSIHashIterator::iterator_adaptor_base(std::forward<T &&>(v)) {} - - uint32_t operator*() const { - uint32_t Off = this->I->Off; - return --Off; - } -}; - -/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp -enum : unsigned { IPHR_HASH = 4096 }; - -/// A readonly view of a hash table used in the globals and publics streams. -/// Most clients will only want to iterate this to get symbol record offsets -/// into the PDB symbol stream. -class GSIHashTable { -public: - const GSIHashHeader *HashHdr; - FixedStreamArray<PSHashRecord> HashRecords; - FixedStreamArray<support::ulittle32_t> HashBitmap; - FixedStreamArray<support::ulittle32_t> HashBuckets; - std::array<int32_t, IPHR_HASH + 1> BucketMap; - - Error read(BinaryStreamReader &Reader); - - uint32_t getVerSignature() const { return HashHdr->VerSignature; } - uint32_t getVerHeader() const { return HashHdr->VerHdr; } - uint32_t getHashRecordSize() const { return HashHdr->HrSize; } - uint32_t getNumBuckets() const { return HashHdr->NumBuckets; } - - typedef GSIHashHeader iterator; - GSIHashIterator begin() const { return GSIHashIterator(HashRecords.begin()); } - GSIHashIterator end() const { return GSIHashIterator(HashRecords.end()); } -}; - -class GlobalsStream { -public: - explicit GlobalsStream(std::unique_ptr<msf::MappedBlockStream> Stream); - ~GlobalsStream(); - const GSIHashTable &getGlobalsTable() const { return GlobalsTable; } - Error reload(); - - std::vector<std::pair<uint32_t, codeview::CVSymbol>> - findRecordsByName(StringRef Name, const SymbolStream &Symbols) const; - -private: - GSIHashTable GlobalsTable; - std::unique_ptr<msf::MappedBlockStream> Stream; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- GlobalsStream.h - PDB Index of Symbols by Name -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_GLOBALS_STREAM_H + +#include "llvm/ADT/iterator.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { +class DbiStream; +class PDBFile; +class SymbolStream; + +/// Iterator over hash records producing symbol record offsets. Abstracts away +/// the fact that symbol record offsets on disk are off-by-one. +class GSIHashIterator + : public iterator_adaptor_base< + GSIHashIterator, FixedStreamArrayIterator<PSHashRecord>, + std::random_access_iterator_tag, const uint32_t> { +public: + template <typename T> + GSIHashIterator(T &&v) + : GSIHashIterator::iterator_adaptor_base(std::forward<T &&>(v)) {} + + uint32_t operator*() const { + uint32_t Off = this->I->Off; + return --Off; + } +}; + +/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp +enum : unsigned { IPHR_HASH = 4096 }; + +/// A readonly view of a hash table used in the globals and publics streams. +/// Most clients will only want to iterate this to get symbol record offsets +/// into the PDB symbol stream. +class GSIHashTable { +public: + const GSIHashHeader *HashHdr; + FixedStreamArray<PSHashRecord> HashRecords; + FixedStreamArray<support::ulittle32_t> HashBitmap; + FixedStreamArray<support::ulittle32_t> HashBuckets; + std::array<int32_t, IPHR_HASH + 1> BucketMap; + + Error read(BinaryStreamReader &Reader); + + uint32_t getVerSignature() const { return HashHdr->VerSignature; } + uint32_t getVerHeader() const { return HashHdr->VerHdr; } + uint32_t getHashRecordSize() const { return HashHdr->HrSize; } + uint32_t getNumBuckets() const { return HashHdr->NumBuckets; } + + typedef GSIHashHeader iterator; + GSIHashIterator begin() const { return GSIHashIterator(HashRecords.begin()); } + GSIHashIterator end() const { return GSIHashIterator(HashRecords.end()); } +}; + +class GlobalsStream { +public: + explicit GlobalsStream(std::unique_ptr<msf::MappedBlockStream> Stream); + ~GlobalsStream(); + const GSIHashTable &getGlobalsTable() const { return GlobalsTable; } + Error reload(); + + std::vector<std::pair<uint32_t, codeview::CVSymbol>> + findRecordsByName(StringRef Name, const SymbolStream &Symbols) const; + +private: + GSIHashTable GlobalsTable; + std::unique_ptr<msf::MappedBlockStream> Stream; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Hash.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Hash.h index 5391fadde5..b3dc3a10a2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Hash.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/Hash.h @@ -1,37 +1,37 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Hash.h - PDB hash functions ------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASH_H -#define LLVM_DEBUGINFO_PDB_NATIVE_HASH_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include <cstdint> - -namespace llvm { -namespace pdb { - -uint32_t hashStringV1(StringRef Str); -uint32_t hashStringV2(StringRef Str); -uint32_t hashBufferV8(ArrayRef<uint8_t> Data); - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_HASH_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Hash.h - PDB hash functions ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASH_H +#define LLVM_DEBUGINFO_PDB_NATIVE_HASH_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include <cstdint> + +namespace llvm { +namespace pdb { + +uint32_t hashStringV1(StringRef Str); +uint32_t hashStringV2(StringRef Str); +uint32_t hashBufferV8(ArrayRef<uint8_t> Data); + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_HASH_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/HashTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/HashTable.h index 4f44e784fa..c0fa726eb6 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/HashTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/HashTable.h @@ -1,347 +1,347 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- HashTable.h - PDB Hash Table -----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H -#define LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H - -#include "llvm/ADT/SparseBitVector.h" -#include "llvm/ADT/iterator.h" -#include "llvm/DebugInfo/PDB/Native/RawError.h" -#include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/BinaryStreamWriter.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <iterator> -#include <utility> -#include <vector> - -namespace llvm { - -class BinaryStreamReader; -class BinaryStreamWriter; - -namespace pdb { - -Error readSparseBitVector(BinaryStreamReader &Stream, SparseBitVector<> &V); -Error writeSparseBitVector(BinaryStreamWriter &Writer, SparseBitVector<> &Vec); - -template <typename ValueT> class HashTable; - -template <typename ValueT> -class HashTableIterator - : public iterator_facade_base<HashTableIterator<ValueT>, - std::forward_iterator_tag, - const std::pair<uint32_t, ValueT>> { - friend HashTable<ValueT>; - - HashTableIterator(const HashTable<ValueT> &Map, uint32_t Index, - bool IsEnd) - : Map(&Map), Index(Index), IsEnd(IsEnd) {} - -public: - HashTableIterator(const HashTable<ValueT> &Map) : Map(&Map) { - int I = Map.Present.find_first(); - if (I == -1) { - Index = 0; - IsEnd = true; - } else { - Index = static_cast<uint32_t>(I); - IsEnd = false; - } - } - - HashTableIterator(const HashTableIterator &R) = default; - HashTableIterator &operator=(const HashTableIterator &R) { - Map = R.Map; - return *this; - } - bool operator==(const HashTableIterator &R) const { - if (IsEnd && R.IsEnd) - return true; - if (IsEnd != R.IsEnd) - return false; - - return (Map == R.Map) && (Index == R.Index); - } - const std::pair<uint32_t, ValueT> &operator*() const { - assert(Map->Present.test(Index)); - return Map->Buckets[Index]; - } - - // Implement postfix op++ in terms of prefix op++ by using the superclass - // implementation. - using iterator_facade_base<HashTableIterator<ValueT>, - std::forward_iterator_tag, - const std::pair<uint32_t, ValueT>>::operator++; - HashTableIterator &operator++() { - while (Index < Map->Buckets.size()) { - ++Index; - if (Map->Present.test(Index)) - return *this; - } - - IsEnd = true; - return *this; - } - -private: - bool isEnd() const { return IsEnd; } - uint32_t index() const { return Index; } - - const HashTable<ValueT> *Map; - uint32_t Index; - bool IsEnd; -}; - -template <typename ValueT> -class HashTable { - struct Header { - support::ulittle32_t Size; - support::ulittle32_t Capacity; - }; - - using BucketList = std::vector<std::pair<uint32_t, ValueT>>; - -public: - using const_iterator = HashTableIterator<ValueT>; - friend const_iterator; - - HashTable() { Buckets.resize(8); } - explicit HashTable(uint32_t Capacity) { - Buckets.resize(Capacity); - } - - Error load(BinaryStreamReader &Stream) { - const Header *H; - if (auto EC = Stream.readObject(H)) - return EC; - if (H->Capacity == 0) - return make_error<RawError>(raw_error_code::corrupt_file, - "Invalid Hash Table Capacity"); - if (H->Size > maxLoad(H->Capacity)) - return make_error<RawError>(raw_error_code::corrupt_file, - "Invalid Hash Table Size"); - - Buckets.resize(H->Capacity); - - if (auto EC = readSparseBitVector(Stream, Present)) - return EC; - if (Present.count() != H->Size) - return make_error<RawError>(raw_error_code::corrupt_file, - "Present bit vector does not match size!"); - - if (auto EC = readSparseBitVector(Stream, Deleted)) - return EC; - if (Present.intersects(Deleted)) - return make_error<RawError>(raw_error_code::corrupt_file, - "Present bit vector intersects deleted!"); - - for (uint32_t P : Present) { - if (auto EC = Stream.readInteger(Buckets[P].first)) - return EC; - const ValueT *Value; - if (auto EC = Stream.readObject(Value)) - return EC; - Buckets[P].second = *Value; - } - - return Error::success(); - } - - uint32_t calculateSerializedLength() const { - uint32_t Size = sizeof(Header); - - constexpr int BitsPerWord = 8 * sizeof(uint32_t); - - int NumBitsP = Present.find_last() + 1; - int NumBitsD = Deleted.find_last() + 1; - - uint32_t NumWordsP = alignTo(NumBitsP, BitsPerWord) / BitsPerWord; - uint32_t NumWordsD = alignTo(NumBitsD, BitsPerWord) / BitsPerWord; - - // Present bit set number of words (4 bytes), followed by that many actual - // words (4 bytes each). - Size += sizeof(uint32_t); - Size += NumWordsP * sizeof(uint32_t); - - // Deleted bit set number of words (4 bytes), followed by that many actual - // words (4 bytes each). - Size += sizeof(uint32_t); - Size += NumWordsD * sizeof(uint32_t); - - // One (Key, ValueT) pair for each entry Present. - Size += (sizeof(uint32_t) + sizeof(ValueT)) * size(); - - return Size; - } - - Error commit(BinaryStreamWriter &Writer) const { - Header H; - H.Size = size(); - H.Capacity = capacity(); - if (auto EC = Writer.writeObject(H)) - return EC; - - if (auto EC = writeSparseBitVector(Writer, Present)) - return EC; - - if (auto EC = writeSparseBitVector(Writer, Deleted)) - return EC; - - for (const auto &Entry : *this) { - if (auto EC = Writer.writeInteger(Entry.first)) - return EC; - if (auto EC = Writer.writeObject(Entry.second)) - return EC; - } - return Error::success(); - } - - void clear() { - Buckets.resize(8); - Present.clear(); - Deleted.clear(); - } - - bool empty() const { return size() == 0; } - uint32_t capacity() const { return Buckets.size(); } - uint32_t size() const { return Present.count(); } - - const_iterator begin() const { return const_iterator(*this); } - const_iterator end() const { return const_iterator(*this, 0, true); } - - /// Find the entry whose key has the specified hash value, using the specified - /// traits defining hash function and equality. - template <typename Key, typename TraitsT> - const_iterator find_as(const Key &K, TraitsT &Traits) const { - uint32_t H = Traits.hashLookupKey(K) % capacity(); - uint32_t I = H; - Optional<uint32_t> FirstUnused; - do { - if (isPresent(I)) { - if (Traits.storageKeyToLookupKey(Buckets[I].first) == K) - return const_iterator(*this, I, false); - } else { - if (!FirstUnused) - FirstUnused = I; - // Insertion occurs via linear probing from the slot hint, and will be - // inserted at the first empty / deleted location. Therefore, if we are - // probing and find a location that is neither present nor deleted, then - // nothing must have EVER been inserted at this location, and thus it is - // not possible for a matching value to occur later. - if (!isDeleted(I)) - break; - } - I = (I + 1) % capacity(); - } while (I != H); - - // The only way FirstUnused would not be set is if every single entry in the - // table were Present. But this would violate the load factor constraints - // that we impose, so it should never happen. - assert(FirstUnused); - return const_iterator(*this, *FirstUnused, true); - } - - /// Set the entry using a key type that the specified Traits can convert - /// from a real key to an internal key. - template <typename Key, typename TraitsT> - bool set_as(const Key &K, ValueT V, TraitsT &Traits) { - return set_as_internal(K, std::move(V), Traits, None); - } - - template <typename Key, typename TraitsT> - ValueT get(const Key &K, TraitsT &Traits) const { - auto Iter = find_as(K, Traits); - assert(Iter != end()); - return (*Iter).second; - } - -protected: - bool isPresent(uint32_t K) const { return Present.test(K); } - bool isDeleted(uint32_t K) const { return Deleted.test(K); } - - BucketList Buckets; - mutable SparseBitVector<> Present; - mutable SparseBitVector<> Deleted; - -private: - /// Set the entry using a key type that the specified Traits can convert - /// from a real key to an internal key. - template <typename Key, typename TraitsT> - bool set_as_internal(const Key &K, ValueT V, TraitsT &Traits, - Optional<uint32_t> InternalKey) { - auto Entry = find_as(K, Traits); - if (Entry != end()) { - assert(isPresent(Entry.index())); - assert(Traits.storageKeyToLookupKey(Buckets[Entry.index()].first) == K); - // We're updating, no need to do anything special. - Buckets[Entry.index()].second = V; - return false; - } - - auto &B = Buckets[Entry.index()]; - assert(!isPresent(Entry.index())); - assert(Entry.isEnd()); - B.first = InternalKey ? *InternalKey : Traits.lookupKeyToStorageKey(K); - B.second = V; - Present.set(Entry.index()); - Deleted.reset(Entry.index()); - - grow(Traits); - - assert((find_as(K, Traits)) != end()); - return true; - } - - static uint32_t maxLoad(uint32_t capacity) { return capacity * 2 / 3 + 1; } - - template <typename TraitsT> - void grow(TraitsT &Traits) { - uint32_t S = size(); - uint32_t MaxLoad = maxLoad(capacity()); - if (S < maxLoad(capacity())) - return; - assert(capacity() != UINT32_MAX && "Can't grow Hash table!"); - - uint32_t NewCapacity = (capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX; - - // Growing requires rebuilding the table and re-hashing every item. Make a - // copy with a larger capacity, insert everything into the copy, then swap - // it in. - HashTable NewMap(NewCapacity); - for (auto I : Present) { - auto LookupKey = Traits.storageKeyToLookupKey(Buckets[I].first); - NewMap.set_as_internal(LookupKey, Buckets[I].second, Traits, - Buckets[I].first); - } - - Buckets.swap(NewMap.Buckets); - std::swap(Present, NewMap.Present); - std::swap(Deleted, NewMap.Deleted); - assert(capacity() == NewCapacity); - assert(size() == S); - } -}; - -} // end namespace pdb - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- HashTable.h - PDB Hash Table -----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H +#define LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H + +#include "llvm/ADT/SparseBitVector.h" +#include "llvm/ADT/iterator.h" +#include "llvm/DebugInfo/PDB/Native/RawError.h" +#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <iterator> +#include <utility> +#include <vector> + +namespace llvm { + +class BinaryStreamReader; +class BinaryStreamWriter; + +namespace pdb { + +Error readSparseBitVector(BinaryStreamReader &Stream, SparseBitVector<> &V); +Error writeSparseBitVector(BinaryStreamWriter &Writer, SparseBitVector<> &Vec); + +template <typename ValueT> class HashTable; + +template <typename ValueT> +class HashTableIterator + : public iterator_facade_base<HashTableIterator<ValueT>, + std::forward_iterator_tag, + const std::pair<uint32_t, ValueT>> { + friend HashTable<ValueT>; + + HashTableIterator(const HashTable<ValueT> &Map, uint32_t Index, + bool IsEnd) + : Map(&Map), Index(Index), IsEnd(IsEnd) {} + +public: + HashTableIterator(const HashTable<ValueT> &Map) : Map(&Map) { + int I = Map.Present.find_first(); + if (I == -1) { + Index = 0; + IsEnd = true; + } else { + Index = static_cast<uint32_t>(I); + IsEnd = false; + } + } + + HashTableIterator(const HashTableIterator &R) = default; + HashTableIterator &operator=(const HashTableIterator &R) { + Map = R.Map; + return *this; + } + bool operator==(const HashTableIterator &R) const { + if (IsEnd && R.IsEnd) + return true; + if (IsEnd != R.IsEnd) + return false; + + return (Map == R.Map) && (Index == R.Index); + } + const std::pair<uint32_t, ValueT> &operator*() const { + assert(Map->Present.test(Index)); + return Map->Buckets[Index]; + } + + // Implement postfix op++ in terms of prefix op++ by using the superclass + // implementation. + using iterator_facade_base<HashTableIterator<ValueT>, + std::forward_iterator_tag, + const std::pair<uint32_t, ValueT>>::operator++; + HashTableIterator &operator++() { + while (Index < Map->Buckets.size()) { + ++Index; + if (Map->Present.test(Index)) + return *this; + } + + IsEnd = true; + return *this; + } + +private: + bool isEnd() const { return IsEnd; } + uint32_t index() const { return Index; } + + const HashTable<ValueT> *Map; + uint32_t Index; + bool IsEnd; +}; + +template <typename ValueT> +class HashTable { + struct Header { + support::ulittle32_t Size; + support::ulittle32_t Capacity; + }; + + using BucketList = std::vector<std::pair<uint32_t, ValueT>>; + +public: + using const_iterator = HashTableIterator<ValueT>; + friend const_iterator; + + HashTable() { Buckets.resize(8); } + explicit HashTable(uint32_t Capacity) { + Buckets.resize(Capacity); + } + + Error load(BinaryStreamReader &Stream) { + const Header *H; + if (auto EC = Stream.readObject(H)) + return EC; + if (H->Capacity == 0) + return make_error<RawError>(raw_error_code::corrupt_file, + "Invalid Hash Table Capacity"); + if (H->Size > maxLoad(H->Capacity)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Invalid Hash Table Size"); + + Buckets.resize(H->Capacity); + + if (auto EC = readSparseBitVector(Stream, Present)) + return EC; + if (Present.count() != H->Size) + return make_error<RawError>(raw_error_code::corrupt_file, + "Present bit vector does not match size!"); + + if (auto EC = readSparseBitVector(Stream, Deleted)) + return EC; + if (Present.intersects(Deleted)) + return make_error<RawError>(raw_error_code::corrupt_file, + "Present bit vector intersects deleted!"); + + for (uint32_t P : Present) { + if (auto EC = Stream.readInteger(Buckets[P].first)) + return EC; + const ValueT *Value; + if (auto EC = Stream.readObject(Value)) + return EC; + Buckets[P].second = *Value; + } + + return Error::success(); + } + + uint32_t calculateSerializedLength() const { + uint32_t Size = sizeof(Header); + + constexpr int BitsPerWord = 8 * sizeof(uint32_t); + + int NumBitsP = Present.find_last() + 1; + int NumBitsD = Deleted.find_last() + 1; + + uint32_t NumWordsP = alignTo(NumBitsP, BitsPerWord) / BitsPerWord; + uint32_t NumWordsD = alignTo(NumBitsD, BitsPerWord) / BitsPerWord; + + // Present bit set number of words (4 bytes), followed by that many actual + // words (4 bytes each). + Size += sizeof(uint32_t); + Size += NumWordsP * sizeof(uint32_t); + + // Deleted bit set number of words (4 bytes), followed by that many actual + // words (4 bytes each). + Size += sizeof(uint32_t); + Size += NumWordsD * sizeof(uint32_t); + + // One (Key, ValueT) pair for each entry Present. + Size += (sizeof(uint32_t) + sizeof(ValueT)) * size(); + + return Size; + } + + Error commit(BinaryStreamWriter &Writer) const { + Header H; + H.Size = size(); + H.Capacity = capacity(); + if (auto EC = Writer.writeObject(H)) + return EC; + + if (auto EC = writeSparseBitVector(Writer, Present)) + return EC; + + if (auto EC = writeSparseBitVector(Writer, Deleted)) + return EC; + + for (const auto &Entry : *this) { + if (auto EC = Writer.writeInteger(Entry.first)) + return EC; + if (auto EC = Writer.writeObject(Entry.second)) + return EC; + } + return Error::success(); + } + + void clear() { + Buckets.resize(8); + Present.clear(); + Deleted.clear(); + } + + bool empty() const { return size() == 0; } + uint32_t capacity() const { return Buckets.size(); } + uint32_t size() const { return Present.count(); } + + const_iterator begin() const { return const_iterator(*this); } + const_iterator end() const { return const_iterator(*this, 0, true); } + + /// Find the entry whose key has the specified hash value, using the specified + /// traits defining hash function and equality. + template <typename Key, typename TraitsT> + const_iterator find_as(const Key &K, TraitsT &Traits) const { + uint32_t H = Traits.hashLookupKey(K) % capacity(); + uint32_t I = H; + Optional<uint32_t> FirstUnused; + do { + if (isPresent(I)) { + if (Traits.storageKeyToLookupKey(Buckets[I].first) == K) + return const_iterator(*this, I, false); + } else { + if (!FirstUnused) + FirstUnused = I; + // Insertion occurs via linear probing from the slot hint, and will be + // inserted at the first empty / deleted location. Therefore, if we are + // probing and find a location that is neither present nor deleted, then + // nothing must have EVER been inserted at this location, and thus it is + // not possible for a matching value to occur later. + if (!isDeleted(I)) + break; + } + I = (I + 1) % capacity(); + } while (I != H); + + // The only way FirstUnused would not be set is if every single entry in the + // table were Present. But this would violate the load factor constraints + // that we impose, so it should never happen. + assert(FirstUnused); + return const_iterator(*this, *FirstUnused, true); + } + + /// Set the entry using a key type that the specified Traits can convert + /// from a real key to an internal key. + template <typename Key, typename TraitsT> + bool set_as(const Key &K, ValueT V, TraitsT &Traits) { + return set_as_internal(K, std::move(V), Traits, None); + } + + template <typename Key, typename TraitsT> + ValueT get(const Key &K, TraitsT &Traits) const { + auto Iter = find_as(K, Traits); + assert(Iter != end()); + return (*Iter).second; + } + +protected: + bool isPresent(uint32_t K) const { return Present.test(K); } + bool isDeleted(uint32_t K) const { return Deleted.test(K); } + + BucketList Buckets; + mutable SparseBitVector<> Present; + mutable SparseBitVector<> Deleted; + +private: + /// Set the entry using a key type that the specified Traits can convert + /// from a real key to an internal key. + template <typename Key, typename TraitsT> + bool set_as_internal(const Key &K, ValueT V, TraitsT &Traits, + Optional<uint32_t> InternalKey) { + auto Entry = find_as(K, Traits); + if (Entry != end()) { + assert(isPresent(Entry.index())); + assert(Traits.storageKeyToLookupKey(Buckets[Entry.index()].first) == K); + // We're updating, no need to do anything special. + Buckets[Entry.index()].second = V; + return false; + } + + auto &B = Buckets[Entry.index()]; + assert(!isPresent(Entry.index())); + assert(Entry.isEnd()); + B.first = InternalKey ? *InternalKey : Traits.lookupKeyToStorageKey(K); + B.second = V; + Present.set(Entry.index()); + Deleted.reset(Entry.index()); + + grow(Traits); + + assert((find_as(K, Traits)) != end()); + return true; + } + + static uint32_t maxLoad(uint32_t capacity) { return capacity * 2 / 3 + 1; } + + template <typename TraitsT> + void grow(TraitsT &Traits) { + uint32_t S = size(); + uint32_t MaxLoad = maxLoad(capacity()); + if (S < maxLoad(capacity())) + return; + assert(capacity() != UINT32_MAX && "Can't grow Hash table!"); + + uint32_t NewCapacity = (capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX; + + // Growing requires rebuilding the table and re-hashing every item. Make a + // copy with a larger capacity, insert everything into the copy, then swap + // it in. + HashTable NewMap(NewCapacity); + for (auto I : Present) { + auto LookupKey = Traits.storageKeyToLookupKey(Buckets[I].first); + NewMap.set_as_internal(LookupKey, Buckets[I].second, Traits, + Buckets[I].first); + } + + Buckets.swap(NewMap.Buckets); + std::swap(Present, NewMap.Present); + std::swap(Deleted, NewMap.Deleted); + assert(capacity() == NewCapacity); + assert(size() == S); + } +}; + +} // end namespace pdb + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h index bdb6bfe2a0..4aeb13854f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h @@ -1,40 +1,40 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- ISectionContribVisitor.h ---------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H -#define LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H - -namespace llvm { -namespace pdb { - -struct SectionContrib; -struct SectionContrib2; - -class ISectionContribVisitor { -public: - virtual ~ISectionContribVisitor() = default; - - virtual void visit(const SectionContrib &C) = 0; - virtual void visit(const SectionContrib2 &C) = 0; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- ISectionContribVisitor.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H +#define LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H + +namespace llvm { +namespace pdb { + +struct SectionContrib; +struct SectionContrib2; + +class ISectionContribVisitor { +public: + virtual ~ISectionContribVisitor() = default; + + virtual void visit(const SectionContrib &C) = 0; + virtual void visit(const SectionContrib2 &C) = 0; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_ISECTIONCONTRIBVISITOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStream.h index 6486cee563..8589ac2d54 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStream.h @@ -1,85 +1,85 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InfoStream.h - PDB Info Stream (Stream 1) Access ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H - -#include "llvm/ADT/BitmaskEnum.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/DebugInfo/CodeView/GUID.h" -#include "llvm/DebugInfo/MSF/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" - -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { -class InfoStreamBuilder; -class PDBFile; - -class InfoStream { - friend class InfoStreamBuilder; - -public: - InfoStream(std::unique_ptr<BinaryStream> Stream); - - Error reload(); - - uint32_t getStreamSize() const; - - const InfoStreamHeader *getHeader() const { return Header; } - - bool containsIdStream() const; - PdbRaw_ImplVer getVersion() const; - uint32_t getSignature() const; - uint32_t getAge() const; - codeview::GUID getGuid() const; - uint32_t getNamedStreamMapByteSize() const; - - PdbRaw_Features getFeatures() const; - ArrayRef<PdbRaw_FeatureSig> getFeatureSignatures() const; - - const NamedStreamMap &getNamedStreams() const; - - BinarySubstreamRef getNamedStreamsBuffer() const; - - Expected<uint32_t> getNamedStreamIndex(llvm::StringRef Name) const; - StringMap<uint32_t> named_streams() const; - -private: - std::unique_ptr<BinaryStream> Stream; - - const InfoStreamHeader *Header; - - BinarySubstreamRef SubNamedStreams; - - std::vector<PdbRaw_FeatureSig> FeatureSignatures; - PdbRaw_Features Features = PdbFeatureNone; - - uint32_t NamedStreamMapByteSize = 0; - - NamedStreamMap NamedStreams; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InfoStream.h - PDB Info Stream (Stream 1) Access ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H + +#include "llvm/ADT/BitmaskEnum.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/DebugInfo/CodeView/GUID.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { +class InfoStreamBuilder; +class PDBFile; + +class InfoStream { + friend class InfoStreamBuilder; + +public: + InfoStream(std::unique_ptr<BinaryStream> Stream); + + Error reload(); + + uint32_t getStreamSize() const; + + const InfoStreamHeader *getHeader() const { return Header; } + + bool containsIdStream() const; + PdbRaw_ImplVer getVersion() const; + uint32_t getSignature() const; + uint32_t getAge() const; + codeview::GUID getGuid() const; + uint32_t getNamedStreamMapByteSize() const; + + PdbRaw_Features getFeatures() const; + ArrayRef<PdbRaw_FeatureSig> getFeatureSignatures() const; + + const NamedStreamMap &getNamedStreams() const; + + BinarySubstreamRef getNamedStreamsBuffer() const; + + Expected<uint32_t> getNamedStreamIndex(llvm::StringRef Name) const; + StringMap<uint32_t> named_streams() const; + +private: + std::unique_ptr<BinaryStream> Stream; + + const InfoStreamHeader *Header; + + BinarySubstreamRef SubNamedStreams; + + std::vector<PdbRaw_FeatureSig> FeatureSignatures; + PdbRaw_Features Features = PdbFeatureNone; + + uint32_t NamedStreamMapByteSize = 0; + + NamedStreamMap NamedStreams; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h index 504b7618d3..eb2a7a47dd 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h @@ -1,87 +1,87 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/Support/Error.h" - -#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" -#include "llvm/DebugInfo/PDB/Native/PDBFile.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" - -namespace llvm { -class WritableBinaryStreamRef; - -namespace msf { -class MSFBuilder; -} -namespace pdb { -class PDBFile; -class NamedStreamMap; - -class InfoStreamBuilder { -public: - InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams); - InfoStreamBuilder(const InfoStreamBuilder &) = delete; - InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete; - - void setVersion(PdbRaw_ImplVer V); - void addFeature(PdbRaw_FeatureSig Sig); - - // If this is true, the PDB contents are hashed and this hash is used as - // PDB GUID and as Signature. The age is always 1. - void setHashPDBContentsToGUID(bool B); - - // These only have an effect if hashPDBContentsToGUID() is false. - void setSignature(uint32_t S); - void setAge(uint32_t A); - void setGuid(codeview::GUID G); - - bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; } - uint32_t getAge() const { return Age; } - codeview::GUID getGuid() const { return Guid; } - Optional<uint32_t> getSignature() const { return Signature; } - - uint32_t finalize(); - - Error finalizeMsfLayout(); - - Error commit(const msf::MSFLayout &Layout, - WritableBinaryStreamRef Buffer) const; - -private: - msf::MSFBuilder &Msf; - - std::vector<PdbRaw_FeatureSig> Features; - PdbRaw_ImplVer Ver; - uint32_t Age; - Optional<uint32_t> Signature; - codeview::GUID Guid; - - bool HashPDBContentsToGUID = false; - - NamedStreamMap &NamedStreams; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InfoStreamBuilder.h - PDB Info Stream Creation -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAMBUILDER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/Support/Error.h" + +#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +namespace llvm { +class WritableBinaryStreamRef; + +namespace msf { +class MSFBuilder; +} +namespace pdb { +class PDBFile; +class NamedStreamMap; + +class InfoStreamBuilder { +public: + InfoStreamBuilder(msf::MSFBuilder &Msf, NamedStreamMap &NamedStreams); + InfoStreamBuilder(const InfoStreamBuilder &) = delete; + InfoStreamBuilder &operator=(const InfoStreamBuilder &) = delete; + + void setVersion(PdbRaw_ImplVer V); + void addFeature(PdbRaw_FeatureSig Sig); + + // If this is true, the PDB contents are hashed and this hash is used as + // PDB GUID and as Signature. The age is always 1. + void setHashPDBContentsToGUID(bool B); + + // These only have an effect if hashPDBContentsToGUID() is false. + void setSignature(uint32_t S); + void setAge(uint32_t A); + void setGuid(codeview::GUID G); + + bool hashPDBContentsToGUID() const { return HashPDBContentsToGUID; } + uint32_t getAge() const { return Age; } + codeview::GUID getGuid() const { return Guid; } + Optional<uint32_t> getSignature() const { return Signature; } + + uint32_t finalize(); + + Error finalizeMsfLayout(); + + Error commit(const msf::MSFLayout &Layout, + WritableBinaryStreamRef Buffer) const; + +private: + msf::MSFBuilder &Msf; + + std::vector<PdbRaw_FeatureSig> Features; + PdbRaw_ImplVer Ver; + uint32_t Age; + Optional<uint32_t> Signature; + codeview::GUID Guid; + + bool HashPDBContentsToGUID = false; + + NamedStreamMap &NamedStreams; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InjectedSourceStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InjectedSourceStream.h index 2535dbc26c..5238bc5357 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InjectedSourceStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/InjectedSourceStream.h @@ -1,55 +1,55 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InjectedSourceStream.h - PDB Headerblock Stream Access ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINJECTEDSOURCESTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBINJECTEDSOURCESTREAM_H - -#include "llvm/DebugInfo/PDB/Native/HashTable.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace msf { -class MappedBlockStream; -} -namespace pdb { -class PDBFile; -class PDBStringTable; - -class InjectedSourceStream { -public: - InjectedSourceStream(std::unique_ptr<msf::MappedBlockStream> Stream); - Error reload(const PDBStringTable &Strings); - - using const_iterator = HashTable<SrcHeaderBlockEntry>::const_iterator; - const_iterator begin() const { return InjectedSourceTable.begin(); } - const_iterator end() const { return InjectedSourceTable.end(); } - - uint32_t size() const { return InjectedSourceTable.size(); } - -private: - std::unique_ptr<msf::MappedBlockStream> Stream; - - const SrcHeaderBlockHeader* Header; - HashTable<SrcHeaderBlockEntry> InjectedSourceTable; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InjectedSourceStream.h - PDB Headerblock Stream Access ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBINJECTEDSOURCESTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBINJECTEDSOURCESTREAM_H + +#include "llvm/DebugInfo/PDB/Native/HashTable.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace msf { +class MappedBlockStream; +} +namespace pdb { +class PDBFile; +class PDBStringTable; + +class InjectedSourceStream { +public: + InjectedSourceStream(std::unique_ptr<msf::MappedBlockStream> Stream); + Error reload(const PDBStringTable &Strings); + + using const_iterator = HashTable<SrcHeaderBlockEntry>::const_iterator; + const_iterator begin() const { return InjectedSourceTable.begin(); } + const_iterator end() const { return InjectedSourceTable.end(); } + + uint32_t size() const { return InjectedSourceTable.size(); } + +private: + std::unique_ptr<msf::MappedBlockStream> Stream; + + const SrcHeaderBlockHeader* Header; + HashTable<SrcHeaderBlockEntry> InjectedSourceTable; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h index 0fce2bf82a..09bad8ad41 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h @@ -1,103 +1,103 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H -#define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H - -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/MSF/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <memory> - -namespace llvm { -namespace pdb { - -class DbiModuleDescriptor; - -class ModuleDebugStreamRef { - using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator; - -public: - ModuleDebugStreamRef(const DbiModuleDescriptor &Module, - std::unique_ptr<msf::MappedBlockStream> Stream); - ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default; - ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default; - ~ModuleDebugStreamRef(); - - Error reload(); - - uint32_t signature() const { return Signature; } - - iterator_range<codeview::CVSymbolArray::Iterator> - symbols(bool *HadError) const; - - const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; } - const codeview::CVSymbolArray - getSymbolArrayForScope(uint32_t ScopeBegin) const; - - BinarySubstreamRef getSymbolsSubstream() const; - BinarySubstreamRef getC11LinesSubstream() const; - BinarySubstreamRef getC13LinesSubstream() const; - BinarySubstreamRef getGlobalRefsSubstream() const; - - ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete; - - codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const; - - iterator_range<DebugSubsectionIterator> subsections() const; - codeview::DebugSubsectionArray getSubsectionsArray() const { - return Subsections; - } - - bool hasDebugSubsections() const; - - Error commit(); - - Expected<codeview::DebugChecksumsSubsectionRef> - findChecksumsSubsection() const; - -private: - Error reloadSerialize(BinaryStreamReader &Reader); - - DbiModuleDescriptor Mod; - - uint32_t Signature; - - std::shared_ptr<msf::MappedBlockStream> Stream; - - codeview::CVSymbolArray SymbolArray; - - BinarySubstreamRef SymbolsSubstream; - BinarySubstreamRef C11LinesSubstream; - BinarySubstreamRef C13LinesSubstream; - BinarySubstreamRef GlobalRefsSubstream; - - codeview::DebugSubsectionArray Subsections; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H +#define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H + +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <memory> + +namespace llvm { +namespace pdb { + +class DbiModuleDescriptor; + +class ModuleDebugStreamRef { + using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator; + +public: + ModuleDebugStreamRef(const DbiModuleDescriptor &Module, + std::unique_ptr<msf::MappedBlockStream> Stream); + ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default; + ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default; + ~ModuleDebugStreamRef(); + + Error reload(); + + uint32_t signature() const { return Signature; } + + iterator_range<codeview::CVSymbolArray::Iterator> + symbols(bool *HadError) const; + + const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; } + const codeview::CVSymbolArray + getSymbolArrayForScope(uint32_t ScopeBegin) const; + + BinarySubstreamRef getSymbolsSubstream() const; + BinarySubstreamRef getC11LinesSubstream() const; + BinarySubstreamRef getC13LinesSubstream() const; + BinarySubstreamRef getGlobalRefsSubstream() const; + + ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete; + + codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const; + + iterator_range<DebugSubsectionIterator> subsections() const; + codeview::DebugSubsectionArray getSubsectionsArray() const { + return Subsections; + } + + bool hasDebugSubsections() const; + + Error commit(); + + Expected<codeview::DebugChecksumsSubsectionRef> + findChecksumsSubsection() const; + +private: + Error reloadSerialize(BinaryStreamReader &Reader); + + DbiModuleDescriptor Mod; + + uint32_t Signature; + + std::shared_ptr<msf::MappedBlockStream> Stream; + + codeview::CVSymbolArray SymbolArray; + + BinarySubstreamRef SymbolsSubstream; + BinarySubstreamRef C11LinesSubstream; + BinarySubstreamRef C13LinesSubstream; + BinarySubstreamRef GlobalRefsSubstream; + + codeview::DebugSubsectionArray Subsections; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h index f5105d4960..bc54d6fbc5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h @@ -1,83 +1,83 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/DebugInfo/PDB/Native/HashTable.h" -#include "llvm/Support/Error.h" -#include <cstdint> - -namespace llvm { - -class BinaryStreamReader; -class BinaryStreamWriter; - -namespace pdb { - -class NamedStreamMap; - -struct NamedStreamMapTraits { - NamedStreamMap *NS; - - explicit NamedStreamMapTraits(NamedStreamMap &NS); - uint16_t hashLookupKey(StringRef S) const; - StringRef storageKeyToLookupKey(uint32_t Offset) const; - uint32_t lookupKeyToStorageKey(StringRef S); -}; - -class NamedStreamMap { - friend class NamedStreamMapBuilder; - -public: - NamedStreamMap(); - - Error load(BinaryStreamReader &Stream); - Error commit(BinaryStreamWriter &Writer) const; - uint32_t calculateSerializedLength() const; - - uint32_t size() const; - bool get(StringRef Stream, uint32_t &StreamNo) const; - void set(StringRef Stream, uint32_t StreamNo); - - uint32_t appendStringData(StringRef S); - StringRef getString(uint32_t Offset) const; - uint32_t hashString(uint32_t Offset) const; - - StringMap<uint32_t> entries() const; - -private: - NamedStreamMapTraits HashTraits; - /// Closed hash table from Offset -> StreamNumber, where Offset is the offset - /// of the stream name in NamesBuffer. - HashTable<support::ulittle32_t> OffsetIndexMap; - - /// Buffer of string data. - std::vector<char> NamesBuffer; -}; - -} // end namespace pdb - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NamedStreamMap.h - PDB Named Stream Map ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/PDB/Native/HashTable.h" +#include "llvm/Support/Error.h" +#include <cstdint> + +namespace llvm { + +class BinaryStreamReader; +class BinaryStreamWriter; + +namespace pdb { + +class NamedStreamMap; + +struct NamedStreamMapTraits { + NamedStreamMap *NS; + + explicit NamedStreamMapTraits(NamedStreamMap &NS); + uint16_t hashLookupKey(StringRef S) const; + StringRef storageKeyToLookupKey(uint32_t Offset) const; + uint32_t lookupKeyToStorageKey(StringRef S); +}; + +class NamedStreamMap { + friend class NamedStreamMapBuilder; + +public: + NamedStreamMap(); + + Error load(BinaryStreamReader &Stream); + Error commit(BinaryStreamWriter &Writer) const; + uint32_t calculateSerializedLength() const; + + uint32_t size() const; + bool get(StringRef Stream, uint32_t &StreamNo) const; + void set(StringRef Stream, uint32_t StreamNo); + + uint32_t appendStringData(StringRef S); + StringRef getString(uint32_t Offset) const; + uint32_t hashString(uint32_t Offset) const; + + StringMap<uint32_t> entries() const; + +private: + NamedStreamMapTraits HashTraits; + /// Closed hash table from Offset -> StreamNumber, where Offset is the offset + /// of the stream name in NamesBuffer. + HashTable<support::ulittle32_t> OffsetIndexMap; + + /// Buffer of string data. + std::vector<char> NamesBuffer; +}; + +} // end namespace pdb + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NAMEDSTREAMMAP_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h index 5201dadd42..4537d27da4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeCompilandSymbol.h - native impl for compiland syms -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVECOMPILANDSYMBOL_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVECOMPILANDSYMBOL_H - -#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" - -namespace llvm { -namespace pdb { - -class NativeCompilandSymbol : public NativeRawSymbol { -public: - NativeCompilandSymbol(NativeSession &Session, SymIndexId SymbolId, - DbiModuleDescriptor MI); - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - PDB_SymType getSymTag() const override; - bool isEditAndContinueEnabled() const override; - SymIndexId getLexicalParentId() const override; - std::string getLibraryName() const override; - std::string getName() const override; - -private: - DbiModuleDescriptor Module; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeCompilandSymbol.h - native impl for compiland syms -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVECOMPILANDSYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVECOMPILANDSYMBOL_H + +#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" + +namespace llvm { +namespace pdb { + +class NativeCompilandSymbol : public NativeRawSymbol { +public: + NativeCompilandSymbol(NativeSession &Session, SymIndexId SymbolId, + DbiModuleDescriptor MI); + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + PDB_SymType getSymTag() const override; + bool isEditAndContinueEnabled() const override; + SymIndexId getLexicalParentId() const override; + std::string getLibraryName() const override; + std::string getName() const override; + +private: + DbiModuleDescriptor Module; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumGlobals.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumGlobals.h index 7746c5ab13..0c1a4de174 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumGlobals.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumGlobals.h @@ -1,53 +1,53 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeEnumGlobals.h - Native Global Enumerator impl --------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMGLOBALS_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMGLOBALS_H - -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" - -#include <vector> - -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeEnumGlobals : public IPDBEnumChildren<PDBSymbol> { -public: - NativeEnumGlobals(NativeSession &Session, - std::vector<codeview::SymbolKind> Kinds); - - uint32_t getChildCount() const override; - std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<PDBSymbol> getNext() override; - void reset() override; - -private: - std::vector<uint32_t> MatchOffsets; - uint32_t Index; - NativeSession &Session; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeEnumGlobals.h - Native Global Enumerator impl --------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMGLOBALS_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMGLOBALS_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +#include <vector> + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeEnumGlobals : public IPDBEnumChildren<PDBSymbol> { +public: + NativeEnumGlobals(NativeSession &Session, + std::vector<codeview::SymbolKind> Kinds); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + +private: + std::vector<uint32_t> MatchOffsets; + uint32_t Index; + NativeSession &Session; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h index 800ace0067..b9cde75c39 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumInjectedSources.h @@ -1,54 +1,54 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeEnumInjectedSources.cpp - Native Injected Source Enumerator --*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMINJECTEDSOURCES_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMINJECTEDSOURCES_H - -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" -#include "llvm/DebugInfo/PDB/Native/InjectedSourceStream.h" - -namespace llvm { -namespace pdb { - -class InjectedSourceStream; -class PDBStringTable; - -class NativeEnumInjectedSources : public IPDBEnumChildren<IPDBInjectedSource> { -public: - NativeEnumInjectedSources(PDBFile &File, const InjectedSourceStream &IJS, - const PDBStringTable &Strings); - - uint32_t getChildCount() const override; - std::unique_ptr<IPDBInjectedSource> - getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<IPDBInjectedSource> getNext() override; - void reset() override; - -private: - PDBFile &File; - const InjectedSourceStream &Stream; - const PDBStringTable &Strings; - InjectedSourceStream::const_iterator Cur; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeEnumInjectedSources.cpp - Native Injected Source Enumerator --*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMINJECTEDSOURCES_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMINJECTEDSOURCES_H + +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h" +#include "llvm/DebugInfo/PDB/Native/InjectedSourceStream.h" + +namespace llvm { +namespace pdb { + +class InjectedSourceStream; +class PDBStringTable; + +class NativeEnumInjectedSources : public IPDBEnumChildren<IPDBInjectedSource> { +public: + NativeEnumInjectedSources(PDBFile &File, const InjectedSourceStream &IJS, + const PDBStringTable &Strings); + + uint32_t getChildCount() const override; + std::unique_ptr<IPDBInjectedSource> + getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<IPDBInjectedSource> getNext() override; + void reset() override; + +private: + PDBFile &File; + const InjectedSourceStream &Stream; + const PDBStringTable &Strings; + InjectedSourceStream::const_iterator Cur; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h index 1b265eaff8..8858017e98 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumLineNumbers.h @@ -1,50 +1,50 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeEnumLineNumbers.h - Native Line Number Enumerator ------------*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMLINENUMBERS_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMLINENUMBERS_H - -#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" -#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" -#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" -#include "llvm/DebugInfo/PDB/Native/NativeLineNumber.h" - -namespace llvm { -namespace pdb { -class IPDBLineNumber; - -class NativeEnumLineNumbers : public IPDBEnumChildren<IPDBLineNumber> { -public: - explicit NativeEnumLineNumbers(std::vector<NativeLineNumber> LineNums); - - uint32_t getChildCount() const override; - ChildTypePtr getChildAtIndex(uint32_t Index) const override; - ChildTypePtr getNext() override; - void reset() override; - -private: - std::vector<NativeLineNumber> Lines; - uint32_t Index; -}; -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeEnumLineNumbers.h - Native Line Number Enumerator ------------*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMLINENUMBERS_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMLINENUMBERS_H + +#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" +#include "llvm/DebugInfo/PDB/Native/NativeLineNumber.h" + +namespace llvm { +namespace pdb { +class IPDBLineNumber; + +class NativeEnumLineNumbers : public IPDBEnumChildren<IPDBLineNumber> { +public: + explicit NativeEnumLineNumbers(std::vector<NativeLineNumber> LineNums); + + uint32_t getChildCount() const override; + ChildTypePtr getChildAtIndex(uint32_t Index) const override; + ChildTypePtr getNext() override; + void reset() override; + +private: + std::vector<NativeLineNumber> Lines; + uint32_t Index; +}; +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h index af3df87966..58de4d7570 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeEnumModules.h - Native Module Enumerator impl --------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMMODULES_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMMODULES_H - -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeEnumModules : public IPDBEnumChildren<PDBSymbol> { -public: - NativeEnumModules(NativeSession &Session, uint32_t Index = 0); - - uint32_t getChildCount() const override; - std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<PDBSymbol> getNext() override; - void reset() override; - -private: - NativeSession &Session; - uint32_t Index; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeEnumModules.h - Native Module Enumerator impl --------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMMODULES_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMMODULES_H + +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeEnumModules : public IPDBEnumChildren<PDBSymbol> { +public: + NativeEnumModules(NativeSession &Session, uint32_t Index = 0); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + +private: + NativeSession &Session; + uint32_t Index; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h index 0138dcc840..9ae2abe9b5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeEnumTypes.h - Native Type Enumerator impl ------------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H - -#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" - -#include <vector> - -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeEnumTypes : public IPDBEnumChildren<PDBSymbol> { -public: - NativeEnumTypes(NativeSession &Session, - codeview::LazyRandomTypeCollection &TypeCollection, - std::vector<codeview::TypeLeafKind> Kinds); - - NativeEnumTypes(NativeSession &Session, - std::vector<codeview::TypeIndex> Indices); - - uint32_t getChildCount() const override; - std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; - std::unique_ptr<PDBSymbol> getNext() override; - void reset() override; - -private: - std::vector<codeview::TypeIndex> Matches; - uint32_t Index; - NativeSession &Session; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeEnumTypes.h - Native Type Enumerator impl ------------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H + +#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +#include <vector> + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeEnumTypes : public IPDBEnumChildren<PDBSymbol> { +public: + NativeEnumTypes(NativeSession &Session, + codeview::LazyRandomTypeCollection &TypeCollection, + std::vector<codeview::TypeLeafKind> Kinds); + + NativeEnumTypes(NativeSession &Session, + std::vector<codeview::TypeIndex> Indices); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + +private: + std::vector<codeview::TypeIndex> Matches; + uint32_t Index; + NativeSession &Session; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h index 2a8e377528..39d1de0663 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h @@ -1,51 +1,51 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeExeSymbol.h - native impl for PDBSymbolExe ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEEXESYMBOL_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEEXESYMBOL_H - -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class DbiStream; - -class NativeExeSymbol : public NativeRawSymbol { - // EXE symbol is the authority on the various symbol types. - DbiStream *Dbi = nullptr; - -public: - NativeExeSymbol(NativeSession &Session, SymIndexId Id); - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const override; - - uint32_t getAge() const override; - std::string getSymbolsFileName() const override; - codeview::GUID getGuid() const override; - bool hasCTypes() const override; - bool hasPrivateSymbols() const override; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeExeSymbol.h - native impl for PDBSymbolExe ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEEXESYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEEXESYMBOL_H + +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class DbiStream; + +class NativeExeSymbol : public NativeRawSymbol { + // EXE symbol is the authority on the various symbol types. + DbiStream *Dbi = nullptr; + +public: + NativeExeSymbol(NativeSession &Session, SymIndexId Id); + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + + uint32_t getAge() const override; + std::string getSymbolsFileName() const override; + codeview::GUID getGuid() const override; + bool hasCTypes() const override; + bool hasPrivateSymbols() const override; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h index 0f25b95cbc..cb9599004e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeFunctionSymbol.h - info about function symbols -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeFunctionSymbol : public NativeRawSymbol { -public: - NativeFunctionSymbol(NativeSession &Session, SymIndexId Id, +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeFunctionSymbol.h - info about function symbols -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeFunctionSymbol : public NativeRawSymbol { +public: + NativeFunctionSymbol(NativeSession &Session, SymIndexId Id, const codeview::ProcSym &Sym, uint32_t RecordOffset); - - ~NativeFunctionSymbol() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - uint32_t getAddressOffset() const override; - uint32_t getAddressSection() const override; - std::string getName() const override; - uint64_t getLength() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; + + ~NativeFunctionSymbol() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + uint32_t getAddressOffset() const override; + uint32_t getAddressSection() const override; + std::string getName() const override; + uint64_t getLength() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; std::unique_ptr<IPDBEnumSymbols> findInlineFramesByVA(uint64_t VA) const override; - -protected: - const codeview::ProcSym Sym; + +protected: + const codeview::ProcSym Sym; uint32_t RecordOffset = 0; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEFUNCTIONSYMBOL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h index 783be3a685..f9bd5157ed 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeLineNumber.h - Native line number implementation ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVELINENUMBER_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVELINENUMBER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { -class NativeLineNumber : public IPDBLineNumber { -public: - explicit NativeLineNumber(const NativeSession &Session, - const codeview::LineInfo Line, - uint32_t ColumnNumber, uint32_t Length, - uint32_t Section, uint32_t Offset, +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeLineNumber.h - Native line number implementation ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVELINENUMBER_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVELINENUMBER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/PDB/IPDBLineNumber.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { +class NativeLineNumber : public IPDBLineNumber { +public: + explicit NativeLineNumber(const NativeSession &Session, + const codeview::LineInfo Line, + uint32_t ColumnNumber, uint32_t Length, + uint32_t Section, uint32_t Offset, uint32_t SrcFileId, uint32_t CompilandId); - - uint32_t getLineNumber() const override; - uint32_t getLineNumberEnd() const override; - uint32_t getColumnNumber() const override; - uint32_t getColumnNumberEnd() const override; - uint32_t getAddressSection() const override; - uint32_t getAddressOffset() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; - uint32_t getLength() const override; - uint32_t getSourceFileId() const override; - uint32_t getCompilandId() const override; - bool isStatement() const override; - -private: - const NativeSession &Session; - const codeview::LineInfo Line; - uint32_t ColumnNumber; - uint32_t Section; - uint32_t Offset; - uint32_t Length; - uint32_t SrcFileId; + + uint32_t getLineNumber() const override; + uint32_t getLineNumberEnd() const override; + uint32_t getColumnNumber() const override; + uint32_t getColumnNumberEnd() const override; + uint32_t getAddressSection() const override; + uint32_t getAddressOffset() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; + uint32_t getLength() const override; + uint32_t getSourceFileId() const override; + uint32_t getCompilandId() const override; + bool isStatement() const override; + +private: + const NativeSession &Session; + const codeview::LineInfo Line; + uint32_t ColumnNumber; + uint32_t Section; + uint32_t Offset; + uint32_t Length; + uint32_t SrcFileId; uint32_t CompilandId; -}; -} // namespace pdb -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +}; +} // namespace pdb +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h index de4d46e431..b9c317def5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h @@ -1,54 +1,54 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativePublicSymbol.h - info about public symbols ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativePublicSymbol : public NativeRawSymbol { -public: - NativePublicSymbol(NativeSession &Session, SymIndexId Id, - const codeview::PublicSym32 &Sym); - - ~NativePublicSymbol() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - uint32_t getAddressOffset() const override; - uint32_t getAddressSection() const override; - std::string getName() const override; - uint32_t getRelativeVirtualAddress() const override; - uint64_t getVirtualAddress() const override; - -protected: - const codeview::PublicSym32 Sym; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativePublicSymbol.h - info about public symbols ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativePublicSymbol : public NativeRawSymbol { +public: + NativePublicSymbol(NativeSession &Session, SymIndexId Id, + const codeview::PublicSym32 &Sym); + + ~NativePublicSymbol() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + uint32_t getAddressOffset() const override; + uint32_t getAddressSection() const override; + std::string getName() const override; + uint32_t getRelativeVirtualAddress() const override; + uint64_t getVirtualAddress() const override; + +protected: + const codeview::PublicSym32 Sym; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEPUBLICSYMBOL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h index 9a59fc457f..940dad3b40 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h @@ -1,251 +1,251 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- NativeRawSymbol.h - Native implementation of IPDBRawSymbol -*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H - -#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" -#include <cstdint> -#include <memory> - -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeRawSymbol : public IPDBRawSymbol { - friend class SymbolCache; - virtual void initialize() {} - -public: - NativeRawSymbol(NativeSession &PDBSession, PDB_SymType Tag, - SymIndexId SymbolId); - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByAddr(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags, - uint32_t Section, uint32_t Offset) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint64_t VA) const override; - std::unique_ptr<IPDBEnumSymbols> - findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, - uint32_t RVA) const override; - - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const override; - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByRVA(uint32_t RVA) const override; - std::unique_ptr<IPDBEnumSymbols> - findInlineFramesByVA(uint64_t VA) const override; - - std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, - uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override; - - void getDataBytes(SmallVector<uint8_t, 32> &Bytes) const override; - void getFrontEndVersion(VersionInfo &Version) const override; - void getBackEndVersion(VersionInfo &Version) const override; - PDB_MemberAccess getAccess() const override; - uint32_t getAddressOffset() const override; - uint32_t getAddressSection() const override; - uint32_t getAge() const override; - SymIndexId getArrayIndexTypeId() const override; - uint32_t getBaseDataOffset() const override; - uint32_t getBaseDataSlot() const override; - SymIndexId getBaseSymbolId() const override; - PDB_BuiltinType getBuiltinType() const override; - uint32_t getBitPosition() const override; - PDB_CallingConv getCallingConvention() const override; - SymIndexId getClassParentId() const override; - std::string getCompilerName() const override; - uint32_t getCount() const override; - uint32_t getCountLiveRanges() const override; - PDB_Lang getLanguage() const override; - SymIndexId getLexicalParentId() const override; - std::string getLibraryName() const override; - uint32_t getLiveRangeStartAddressOffset() const override; - uint32_t getLiveRangeStartAddressSection() const override; - uint32_t getLiveRangeStartRelativeVirtualAddress() const override; - codeview::RegisterId getLocalBasePointerRegisterId() const override; - SymIndexId getLowerBoundId() const override; - uint32_t getMemorySpaceKind() const override; - std::string getName() const override; - uint32_t getNumberOfAcceleratorPointerTags() const override; - uint32_t getNumberOfColumns() const override; - uint32_t getNumberOfModifiers() const override; - uint32_t getNumberOfRegisterIndices() const override; - uint32_t getNumberOfRows() const override; - std::string getObjectFileName() const override; - uint32_t getOemId() const override; - SymIndexId getOemSymbolId() const override; - uint32_t getOffsetInUdt() const override; - PDB_Cpu getPlatform() const override; - uint32_t getRank() const override; - codeview::RegisterId getRegisterId() const override; - uint32_t getRegisterType() const override; - uint32_t getRelativeVirtualAddress() const override; - uint32_t getSamplerSlot() const override; - uint32_t getSignature() const override; - uint32_t getSizeInUdt() const override; - uint32_t getSlot() const override; - std::string getSourceFileName() const override; - std::unique_ptr<IPDBLineNumber> getSrcLineOnTypeDefn() const override; - uint32_t getStride() const override; - SymIndexId getSubTypeId() const override; - std::string getSymbolsFileName() const override; - SymIndexId getSymIndexId() const override; - uint32_t getTargetOffset() const override; - uint32_t getTargetRelativeVirtualAddress() const override; - uint64_t getTargetVirtualAddress() const override; - uint32_t getTargetSection() const override; - uint32_t getTextureSlot() const override; - uint32_t getTimeStamp() const override; - uint32_t getToken() const override; - SymIndexId getTypeId() const override; - uint32_t getUavSlot() const override; - std::string getUndecoratedName() const override; - std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override; - SymIndexId getUnmodifiedTypeId() const override; - SymIndexId getUpperBoundId() const override; - Variant getValue() const override; - uint32_t getVirtualBaseDispIndex() const override; - uint32_t getVirtualBaseOffset() const override; - SymIndexId getVirtualTableShapeId() const override; - std::unique_ptr<PDBSymbolTypeBuiltin> - getVirtualBaseTableType() const override; - PDB_DataKind getDataKind() const override; - PDB_SymType getSymTag() const override; - codeview::GUID getGuid() const override; - int32_t getOffset() const override; - int32_t getThisAdjust() const override; - int32_t getVirtualBasePointerOffset() const override; - PDB_LocType getLocationType() const override; - PDB_Machine getMachineType() const override; - codeview::ThunkOrdinal getThunkOrdinal() const override; - uint64_t getLength() const override; - uint64_t getLiveRangeLength() const override; - uint64_t getVirtualAddress() const override; - PDB_UdtType getUdtKind() const override; - bool hasConstructor() const override; - bool hasCustomCallingConvention() const override; - bool hasFarReturn() const override; - bool isCode() const override; - bool isCompilerGenerated() const override; - bool isConstType() const override; - bool isEditAndContinueEnabled() const override; - bool isFunction() const override; - bool getAddressTaken() const override; - bool getNoStackOrdering() const override; - bool hasAlloca() const override; - bool hasAssignmentOperator() const override; - bool hasCTypes() const override; - bool hasCastOperator() const override; - bool hasDebugInfo() const override; - bool hasEH() const override; - bool hasEHa() const override; - bool hasInlAsm() const override; - bool hasInlineAttribute() const override; - bool hasInterruptReturn() const override; - bool hasFramePointer() const override; - bool hasLongJump() const override; - bool hasManagedCode() const override; - bool hasNestedTypes() const override; - bool hasNoInlineAttribute() const override; - bool hasNoReturnAttribute() const override; - bool hasOptimizedCodeDebugInfo() const override; - bool hasOverloadedOperator() const override; - bool hasSEH() const override; - bool hasSecurityChecks() const override; - bool hasSetJump() const override; - bool hasStrictGSCheck() const override; - bool isAcceleratorGroupSharedLocal() const override; - bool isAcceleratorPointerTagLiveRange() const override; - bool isAcceleratorStubFunction() const override; - bool isAggregated() const override; - bool isIntroVirtualFunction() const override; - bool isCVTCIL() const override; - bool isConstructorVirtualBase() const override; - bool isCxxReturnUdt() const override; - bool isDataAligned() const override; - bool isHLSLData() const override; - bool isHotpatchable() const override; - bool isIndirectVirtualBaseClass() const override; - bool isInterfaceUdt() const override; - bool isIntrinsic() const override; - bool isLTCG() const override; - bool isLocationControlFlowDependent() const override; - bool isMSILNetmodule() const override; - bool isMatrixRowMajor() const override; - bool isManagedCode() const override; - bool isMSILCode() const override; - bool isMultipleInheritance() const override; - bool isNaked() const override; - bool isNested() const override; - bool isOptimizedAway() const override; - bool isPacked() const override; - bool isPointerBasedOnSymbolValue() const override; - bool isPointerToDataMember() const override; - bool isPointerToMemberFunction() const override; - bool isPureVirtual() const override; - bool isRValueReference() const override; - bool isRefUdt() const override; - bool isReference() const override; - bool isRestrictedType() const override; - bool isReturnValue() const override; - bool isSafeBuffers() const override; - bool isScoped() const override; - bool isSdl() const override; - bool isSingleInheritance() const override; - bool isSplitted() const override; - bool isStatic() const override; - bool hasPrivateSymbols() const override; - bool isUnalignedType() const override; - bool isUnreached() const override; - bool isValueUdt() const override; - bool isVirtual() const override; - bool isVirtualBaseClass() const override; - bool isVirtualInheritance() const override; - bool isVolatileType() const override; - bool wasInlined() const override; - std::string getUnused() const override; - -protected: - NativeSession &Session; - PDB_SymType Tag; - SymIndexId SymbolId; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- NativeRawSymbol.h - Native implementation of IPDBRawSymbol -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H + +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include <cstdint> +#include <memory> + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeRawSymbol : public IPDBRawSymbol { + friend class SymbolCache; + virtual void initialize() {} + +public: + NativeRawSymbol(NativeSession &PDBSession, PDB_SymType Tag, + SymIndexId SymbolId); + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByAddr(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags, + uint32_t Section, uint32_t Offset) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint64_t VA) const override; + std::unique_ptr<IPDBEnumSymbols> + findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, + uint32_t RVA) const override; + + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const override; + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByRVA(uint32_t RVA) const override; + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByVA(uint64_t VA) const override; + + std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, + uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override; + + void getDataBytes(SmallVector<uint8_t, 32> &Bytes) const override; + void getFrontEndVersion(VersionInfo &Version) const override; + void getBackEndVersion(VersionInfo &Version) const override; + PDB_MemberAccess getAccess() const override; + uint32_t getAddressOffset() const override; + uint32_t getAddressSection() const override; + uint32_t getAge() const override; + SymIndexId getArrayIndexTypeId() const override; + uint32_t getBaseDataOffset() const override; + uint32_t getBaseDataSlot() const override; + SymIndexId getBaseSymbolId() const override; + PDB_BuiltinType getBuiltinType() const override; + uint32_t getBitPosition() const override; + PDB_CallingConv getCallingConvention() const override; + SymIndexId getClassParentId() const override; + std::string getCompilerName() const override; + uint32_t getCount() const override; + uint32_t getCountLiveRanges() const override; + PDB_Lang getLanguage() const override; + SymIndexId getLexicalParentId() const override; + std::string getLibraryName() const override; + uint32_t getLiveRangeStartAddressOffset() const override; + uint32_t getLiveRangeStartAddressSection() const override; + uint32_t getLiveRangeStartRelativeVirtualAddress() const override; + codeview::RegisterId getLocalBasePointerRegisterId() const override; + SymIndexId getLowerBoundId() const override; + uint32_t getMemorySpaceKind() const override; + std::string getName() const override; + uint32_t getNumberOfAcceleratorPointerTags() const override; + uint32_t getNumberOfColumns() const override; + uint32_t getNumberOfModifiers() const override; + uint32_t getNumberOfRegisterIndices() const override; + uint32_t getNumberOfRows() const override; + std::string getObjectFileName() const override; + uint32_t getOemId() const override; + SymIndexId getOemSymbolId() const override; + uint32_t getOffsetInUdt() const override; + PDB_Cpu getPlatform() const override; + uint32_t getRank() const override; + codeview::RegisterId getRegisterId() const override; + uint32_t getRegisterType() const override; + uint32_t getRelativeVirtualAddress() const override; + uint32_t getSamplerSlot() const override; + uint32_t getSignature() const override; + uint32_t getSizeInUdt() const override; + uint32_t getSlot() const override; + std::string getSourceFileName() const override; + std::unique_ptr<IPDBLineNumber> getSrcLineOnTypeDefn() const override; + uint32_t getStride() const override; + SymIndexId getSubTypeId() const override; + std::string getSymbolsFileName() const override; + SymIndexId getSymIndexId() const override; + uint32_t getTargetOffset() const override; + uint32_t getTargetRelativeVirtualAddress() const override; + uint64_t getTargetVirtualAddress() const override; + uint32_t getTargetSection() const override; + uint32_t getTextureSlot() const override; + uint32_t getTimeStamp() const override; + uint32_t getToken() const override; + SymIndexId getTypeId() const override; + uint32_t getUavSlot() const override; + std::string getUndecoratedName() const override; + std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override; + SymIndexId getUnmodifiedTypeId() const override; + SymIndexId getUpperBoundId() const override; + Variant getValue() const override; + uint32_t getVirtualBaseDispIndex() const override; + uint32_t getVirtualBaseOffset() const override; + SymIndexId getVirtualTableShapeId() const override; + std::unique_ptr<PDBSymbolTypeBuiltin> + getVirtualBaseTableType() const override; + PDB_DataKind getDataKind() const override; + PDB_SymType getSymTag() const override; + codeview::GUID getGuid() const override; + int32_t getOffset() const override; + int32_t getThisAdjust() const override; + int32_t getVirtualBasePointerOffset() const override; + PDB_LocType getLocationType() const override; + PDB_Machine getMachineType() const override; + codeview::ThunkOrdinal getThunkOrdinal() const override; + uint64_t getLength() const override; + uint64_t getLiveRangeLength() const override; + uint64_t getVirtualAddress() const override; + PDB_UdtType getUdtKind() const override; + bool hasConstructor() const override; + bool hasCustomCallingConvention() const override; + bool hasFarReturn() const override; + bool isCode() const override; + bool isCompilerGenerated() const override; + bool isConstType() const override; + bool isEditAndContinueEnabled() const override; + bool isFunction() const override; + bool getAddressTaken() const override; + bool getNoStackOrdering() const override; + bool hasAlloca() const override; + bool hasAssignmentOperator() const override; + bool hasCTypes() const override; + bool hasCastOperator() const override; + bool hasDebugInfo() const override; + bool hasEH() const override; + bool hasEHa() const override; + bool hasInlAsm() const override; + bool hasInlineAttribute() const override; + bool hasInterruptReturn() const override; + bool hasFramePointer() const override; + bool hasLongJump() const override; + bool hasManagedCode() const override; + bool hasNestedTypes() const override; + bool hasNoInlineAttribute() const override; + bool hasNoReturnAttribute() const override; + bool hasOptimizedCodeDebugInfo() const override; + bool hasOverloadedOperator() const override; + bool hasSEH() const override; + bool hasSecurityChecks() const override; + bool hasSetJump() const override; + bool hasStrictGSCheck() const override; + bool isAcceleratorGroupSharedLocal() const override; + bool isAcceleratorPointerTagLiveRange() const override; + bool isAcceleratorStubFunction() const override; + bool isAggregated() const override; + bool isIntroVirtualFunction() const override; + bool isCVTCIL() const override; + bool isConstructorVirtualBase() const override; + bool isCxxReturnUdt() const override; + bool isDataAligned() const override; + bool isHLSLData() const override; + bool isHotpatchable() const override; + bool isIndirectVirtualBaseClass() const override; + bool isInterfaceUdt() const override; + bool isIntrinsic() const override; + bool isLTCG() const override; + bool isLocationControlFlowDependent() const override; + bool isMSILNetmodule() const override; + bool isMatrixRowMajor() const override; + bool isManagedCode() const override; + bool isMSILCode() const override; + bool isMultipleInheritance() const override; + bool isNaked() const override; + bool isNested() const override; + bool isOptimizedAway() const override; + bool isPacked() const override; + bool isPointerBasedOnSymbolValue() const override; + bool isPointerToDataMember() const override; + bool isPointerToMemberFunction() const override; + bool isPureVirtual() const override; + bool isRValueReference() const override; + bool isRefUdt() const override; + bool isReference() const override; + bool isRestrictedType() const override; + bool isReturnValue() const override; + bool isSafeBuffers() const override; + bool isScoped() const override; + bool isSdl() const override; + bool isSingleInheritance() const override; + bool isSplitted() const override; + bool isStatic() const override; + bool hasPrivateSymbols() const override; + bool isUnalignedType() const override; + bool isUnreached() const override; + bool isValueUdt() const override; + bool isVirtual() const override; + bool isVirtualBaseClass() const override; + bool isVirtualInheritance() const override; + bool isVolatileType() const override; + bool wasInlined() const override; + std::string getUnused() const override; + +protected: + NativeSession &Session; + PDB_SymType Tag; + SymIndexId SymbolId; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVERAWSYMBOL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSession.h index 28c4828d72..37222ba4bf 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSession.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSession.h @@ -1,149 +1,149 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeSession.h - Native implementation of IPDBSession ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/SymbolCache.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/Error.h" - -namespace llvm { -class MemoryBuffer; -namespace pdb { -class PDBFile; -class NativeExeSymbol; - -class NativeSession : public IPDBSession { - struct PdbSearchOptions { - StringRef ExePath; - // FIXME: Add other PDB search options (_NT_SYMBOL_PATH, symsrv) - }; - -public: - NativeSession(std::unique_ptr<PDBFile> PdbFile, - std::unique_ptr<BumpPtrAllocator> Allocator); - ~NativeSession() override; - - static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB, - std::unique_ptr<IPDBSession> &Session); - static Error createFromPdbPath(StringRef PdbPath, - std::unique_ptr<IPDBSession> &Session); - static Error createFromExe(StringRef Path, - std::unique_ptr<IPDBSession> &Session); - static Expected<std::string> searchForPdb(const PdbSearchOptions &Opts); - - uint64_t getLoadAddress() const override; - bool setLoadAddress(uint64_t Address) override; - std::unique_ptr<PDBSymbolExe> getGlobalScope() override; - std::unique_ptr<PDBSymbol> getSymbolById(SymIndexId SymbolId) const override; - - bool addressForVA(uint64_t VA, uint32_t &Section, - uint32_t &Offset) const override; - bool addressForRVA(uint32_t RVA, uint32_t &Section, - uint32_t &Offset) const override; - - std::unique_ptr<PDBSymbol> findSymbolByAddress(uint64_t Address, - PDB_SymType Type) override; - std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA, - PDB_SymType Type) override; - std::unique_ptr<PDBSymbol> findSymbolBySectOffset(uint32_t Sect, - uint32_t Offset, - PDB_SymType Type) override; - - std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbers(const PDBSymbolCompiland &Compiland, - const IPDBSourceFile &File) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const override; - std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, - uint32_t Length) const override; - - std::unique_ptr<IPDBEnumSourceFiles> - findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<IPDBSourceFile> - findOneSourceFile(const PDBSymbolCompiland *Compiland, - llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> - findCompilandsForSourceFile(llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<PDBSymbolCompiland> - findOneCompilandForSourceFile(llvm::StringRef Pattern, - PDB_NameSearchFlags Flags) const override; - std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override; - std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland( - const PDBSymbolCompiland &Compiland) const override; - std::unique_ptr<IPDBSourceFile> - getSourceFileById(uint32_t FileId) const override; - - std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override; - - std::unique_ptr<IPDBEnumTables> getEnumTables() const override; - - std::unique_ptr<IPDBEnumInjectedSources> getInjectedSources() const override; - - std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override; - - std::unique_ptr<IPDBEnumFrameData> getFrameData() const override; - - PDBFile &getPDBFile() { return *Pdb; } - const PDBFile &getPDBFile() const { return *Pdb; } - - NativeExeSymbol &getNativeGlobalScope() const; - SymbolCache &getSymbolCache() { return Cache; } - const SymbolCache &getSymbolCache() const { return Cache; } - uint32_t getRVAFromSectOffset(uint32_t Section, uint32_t Offset) const; - uint64_t getVAFromSectOffset(uint32_t Section, uint32_t Offset) const; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeSession.h - Native implementation of IPDBSession ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/SymbolCache.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" + +namespace llvm { +class MemoryBuffer; +namespace pdb { +class PDBFile; +class NativeExeSymbol; + +class NativeSession : public IPDBSession { + struct PdbSearchOptions { + StringRef ExePath; + // FIXME: Add other PDB search options (_NT_SYMBOL_PATH, symsrv) + }; + +public: + NativeSession(std::unique_ptr<PDBFile> PdbFile, + std::unique_ptr<BumpPtrAllocator> Allocator); + ~NativeSession() override; + + static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB, + std::unique_ptr<IPDBSession> &Session); + static Error createFromPdbPath(StringRef PdbPath, + std::unique_ptr<IPDBSession> &Session); + static Error createFromExe(StringRef Path, + std::unique_ptr<IPDBSession> &Session); + static Expected<std::string> searchForPdb(const PdbSearchOptions &Opts); + + uint64_t getLoadAddress() const override; + bool setLoadAddress(uint64_t Address) override; + std::unique_ptr<PDBSymbolExe> getGlobalScope() override; + std::unique_ptr<PDBSymbol> getSymbolById(SymIndexId SymbolId) const override; + + bool addressForVA(uint64_t VA, uint32_t &Section, + uint32_t &Offset) const override; + bool addressForRVA(uint32_t RVA, uint32_t &Section, + uint32_t &Offset) const override; + + std::unique_ptr<PDBSymbol> findSymbolByAddress(uint64_t Address, + PDB_SymType Type) override; + std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA, + PDB_SymType Type) override; + std::unique_ptr<PDBSymbol> findSymbolBySectOffset(uint32_t Sect, + uint32_t Offset, + PDB_SymType Type) override; + + std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbers(const PDBSymbolCompiland &Compiland, + const IPDBSourceFile &File) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const override; + std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const override; + + std::unique_ptr<IPDBEnumSourceFiles> + findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<IPDBSourceFile> + findOneSourceFile(const PDBSymbolCompiland *Compiland, + llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> + findCompilandsForSourceFile(llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<PDBSymbolCompiland> + findOneCompilandForSourceFile(llvm::StringRef Pattern, + PDB_NameSearchFlags Flags) const override; + std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override; + std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland( + const PDBSymbolCompiland &Compiland) const override; + std::unique_ptr<IPDBSourceFile> + getSourceFileById(uint32_t FileId) const override; + + std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override; + + std::unique_ptr<IPDBEnumTables> getEnumTables() const override; + + std::unique_ptr<IPDBEnumInjectedSources> getInjectedSources() const override; + + std::unique_ptr<IPDBEnumSectionContribs> getSectionContribs() const override; + + std::unique_ptr<IPDBEnumFrameData> getFrameData() const override; + + PDBFile &getPDBFile() { return *Pdb; } + const PDBFile &getPDBFile() const { return *Pdb; } + + NativeExeSymbol &getNativeGlobalScope() const; + SymbolCache &getSymbolCache() { return Cache; } + const SymbolCache &getSymbolCache() const { return Cache; } + uint32_t getRVAFromSectOffset(uint32_t Section, uint32_t Offset) const; + uint64_t getVAFromSectOffset(uint32_t Section, uint32_t Offset) const; bool moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const; bool moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, uint16_t &ModuleIndex) const; Expected<ModuleDebugStreamRef> getModuleDebugStream(uint32_t Index) const; - -private: - void initializeExeSymbol(); + +private: + void initializeExeSymbol(); void parseSectionContribs(); - - std::unique_ptr<PDBFile> Pdb; - std::unique_ptr<BumpPtrAllocator> Allocator; - - SymbolCache Cache; - SymIndexId ExeSymbol = 0; - uint64_t LoadAddress = 0; + + std::unique_ptr<PDBFile> Pdb; + std::unique_ptr<BumpPtrAllocator> Allocator; + + SymbolCache Cache; + SymIndexId ExeSymbol = 0; + uint64_t LoadAddress = 0; /// Map from virtual address to module index. using IMap = IntervalMap<uint64_t, uint16_t, 8, IntervalMapHalfOpenInfo<uint64_t>>; IMap::Allocator IMapAllocator; IMap AddrToModuleIndex; -}; -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +}; +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSourceFile.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSourceFile.h index 6489c2cd69..8d92897271 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSourceFile.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSourceFile.h @@ -1,51 +1,51 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeSourceFile.h - Native source file implementation ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESOURCEFILE_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESOURCEFILE_H - -#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" -#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" -#include "llvm/DebugInfo/PDB/Native/PDBFile.h" -#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" - -namespace llvm { -namespace pdb { -class NativeSession; - -class NativeSourceFile : public IPDBSourceFile { -public: - explicit NativeSourceFile(NativeSession &Session, uint32_t FileId, - const codeview::FileChecksumEntry &Checksum); - - std::string getFileName() const override; - uint32_t getUniqueId() const override; - std::string getChecksum() const override; - PDB_Checksum getChecksumType() const override; - std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> - getCompilands() const override; - -private: - NativeSession &Session; - uint32_t FileId; - const codeview::FileChecksumEntry Checksum; -}; -} // namespace pdb -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeSourceFile.h - Native source file implementation ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESOURCEFILE_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESOURCEFILE_H + +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/PDB/IPDBSourceFile.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" + +namespace llvm { +namespace pdb { +class NativeSession; + +class NativeSourceFile : public IPDBSourceFile { +public: + explicit NativeSourceFile(NativeSession &Session, uint32_t FileId, + const codeview::FileChecksumEntry &Checksum); + + std::string getFileName() const override; + uint32_t getUniqueId() const override; + std::string getChecksum() const override; + PDB_Checksum getChecksumType() const override; + std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> + getCompilands() const override; + +private: + NativeSession &Session; + uint32_t FileId; + const codeview::FileChecksumEntry Checksum; +}; +} // namespace pdb +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h index 7a883539a0..a14f5a024c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h @@ -1,61 +1,61 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeSymbolEnumerator.h - info about enumerator values --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESYMBOLENUMERATOR_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESYMBOLENUMERATOR_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { -class NativeTypeEnum; - -class NativeSymbolEnumerator : public NativeRawSymbol { -public: - NativeSymbolEnumerator(NativeSession &Session, SymIndexId Id, - const NativeTypeEnum &Parent, - codeview::EnumeratorRecord Record); - - ~NativeSymbolEnumerator() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - SymIndexId getClassParentId() const override; - SymIndexId getLexicalParentId() const override; - std::string getName() const override; - SymIndexId getTypeId() const override; - PDB_DataKind getDataKind() const override; - PDB_LocType getLocationType() const override; - bool isConstType() const override; - bool isVolatileType() const override; - bool isUnalignedType() const override; - Variant getValue() const override; - -protected: - const NativeTypeEnum &Parent; - codeview::EnumeratorRecord Record; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeSymbolEnumerator.h - info about enumerator values --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESYMBOLENUMERATOR_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESYMBOLENUMERATOR_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { +class NativeTypeEnum; + +class NativeSymbolEnumerator : public NativeRawSymbol { +public: + NativeSymbolEnumerator(NativeSession &Session, SymIndexId Id, + const NativeTypeEnum &Parent, + codeview::EnumeratorRecord Record); + + ~NativeSymbolEnumerator() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + SymIndexId getClassParentId() const override; + SymIndexId getLexicalParentId() const override; + std::string getName() const override; + SymIndexId getTypeId() const override; + PDB_DataKind getDataKind() const override; + PDB_LocType getLocationType() const override; + bool isConstType() const override; + bool isVolatileType() const override; + bool isUnalignedType() const override; + Variant getValue() const override; + +protected: + const NativeTypeEnum &Parent; + codeview::EnumeratorRecord Record; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h index 7d7fc299ed..b4223d0b4f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeArray.h ------------------------------------------ C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H - -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" - -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" - -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeTypeArray : public NativeRawSymbol { -public: - NativeTypeArray(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, - codeview::ArrayRecord Record); - ~NativeTypeArray() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - SymIndexId getArrayIndexTypeId() const override; - - bool isConstType() const override; - bool isUnalignedType() const override; - bool isVolatileType() const override; - - uint32_t getCount() const override; - SymIndexId getTypeId() const override; - uint64_t getLength() const override; - -protected: - codeview::ArrayRecord Record; - codeview::TypeIndex Index; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeArray.h ------------------------------------------ C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEARRAY_H + +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" + +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeTypeArray : public NativeRawSymbol { +public: + NativeTypeArray(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, + codeview::ArrayRecord Record); + ~NativeTypeArray() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + SymIndexId getArrayIndexTypeId() const override; + + bool isConstType() const override; + bool isUnalignedType() const override; + bool isVolatileType() const override; + + uint32_t getCount() const override; + SymIndexId getTypeId() const override; + uint64_t getLength() const override; + +protected: + codeview::ArrayRecord Record; + codeview::TypeIndex Index; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h index 0ae0cbb441..2b9eabbf8b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h @@ -1,60 +1,60 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeBuiltin.h ---------------------------------------- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEBUILTIN_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEBUILTIN_H - -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" - -#include "llvm/DebugInfo/PDB/PDBTypes.h" - -namespace llvm { -namespace pdb { - -class NativeSession; - -class NativeTypeBuiltin : public NativeRawSymbol { -public: - NativeTypeBuiltin(NativeSession &PDBSession, SymIndexId Id, - codeview::ModifierOptions Mods, PDB_BuiltinType T, - uint64_t L); - ~NativeTypeBuiltin() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - PDB_SymType getSymTag() const override; - - PDB_BuiltinType getBuiltinType() const override; - bool isConstType() const override; - uint64_t getLength() const override; - bool isUnalignedType() const override; - bool isVolatileType() const override; - -protected: - NativeSession &Session; - codeview::ModifierOptions Mods; - PDB_BuiltinType Type; - uint64_t Length; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeBuiltin.h ---------------------------------------- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEBUILTIN_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEBUILTIN_H + +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" + +#include "llvm/DebugInfo/PDB/PDBTypes.h" + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeTypeBuiltin : public NativeRawSymbol { +public: + NativeTypeBuiltin(NativeSession &PDBSession, SymIndexId Id, + codeview::ModifierOptions Mods, PDB_BuiltinType T, + uint64_t L); + ~NativeTypeBuiltin() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + PDB_SymType getSymTag() const override; + + PDB_BuiltinType getBuiltinType() const override; + bool isConstType() const override; + uint64_t getLength() const override; + bool isUnalignedType() const override; + bool isVolatileType() const override; + +protected: + NativeSession &Session; + codeview::ModifierOptions Mods; + PDB_BuiltinType Type; + uint64_t Length; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h index fa9ce8d2f4..568378aa4c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h @@ -1,85 +1,85 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeEnum.h - info about enum type ------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypeBuiltin; - -class NativeTypeEnum : public NativeRawSymbol { -public: - NativeTypeEnum(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, - codeview::EnumRecord Record); - - NativeTypeEnum(NativeSession &Session, SymIndexId Id, - NativeTypeEnum &UnmodifiedType, - codeview::ModifierRecord Modifier); - ~NativeTypeEnum() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const override; - - PDB_BuiltinType getBuiltinType() const override; - PDB_SymType getSymTag() const override; - SymIndexId getUnmodifiedTypeId() const override; - bool hasConstructor() const override; - bool hasAssignmentOperator() const override; - bool hasCastOperator() const override; - uint64_t getLength() const override; - std::string getName() const override; - bool isConstType() const override; - bool isVolatileType() const override; - bool isUnalignedType() const override; - bool isNested() const override; - bool hasOverloadedOperator() const override; - bool hasNestedTypes() const override; - bool isIntrinsic() const override; - bool isPacked() const override; - bool isScoped() const override; - SymIndexId getTypeId() const override; - bool isRefUdt() const override; - bool isValueUdt() const override; - bool isInterfaceUdt() const override; - - const NativeTypeBuiltin &getUnderlyingBuiltinType() const; - const codeview::EnumRecord &getEnumRecord() const { return *Record; } - -protected: - codeview::TypeIndex Index; - Optional<codeview::EnumRecord> Record; - NativeTypeEnum *UnmodifiedType = nullptr; - Optional<codeview::ModifierRecord> Modifiers; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeEnum.h - info about enum type ------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypeBuiltin; + +class NativeTypeEnum : public NativeRawSymbol { +public: + NativeTypeEnum(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, + codeview::EnumRecord Record); + + NativeTypeEnum(NativeSession &Session, SymIndexId Id, + NativeTypeEnum &UnmodifiedType, + codeview::ModifierRecord Modifier); + ~NativeTypeEnum() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + + PDB_BuiltinType getBuiltinType() const override; + PDB_SymType getSymTag() const override; + SymIndexId getUnmodifiedTypeId() const override; + bool hasConstructor() const override; + bool hasAssignmentOperator() const override; + bool hasCastOperator() const override; + uint64_t getLength() const override; + std::string getName() const override; + bool isConstType() const override; + bool isVolatileType() const override; + bool isUnalignedType() const override; + bool isNested() const override; + bool hasOverloadedOperator() const override; + bool hasNestedTypes() const override; + bool isIntrinsic() const override; + bool isPacked() const override; + bool isScoped() const override; + SymIndexId getTypeId() const override; + bool isRefUdt() const override; + bool isValueUdt() const override; + bool isInterfaceUdt() const override; + + const NativeTypeBuiltin &getUnderlyingBuiltinType() const; + const codeview::EnumRecord &getEnumRecord() const { return *Record; } + +protected: + codeview::TypeIndex Index; + Optional<codeview::EnumRecord> Record; + NativeTypeEnum *UnmodifiedType = nullptr; + Optional<codeview::ModifierRecord> Modifiers; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEENUM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h index 01379535bc..6672108bb1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h @@ -1,84 +1,84 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeFunctionSig.h - info about function signature ---*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEFUNCTIONSIG_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEFUNCTIONSIG_H - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypeUDT; - -class NativeTypeFunctionSig : public NativeRawSymbol { -protected: - void initialize() override; - -public: - NativeTypeFunctionSig(NativeSession &Session, SymIndexId Id, - codeview::TypeIndex TI, codeview::ProcedureRecord Proc); - - NativeTypeFunctionSig(NativeSession &Session, SymIndexId Id, - codeview::TypeIndex TI, - codeview::MemberFunctionRecord MemberFunc); - - ~NativeTypeFunctionSig() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type) const override; - - SymIndexId getClassParentId() const override; - PDB_CallingConv getCallingConvention() const override; - uint32_t getCount() const override; - SymIndexId getTypeId() const override; - int32_t getThisAdjust() const override; - bool hasConstructor() const override; - bool isConstType() const override; - bool isConstructorVirtualBase() const override; - bool isCxxReturnUdt() const override; - bool isUnalignedType() const override; - bool isVolatileType() const override; - -private: - void initializeArgList(codeview::TypeIndex ArgListTI); - - union { - codeview::MemberFunctionRecord MemberFunc; - codeview::ProcedureRecord Proc; - }; - - SymIndexId ClassParentId = 0; - codeview::TypeIndex Index; - codeview::ArgListRecord ArgList; - bool IsMemberFunction = false; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeFunctionSig.h - info about function signature ---*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEFUNCTIONSIG_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEFUNCTIONSIG_H + +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypeUDT; + +class NativeTypeFunctionSig : public NativeRawSymbol { +protected: + void initialize() override; + +public: + NativeTypeFunctionSig(NativeSession &Session, SymIndexId Id, + codeview::TypeIndex TI, codeview::ProcedureRecord Proc); + + NativeTypeFunctionSig(NativeSession &Session, SymIndexId Id, + codeview::TypeIndex TI, + codeview::MemberFunctionRecord MemberFunc); + + ~NativeTypeFunctionSig() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type) const override; + + SymIndexId getClassParentId() const override; + PDB_CallingConv getCallingConvention() const override; + uint32_t getCount() const override; + SymIndexId getTypeId() const override; + int32_t getThisAdjust() const override; + bool hasConstructor() const override; + bool isConstType() const override; + bool isConstructorVirtualBase() const override; + bool isCxxReturnUdt() const override; + bool isUnalignedType() const override; + bool isVolatileType() const override; + +private: + void initializeArgList(codeview::TypeIndex ArgListTI); + + union { + codeview::MemberFunctionRecord MemberFunc; + codeview::ProcedureRecord Proc; + }; + + SymIndexId ClassParentId = 0; + codeview::TypeIndex Index; + codeview::ArgListRecord ArgList; + bool IsMemberFunction = false; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h index 76698b7e3f..bdf70bc364 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h @@ -1,71 +1,71 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypePointer.h - info about pointer type -------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypePointer : public NativeRawSymbol { -public: - // Create a pointer record for a simple type. - NativeTypePointer(NativeSession &Session, SymIndexId Id, - codeview::TypeIndex TI); - - // Create a pointer record for a non-simple type. - NativeTypePointer(NativeSession &Session, SymIndexId Id, - codeview::TypeIndex TI, codeview::PointerRecord PR); - ~NativeTypePointer() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - SymIndexId getClassParentId() const override; - bool isConstType() const override; - uint64_t getLength() const override; - bool isReference() const override; - bool isRValueReference() const override; - bool isPointerToDataMember() const override; - bool isPointerToMemberFunction() const override; - SymIndexId getTypeId() const override; - bool isRestrictedType() const override; - bool isVolatileType() const override; - bool isUnalignedType() const override; - - bool isSingleInheritance() const override; - bool isMultipleInheritance() const override; - bool isVirtualInheritance() const override; - -protected: - bool isMemberPointer() const; - codeview::TypeIndex TI; - Optional<codeview::PointerRecord> Record; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypePointer.h - info about pointer type -------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypePointer : public NativeRawSymbol { +public: + // Create a pointer record for a simple type. + NativeTypePointer(NativeSession &Session, SymIndexId Id, + codeview::TypeIndex TI); + + // Create a pointer record for a non-simple type. + NativeTypePointer(NativeSession &Session, SymIndexId Id, + codeview::TypeIndex TI, codeview::PointerRecord PR); + ~NativeTypePointer() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + SymIndexId getClassParentId() const override; + bool isConstType() const override; + uint64_t getLength() const override; + bool isReference() const override; + bool isRValueReference() const override; + bool isPointerToDataMember() const override; + bool isPointerToMemberFunction() const override; + SymIndexId getTypeId() const override; + bool isRestrictedType() const override; + bool isVolatileType() const override; + bool isUnalignedType() const override; + + bool isSingleInheritance() const override; + bool isMultipleInheritance() const override; + bool isVirtualInheritance() const override; + +protected: + bool isMemberPointer() const; + codeview::TypeIndex TI; + Optional<codeview::PointerRecord> Record; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeTypedef.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeTypedef.h index bef4e462f4..82c96e4366 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeTypedef.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeTypedef.h @@ -1,52 +1,52 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeTypedef.h - info about typedef ------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEF_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEF_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypeTypedef : public NativeRawSymbol { -public: - // Create a pointer record for a non-simple type. - NativeTypeTypedef(NativeSession &Session, SymIndexId Id, - codeview::UDTSym Typedef); - - ~NativeTypeTypedef() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - std::string getName() const override; - SymIndexId getTypeId() const override; - -protected: - codeview::UDTSym Record; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeTypedef.h - info about typedef ------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEF_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPETYPEDEF_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypeTypedef : public NativeRawSymbol { +public: + // Create a pointer record for a non-simple type. + NativeTypeTypedef(NativeSession &Session, SymIndexId Id, + codeview::UDTSym Typedef); + + ~NativeTypeTypedef() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::string getName() const override; + SymIndexId getTypeId() const override; + +protected: + codeview::UDTSym Record; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEPOINTER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h index 65886d64ca..135a4416d1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h @@ -1,84 +1,84 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeUDT.h - info about class/struct type ------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypeUDT : public NativeRawSymbol { -public: - NativeTypeUDT(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, - codeview::ClassRecord Class); - - NativeTypeUDT(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, - codeview::UnionRecord Union); - - NativeTypeUDT(NativeSession &Session, SymIndexId Id, - NativeTypeUDT &UnmodifiedType, - codeview::ModifierRecord Modifier); - - ~NativeTypeUDT() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - std::string getName() const override; - SymIndexId getLexicalParentId() const override; - SymIndexId getUnmodifiedTypeId() const override; - SymIndexId getVirtualTableShapeId() const override; - uint64_t getLength() const override; - PDB_UdtType getUdtKind() const override; - bool hasConstructor() const override; - bool isConstType() const override; - bool hasAssignmentOperator() const override; - bool hasCastOperator() const override; - bool hasNestedTypes() const override; - bool hasOverloadedOperator() const override; - bool isInterfaceUdt() const override; - bool isIntrinsic() const override; - bool isNested() const override; - bool isPacked() const override; - bool isRefUdt() const override; - bool isScoped() const override; - bool isValueUdt() const override; - bool isUnalignedType() const override; - bool isVolatileType() const override; - -protected: - codeview::TypeIndex Index; - - Optional<codeview::ClassRecord> Class; - Optional<codeview::UnionRecord> Union; - NativeTypeUDT *UnmodifiedType = nullptr; - codeview::TagRecord *Tag = nullptr; - Optional<codeview::ModifierRecord> Modifiers; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeUDT.h - info about class/struct type ------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypeUDT : public NativeRawSymbol { +public: + NativeTypeUDT(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, + codeview::ClassRecord Class); + + NativeTypeUDT(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI, + codeview::UnionRecord Union); + + NativeTypeUDT(NativeSession &Session, SymIndexId Id, + NativeTypeUDT &UnmodifiedType, + codeview::ModifierRecord Modifier); + + ~NativeTypeUDT() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::string getName() const override; + SymIndexId getLexicalParentId() const override; + SymIndexId getUnmodifiedTypeId() const override; + SymIndexId getVirtualTableShapeId() const override; + uint64_t getLength() const override; + PDB_UdtType getUdtKind() const override; + bool hasConstructor() const override; + bool isConstType() const override; + bool hasAssignmentOperator() const override; + bool hasCastOperator() const override; + bool hasNestedTypes() const override; + bool hasOverloadedOperator() const override; + bool isInterfaceUdt() const override; + bool isIntrinsic() const override; + bool isNested() const override; + bool isPacked() const override; + bool isRefUdt() const override; + bool isScoped() const override; + bool isValueUdt() const override; + bool isUnalignedType() const override; + bool isVolatileType() const override; + +protected: + codeview::TypeIndex Index; + + Optional<codeview::ClassRecord> Class; + Optional<codeview::UnionRecord> Union; + NativeTypeUDT *UnmodifiedType = nullptr; + codeview::TagRecord *Tag = nullptr; + Optional<codeview::ModifierRecord> Modifiers; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEUDT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h index 1f3a064e1a..003f4806d2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h @@ -1,56 +1,56 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- NativeTypeVTShape.h - info about virtual table shape ------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H -#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSession.h" - -namespace llvm { -namespace pdb { - -class NativeTypeVTShape : public NativeRawSymbol { -public: - // Create a pointer record for a non-simple type. - NativeTypeVTShape(NativeSession &Session, SymIndexId Id, - codeview::TypeIndex TI, codeview::VFTableShapeRecord SR); - - ~NativeTypeVTShape() override; - - void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, - PdbSymbolIdField RecurseIdFields) const override; - - bool isConstType() const override; - bool isVolatileType() const override; - bool isUnalignedType() const override; - uint32_t getCount() const override; - -protected: - codeview::TypeIndex TI; - codeview::VFTableShapeRecord Record; -}; - -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- NativeTypeVTShape.h - info about virtual table shape ------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeTypeVTShape : public NativeRawSymbol { +public: + // Create a pointer record for a non-simple type. + NativeTypeVTShape(NativeSession &Session, SymIndexId Id, + codeview::TypeIndex TI, codeview::VFTableShapeRecord SR); + + ~NativeTypeVTShape() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + bool isConstType() const override; + bool isVolatileType() const override; + bool isUnalignedType() const override; + uint32_t getCount() const override; + +protected: + codeview::TypeIndex TI; + codeview::VFTableShapeRecord Record; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVETYPEVTSHAPE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFile.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFile.h index 7c3ee23515..d54abe660f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFile.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFile.h @@ -1,158 +1,158 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBFile.h - Low level interface to a PDB file ------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/DebugInfo/MSF/IMSFFile.h" -#include "llvm/DebugInfo/MSF/MSFCommon.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/MathExtras.h" - -#include <memory> - -namespace llvm { - -class BinaryStream; - -namespace msf { -class MappedBlockStream; -} - -namespace pdb { -class DbiStream; -class GlobalsStream; -class InfoStream; -class InjectedSourceStream; -class PDBStringTable; -class PDBFileBuilder; -class PublicsStream; -class SymbolStream; -class TpiStream; - -class PDBFile : public msf::IMSFFile { - friend PDBFileBuilder; - -public: - PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer, - BumpPtrAllocator &Allocator); - ~PDBFile() override; - - StringRef getFileDirectory() const; - StringRef getFilePath() const; - - uint32_t getFreeBlockMapBlock() const; - uint32_t getUnknown1() const; - - uint32_t getBlockSize() const override; - uint32_t getBlockCount() const override; - uint32_t getNumDirectoryBytes() const; - uint32_t getBlockMapIndex() const; - uint32_t getNumDirectoryBlocks() const; - uint64_t getBlockMapOffset() const; - - uint32_t getNumStreams() const override; - uint32_t getMaxStreamSize() const; - uint32_t getStreamByteSize(uint32_t StreamIndex) const override; - ArrayRef<support::ulittle32_t> - getStreamBlockList(uint32_t StreamIndex) const override; - uint32_t getFileSize() const; - - Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex, - uint32_t NumBytes) const override; - Error setBlockData(uint32_t BlockIndex, uint32_t Offset, - ArrayRef<uint8_t> Data) const override; - - ArrayRef<support::ulittle32_t> getStreamSizes() const { - return ContainerLayout.StreamSizes; - } - ArrayRef<ArrayRef<support::ulittle32_t>> getStreamMap() const { - return ContainerLayout.StreamMap; - } - - const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; } - BinaryStreamRef getMsfBuffer() const { return *Buffer; } - - ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const; - - std::unique_ptr<msf::MappedBlockStream> - createIndexedStream(uint16_t SN) const; - Expected<std::unique_ptr<msf::MappedBlockStream>> - safelyCreateIndexedStream(uint32_t StreamIndex) const; - Expected<std::unique_ptr<msf::MappedBlockStream>> - safelyCreateNamedStream(StringRef Name); - - msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const; - msf::MSFStreamLayout getFpmStreamLayout() const; - - Error parseFileHeaders(); - Error parseStreamData(); - - Expected<InfoStream &> getPDBInfoStream(); - Expected<DbiStream &> getPDBDbiStream(); - Expected<GlobalsStream &> getPDBGlobalsStream(); - Expected<TpiStream &> getPDBTpiStream(); - Expected<TpiStream &> getPDBIpiStream(); - Expected<PublicsStream &> getPDBPublicsStream(); - Expected<SymbolStream &> getPDBSymbolStream(); - Expected<PDBStringTable &> getStringTable(); - Expected<InjectedSourceStream &> getInjectedSourceStream(); - - BumpPtrAllocator &getAllocator() { return Allocator; } - - bool hasPDBDbiStream() const; - bool hasPDBGlobalsStream(); - bool hasPDBInfoStream() const; - bool hasPDBIpiStream() const; - bool hasPDBPublicsStream(); - bool hasPDBSymbolStream(); - bool hasPDBTpiStream() const; - bool hasPDBStringTable(); - bool hasPDBInjectedSourceStream(); - - uint32_t getPointerSize(); - -private: - std::string FilePath; - BumpPtrAllocator &Allocator; - - std::unique_ptr<BinaryStream> Buffer; - - msf::MSFLayout ContainerLayout; - - std::unique_ptr<GlobalsStream> Globals; - std::unique_ptr<InfoStream> Info; - std::unique_ptr<DbiStream> Dbi; - std::unique_ptr<TpiStream> Tpi; - std::unique_ptr<TpiStream> Ipi; - std::unique_ptr<PublicsStream> Publics; - std::unique_ptr<SymbolStream> Symbols; - std::unique_ptr<msf::MappedBlockStream> DirectoryStream; - std::unique_ptr<msf::MappedBlockStream> StringTableStream; - std::unique_ptr<InjectedSourceStream> InjectedSources; - std::unique_ptr<PDBStringTable> Strings; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBFile.h - Low level interface to a PDB file ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/DebugInfo/MSF/IMSFFile.h" +#include "llvm/DebugInfo/MSF/MSFCommon.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" + +#include <memory> + +namespace llvm { + +class BinaryStream; + +namespace msf { +class MappedBlockStream; +} + +namespace pdb { +class DbiStream; +class GlobalsStream; +class InfoStream; +class InjectedSourceStream; +class PDBStringTable; +class PDBFileBuilder; +class PublicsStream; +class SymbolStream; +class TpiStream; + +class PDBFile : public msf::IMSFFile { + friend PDBFileBuilder; + +public: + PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer, + BumpPtrAllocator &Allocator); + ~PDBFile() override; + + StringRef getFileDirectory() const; + StringRef getFilePath() const; + + uint32_t getFreeBlockMapBlock() const; + uint32_t getUnknown1() const; + + uint32_t getBlockSize() const override; + uint32_t getBlockCount() const override; + uint32_t getNumDirectoryBytes() const; + uint32_t getBlockMapIndex() const; + uint32_t getNumDirectoryBlocks() const; + uint64_t getBlockMapOffset() const; + + uint32_t getNumStreams() const override; + uint32_t getMaxStreamSize() const; + uint32_t getStreamByteSize(uint32_t StreamIndex) const override; + ArrayRef<support::ulittle32_t> + getStreamBlockList(uint32_t StreamIndex) const override; + uint32_t getFileSize() const; + + Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex, + uint32_t NumBytes) const override; + Error setBlockData(uint32_t BlockIndex, uint32_t Offset, + ArrayRef<uint8_t> Data) const override; + + ArrayRef<support::ulittle32_t> getStreamSizes() const { + return ContainerLayout.StreamSizes; + } + ArrayRef<ArrayRef<support::ulittle32_t>> getStreamMap() const { + return ContainerLayout.StreamMap; + } + + const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; } + BinaryStreamRef getMsfBuffer() const { return *Buffer; } + + ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const; + + std::unique_ptr<msf::MappedBlockStream> + createIndexedStream(uint16_t SN) const; + Expected<std::unique_ptr<msf::MappedBlockStream>> + safelyCreateIndexedStream(uint32_t StreamIndex) const; + Expected<std::unique_ptr<msf::MappedBlockStream>> + safelyCreateNamedStream(StringRef Name); + + msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const; + msf::MSFStreamLayout getFpmStreamLayout() const; + + Error parseFileHeaders(); + Error parseStreamData(); + + Expected<InfoStream &> getPDBInfoStream(); + Expected<DbiStream &> getPDBDbiStream(); + Expected<GlobalsStream &> getPDBGlobalsStream(); + Expected<TpiStream &> getPDBTpiStream(); + Expected<TpiStream &> getPDBIpiStream(); + Expected<PublicsStream &> getPDBPublicsStream(); + Expected<SymbolStream &> getPDBSymbolStream(); + Expected<PDBStringTable &> getStringTable(); + Expected<InjectedSourceStream &> getInjectedSourceStream(); + + BumpPtrAllocator &getAllocator() { return Allocator; } + + bool hasPDBDbiStream() const; + bool hasPDBGlobalsStream(); + bool hasPDBInfoStream() const; + bool hasPDBIpiStream() const; + bool hasPDBPublicsStream(); + bool hasPDBSymbolStream(); + bool hasPDBTpiStream() const; + bool hasPDBStringTable(); + bool hasPDBInjectedSourceStream(); + + uint32_t getPointerSize(); + +private: + std::string FilePath; + BumpPtrAllocator &Allocator; + + std::unique_ptr<BinaryStream> Buffer; + + msf::MSFLayout ContainerLayout; + + std::unique_ptr<GlobalsStream> Globals; + std::unique_ptr<InfoStream> Info; + std::unique_ptr<DbiStream> Dbi; + std::unique_ptr<TpiStream> Tpi; + std::unique_ptr<TpiStream> Ipi; + std::unique_ptr<PublicsStream> Publics; + std::unique_ptr<SymbolStream> Symbols; + std::unique_ptr<msf::MappedBlockStream> DirectoryStream; + std::unique_ptr<msf::MappedBlockStream> StringTableStream; + std::unique_ptr<InjectedSourceStream> InjectedSources; + std::unique_ptr<PDBStringTable> Strings; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h index de62f49bc0..79850a3748 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h @@ -1,120 +1,120 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBFileBuilder.h - PDB File Creation ---------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/BitVector.h" -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" -#include "llvm/DebugInfo/PDB/Native/PDBFile.h" -#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include "llvm/Support/MemoryBuffer.h" - -#include <memory> -#include <vector> - -namespace llvm { -namespace msf { -class MSFBuilder; -} -namespace pdb { -class DbiStreamBuilder; -class InfoStreamBuilder; -class GSIStreamBuilder; -class TpiStreamBuilder; - -class PDBFileBuilder { -public: - explicit PDBFileBuilder(BumpPtrAllocator &Allocator); - ~PDBFileBuilder(); - PDBFileBuilder(const PDBFileBuilder &) = delete; - PDBFileBuilder &operator=(const PDBFileBuilder &) = delete; - - Error initialize(uint32_t BlockSize); - - msf::MSFBuilder &getMsfBuilder(); - InfoStreamBuilder &getInfoBuilder(); - DbiStreamBuilder &getDbiBuilder(); - TpiStreamBuilder &getTpiBuilder(); - TpiStreamBuilder &getIpiBuilder(); - PDBStringTableBuilder &getStringTableBuilder(); - GSIStreamBuilder &getGsiBuilder(); - - // If HashPDBContentsToGUID is true on the InfoStreamBuilder, Guid is filled - // with the computed PDB GUID on return. - Error commit(StringRef Filename, codeview::GUID *Guid); - - Expected<uint32_t> getNamedStreamIndex(StringRef Name) const; - Error addNamedStream(StringRef Name, StringRef Data); - void addInjectedSource(StringRef Name, std::unique_ptr<MemoryBuffer> Buffer); - -private: - struct InjectedSourceDescriptor { - // The full name of the stream that contains the contents of this injected - // source. This is built as a concatenation of the literal "/src/files" - // plus the "vname". - std::string StreamName; - - // The exact name of the file name as specified by the user. - uint32_t NameIndex; - - // The string table index of the "vname" of the file. As far as we - // understand, this is the same as the name, except it is lowercased and - // forward slashes are converted to backslashes. - uint32_t VNameIndex; - std::unique_ptr<MemoryBuffer> Content; - }; - - Error finalizeMsfLayout(); - Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size); - - void commitInjectedSources(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout); - void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer, - const msf::MSFLayout &Layout); - - BumpPtrAllocator &Allocator; - - std::unique_ptr<msf::MSFBuilder> Msf; - std::unique_ptr<InfoStreamBuilder> Info; - std::unique_ptr<DbiStreamBuilder> Dbi; - std::unique_ptr<GSIStreamBuilder> Gsi; - std::unique_ptr<TpiStreamBuilder> Tpi; - std::unique_ptr<TpiStreamBuilder> Ipi; - - PDBStringTableBuilder Strings; - StringTableHashTraits InjectedSourceHashTraits; - HashTable<SrcHeaderBlockEntry> InjectedSourceTable; - - SmallVector<InjectedSourceDescriptor, 2> InjectedSources; - - NamedStreamMap NamedStreams; - DenseMap<uint32_t, std::string> NamedStreamData; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBFileBuilder.h - PDB File Creation ---------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBFILEBUILDER_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h" +#include "llvm/DebugInfo/PDB/Native/PDBFile.h" +#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MemoryBuffer.h" + +#include <memory> +#include <vector> + +namespace llvm { +namespace msf { +class MSFBuilder; +} +namespace pdb { +class DbiStreamBuilder; +class InfoStreamBuilder; +class GSIStreamBuilder; +class TpiStreamBuilder; + +class PDBFileBuilder { +public: + explicit PDBFileBuilder(BumpPtrAllocator &Allocator); + ~PDBFileBuilder(); + PDBFileBuilder(const PDBFileBuilder &) = delete; + PDBFileBuilder &operator=(const PDBFileBuilder &) = delete; + + Error initialize(uint32_t BlockSize); + + msf::MSFBuilder &getMsfBuilder(); + InfoStreamBuilder &getInfoBuilder(); + DbiStreamBuilder &getDbiBuilder(); + TpiStreamBuilder &getTpiBuilder(); + TpiStreamBuilder &getIpiBuilder(); + PDBStringTableBuilder &getStringTableBuilder(); + GSIStreamBuilder &getGsiBuilder(); + + // If HashPDBContentsToGUID is true on the InfoStreamBuilder, Guid is filled + // with the computed PDB GUID on return. + Error commit(StringRef Filename, codeview::GUID *Guid); + + Expected<uint32_t> getNamedStreamIndex(StringRef Name) const; + Error addNamedStream(StringRef Name, StringRef Data); + void addInjectedSource(StringRef Name, std::unique_ptr<MemoryBuffer> Buffer); + +private: + struct InjectedSourceDescriptor { + // The full name of the stream that contains the contents of this injected + // source. This is built as a concatenation of the literal "/src/files" + // plus the "vname". + std::string StreamName; + + // The exact name of the file name as specified by the user. + uint32_t NameIndex; + + // The string table index of the "vname" of the file. As far as we + // understand, this is the same as the name, except it is lowercased and + // forward slashes are converted to backslashes. + uint32_t VNameIndex; + std::unique_ptr<MemoryBuffer> Content; + }; + + Error finalizeMsfLayout(); + Expected<uint32_t> allocateNamedStream(StringRef Name, uint32_t Size); + + void commitInjectedSources(WritableBinaryStream &MsfBuffer, + const msf::MSFLayout &Layout); + void commitSrcHeaderBlock(WritableBinaryStream &MsfBuffer, + const msf::MSFLayout &Layout); + + BumpPtrAllocator &Allocator; + + std::unique_ptr<msf::MSFBuilder> Msf; + std::unique_ptr<InfoStreamBuilder> Info; + std::unique_ptr<DbiStreamBuilder> Dbi; + std::unique_ptr<GSIStreamBuilder> Gsi; + std::unique_ptr<TpiStreamBuilder> Tpi; + std::unique_ptr<TpiStreamBuilder> Ipi; + + PDBStringTableBuilder Strings; + StringTableHashTraits InjectedSourceHashTraits; + HashTable<SrcHeaderBlockEntry> InjectedSourceTable; + + SmallVector<InjectedSourceDescriptor, 2> InjectedSources; + + NamedStreamMap NamedStreams; + DenseMap<uint32_t, std::string> NamedStreamData; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h index 2f5d251149..344e45116f 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h @@ -1,75 +1,75 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBStringTable.h - PDB String Table -----------------------*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstdint> -#include <vector> - -namespace llvm { -class BinaryStreamReader; - -namespace msf { -class MappedBlockStream; -} - -namespace pdb { - -struct PDBStringTableHeader; - -class PDBStringTable { -public: - Error reload(BinaryStreamReader &Reader); - - uint32_t getByteSize() const; - uint32_t getNameCount() const; - uint32_t getHashVersion() const; - uint32_t getSignature() const; - - Expected<StringRef> getStringForID(uint32_t ID) const; - Expected<uint32_t> getIDForString(StringRef Str) const; - - FixedStreamArray<support::ulittle32_t> name_ids() const; - - const codeview::DebugStringTableSubsectionRef &getStringTable() const; - -private: - Error readHeader(BinaryStreamReader &Reader); - Error readStrings(BinaryStreamReader &Reader); - Error readHashTable(BinaryStreamReader &Reader); - Error readEpilogue(BinaryStreamReader &Reader); - - const PDBStringTableHeader *Header = nullptr; - codeview::DebugStringTableSubsectionRef Strings; - FixedStreamArray<support::ulittle32_t> IDs; - uint32_t NameCount = 0; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBStringTable.h - PDB String Table -----------------------*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLE_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> + +namespace llvm { +class BinaryStreamReader; + +namespace msf { +class MappedBlockStream; +} + +namespace pdb { + +struct PDBStringTableHeader; + +class PDBStringTable { +public: + Error reload(BinaryStreamReader &Reader); + + uint32_t getByteSize() const; + uint32_t getNameCount() const; + uint32_t getHashVersion() const; + uint32_t getSignature() const; + + Expected<StringRef> getStringForID(uint32_t ID) const; + Expected<uint32_t> getIDForString(StringRef Str) const; + + FixedStreamArray<support::ulittle32_t> name_ids() const; + + const codeview::DebugStringTableSubsectionRef &getStringTable() const; + +private: + Error readHeader(BinaryStreamReader &Reader); + Error readStrings(BinaryStreamReader &Reader); + Error readHashTable(BinaryStreamReader &Reader); + Error readEpilogue(BinaryStreamReader &Reader); + + const PDBStringTableHeader *Header = nullptr; + codeview::DebugStringTableSubsectionRef Strings; + FixedStreamArray<support::ulittle32_t> IDs; + uint32_t NameCount = 0; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_STRINGTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h index d7793aef6d..8f6764f429 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h @@ -1,82 +1,82 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBStringTableBuilder.h - PDB String Table Builder -------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file creates the "/names" stream. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" -#include "llvm/Support/Error.h" -#include <vector> - -namespace llvm { -class BinaryStreamWriter; -class WritableBinaryStreamRef; - -namespace msf { -struct MSFLayout; -} - -namespace pdb { - -class PDBFileBuilder; -class PDBStringTableBuilder; - -struct StringTableHashTraits { - PDBStringTableBuilder *Table; - - explicit StringTableHashTraits(PDBStringTableBuilder &Table); - uint32_t hashLookupKey(StringRef S) const; - StringRef storageKeyToLookupKey(uint32_t Offset) const; - uint32_t lookupKeyToStorageKey(StringRef S); -}; - -class PDBStringTableBuilder { -public: - // If string S does not exist in the string table, insert it. - // Returns the ID for S. - uint32_t insert(StringRef S); - - uint32_t getIdForString(StringRef S) const; - StringRef getStringForId(uint32_t Id) const; - - uint32_t calculateSerializedSize() const; - Error commit(BinaryStreamWriter &Writer) const; - - void setStrings(const codeview::DebugStringTableSubsection &Strings); - -private: - uint32_t calculateHashTableSize() const; - Error writeHeader(BinaryStreamWriter &Writer) const; - Error writeStrings(BinaryStreamWriter &Writer) const; - Error writeHashTable(BinaryStreamWriter &Writer) const; - Error writeEpilogue(BinaryStreamWriter &Writer) const; - - codeview::DebugStringTableSubsection Strings; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBStringTableBuilder.h - PDB String Table Builder -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file creates the "/names" stream. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" +#include "llvm/Support/Error.h" +#include <vector> + +namespace llvm { +class BinaryStreamWriter; +class WritableBinaryStreamRef; + +namespace msf { +struct MSFLayout; +} + +namespace pdb { + +class PDBFileBuilder; +class PDBStringTableBuilder; + +struct StringTableHashTraits { + PDBStringTableBuilder *Table; + + explicit StringTableHashTraits(PDBStringTableBuilder &Table); + uint32_t hashLookupKey(StringRef S) const; + StringRef storageKeyToLookupKey(uint32_t Offset) const; + uint32_t lookupKeyToStorageKey(StringRef S); +}; + +class PDBStringTableBuilder { +public: + // If string S does not exist in the string table, insert it. + // Returns the ID for S. + uint32_t insert(StringRef S); + + uint32_t getIdForString(StringRef S) const; + StringRef getStringForId(uint32_t Id) const; + + uint32_t calculateSerializedSize() const; + Error commit(BinaryStreamWriter &Writer) const; + + void setStrings(const codeview::DebugStringTableSubsection &Strings); + +private: + uint32_t calculateHashTableSize() const; + Error writeHeader(BinaryStreamWriter &Writer) const; + Error writeStrings(BinaryStreamWriter &Writer) const; + Error writeHashTable(BinaryStreamWriter &Writer) const; + Error writeEpilogue(BinaryStreamWriter &Writer) const; + + codeview::DebugStringTableSubsection Strings; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_PDBSTRINGTABLEBUILDER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PublicsStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PublicsStream.h index 8f6a844568..4f498ee25a 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PublicsStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/PublicsStream.h @@ -1,70 +1,70 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PublicsStream.h - PDB Public Symbol Stream -------- ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H - -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/MSF/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { -class DbiStream; -struct GSIHashHeader; -class PDBFile; - -class PublicsStream { -public: - PublicsStream(std::unique_ptr<msf::MappedBlockStream> Stream); - ~PublicsStream(); - Error reload(); - - uint32_t getSymHash() const; - uint16_t getThunkTableSection() const; - uint32_t getThunkTableOffset() const; - const GSIHashTable &getPublicsTable() const { return PublicsTable; } - FixedStreamArray<support::ulittle32_t> getAddressMap() const { - return AddressMap; - } - FixedStreamArray<support::ulittle32_t> getThunkMap() const { - return ThunkMap; - } - FixedStreamArray<SectionOffset> getSectionOffsets() const { - return SectionOffsets; - } - -private: - std::unique_ptr<msf::MappedBlockStream> Stream; - GSIHashTable PublicsTable; - FixedStreamArray<support::ulittle32_t> AddressMap; - FixedStreamArray<support::ulittle32_t> ThunkMap; - FixedStreamArray<SectionOffset> SectionOffsets; - - const PublicsStreamHeader *Header; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PublicsStream.h - PDB Public Symbol Stream -------- ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/MSF/MappedBlockStream.h" +#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { +class DbiStream; +struct GSIHashHeader; +class PDBFile; + +class PublicsStream { +public: + PublicsStream(std::unique_ptr<msf::MappedBlockStream> Stream); + ~PublicsStream(); + Error reload(); + + uint32_t getSymHash() const; + uint16_t getThunkTableSection() const; + uint32_t getThunkTableOffset() const; + const GSIHashTable &getPublicsTable() const { return PublicsTable; } + FixedStreamArray<support::ulittle32_t> getAddressMap() const { + return AddressMap; + } + FixedStreamArray<support::ulittle32_t> getThunkMap() const { + return ThunkMap; + } + FixedStreamArray<SectionOffset> getSectionOffsets() const { + return SectionOffsets; + } + +private: + std::unique_ptr<msf::MappedBlockStream> Stream; + GSIHashTable PublicsTable; + FixedStreamArray<support::ulittle32_t> AddressMap; + FixedStreamArray<support::ulittle32_t> ThunkMap; + FixedStreamArray<SectionOffset> SectionOffsets; + + const PublicsStreamHeader *Header; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawConstants.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawConstants.h index bbb8190581..68d3a59bf5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawConstants.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawConstants.h @@ -1,129 +1,129 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- RawConstants.h -------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H - -#include "llvm/ADT/BitmaskEnum.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include <cstdint> - -namespace llvm { -namespace pdb { - -const uint16_t kInvalidStreamIndex = 0xFFFF; - -enum PdbRaw_ImplVer : uint32_t { - PdbImplVC2 = 19941610, - PdbImplVC4 = 19950623, - PdbImplVC41 = 19950814, - PdbImplVC50 = 19960307, - PdbImplVC98 = 19970604, - PdbImplVC70Dep = 19990604, // deprecated - PdbImplVC70 = 20000404, - PdbImplVC80 = 20030901, - PdbImplVC110 = 20091201, - PdbImplVC140 = 20140508, -}; - -enum class PdbRaw_SrcHeaderBlockVer : uint32_t { SrcVerOne = 19980827 }; - -enum class PdbRaw_FeatureSig : uint32_t { - VC110 = PdbImplVC110, - VC140 = PdbImplVC140, - NoTypeMerge = 0x4D544F4E, - MinimalDebugInfo = 0x494E494D, -}; - -enum PdbRaw_Features : uint32_t { - PdbFeatureNone = 0x0, - PdbFeatureContainsIdStream = 0x1, - PdbFeatureMinimalDebugInfo = 0x2, - PdbFeatureNoTypeMerging = 0x4, - LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ PdbFeatureNoTypeMerging) -}; - -enum PdbRaw_DbiVer : uint32_t { - PdbDbiVC41 = 930803, - PdbDbiV50 = 19960307, - PdbDbiV60 = 19970606, - PdbDbiV70 = 19990903, - PdbDbiV110 = 20091201 -}; - -enum PdbRaw_TpiVer : uint32_t { - PdbTpiV40 = 19950410, - PdbTpiV41 = 19951122, - PdbTpiV50 = 19961031, - PdbTpiV70 = 19990903, - PdbTpiV80 = 20040203, -}; - -enum PdbRaw_DbiSecContribVer : uint32_t { - DbiSecContribVer60 = 0xeffe0000 + 19970605, - DbiSecContribV2 = 0xeffe0000 + 20140516 -}; - -enum SpecialStream : uint32_t { - // Stream 0 contains the copy of previous version of the MSF directory. - // We are not currently using it, but technically if we find the main - // MSF is corrupted, we could fallback to it. - OldMSFDirectory = 0, - - StreamPDB = 1, - StreamTPI = 2, - StreamDBI = 3, - StreamIPI = 4, - - kSpecialStreamCount -}; - -enum class DbgHeaderType : uint16_t { - FPO, - Exception, - Fixup, - OmapToSrc, - OmapFromSrc, - SectionHdr, - TokenRidMap, - Xdata, - Pdata, - NewFPO, - SectionHdrOrig, - Max -}; - -enum class OMFSegDescFlags : uint16_t { - None = 0, - Read = 1 << 0, // Segment is readable. - Write = 1 << 1, // Segment is writable. - Execute = 1 << 2, // Segment is executable. - AddressIs32Bit = 1 << 3, // Descriptor describes a 32-bit linear address. - IsSelector = 1 << 8, // Frame represents a selector. - IsAbsoluteAddress = 1 << 9, // Frame represents an absolute address. - IsGroup = 1 << 10, // If set, descriptor represents a group. - LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IsGroup) -}; - -LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- RawConstants.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H + +#include "llvm/ADT/BitmaskEnum.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include <cstdint> + +namespace llvm { +namespace pdb { + +const uint16_t kInvalidStreamIndex = 0xFFFF; + +enum PdbRaw_ImplVer : uint32_t { + PdbImplVC2 = 19941610, + PdbImplVC4 = 19950623, + PdbImplVC41 = 19950814, + PdbImplVC50 = 19960307, + PdbImplVC98 = 19970604, + PdbImplVC70Dep = 19990604, // deprecated + PdbImplVC70 = 20000404, + PdbImplVC80 = 20030901, + PdbImplVC110 = 20091201, + PdbImplVC140 = 20140508, +}; + +enum class PdbRaw_SrcHeaderBlockVer : uint32_t { SrcVerOne = 19980827 }; + +enum class PdbRaw_FeatureSig : uint32_t { + VC110 = PdbImplVC110, + VC140 = PdbImplVC140, + NoTypeMerge = 0x4D544F4E, + MinimalDebugInfo = 0x494E494D, +}; + +enum PdbRaw_Features : uint32_t { + PdbFeatureNone = 0x0, + PdbFeatureContainsIdStream = 0x1, + PdbFeatureMinimalDebugInfo = 0x2, + PdbFeatureNoTypeMerging = 0x4, + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ PdbFeatureNoTypeMerging) +}; + +enum PdbRaw_DbiVer : uint32_t { + PdbDbiVC41 = 930803, + PdbDbiV50 = 19960307, + PdbDbiV60 = 19970606, + PdbDbiV70 = 19990903, + PdbDbiV110 = 20091201 +}; + +enum PdbRaw_TpiVer : uint32_t { + PdbTpiV40 = 19950410, + PdbTpiV41 = 19951122, + PdbTpiV50 = 19961031, + PdbTpiV70 = 19990903, + PdbTpiV80 = 20040203, +}; + +enum PdbRaw_DbiSecContribVer : uint32_t { + DbiSecContribVer60 = 0xeffe0000 + 19970605, + DbiSecContribV2 = 0xeffe0000 + 20140516 +}; + +enum SpecialStream : uint32_t { + // Stream 0 contains the copy of previous version of the MSF directory. + // We are not currently using it, but technically if we find the main + // MSF is corrupted, we could fallback to it. + OldMSFDirectory = 0, + + StreamPDB = 1, + StreamTPI = 2, + StreamDBI = 3, + StreamIPI = 4, + + kSpecialStreamCount +}; + +enum class DbgHeaderType : uint16_t { + FPO, + Exception, + Fixup, + OmapToSrc, + OmapFromSrc, + SectionHdr, + TokenRidMap, + Xdata, + Pdata, + NewFPO, + SectionHdrOrig, + Max +}; + +enum class OMFSegDescFlags : uint16_t { + None = 0, + Read = 1 << 0, // Segment is readable. + Write = 1 << 1, // Segment is writable. + Execute = 1 << 2, // Segment is executable. + AddressIs32Bit = 1 << 3, // Descriptor describes a 32-bit linear address. + IsSelector = 1 << 8, // Frame represents a selector. + IsAbsoluteAddress = 1 << 9, // Frame represents an absolute address. + IsGroup = 1 << 10, // If set, descriptor represents a group. + LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IsGroup) +}; + +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_RAW_PDBRAWCONSTANTS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawError.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawError.h index 3036da6d80..a052b691d2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawError.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawError.h @@ -1,69 +1,69 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- RawError.h - Error extensions for raw PDB implementation -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWERROR_H -#define LLVM_DEBUGINFO_PDB_RAW_RAWERROR_H - -#include "llvm/Support/Error.h" - -#include <string> - -namespace llvm { -namespace pdb { -enum class raw_error_code { - unspecified = 1, - feature_unsupported, - invalid_format, - corrupt_file, - insufficient_buffer, - no_stream, - index_out_of_bounds, - invalid_block_address, - duplicate_entry, - no_entry, - not_writable, - stream_too_long, - invalid_tpi_hash, -}; -} // namespace pdb -} // namespace llvm - -namespace std { -template <> -struct is_error_code_enum<llvm::pdb::raw_error_code> : std::true_type {}; -} // namespace std - -namespace llvm { -namespace pdb { -const std::error_category &RawErrCategory(); - -inline std::error_code make_error_code(raw_error_code E) { - return std::error_code(static_cast<int>(E), RawErrCategory()); -} - -/// Base class for errors originating when parsing raw PDB files -class RawError : public ErrorInfo<RawError, StringError> { -public: - using ErrorInfo<RawError, StringError>::ErrorInfo; // inherit constructors - RawError(const Twine &S) : ErrorInfo(S, raw_error_code::unspecified) {} - static char ID; -}; -} // namespace pdb -} // namespace llvm -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- RawError.h - Error extensions for raw PDB implementation -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWERROR_H +#define LLVM_DEBUGINFO_PDB_RAW_RAWERROR_H + +#include "llvm/Support/Error.h" + +#include <string> + +namespace llvm { +namespace pdb { +enum class raw_error_code { + unspecified = 1, + feature_unsupported, + invalid_format, + corrupt_file, + insufficient_buffer, + no_stream, + index_out_of_bounds, + invalid_block_address, + duplicate_entry, + no_entry, + not_writable, + stream_too_long, + invalid_tpi_hash, +}; +} // namespace pdb +} // namespace llvm + +namespace std { +template <> +struct is_error_code_enum<llvm::pdb::raw_error_code> : std::true_type {}; +} // namespace std + +namespace llvm { +namespace pdb { +const std::error_category &RawErrCategory(); + +inline std::error_code make_error_code(raw_error_code E) { + return std::error_code(static_cast<int>(E), RawErrCategory()); +} + +/// Base class for errors originating when parsing raw PDB files +class RawError : public ErrorInfo<RawError, StringError> { +public: + using ErrorInfo<RawError, StringError>::ErrorInfo; // inherit constructors + RawError(const Twine &S) : ErrorInfo(S, raw_error_code::unspecified) {} + static char ID; +}; +} // namespace pdb +} // namespace llvm +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawTypes.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawTypes.h index 133f5a12ef..b6480295e5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawTypes.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/RawTypes.h @@ -1,360 +1,360 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- RawTypes.h -----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H -#define LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H - -#include "llvm/DebugInfo/CodeView/GUID.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/Support/Endian.h" - -namespace llvm { -namespace pdb { -// This struct is defined as "SO" in langapi/include/pdb.h. -struct SectionOffset { - support::ulittle32_t Off; - support::ulittle16_t Isect; - char Padding[2]; -}; - -/// Header of the hash tables found in the globals and publics sections. -/// Based on GSIHashHdr in -/// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h -struct GSIHashHeader { - enum : unsigned { - HdrSignature = ~0U, - HdrVersion = 0xeffe0000 + 19990810, - }; - support::ulittle32_t VerSignature; - support::ulittle32_t VerHdr; - support::ulittle32_t HrSize; - support::ulittle32_t NumBuckets; -}; - -// This is HRFile. -struct PSHashRecord { - support::ulittle32_t Off; // Offset in the symbol record stream - support::ulittle32_t CRef; -}; - -// This struct is defined as `SC` in include/dbicommon.h -struct SectionContrib { - support::ulittle16_t ISect; - char Padding[2]; - support::little32_t Off; - support::little32_t Size; - support::ulittle32_t Characteristics; - support::ulittle16_t Imod; - char Padding2[2]; - support::ulittle32_t DataCrc; - support::ulittle32_t RelocCrc; -}; - -// This struct is defined as `SC2` in include/dbicommon.h -struct SectionContrib2 { - // To guarantee SectionContrib2 is standard layout, we cannot use inheritance. - SectionContrib Base; - support::ulittle32_t ISectCoff; -}; - -// This corresponds to the `OMFSegMap` structure. -struct SecMapHeader { - support::ulittle16_t SecCount; // Number of segment descriptors in table - support::ulittle16_t SecCountLog; // Number of logical segment descriptors -}; - -// This corresponds to the `OMFSegMapDesc` structure. The definition is not -// present in the reference implementation, but the layout is derived from -// code that accesses the fields. -struct SecMapEntry { - support::ulittle16_t Flags; // Descriptor flags. See OMFSegDescFlags - support::ulittle16_t Ovl; // Logical overlay number. - support::ulittle16_t Group; // Group index into descriptor array. - support::ulittle16_t Frame; - support::ulittle16_t SecName; // Byte index of the segment or group name - // in the sstSegName table, or 0xFFFF. - support::ulittle16_t ClassName; // Byte index of the class name in the - // sstSegName table, or 0xFFFF. - support::ulittle32_t Offset; // Byte offset of the logical segment - // within the specified physical segment. - // If group is set in flags, offset is the - // offset of the group. - support::ulittle32_t SecByteLength; // Byte count of the segment or group. -}; - -/// Some of the values are stored in bitfields. Since this needs to be portable -/// across compilers and architectures (big / little endian in particular) we -/// can't use the actual structures below, but must instead do the shifting -/// and masking ourselves. The struct definitions are provided for reference. -struct DbiFlags { - /// uint16_t IncrementalLinking : 1; // True if linked incrementally - /// uint16_t IsStripped : 1; // True if private symbols were - /// stripped. - /// uint16_t HasCTypes : 1; // True if linked with /debug:ctypes. - /// uint16_t Reserved : 13; - static const uint16_t FlagIncrementalMask = 0x0001; - static const uint16_t FlagStrippedMask = 0x0002; - static const uint16_t FlagHasCTypesMask = 0x0004; -}; - -struct DbiBuildNo { - /// uint16_t MinorVersion : 8; - /// uint16_t MajorVersion : 7; - /// uint16_t NewVersionFormat : 1; - static const uint16_t BuildMinorMask = 0x00FF; - static const uint16_t BuildMinorShift = 0; - - static const uint16_t BuildMajorMask = 0x7F00; - static const uint16_t BuildMajorShift = 8; - - static const uint16_t NewVersionFormatMask = 0x8000; -}; - -/// The fixed size header that appears at the beginning of the DBI Stream. -struct DbiStreamHeader { - support::little32_t VersionSignature; - support::ulittle32_t VersionHeader; - - /// How "old" is this DBI Stream. Should match the age of the PDB InfoStream. - support::ulittle32_t Age; - - /// Global symbol stream # - support::ulittle16_t GlobalSymbolStreamIndex; - - /// See DbiBuildNo structure. - support::ulittle16_t BuildNumber; - - /// Public symbols stream # - support::ulittle16_t PublicSymbolStreamIndex; - - /// version of mspdbNNN.dll - support::ulittle16_t PdbDllVersion; - - /// Symbol records stream # - support::ulittle16_t SymRecordStreamIndex; - - /// rbld number of mspdbNNN.dll - support::ulittle16_t PdbDllRbld; - - /// Size of module info stream - support::little32_t ModiSubstreamSize; - - /// Size of sec. contrib stream - support::little32_t SecContrSubstreamSize; - - /// Size of sec. map substream - support::little32_t SectionMapSize; - - /// Size of file info substream - support::little32_t FileInfoSize; - - /// Size of type server map - support::little32_t TypeServerSize; - - /// Index of MFC Type Server - support::ulittle32_t MFCTypeServerIndex; - - /// Size of DbgHeader info - support::little32_t OptionalDbgHdrSize; - - /// Size of EC stream (what is EC?) - support::little32_t ECSubstreamSize; - - /// See DbiFlags enum. - support::ulittle16_t Flags; - - /// See PDB_MachineType enum. - support::ulittle16_t MachineType; - - /// Pad to 64 bytes - support::ulittle32_t Reserved; -}; -static_assert(sizeof(DbiStreamHeader) == 64, "Invalid DbiStreamHeader size!"); - -/// The header preceding the File Info Substream of the DBI stream. -struct FileInfoSubstreamHeader { - /// Total # of modules, should match number of records in the ModuleInfo - /// substream. - support::ulittle16_t NumModules; - - /// Total # of source files. This value is not accurate because PDB actually - /// supports more than 64k source files, so we ignore it and compute the value - /// from other stream fields. - support::ulittle16_t NumSourceFiles; - - /// Following this header the File Info Substream is laid out as follows: - /// ulittle16_t ModIndices[NumModules]; - /// ulittle16_t ModFileCounts[NumModules]; - /// ulittle32_t FileNameOffsets[NumSourceFiles]; - /// char Names[][NumSourceFiles]; - /// with the caveat that `NumSourceFiles` cannot be trusted, so - /// it is computed by summing the `ModFileCounts` array. -}; - -struct ModInfoFlags { - /// uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty - /// uint16_t fECEnabled : 1; // Is EC symbolic info present? (What is EC?) - /// uint16_t unused : 6; // Reserved - /// uint16_t iTSM : 8; // Type Server Index for this module - static const uint16_t HasECFlagMask = 0x2; - - static const uint16_t TypeServerIndexMask = 0xFF00; - static const uint16_t TypeServerIndexShift = 8; -}; - -/// The header preceding each entry in the Module Info substream of the DBI -/// stream. Corresponds to the type MODI in the reference implementation. -struct ModuleInfoHeader { - /// Currently opened module. This field is a pointer in the reference - /// implementation, but that won't work on 64-bit systems, and anyway it - /// doesn't make sense to read a pointer from a file. For now it is unused, - /// so just ignore it. - support::ulittle32_t Mod; - - /// First section contribution of this module. - SectionContrib SC; - - /// See ModInfoFlags definition. - support::ulittle16_t Flags; - - /// Stream Number of module debug info - support::ulittle16_t ModDiStream; - - /// Size of local symbol debug info in above stream - support::ulittle32_t SymBytes; - - /// Size of C11 line number info in above stream - support::ulittle32_t C11Bytes; - - /// Size of C13 line number info in above stream - support::ulittle32_t C13Bytes; - - /// Number of files contributing to this module - support::ulittle16_t NumFiles; - - /// Padding so the next field is 4-byte aligned. - char Padding1[2]; - - /// Array of [0..NumFiles) DBI name buffer offsets. In the reference - /// implementation this field is a pointer. But since you can't portably - /// serialize a pointer, on 64-bit platforms they copy all the values except - /// this one into the 32-bit version of the struct and use that for - /// serialization. Regardless, this field is unused, it is only there to - /// store a pointer that can be accessed at runtime. - support::ulittle32_t FileNameOffs; - - /// Name Index for src file name - support::ulittle32_t SrcFileNameNI; - - /// Name Index for path to compiler PDB - support::ulittle32_t PdbFilePathNI; - - /// Following this header are two zero terminated strings. - /// char ModuleName[]; - /// char ObjFileName[]; -}; - -// This is PSGSIHDR struct defined in -// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h -struct PublicsStreamHeader { - support::ulittle32_t SymHash; - support::ulittle32_t AddrMap; - support::ulittle32_t NumThunks; - support::ulittle32_t SizeOfThunk; - support::ulittle16_t ISectThunkTable; - char Padding[2]; - support::ulittle32_t OffThunkTable; - support::ulittle32_t NumSections; -}; - -// The header preceding the global TPI stream. -// This corresponds to `HDR` in PDB/dbi/tpi.h. -struct TpiStreamHeader { - struct EmbeddedBuf { - support::little32_t Off; - support::ulittle32_t Length; - }; - - support::ulittle32_t Version; - support::ulittle32_t HeaderSize; - support::ulittle32_t TypeIndexBegin; - support::ulittle32_t TypeIndexEnd; - support::ulittle32_t TypeRecordBytes; - - // The following members correspond to `TpiHash` in PDB/dbi/tpi.h. - support::ulittle16_t HashStreamIndex; - support::ulittle16_t HashAuxStreamIndex; - support::ulittle32_t HashKeySize; - support::ulittle32_t NumHashBuckets; - - EmbeddedBuf HashValueBuffer; - EmbeddedBuf IndexOffsetBuffer; - EmbeddedBuf HashAdjBuffer; -}; - -const uint32_t MinTpiHashBuckets = 0x1000; -const uint32_t MaxTpiHashBuckets = 0x40000; - -/// The header preceding the global PDB Stream (Stream 1) -struct InfoStreamHeader { - support::ulittle32_t Version; - support::ulittle32_t Signature; - support::ulittle32_t Age; - codeview::GUID Guid; -}; - -/// The header preceding the /names stream. -struct PDBStringTableHeader { - support::ulittle32_t Signature; // PDBStringTableSignature - support::ulittle32_t HashVersion; // 1 or 2 - support::ulittle32_t ByteSize; // Number of bytes of names buffer. -}; - -const uint32_t PDBStringTableSignature = 0xEFFEEFFE; - -/// The header preceding the /src/headerblock stream. -struct SrcHeaderBlockHeader { - support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. - support::ulittle32_t Size; // Size of entire stream. - uint64_t FileTime; // Time stamp (Windows FILETIME format). - support::ulittle32_t Age; // Age - uint8_t Padding[44]; // Pad to 64 bytes. -}; -static_assert(sizeof(SrcHeaderBlockHeader) == 64, "Incorrect struct size!"); - -/// A single file record entry within the /src/headerblock stream. -struct SrcHeaderBlockEntry { - support::ulittle32_t Size; // Record Length. - support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. - support::ulittle32_t CRC; // CRC of the original file contents. - support::ulittle32_t FileSize; // Size of original source file. - support::ulittle32_t FileNI; // String table index of file name. - support::ulittle32_t ObjNI; // String table index of object name. - support::ulittle32_t VFileNI; // String table index of virtual file name. - uint8_t Compression; // PDB_SourceCompression enumeration. - uint8_t IsVirtual; // Is this a virtual file (injected)? - short Padding; // Pad to 4 bytes. - char Reserved[8]; -}; -static_assert(sizeof(SrcHeaderBlockEntry) == 40, "Incorrect struct size!"); - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- RawTypes.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H +#define LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H + +#include "llvm/DebugInfo/CodeView/GUID.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/Support/Endian.h" + +namespace llvm { +namespace pdb { +// This struct is defined as "SO" in langapi/include/pdb.h. +struct SectionOffset { + support::ulittle32_t Off; + support::ulittle16_t Isect; + char Padding[2]; +}; + +/// Header of the hash tables found in the globals and publics sections. +/// Based on GSIHashHdr in +/// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h +struct GSIHashHeader { + enum : unsigned { + HdrSignature = ~0U, + HdrVersion = 0xeffe0000 + 19990810, + }; + support::ulittle32_t VerSignature; + support::ulittle32_t VerHdr; + support::ulittle32_t HrSize; + support::ulittle32_t NumBuckets; +}; + +// This is HRFile. +struct PSHashRecord { + support::ulittle32_t Off; // Offset in the symbol record stream + support::ulittle32_t CRef; +}; + +// This struct is defined as `SC` in include/dbicommon.h +struct SectionContrib { + support::ulittle16_t ISect; + char Padding[2]; + support::little32_t Off; + support::little32_t Size; + support::ulittle32_t Characteristics; + support::ulittle16_t Imod; + char Padding2[2]; + support::ulittle32_t DataCrc; + support::ulittle32_t RelocCrc; +}; + +// This struct is defined as `SC2` in include/dbicommon.h +struct SectionContrib2 { + // To guarantee SectionContrib2 is standard layout, we cannot use inheritance. + SectionContrib Base; + support::ulittle32_t ISectCoff; +}; + +// This corresponds to the `OMFSegMap` structure. +struct SecMapHeader { + support::ulittle16_t SecCount; // Number of segment descriptors in table + support::ulittle16_t SecCountLog; // Number of logical segment descriptors +}; + +// This corresponds to the `OMFSegMapDesc` structure. The definition is not +// present in the reference implementation, but the layout is derived from +// code that accesses the fields. +struct SecMapEntry { + support::ulittle16_t Flags; // Descriptor flags. See OMFSegDescFlags + support::ulittle16_t Ovl; // Logical overlay number. + support::ulittle16_t Group; // Group index into descriptor array. + support::ulittle16_t Frame; + support::ulittle16_t SecName; // Byte index of the segment or group name + // in the sstSegName table, or 0xFFFF. + support::ulittle16_t ClassName; // Byte index of the class name in the + // sstSegName table, or 0xFFFF. + support::ulittle32_t Offset; // Byte offset of the logical segment + // within the specified physical segment. + // If group is set in flags, offset is the + // offset of the group. + support::ulittle32_t SecByteLength; // Byte count of the segment or group. +}; + +/// Some of the values are stored in bitfields. Since this needs to be portable +/// across compilers and architectures (big / little endian in particular) we +/// can't use the actual structures below, but must instead do the shifting +/// and masking ourselves. The struct definitions are provided for reference. +struct DbiFlags { + /// uint16_t IncrementalLinking : 1; // True if linked incrementally + /// uint16_t IsStripped : 1; // True if private symbols were + /// stripped. + /// uint16_t HasCTypes : 1; // True if linked with /debug:ctypes. + /// uint16_t Reserved : 13; + static const uint16_t FlagIncrementalMask = 0x0001; + static const uint16_t FlagStrippedMask = 0x0002; + static const uint16_t FlagHasCTypesMask = 0x0004; +}; + +struct DbiBuildNo { + /// uint16_t MinorVersion : 8; + /// uint16_t MajorVersion : 7; + /// uint16_t NewVersionFormat : 1; + static const uint16_t BuildMinorMask = 0x00FF; + static const uint16_t BuildMinorShift = 0; + + static const uint16_t BuildMajorMask = 0x7F00; + static const uint16_t BuildMajorShift = 8; + + static const uint16_t NewVersionFormatMask = 0x8000; +}; + +/// The fixed size header that appears at the beginning of the DBI Stream. +struct DbiStreamHeader { + support::little32_t VersionSignature; + support::ulittle32_t VersionHeader; + + /// How "old" is this DBI Stream. Should match the age of the PDB InfoStream. + support::ulittle32_t Age; + + /// Global symbol stream # + support::ulittle16_t GlobalSymbolStreamIndex; + + /// See DbiBuildNo structure. + support::ulittle16_t BuildNumber; + + /// Public symbols stream # + support::ulittle16_t PublicSymbolStreamIndex; + + /// version of mspdbNNN.dll + support::ulittle16_t PdbDllVersion; + + /// Symbol records stream # + support::ulittle16_t SymRecordStreamIndex; + + /// rbld number of mspdbNNN.dll + support::ulittle16_t PdbDllRbld; + + /// Size of module info stream + support::little32_t ModiSubstreamSize; + + /// Size of sec. contrib stream + support::little32_t SecContrSubstreamSize; + + /// Size of sec. map substream + support::little32_t SectionMapSize; + + /// Size of file info substream + support::little32_t FileInfoSize; + + /// Size of type server map + support::little32_t TypeServerSize; + + /// Index of MFC Type Server + support::ulittle32_t MFCTypeServerIndex; + + /// Size of DbgHeader info + support::little32_t OptionalDbgHdrSize; + + /// Size of EC stream (what is EC?) + support::little32_t ECSubstreamSize; + + /// See DbiFlags enum. + support::ulittle16_t Flags; + + /// See PDB_MachineType enum. + support::ulittle16_t MachineType; + + /// Pad to 64 bytes + support::ulittle32_t Reserved; +}; +static_assert(sizeof(DbiStreamHeader) == 64, "Invalid DbiStreamHeader size!"); + +/// The header preceding the File Info Substream of the DBI stream. +struct FileInfoSubstreamHeader { + /// Total # of modules, should match number of records in the ModuleInfo + /// substream. + support::ulittle16_t NumModules; + + /// Total # of source files. This value is not accurate because PDB actually + /// supports more than 64k source files, so we ignore it and compute the value + /// from other stream fields. + support::ulittle16_t NumSourceFiles; + + /// Following this header the File Info Substream is laid out as follows: + /// ulittle16_t ModIndices[NumModules]; + /// ulittle16_t ModFileCounts[NumModules]; + /// ulittle32_t FileNameOffsets[NumSourceFiles]; + /// char Names[][NumSourceFiles]; + /// with the caveat that `NumSourceFiles` cannot be trusted, so + /// it is computed by summing the `ModFileCounts` array. +}; + +struct ModInfoFlags { + /// uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty + /// uint16_t fECEnabled : 1; // Is EC symbolic info present? (What is EC?) + /// uint16_t unused : 6; // Reserved + /// uint16_t iTSM : 8; // Type Server Index for this module + static const uint16_t HasECFlagMask = 0x2; + + static const uint16_t TypeServerIndexMask = 0xFF00; + static const uint16_t TypeServerIndexShift = 8; +}; + +/// The header preceding each entry in the Module Info substream of the DBI +/// stream. Corresponds to the type MODI in the reference implementation. +struct ModuleInfoHeader { + /// Currently opened module. This field is a pointer in the reference + /// implementation, but that won't work on 64-bit systems, and anyway it + /// doesn't make sense to read a pointer from a file. For now it is unused, + /// so just ignore it. + support::ulittle32_t Mod; + + /// First section contribution of this module. + SectionContrib SC; + + /// See ModInfoFlags definition. + support::ulittle16_t Flags; + + /// Stream Number of module debug info + support::ulittle16_t ModDiStream; + + /// Size of local symbol debug info in above stream + support::ulittle32_t SymBytes; + + /// Size of C11 line number info in above stream + support::ulittle32_t C11Bytes; + + /// Size of C13 line number info in above stream + support::ulittle32_t C13Bytes; + + /// Number of files contributing to this module + support::ulittle16_t NumFiles; + + /// Padding so the next field is 4-byte aligned. + char Padding1[2]; + + /// Array of [0..NumFiles) DBI name buffer offsets. In the reference + /// implementation this field is a pointer. But since you can't portably + /// serialize a pointer, on 64-bit platforms they copy all the values except + /// this one into the 32-bit version of the struct and use that for + /// serialization. Regardless, this field is unused, it is only there to + /// store a pointer that can be accessed at runtime. + support::ulittle32_t FileNameOffs; + + /// Name Index for src file name + support::ulittle32_t SrcFileNameNI; + + /// Name Index for path to compiler PDB + support::ulittle32_t PdbFilePathNI; + + /// Following this header are two zero terminated strings. + /// char ModuleName[]; + /// char ObjFileName[]; +}; + +// This is PSGSIHDR struct defined in +// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h +struct PublicsStreamHeader { + support::ulittle32_t SymHash; + support::ulittle32_t AddrMap; + support::ulittle32_t NumThunks; + support::ulittle32_t SizeOfThunk; + support::ulittle16_t ISectThunkTable; + char Padding[2]; + support::ulittle32_t OffThunkTable; + support::ulittle32_t NumSections; +}; + +// The header preceding the global TPI stream. +// This corresponds to `HDR` in PDB/dbi/tpi.h. +struct TpiStreamHeader { + struct EmbeddedBuf { + support::little32_t Off; + support::ulittle32_t Length; + }; + + support::ulittle32_t Version; + support::ulittle32_t HeaderSize; + support::ulittle32_t TypeIndexBegin; + support::ulittle32_t TypeIndexEnd; + support::ulittle32_t TypeRecordBytes; + + // The following members correspond to `TpiHash` in PDB/dbi/tpi.h. + support::ulittle16_t HashStreamIndex; + support::ulittle16_t HashAuxStreamIndex; + support::ulittle32_t HashKeySize; + support::ulittle32_t NumHashBuckets; + + EmbeddedBuf HashValueBuffer; + EmbeddedBuf IndexOffsetBuffer; + EmbeddedBuf HashAdjBuffer; +}; + +const uint32_t MinTpiHashBuckets = 0x1000; +const uint32_t MaxTpiHashBuckets = 0x40000; + +/// The header preceding the global PDB Stream (Stream 1) +struct InfoStreamHeader { + support::ulittle32_t Version; + support::ulittle32_t Signature; + support::ulittle32_t Age; + codeview::GUID Guid; +}; + +/// The header preceding the /names stream. +struct PDBStringTableHeader { + support::ulittle32_t Signature; // PDBStringTableSignature + support::ulittle32_t HashVersion; // 1 or 2 + support::ulittle32_t ByteSize; // Number of bytes of names buffer. +}; + +const uint32_t PDBStringTableSignature = 0xEFFEEFFE; + +/// The header preceding the /src/headerblock stream. +struct SrcHeaderBlockHeader { + support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. + support::ulittle32_t Size; // Size of entire stream. + uint64_t FileTime; // Time stamp (Windows FILETIME format). + support::ulittle32_t Age; // Age + uint8_t Padding[44]; // Pad to 64 bytes. +}; +static_assert(sizeof(SrcHeaderBlockHeader) == 64, "Incorrect struct size!"); + +/// A single file record entry within the /src/headerblock stream. +struct SrcHeaderBlockEntry { + support::ulittle32_t Size; // Record Length. + support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration. + support::ulittle32_t CRC; // CRC of the original file contents. + support::ulittle32_t FileSize; // Size of original source file. + support::ulittle32_t FileNI; // String table index of file name. + support::ulittle32_t ObjNI; // String table index of object name. + support::ulittle32_t VFileNI; // String table index of virtual file name. + uint8_t Compression; // PDB_SourceCompression enumeration. + uint8_t IsVirtual; // Is this a virtual file (injected)? + short Padding; // Pad to 4 bytes. + char Reserved[8]; +}; +static_assert(sizeof(SrcHeaderBlockEntry) == 40, "Incorrect struct size!"); + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolCache.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolCache.h index 73229e5a1e..730142f3c7 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolCache.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolCache.h @@ -1,207 +1,207 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//==- SymbolCache.h - Cache of native symbols and ids ------------*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_NATIVE_SYMBOLCACHE_H -#define LLVM_DEBUGINFO_PDB_NATIVE_SYMBOLCACHE_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/IntervalMap.h" -#include "llvm/DebugInfo/CodeView/Line.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" -#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" -#include "llvm/DebugInfo/PDB/Native/NativeSourceFile.h" - -#include <memory> -#include <vector> - -namespace llvm { -namespace pdb { -class DbiStream; -class PDBFile; - -class SymbolCache { - NativeSession &Session; - DbiStream *Dbi = nullptr; - - /// Cache of all stable symbols, indexed by SymIndexId. Just because a - /// symbol has been parsed does not imply that it will be stable and have - /// an Id. Id allocation is an implementation, with the only guarantee - /// being that once an Id is allocated, the symbol can be assumed to be - /// cached. +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//==- SymbolCache.h - Cache of native symbols and ids ------------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_SYMBOLCACHE_H +#define LLVM_DEBUGINFO_PDB_NATIVE_SYMBOLCACHE_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/IntervalMap.h" +#include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/TypeDeserializer.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSourceFile.h" + +#include <memory> +#include <vector> + +namespace llvm { +namespace pdb { +class DbiStream; +class PDBFile; + +class SymbolCache { + NativeSession &Session; + DbiStream *Dbi = nullptr; + + /// Cache of all stable symbols, indexed by SymIndexId. Just because a + /// symbol has been parsed does not imply that it will be stable and have + /// an Id. Id allocation is an implementation, with the only guarantee + /// being that once an Id is allocated, the symbol can be assumed to be + /// cached. mutable std::vector<std::unique_ptr<NativeRawSymbol>> Cache; - - /// For type records from the TPI stream which have been paresd and cached, - /// stores a mapping to SymIndexId of the cached symbol. + + /// For type records from the TPI stream which have been paresd and cached, + /// stores a mapping to SymIndexId of the cached symbol. mutable DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId; - - /// For field list members which have been parsed and cached, stores a mapping - /// from (IndexOfClass, MemberIndex) to the corresponding SymIndexId of the - /// cached symbol. + + /// For field list members which have been parsed and cached, stores a mapping + /// from (IndexOfClass, MemberIndex) to the corresponding SymIndexId of the + /// cached symbol. mutable DenseMap<std::pair<codeview::TypeIndex, uint32_t>, SymIndexId> - FieldListMembersToSymbolId; - - /// List of SymIndexIds for each compiland, indexed by compiland index as they - /// appear in the PDB file. + FieldListMembersToSymbolId; + + /// List of SymIndexIds for each compiland, indexed by compiland index as they + /// appear in the PDB file. mutable std::vector<SymIndexId> Compilands; - - /// List of source files, indexed by unique source file index. - mutable std::vector<std::unique_ptr<NativeSourceFile>> SourceFiles; + + /// List of source files, indexed by unique source file index. + mutable std::vector<std::unique_ptr<NativeSourceFile>> SourceFiles; /// Map from string table offset to source file Id. - mutable DenseMap<uint32_t, SymIndexId> FileNameOffsetToId; - - /// Map from global symbol offset to SymIndexId. + mutable DenseMap<uint32_t, SymIndexId> FileNameOffsetToId; + + /// Map from global symbol offset to SymIndexId. mutable DenseMap<uint32_t, SymIndexId> GlobalOffsetToSymbolId; - + /// Map from segment and code offset to function symbols. mutable DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> AddressToSymbolId; /// Map from segment and code offset to public symbols. mutable DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> AddressToPublicSymId; - + /// Map from module index and symbol table offset to SymIndexId. mutable DenseMap<std::pair<uint16_t, uint32_t>, SymIndexId> SymTabOffsetToSymbolId; - - struct LineTableEntry { - uint64_t Addr; - codeview::LineInfo Line; - uint32_t ColumnNumber; - uint32_t FileNameIndex; - bool IsTerminalEntry; - }; - - std::vector<LineTableEntry> findLineTable(uint16_t Modi) const; - mutable DenseMap<uint16_t, std::vector<LineTableEntry>> LineTable; - + + struct LineTableEntry { + uint64_t Addr; + codeview::LineInfo Line; + uint32_t ColumnNumber; + uint32_t FileNameIndex; + bool IsTerminalEntry; + }; + + std::vector<LineTableEntry> findLineTable(uint16_t Modi) const; + mutable DenseMap<uint16_t, std::vector<LineTableEntry>> LineTable; + SymIndexId createSymbolPlaceholder() const { - SymIndexId Id = Cache.size(); - Cache.push_back(nullptr); - return Id; - } - - template <typename ConcreteSymbolT, typename CVRecordT, typename... Args> - SymIndexId createSymbolForType(codeview::TypeIndex TI, codeview::CVType CVT, + SymIndexId Id = Cache.size(); + Cache.push_back(nullptr); + return Id; + } + + template <typename ConcreteSymbolT, typename CVRecordT, typename... Args> + SymIndexId createSymbolForType(codeview::TypeIndex TI, codeview::CVType CVT, Args &&...ConstructorArgs) const { - CVRecordT Record; - if (auto EC = - codeview::TypeDeserializer::deserializeAs<CVRecordT>(CVT, Record)) { - consumeError(std::move(EC)); - return 0; - } - - return createSymbol<ConcreteSymbolT>( - TI, std::move(Record), std::forward<Args>(ConstructorArgs)...); - } - - SymIndexId createSymbolForModifiedType(codeview::TypeIndex ModifierTI, + CVRecordT Record; + if (auto EC = + codeview::TypeDeserializer::deserializeAs<CVRecordT>(CVT, Record)) { + consumeError(std::move(EC)); + return 0; + } + + return createSymbol<ConcreteSymbolT>( + TI, std::move(Record), std::forward<Args>(ConstructorArgs)...); + } + + SymIndexId createSymbolForModifiedType(codeview::TypeIndex ModifierTI, codeview::CVType CVT) const; - - SymIndexId createSimpleType(codeview::TypeIndex TI, + + SymIndexId createSimpleType(codeview::TypeIndex TI, codeview::ModifierOptions Mods) const; - - std::unique_ptr<PDBSymbol> findFunctionSymbolBySectOffset(uint32_t Sect, - uint32_t Offset); - std::unique_ptr<PDBSymbol> findPublicSymbolBySectOffset(uint32_t Sect, - uint32_t Offset); - -public: - SymbolCache(NativeSession &Session, DbiStream *Dbi); - - template <typename ConcreteSymbolT, typename... Args> + + std::unique_ptr<PDBSymbol> findFunctionSymbolBySectOffset(uint32_t Sect, + uint32_t Offset); + std::unique_ptr<PDBSymbol> findPublicSymbolBySectOffset(uint32_t Sect, + uint32_t Offset); + +public: + SymbolCache(NativeSession &Session, DbiStream *Dbi); + + template <typename ConcreteSymbolT, typename... Args> SymIndexId createSymbol(Args &&...ConstructorArgs) const { - SymIndexId Id = Cache.size(); - - // Initial construction must not access the cache, since it must be done - // atomically. - auto Result = std::make_unique<ConcreteSymbolT>( - Session, Id, std::forward<Args>(ConstructorArgs)...); - Result->SymbolId = Id; - - NativeRawSymbol *NRS = static_cast<NativeRawSymbol *>(Result.get()); - Cache.push_back(std::move(Result)); - - // After the item is in the cache, we can do further initialization which - // is then allowed to access the cache. - NRS->initialize(); - return Id; - } - - std::unique_ptr<IPDBEnumSymbols> - createTypeEnumerator(codeview::TypeLeafKind Kind); - - std::unique_ptr<IPDBEnumSymbols> - createTypeEnumerator(std::vector<codeview::TypeLeafKind> Kinds); - - std::unique_ptr<IPDBEnumSymbols> - createGlobalsEnumerator(codeview::SymbolKind Kind); - + SymIndexId Id = Cache.size(); + + // Initial construction must not access the cache, since it must be done + // atomically. + auto Result = std::make_unique<ConcreteSymbolT>( + Session, Id, std::forward<Args>(ConstructorArgs)...); + Result->SymbolId = Id; + + NativeRawSymbol *NRS = static_cast<NativeRawSymbol *>(Result.get()); + Cache.push_back(std::move(Result)); + + // After the item is in the cache, we can do further initialization which + // is then allowed to access the cache. + NRS->initialize(); + return Id; + } + + std::unique_ptr<IPDBEnumSymbols> + createTypeEnumerator(codeview::TypeLeafKind Kind); + + std::unique_ptr<IPDBEnumSymbols> + createTypeEnumerator(std::vector<codeview::TypeLeafKind> Kinds); + + std::unique_ptr<IPDBEnumSymbols> + createGlobalsEnumerator(codeview::SymbolKind Kind); + SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const; - - template <typename ConcreteSymbolT, typename... Args> - SymIndexId getOrCreateFieldListMember(codeview::TypeIndex FieldListTI, - uint32_t Index, - Args &&... ConstructorArgs) { - SymIndexId SymId = Cache.size(); - std::pair<codeview::TypeIndex, uint32_t> Key{FieldListTI, Index}; - auto Result = FieldListMembersToSymbolId.try_emplace(Key, SymId); - if (Result.second) - SymId = - createSymbol<ConcreteSymbolT>(std::forward<Args>(ConstructorArgs)...); - else - SymId = Result.first->second; - return SymId; - } - - SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset); + + template <typename ConcreteSymbolT, typename... Args> + SymIndexId getOrCreateFieldListMember(codeview::TypeIndex FieldListTI, + uint32_t Index, + Args &&... ConstructorArgs) { + SymIndexId SymId = Cache.size(); + std::pair<codeview::TypeIndex, uint32_t> Key{FieldListTI, Index}; + auto Result = FieldListMembersToSymbolId.try_emplace(Key, SymId); + if (Result.second) + SymId = + createSymbol<ConcreteSymbolT>(std::forward<Args>(ConstructorArgs)...); + else + SymId = Result.first->second; + return SymId; + } + + SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset); SymIndexId getOrCreateInlineSymbol(codeview::InlineSiteSym Sym, uint64_t ParentAddr, uint16_t Modi, uint32_t RecordOffset) const; - - std::unique_ptr<PDBSymbol> - findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type); - - std::unique_ptr<IPDBEnumLineNumbers> - findLineNumbersByVA(uint64_t VA, uint32_t Length) const; - - std::unique_ptr<PDBSymbolCompiland> getOrCreateCompiland(uint32_t Index); - uint32_t getNumCompilands() const; - - std::unique_ptr<PDBSymbol> getSymbolById(SymIndexId SymbolId) const; - - NativeRawSymbol &getNativeSymbolById(SymIndexId SymbolId) const; - - template <typename ConcreteT> - ConcreteT &getNativeSymbolById(SymIndexId SymbolId) const { - return static_cast<ConcreteT &>(getNativeSymbolById(SymbolId)); - } - - std::unique_ptr<IPDBSourceFile> getSourceFileById(SymIndexId FileId) const; - SymIndexId - getOrCreateSourceFile(const codeview::FileChecksumEntry &Checksum) const; -}; - -} // namespace pdb -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + + std::unique_ptr<PDBSymbol> + findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type); + + std::unique_ptr<IPDBEnumLineNumbers> + findLineNumbersByVA(uint64_t VA, uint32_t Length) const; + + std::unique_ptr<PDBSymbolCompiland> getOrCreateCompiland(uint32_t Index); + uint32_t getNumCompilands() const; + + std::unique_ptr<PDBSymbol> getSymbolById(SymIndexId SymbolId) const; + + NativeRawSymbol &getNativeSymbolById(SymIndexId SymbolId) const; + + template <typename ConcreteT> + ConcreteT &getNativeSymbolById(SymIndexId SymbolId) const { + return static_cast<ConcreteT &>(getNativeSymbolById(SymbolId)); + } + + std::unique_ptr<IPDBSourceFile> getSourceFileById(SymIndexId FileId) const; + SymIndexId + getOrCreateSourceFile(const codeview::FileChecksumEntry &Checksum) const; +}; + +} // namespace pdb +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolStream.h index 62378cbb29..a0fe59b8d4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/SymbolStream.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolStream.cpp - PDB Symbol Stream Access --------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H - -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" - -#include "llvm/Support/Error.h" - -namespace llvm { -namespace msf { -class MappedBlockStream; -} -namespace pdb { -class PDBFile; - -class SymbolStream { -public: - SymbolStream(std::unique_ptr<msf::MappedBlockStream> Stream); - ~SymbolStream(); - Error reload(); - - const codeview::CVSymbolArray &getSymbolArray() const { - return SymbolRecords; - } - - codeview::CVSymbol readRecord(uint32_t Offset) const; - - iterator_range<codeview::CVSymbolArray::Iterator> - getSymbols(bool *HadError) const; - - Error commit(); - -private: - codeview::CVSymbolArray SymbolRecords; - std::unique_ptr<msf::MappedBlockStream> Stream; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolStream.cpp - PDB Symbol Stream Access --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H + +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" + +#include "llvm/Support/Error.h" + +namespace llvm { +namespace msf { +class MappedBlockStream; +} +namespace pdb { +class PDBFile; + +class SymbolStream { +public: + SymbolStream(std::unique_ptr<msf::MappedBlockStream> Stream); + ~SymbolStream(); + Error reload(); + + const codeview::CVSymbolArray &getSymbolArray() const { + return SymbolRecords; + } + + codeview::CVSymbol readRecord(uint32_t Offset) const; + + iterator_range<codeview::CVSymbolArray::Iterator> + getSymbols(bool *HadError) const; + + Error commit(); + +private: + codeview::CVSymbolArray SymbolRecords; + std::unique_ptr<msf::MappedBlockStream> Stream; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiHashing.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiHashing.h index 59bdc7ce20..47e2946607 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiHashing.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiHashing.h @@ -1,82 +1,82 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TpiHashing.h ---------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_TPIHASHING_H -#define LLVM_DEBUGINFO_PDB_TPIHASHING_H - -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace pdb { - -Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type); - -struct TagRecordHash { - explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full, - uint32_t Forward) - : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) { - State = 0; - } - - explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full, - uint32_t Forward) - : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) { - State = 1; - } - - explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full, - uint32_t Forward) - : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) { - State = 2; - } - - uint32_t FullRecordHash; - uint32_t ForwardDeclHash; - - codeview::TagRecord &getRecord() { - switch (State) { - case 0: - return Class; - case 1: - return Enum; - case 2: - return Union; - } - llvm_unreachable("unreachable!"); - } - -private: - union { - codeview::ClassRecord Class; - codeview::EnumRecord Enum; - codeview::UnionRecord Union; - }; - - uint8_t State = 0; -}; - -/// Given a CVType referring to a class, structure, union, or enum, compute -/// the hash of its forward decl and full decl. -Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type); - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TpiHashing.h ---------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_TPIHASHING_H +#define LLVM_DEBUGINFO_PDB_TPIHASHING_H + +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/Support/Error.h" + +namespace llvm { +namespace pdb { + +Expected<uint32_t> hashTypeRecord(const llvm::codeview::CVType &Type); + +struct TagRecordHash { + explicit TagRecordHash(codeview::ClassRecord CR, uint32_t Full, + uint32_t Forward) + : FullRecordHash(Full), ForwardDeclHash(Forward), Class(std::move(CR)) { + State = 0; + } + + explicit TagRecordHash(codeview::EnumRecord ER, uint32_t Full, + uint32_t Forward) + : FullRecordHash(Full), ForwardDeclHash(Forward), Enum(std::move(ER)) { + State = 1; + } + + explicit TagRecordHash(codeview::UnionRecord UR, uint32_t Full, + uint32_t Forward) + : FullRecordHash(Full), ForwardDeclHash(Forward), Union(std::move(UR)) { + State = 2; + } + + uint32_t FullRecordHash; + uint32_t ForwardDeclHash; + + codeview::TagRecord &getRecord() { + switch (State) { + case 0: + return Class; + case 1: + return Enum; + case 2: + return Union; + } + llvm_unreachable("unreachable!"); + } + +private: + union { + codeview::ClassRecord Class; + codeview::EnumRecord Enum; + codeview::UnionRecord Union; + }; + + uint8_t State = 0; +}; + +/// Given a CVType referring to a class, structure, union, or enum, compute +/// the hash of its forward decl and full decl. +Expected<TagRecordHash> hashTagRecord(const codeview::CVType &Type); + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_TPIHASHING_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStream.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStream.h index 0fb3b3d911..4b2d9854a8 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStream.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStream.h @@ -1,108 +1,108 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TpiStream.cpp - PDB Type Info (TPI) Stream 2 Access ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TpiStream.cpp - PDB Type Info (TPI) Stream 2 Access ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H + #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/PDB/Native/HashTable.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/raw_ostream.h" - -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { -class LazyRandomTypeCollection; -} -namespace msf { -class MappedBlockStream; -} -namespace pdb { -class PDBFile; - -class TpiStream { - friend class TpiStreamBuilder; - -public: - TpiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream); - ~TpiStream(); - Error reload(); - - PdbRaw_TpiVer getTpiVersion() const; - - uint32_t TypeIndexBegin() const; - uint32_t TypeIndexEnd() const; - uint32_t getNumTypeRecords() const; - uint16_t getTypeHashStreamIndex() const; - uint16_t getTypeHashStreamAuxIndex() const; - - uint32_t getHashKeySize() const; - uint32_t getNumHashBuckets() const; - FixedStreamArray<support::ulittle32_t> getHashValues() const; - FixedStreamArray<codeview::TypeIndexOffset> getTypeIndexOffsets() const; - HashTable<support::ulittle32_t> &getHashAdjusters(); - - codeview::CVTypeRange types(bool *HadError) const; - const codeview::CVTypeArray &typeArray() const { return TypeRecords; } - - codeview::LazyRandomTypeCollection &typeCollection() { return *Types; } - - Expected<codeview::TypeIndex> - findFullDeclForForwardRef(codeview::TypeIndex ForwardRefTI) const; - - std::vector<codeview::TypeIndex> findRecordsByName(StringRef Name) const; - - codeview::CVType getType(codeview::TypeIndex Index); - - BinarySubstreamRef getTypeRecordsSubstream() const; - - Error commit(); - - void buildHashMap(); - - bool supportsTypeLookup() const; - -private: - PDBFile &Pdb; - std::unique_ptr<msf::MappedBlockStream> Stream; - - std::unique_ptr<codeview::LazyRandomTypeCollection> Types; - - BinarySubstreamRef TypeRecordsSubstream; - - codeview::CVTypeArray TypeRecords; - - std::unique_ptr<BinaryStream> HashStream; - FixedStreamArray<support::ulittle32_t> HashValues; - FixedStreamArray<codeview::TypeIndexOffset> TypeIndexOffsets; - HashTable<support::ulittle32_t> HashAdjusters; - - std::vector<std::vector<codeview::TypeIndex>> HashMap; - - const TpiStreamHeader *Header; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include "llvm/DebugInfo/PDB/Native/HashTable.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/BinaryStreamArray.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/raw_ostream.h" + +#include "llvm/Support/Error.h" + +namespace llvm { +namespace codeview { +class LazyRandomTypeCollection; +} +namespace msf { +class MappedBlockStream; +} +namespace pdb { +class PDBFile; + +class TpiStream { + friend class TpiStreamBuilder; + +public: + TpiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream); + ~TpiStream(); + Error reload(); + + PdbRaw_TpiVer getTpiVersion() const; + + uint32_t TypeIndexBegin() const; + uint32_t TypeIndexEnd() const; + uint32_t getNumTypeRecords() const; + uint16_t getTypeHashStreamIndex() const; + uint16_t getTypeHashStreamAuxIndex() const; + + uint32_t getHashKeySize() const; + uint32_t getNumHashBuckets() const; + FixedStreamArray<support::ulittle32_t> getHashValues() const; + FixedStreamArray<codeview::TypeIndexOffset> getTypeIndexOffsets() const; + HashTable<support::ulittle32_t> &getHashAdjusters(); + + codeview::CVTypeRange types(bool *HadError) const; + const codeview::CVTypeArray &typeArray() const { return TypeRecords; } + + codeview::LazyRandomTypeCollection &typeCollection() { return *Types; } + + Expected<codeview::TypeIndex> + findFullDeclForForwardRef(codeview::TypeIndex ForwardRefTI) const; + + std::vector<codeview::TypeIndex> findRecordsByName(StringRef Name) const; + + codeview::CVType getType(codeview::TypeIndex Index); + + BinarySubstreamRef getTypeRecordsSubstream() const; + + Error commit(); + + void buildHashMap(); + + bool supportsTypeLookup() const; + +private: + PDBFile &Pdb; + std::unique_ptr<msf::MappedBlockStream> Stream; + + std::unique_ptr<codeview::LazyRandomTypeCollection> Types; + + BinarySubstreamRef TypeRecordsSubstream; + + codeview::CVTypeArray TypeRecords; + + std::unique_ptr<BinaryStream> HashStream; + FixedStreamArray<support::ulittle32_t> HashValues; + FixedStreamArray<codeview::TypeIndexOffset> TypeIndexOffsets; + HashTable<support::ulittle32_t> HashAdjusters; + + std::vector<std::vector<codeview::TypeIndex>> HashMap; + + const TpiStreamHeader *Header; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h index e958d0f069..8cfb4ff501 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h @@ -1,105 +1,105 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- TpiStreamBuilder.h - PDB Tpi Stream Creation -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAMBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAMBUILDER_H - -#include "llvm/ADT/Optional.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Native/RawConstants.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/BinaryByteStream.h" -#include "llvm/Support/BinaryItemStream.h" -#include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/Error.h" - -#include <vector> - -namespace llvm { -class BinaryByteStream; -class WritableBinaryStreamRef; - -template <> struct BinaryItemTraits<llvm::codeview::CVType> { - static size_t length(const codeview::CVType &Item) { return Item.length(); } - static ArrayRef<uint8_t> bytes(const codeview::CVType &Item) { - return Item.data(); - } -}; - -namespace codeview { -class TypeRecord; -} -namespace msf { -class MSFBuilder; -struct MSFLayout; -} -namespace pdb { -class PDBFile; -class TpiStream; -struct TpiStreamHeader; - -class TpiStreamBuilder { -public: - explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx); - ~TpiStreamBuilder(); - - TpiStreamBuilder(const TpiStreamBuilder &) = delete; - TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete; - - void setVersionHeader(PdbRaw_TpiVer Version); - void addTypeRecord(ArrayRef<uint8_t> Type, Optional<uint32_t> Hash); +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- TpiStreamBuilder.h - PDB Tpi Stream Creation -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAMBUILDER_H +#define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAMBUILDER_H + +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/Native/RawConstants.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/BinaryByteStream.h" +#include "llvm/Support/BinaryItemStream.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" + +#include <vector> + +namespace llvm { +class BinaryByteStream; +class WritableBinaryStreamRef; + +template <> struct BinaryItemTraits<llvm::codeview::CVType> { + static size_t length(const codeview::CVType &Item) { return Item.length(); } + static ArrayRef<uint8_t> bytes(const codeview::CVType &Item) { + return Item.data(); + } +}; + +namespace codeview { +class TypeRecord; +} +namespace msf { +class MSFBuilder; +struct MSFLayout; +} +namespace pdb { +class PDBFile; +class TpiStream; +struct TpiStreamHeader; + +class TpiStreamBuilder { +public: + explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx); + ~TpiStreamBuilder(); + + TpiStreamBuilder(const TpiStreamBuilder &) = delete; + TpiStreamBuilder &operator=(const TpiStreamBuilder &) = delete; + + void setVersionHeader(PdbRaw_TpiVer Version); + void addTypeRecord(ArrayRef<uint8_t> Type, Optional<uint32_t> Hash); void addTypeRecords(ArrayRef<uint8_t> Types, ArrayRef<uint16_t> Sizes, ArrayRef<uint32_t> Hashes); - - Error finalizeMsfLayout(); - + + Error finalizeMsfLayout(); + uint32_t getRecordCount() const { return TypeRecordCount; } - - Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); - - uint32_t calculateSerializedLength(); - -private: + + Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); + + uint32_t calculateSerializedLength(); + +private: void updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes); - uint32_t calculateHashBufferSize() const; - uint32_t calculateIndexOffsetSize() const; - Error finalize(); - - msf::MSFBuilder &Msf; - BumpPtrAllocator &Allocator; - + uint32_t calculateHashBufferSize() const; + uint32_t calculateIndexOffsetSize() const; + Error finalize(); + + msf::MSFBuilder &Msf; + BumpPtrAllocator &Allocator; + uint32_t TypeRecordCount = 0; - size_t TypeRecordBytes = 0; - - PdbRaw_TpiVer VerHeader = PdbRaw_TpiVer::PdbTpiV80; + size_t TypeRecordBytes = 0; + + PdbRaw_TpiVer VerHeader = PdbRaw_TpiVer::PdbTpiV80; std::vector<ArrayRef<uint8_t>> TypeRecBuffers; - std::vector<uint32_t> TypeHashes; - std::vector<codeview::TypeIndexOffset> TypeIndexOffsets; - uint32_t HashStreamIndex = kInvalidStreamIndex; - std::unique_ptr<BinaryByteStream> HashValueStream; - - const TpiStreamHeader *Header; - uint32_t Idx; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + std::vector<uint32_t> TypeHashes; + std::vector<codeview::TypeIndexOffset> TypeIndexOffsets; + uint32_t HashStreamIndex = kInvalidStreamIndex; + std::unique_ptr<BinaryByteStream> HashValueStream; + + const TpiStreamHeader *Header; + uint32_t Idx; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDB.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDB.h index d63e122754..4c6c54efe3 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDB.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDB.h @@ -1,42 +1,42 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDB.h - base header file for creating a PDB reader -------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDB_H -#define LLVM_DEBUGINFO_PDB_PDB_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/Error.h" -#include <memory> - -namespace llvm { -namespace pdb { - -class IPDBSession; - -Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, - std::unique_ptr<IPDBSession> &Session); - -Error loadDataForEXE(PDB_ReaderType Type, StringRef Path, - std::unique_ptr<IPDBSession> &Session); - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_PDB_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDB.h - base header file for creating a PDB reader -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDB_H +#define LLVM_DEBUGINFO_PDB_PDB_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/Error.h" +#include <memory> + +namespace llvm { +namespace pdb { + +class IPDBSession; + +Error loadDataForPDB(PDB_ReaderType Type, StringRef Path, + std::unique_ptr<IPDBSession> &Session); + +Error loadDataForEXE(PDB_ReaderType Type, StringRef Path, + std::unique_ptr<IPDBSession> &Session); + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDB_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBContext.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBContext.h index 3eb42699a1..d34bd56525 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBContext.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBContext.h @@ -1,78 +1,78 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===-- PDBContext.h --------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===/ - -#ifndef LLVM_DEBUGINFO_PDB_PDBCONTEXT_H -#define LLVM_DEBUGINFO_PDB_PDBCONTEXT_H - -#include "llvm/DebugInfo/DIContext.h" -#include "llvm/DebugInfo/PDB/IPDBSession.h" -#include <cstdint> -#include <memory> -#include <string> - -namespace llvm { - -namespace object { -class COFFObjectFile; -} // end namespace object - -namespace pdb { - - /// PDBContext - /// This data structure is the top level entity that deals with PDB debug - /// information parsing. This data structure exists only when there is a - /// need for a transparent interface to different debug information formats - /// (e.g. PDB and DWARF). More control and power over the debug information - /// access can be had by using the PDB interfaces directly. - class PDBContext : public DIContext { - public: - PDBContext(const object::COFFObjectFile &Object, - std::unique_ptr<IPDBSession> PDBSession); - PDBContext(PDBContext &) = delete; - PDBContext &operator=(PDBContext &) = delete; - - static bool classof(const DIContext *DICtx) { - return DICtx->getKind() == CK_PDB; - } - - void dump(raw_ostream &OS, DIDumpOptions DIDumpOpts) override; - - DILineInfo getLineInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DILineInfoTable getLineInfoForAddressRange( - object::SectionedAddress Address, uint64_t Size, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - DIInliningInfo getInliningInfoForAddress( - object::SectionedAddress Address, - DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; - - std::vector<DILocal> - getLocalsForAddress(object::SectionedAddress Address) override; - - private: - std::string getFunctionName(uint64_t Address, DINameKind NameKind) const; - std::unique_ptr<IPDBSession> Session; - }; - -} // end namespace pdb - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_PDBCONTEXT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===-- PDBContext.h --------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===/ + +#ifndef LLVM_DEBUGINFO_PDB_PDBCONTEXT_H +#define LLVM_DEBUGINFO_PDB_PDBCONTEXT_H + +#include "llvm/DebugInfo/DIContext.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" +#include <cstdint> +#include <memory> +#include <string> + +namespace llvm { + +namespace object { +class COFFObjectFile; +} // end namespace object + +namespace pdb { + + /// PDBContext + /// This data structure is the top level entity that deals with PDB debug + /// information parsing. This data structure exists only when there is a + /// need for a transparent interface to different debug information formats + /// (e.g. PDB and DWARF). More control and power over the debug information + /// access can be had by using the PDB interfaces directly. + class PDBContext : public DIContext { + public: + PDBContext(const object::COFFObjectFile &Object, + std::unique_ptr<IPDBSession> PDBSession); + PDBContext(PDBContext &) = delete; + PDBContext &operator=(PDBContext &) = delete; + + static bool classof(const DIContext *DICtx) { + return DICtx->getKind() == CK_PDB; + } + + void dump(raw_ostream &OS, DIDumpOptions DIDumpOpts) override; + + DILineInfo getLineInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DILineInfoTable getLineInfoForAddressRange( + object::SectionedAddress Address, uint64_t Size, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + DIInliningInfo getInliningInfoForAddress( + object::SectionedAddress Address, + DILineInfoSpecifier Specifier = DILineInfoSpecifier()) override; + + std::vector<DILocal> + getLocalsForAddress(object::SectionedAddress Address) override; + + private: + std::string getFunctionName(uint64_t Address, DINameKind NameKind) const; + std::unique_ptr<IPDBSession> Session; + }; + +} // end namespace pdb + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDBCONTEXT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBExtras.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBExtras.h index c42c49cbae..7b5e4b5de2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBExtras.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBExtras.h @@ -1,68 +1,68 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBExtras.h - helper functions and classes for PDBs ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBEXTRAS_H -#define LLVM_DEBUGINFO_PDB_PDBEXTRAS_H - +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBExtras.h - helper functions and classes for PDBs ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBEXTRAS_H +#define LLVM_DEBUGINFO_PDB_PDBEXTRAS_H + #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include "llvm/Support/raw_ostream.h" #include <cstdint> -#include <unordered_map> - -namespace llvm { - -namespace pdb { - -using TagStats = std::unordered_map<PDB_SymType, int>; - -raw_ostream &operator<<(raw_ostream &OS, const PDB_VariantType &Value); -raw_ostream &operator<<(raw_ostream &OS, const PDB_CallingConv &Conv); -raw_ostream &operator<<(raw_ostream &OS, const PDB_BuiltinType &Type); -raw_ostream &operator<<(raw_ostream &OS, const PDB_DataKind &Data); -raw_ostream &operator<<(raw_ostream &OS, - const llvm::codeview::CPURegister &CpuReg); -raw_ostream &operator<<(raw_ostream &OS, const PDB_LocType &Loc); -raw_ostream &operator<<(raw_ostream &OS, const codeview::ThunkOrdinal &Thunk); -raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum); -raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang); -raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag); -raw_ostream &operator<<(raw_ostream &OS, const PDB_MemberAccess &Access); -raw_ostream &operator<<(raw_ostream &OS, const PDB_UdtType &Type); -raw_ostream &operator<<(raw_ostream &OS, const PDB_Machine &Machine); - -raw_ostream &operator<<(raw_ostream &OS, const Variant &Value); -raw_ostream &operator<<(raw_ostream &OS, const VersionInfo &Version); -raw_ostream &operator<<(raw_ostream &OS, const TagStats &Stats); - -raw_ostream& dumpPDBSourceCompression(raw_ostream& OS, uint32_t Compression); - -template <typename T> -void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent) { - OS << "\n"; - OS.indent(Indent); - OS << Name << ": " << Value; -} - -} // end namespace pdb - -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_PDBEXTRAS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include <unordered_map> + +namespace llvm { + +namespace pdb { + +using TagStats = std::unordered_map<PDB_SymType, int>; + +raw_ostream &operator<<(raw_ostream &OS, const PDB_VariantType &Value); +raw_ostream &operator<<(raw_ostream &OS, const PDB_CallingConv &Conv); +raw_ostream &operator<<(raw_ostream &OS, const PDB_BuiltinType &Type); +raw_ostream &operator<<(raw_ostream &OS, const PDB_DataKind &Data); +raw_ostream &operator<<(raw_ostream &OS, + const llvm::codeview::CPURegister &CpuReg); +raw_ostream &operator<<(raw_ostream &OS, const PDB_LocType &Loc); +raw_ostream &operator<<(raw_ostream &OS, const codeview::ThunkOrdinal &Thunk); +raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum); +raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang); +raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag); +raw_ostream &operator<<(raw_ostream &OS, const PDB_MemberAccess &Access); +raw_ostream &operator<<(raw_ostream &OS, const PDB_UdtType &Type); +raw_ostream &operator<<(raw_ostream &OS, const PDB_Machine &Machine); + +raw_ostream &operator<<(raw_ostream &OS, const Variant &Value); +raw_ostream &operator<<(raw_ostream &OS, const VersionInfo &Version); +raw_ostream &operator<<(raw_ostream &OS, const TagStats &Stats); + +raw_ostream& dumpPDBSourceCompression(raw_ostream& OS, uint32_t Compression); + +template <typename T> +void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent) { + OS << "\n"; + OS.indent(Indent); + OS << Name << ": " << Value; +} + +} // end namespace pdb + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDBEXTRAS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymDumper.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymDumper.h index 10e518a81b..13f3cc5a48 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymDumper.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymDumper.h @@ -1,89 +1,89 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymDumper.h - base interface for PDB symbol dumper *- C++ -----*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H -#define LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H - -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymDumper { -public: - PDBSymDumper(bool ShouldRequireImpl); - virtual ~PDBSymDumper(); - - virtual void dump(const PDBSymbolAnnotation &Symbol); - virtual void dump(const PDBSymbolBlock &Symbol); - virtual void dump(const PDBSymbolCompiland &Symbol); - virtual void dump(const PDBSymbolCompilandDetails &Symbol); - virtual void dump(const PDBSymbolCompilandEnv &Symbol); - virtual void dump(const PDBSymbolCustom &Symbol); - virtual void dump(const PDBSymbolData &Symbol); - virtual void dump(const PDBSymbolExe &Symbol); - virtual void dump(const PDBSymbolFunc &Symbol); - virtual void dump(const PDBSymbolFuncDebugEnd &Symbol); - virtual void dump(const PDBSymbolFuncDebugStart &Symbol); - virtual void dump(const PDBSymbolLabel &Symbol); - virtual void dump(const PDBSymbolPublicSymbol &Symbol); - virtual void dump(const PDBSymbolThunk &Symbol); - virtual void dump(const PDBSymbolTypeArray &Symbol); - virtual void dump(const PDBSymbolTypeBaseClass &Symbol); - virtual void dump(const PDBSymbolTypeBuiltin &Symbol); - virtual void dump(const PDBSymbolTypeCustom &Symbol); - virtual void dump(const PDBSymbolTypeDimension &Symbol); - virtual void dump(const PDBSymbolTypeEnum &Symbol); - virtual void dump(const PDBSymbolTypeFriend &Symbol); - virtual void dump(const PDBSymbolTypeFunctionArg &Symbol); - virtual void dump(const PDBSymbolTypeFunctionSig &Symbol); - virtual void dump(const PDBSymbolTypeManaged &Symbol); - virtual void dump(const PDBSymbolTypePointer &Symbol); - virtual void dump(const PDBSymbolTypeTypedef &Symbol); - virtual void dump(const PDBSymbolTypeUDT &Symbol); - virtual void dump(const PDBSymbolTypeVTable &Symbol); - virtual void dump(const PDBSymbolTypeVTableShape &Symbol); - virtual void dump(const PDBSymbolUnknown &Symbol); - virtual void dump(const PDBSymbolUsingNamespace &Symbol); - - virtual void dumpRight(const PDBSymbolTypeArray &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeBaseClass &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeBuiltin &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeCustom &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeDimension &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeEnum &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeFriend &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeFunctionArg &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeFunctionSig &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeManaged &Symbol) {} - virtual void dumpRight(const PDBSymbolTypePointer &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeTypedef &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeUDT &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeVTable &Symbol) {} - virtual void dumpRight(const PDBSymbolTypeVTableShape &Symbol) {} - -private: - bool RequireImpl; -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymDumper.h - base interface for PDB symbol dumper *- C++ -----*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H +#define LLVM_DEBUGINFO_PDB_PDBSYMDUMPER_H + +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymDumper { +public: + PDBSymDumper(bool ShouldRequireImpl); + virtual ~PDBSymDumper(); + + virtual void dump(const PDBSymbolAnnotation &Symbol); + virtual void dump(const PDBSymbolBlock &Symbol); + virtual void dump(const PDBSymbolCompiland &Symbol); + virtual void dump(const PDBSymbolCompilandDetails &Symbol); + virtual void dump(const PDBSymbolCompilandEnv &Symbol); + virtual void dump(const PDBSymbolCustom &Symbol); + virtual void dump(const PDBSymbolData &Symbol); + virtual void dump(const PDBSymbolExe &Symbol); + virtual void dump(const PDBSymbolFunc &Symbol); + virtual void dump(const PDBSymbolFuncDebugEnd &Symbol); + virtual void dump(const PDBSymbolFuncDebugStart &Symbol); + virtual void dump(const PDBSymbolLabel &Symbol); + virtual void dump(const PDBSymbolPublicSymbol &Symbol); + virtual void dump(const PDBSymbolThunk &Symbol); + virtual void dump(const PDBSymbolTypeArray &Symbol); + virtual void dump(const PDBSymbolTypeBaseClass &Symbol); + virtual void dump(const PDBSymbolTypeBuiltin &Symbol); + virtual void dump(const PDBSymbolTypeCustom &Symbol); + virtual void dump(const PDBSymbolTypeDimension &Symbol); + virtual void dump(const PDBSymbolTypeEnum &Symbol); + virtual void dump(const PDBSymbolTypeFriend &Symbol); + virtual void dump(const PDBSymbolTypeFunctionArg &Symbol); + virtual void dump(const PDBSymbolTypeFunctionSig &Symbol); + virtual void dump(const PDBSymbolTypeManaged &Symbol); + virtual void dump(const PDBSymbolTypePointer &Symbol); + virtual void dump(const PDBSymbolTypeTypedef &Symbol); + virtual void dump(const PDBSymbolTypeUDT &Symbol); + virtual void dump(const PDBSymbolTypeVTable &Symbol); + virtual void dump(const PDBSymbolTypeVTableShape &Symbol); + virtual void dump(const PDBSymbolUnknown &Symbol); + virtual void dump(const PDBSymbolUsingNamespace &Symbol); + + virtual void dumpRight(const PDBSymbolTypeArray &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeBaseClass &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeBuiltin &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeCustom &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeDimension &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeEnum &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFriend &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFunctionArg &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeFunctionSig &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeManaged &Symbol) {} + virtual void dumpRight(const PDBSymbolTypePointer &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeTypedef &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeUDT &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeVTable &Symbol) {} + virtual void dumpRight(const PDBSymbolTypeVTableShape &Symbol) {} + +private: + bool RequireImpl; +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbol.h index 4f09f4992a..1154cc660b 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -1,186 +1,186 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbol.h - base class for user-facing symbol types -----*- C++-*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOL_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOL_H - -#include "ConcreteSymbolEnumerator.h" -#include "IPDBRawSymbol.h" -#include "PDBExtras.h" -#include "PDBTypes.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/Casting.h" - -#define FORWARD_SYMBOL_METHOD(MethodName) \ - decltype(auto) MethodName() const { return RawSymbol->MethodName(); } - -#define FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(ConcreteType, PrivateName, \ - PublicName) \ - decltype(auto) PublicName##Id() const { \ - return RawSymbol->PrivateName##Id(); \ - } \ - std::unique_ptr<ConcreteType> PublicName() const { \ - uint32_t Id = PublicName##Id(); \ - return getConcreteSymbolByIdHelper<ConcreteType>(Id); \ - } - -#define FORWARD_SYMBOL_ID_METHOD_WITH_NAME(PrivateName, PublicName) \ - FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbol, PrivateName, \ - PublicName) - -#define FORWARD_SYMBOL_ID_METHOD(MethodName) \ - FORWARD_SYMBOL_ID_METHOD_WITH_NAME(MethodName, MethodName) - -namespace llvm { - -class StringRef; -class raw_ostream; - -namespace pdb { -class IPDBSession; - -#define DECLARE_PDB_SYMBOL_CONCRETE_TYPE(TagValue) \ -private: \ - using PDBSymbol::PDBSymbol; \ - friend class PDBSymbol; \ - \ -public: \ - static const PDB_SymType Tag = TagValue; \ - static bool classof(const PDBSymbol *S) { return S->getSymTag() == Tag; } - -#define DECLARE_PDB_SYMBOL_CUSTOM_TYPE(Condition) \ -private: \ - using PDBSymbol::PDBSymbol; \ - friend class PDBSymbol; \ - \ -public: \ - static bool classof(const PDBSymbol *S) { return Condition; } - -/// PDBSymbol defines the base of the inheritance hierarchy for concrete symbol -/// types (e.g. functions, executables, vtables, etc). All concrete symbol -/// types inherit from PDBSymbol and expose the exact set of methods that are -/// valid for that particular symbol type, as described in the Microsoft -/// reference "Lexical and Class Hierarchy of Symbol Types": -/// https://msdn.microsoft.com/en-us/library/370hs6k4.aspx -class PDBSymbol { - static std::unique_ptr<PDBSymbol> createSymbol(const IPDBSession &PDBSession, - PDB_SymType Tag); - -protected: - explicit PDBSymbol(const IPDBSession &PDBSession); - PDBSymbol(PDBSymbol &&Other); - -public: - static std::unique_ptr<PDBSymbol> - create(const IPDBSession &PDBSession, - std::unique_ptr<IPDBRawSymbol> RawSymbol); - static std::unique_ptr<PDBSymbol> create(const IPDBSession &PDBSession, - IPDBRawSymbol &RawSymbol); - - template <typename ConcreteT> - static std::unique_ptr<ConcreteT> - createAs(const IPDBSession &PDBSession, - std::unique_ptr<IPDBRawSymbol> RawSymbol) { - std::unique_ptr<PDBSymbol> S = create(PDBSession, std::move(RawSymbol)); - return unique_dyn_cast_or_null<ConcreteT>(std::move(S)); - } - template <typename ConcreteT> - static std::unique_ptr<ConcreteT> createAs(const IPDBSession &PDBSession, - IPDBRawSymbol &RawSymbol) { - std::unique_ptr<PDBSymbol> S = create(PDBSession, RawSymbol); - return unique_dyn_cast_or_null<ConcreteT>(std::move(S)); - } - - virtual ~PDBSymbol(); - - /// Dumps the contents of a symbol a raw_ostream. By default this will just - /// call dump() on the underlying RawSymbol, which allows us to discover - /// unknown properties, but individual implementations of PDBSymbol may - /// override the behavior to only dump known fields. - virtual void dump(PDBSymDumper &Dumper) const = 0; - - /// For certain PDBSymbolTypes, dumps additional information for the type that - /// normally goes on the right side of the symbol. - virtual void dumpRight(PDBSymDumper &Dumper) const {} - - void defaultDump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowFlags, - PdbSymbolIdField RecurseFlags) const; - void dumpProperties() const; - void dumpChildStats() const; - - PDB_SymType getSymTag() const; - uint32_t getSymIndexId() const; - - template <typename T> std::unique_ptr<T> findOneChild() const { - auto Enumerator(findAllChildren<T>()); - if (!Enumerator) - return nullptr; - return Enumerator->getNext(); - } - - template <typename T> - std::unique_ptr<ConcreteSymbolEnumerator<T>> findAllChildren() const { - auto BaseIter = RawSymbol->findChildren(T::Tag); - if (!BaseIter) - return nullptr; - return std::make_unique<ConcreteSymbolEnumerator<T>>(std::move(BaseIter)); - } - std::unique_ptr<IPDBEnumSymbols> findAllChildren(PDB_SymType Type) const; - std::unique_ptr<IPDBEnumSymbols> findAllChildren() const; - - std::unique_ptr<IPDBEnumSymbols> - findChildren(PDB_SymType Type, StringRef Name, - PDB_NameSearchFlags Flags) const; - std::unique_ptr<IPDBEnumSymbols> findChildrenByRVA(PDB_SymType Type, - StringRef Name, - PDB_NameSearchFlags Flags, - uint32_t RVA) const; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbol.h - base class for user-facing symbol types -----*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOL_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOL_H + +#include "ConcreteSymbolEnumerator.h" +#include "IPDBRawSymbol.h" +#include "PDBExtras.h" +#include "PDBTypes.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Casting.h" + +#define FORWARD_SYMBOL_METHOD(MethodName) \ + decltype(auto) MethodName() const { return RawSymbol->MethodName(); } + +#define FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(ConcreteType, PrivateName, \ + PublicName) \ + decltype(auto) PublicName##Id() const { \ + return RawSymbol->PrivateName##Id(); \ + } \ + std::unique_ptr<ConcreteType> PublicName() const { \ + uint32_t Id = PublicName##Id(); \ + return getConcreteSymbolByIdHelper<ConcreteType>(Id); \ + } + +#define FORWARD_SYMBOL_ID_METHOD_WITH_NAME(PrivateName, PublicName) \ + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbol, PrivateName, \ + PublicName) + +#define FORWARD_SYMBOL_ID_METHOD(MethodName) \ + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(MethodName, MethodName) + +namespace llvm { + +class StringRef; +class raw_ostream; + +namespace pdb { +class IPDBSession; + +#define DECLARE_PDB_SYMBOL_CONCRETE_TYPE(TagValue) \ +private: \ + using PDBSymbol::PDBSymbol; \ + friend class PDBSymbol; \ + \ +public: \ + static const PDB_SymType Tag = TagValue; \ + static bool classof(const PDBSymbol *S) { return S->getSymTag() == Tag; } + +#define DECLARE_PDB_SYMBOL_CUSTOM_TYPE(Condition) \ +private: \ + using PDBSymbol::PDBSymbol; \ + friend class PDBSymbol; \ + \ +public: \ + static bool classof(const PDBSymbol *S) { return Condition; } + +/// PDBSymbol defines the base of the inheritance hierarchy for concrete symbol +/// types (e.g. functions, executables, vtables, etc). All concrete symbol +/// types inherit from PDBSymbol and expose the exact set of methods that are +/// valid for that particular symbol type, as described in the Microsoft +/// reference "Lexical and Class Hierarchy of Symbol Types": +/// https://msdn.microsoft.com/en-us/library/370hs6k4.aspx +class PDBSymbol { + static std::unique_ptr<PDBSymbol> createSymbol(const IPDBSession &PDBSession, + PDB_SymType Tag); + +protected: + explicit PDBSymbol(const IPDBSession &PDBSession); + PDBSymbol(PDBSymbol &&Other); + +public: + static std::unique_ptr<PDBSymbol> + create(const IPDBSession &PDBSession, + std::unique_ptr<IPDBRawSymbol> RawSymbol); + static std::unique_ptr<PDBSymbol> create(const IPDBSession &PDBSession, + IPDBRawSymbol &RawSymbol); + + template <typename ConcreteT> + static std::unique_ptr<ConcreteT> + createAs(const IPDBSession &PDBSession, + std::unique_ptr<IPDBRawSymbol> RawSymbol) { + std::unique_ptr<PDBSymbol> S = create(PDBSession, std::move(RawSymbol)); + return unique_dyn_cast_or_null<ConcreteT>(std::move(S)); + } + template <typename ConcreteT> + static std::unique_ptr<ConcreteT> createAs(const IPDBSession &PDBSession, + IPDBRawSymbol &RawSymbol) { + std::unique_ptr<PDBSymbol> S = create(PDBSession, RawSymbol); + return unique_dyn_cast_or_null<ConcreteT>(std::move(S)); + } + + virtual ~PDBSymbol(); + + /// Dumps the contents of a symbol a raw_ostream. By default this will just + /// call dump() on the underlying RawSymbol, which allows us to discover + /// unknown properties, but individual implementations of PDBSymbol may + /// override the behavior to only dump known fields. + virtual void dump(PDBSymDumper &Dumper) const = 0; + + /// For certain PDBSymbolTypes, dumps additional information for the type that + /// normally goes on the right side of the symbol. + virtual void dumpRight(PDBSymDumper &Dumper) const {} + + void defaultDump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowFlags, + PdbSymbolIdField RecurseFlags) const; + void dumpProperties() const; + void dumpChildStats() const; + + PDB_SymType getSymTag() const; + uint32_t getSymIndexId() const; + + template <typename T> std::unique_ptr<T> findOneChild() const { + auto Enumerator(findAllChildren<T>()); + if (!Enumerator) + return nullptr; + return Enumerator->getNext(); + } + + template <typename T> + std::unique_ptr<ConcreteSymbolEnumerator<T>> findAllChildren() const { + auto BaseIter = RawSymbol->findChildren(T::Tag); + if (!BaseIter) + return nullptr; + return std::make_unique<ConcreteSymbolEnumerator<T>>(std::move(BaseIter)); + } + std::unique_ptr<IPDBEnumSymbols> findAllChildren(PDB_SymType Type) const; + std::unique_ptr<IPDBEnumSymbols> findAllChildren() const; + + std::unique_ptr<IPDBEnumSymbols> + findChildren(PDB_SymType Type, StringRef Name, + PDB_NameSearchFlags Flags) const; + std::unique_ptr<IPDBEnumSymbols> findChildrenByRVA(PDB_SymType Type, + StringRef Name, + PDB_NameSearchFlags Flags, + uint32_t RVA) const; std::unique_ptr<IPDBEnumSymbols> findInlineFramesByVA(uint64_t VA) const; - std::unique_ptr<IPDBEnumSymbols> findInlineFramesByRVA(uint32_t RVA) const; + std::unique_ptr<IPDBEnumSymbols> findInlineFramesByRVA(uint32_t RVA) const; std::unique_ptr<IPDBEnumLineNumbers> findInlineeLinesByVA(uint64_t VA, uint32_t Length) const; std::unique_ptr<IPDBEnumLineNumbers> findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const; - + std::string getName() const; - const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; } - IPDBRawSymbol &getRawSymbol() { return *RawSymbol; } - - const IPDBSession &getSession() const { return Session; } - - std::unique_ptr<IPDBEnumSymbols> getChildStats(TagStats &Stats) const; - -protected: - std::unique_ptr<PDBSymbol> getSymbolByIdHelper(uint32_t Id) const; - - template <typename ConcreteType> - std::unique_ptr<ConcreteType> getConcreteSymbolByIdHelper(uint32_t Id) const { - return unique_dyn_cast_or_null<ConcreteType>(getSymbolByIdHelper(Id)); - } - - const IPDBSession &Session; - std::unique_ptr<IPDBRawSymbol> OwnedRawSymbol; - IPDBRawSymbol *RawSymbol = nullptr; -}; - -} // namespace llvm -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; } + IPDBRawSymbol &getRawSymbol() { return *RawSymbol; } + + const IPDBSession &getSession() const { return Session; } + + std::unique_ptr<IPDBEnumSymbols> getChildStats(TagStats &Stats) const; + +protected: + std::unique_ptr<PDBSymbol> getSymbolByIdHelper(uint32_t Id) const; + + template <typename ConcreteType> + std::unique_ptr<ConcreteType> getConcreteSymbolByIdHelper(uint32_t Id) const { + return unique_dyn_cast_or_null<ConcreteType>(getSymbolByIdHelper(Id)); + } + + const IPDBSession &Session; + std::unique_ptr<IPDBRawSymbol> OwnedRawSymbol; + IPDBRawSymbol *RawSymbol = nullptr; +}; + +} // namespace llvm +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h index 2ea5de844e..f7ecb96a00 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolAnnotation.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolAnnotation.h - Accessors for querying PDB annotations ---*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolAnnotation : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Annotation) - -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(getDataKind) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - // FORWARD_SYMBOL_METHOD(getValue) - FORWARD_SYMBOL_METHOD(getVirtualAddress) -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolAnnotation.h - Accessors for querying PDB annotations ---*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolAnnotation : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Annotation) + +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(getDataKind) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + // FORWARD_SYMBOL_METHOD(getValue) + FORWARD_SYMBOL_METHOD(getVirtualAddress) +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLANNOTATION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h index 0fae4ce8c6..a78437bf34 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolBlock.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolBlock.h - Accessors for querying PDB blocks -------------*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolBlock : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Block) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualAddress) -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolBlock.h - Accessors for querying PDB blocks -------------*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolBlock : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Block) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualAddress) +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLBLOCK_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h index 0a7329bed6..e5cb4556ff 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompiland.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolCompiland.h - Accessors for querying PDB compilands -----*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" -#include <string> - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolCompiland : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Compiland) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLibraryName) - FORWARD_SYMBOL_METHOD(getName) - - std::string getSourceFileName() const; - std::string getSourceFileFullPath() const; -}; -} -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolCompiland.h - Accessors for querying PDB compilands -----*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" +#include <string> + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolCompiland : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Compiland) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLibraryName) + FORWARD_SYMBOL_METHOD(getName) + + std::string getSourceFileName() const; + std::string getSourceFileFullPath() const; +}; +} +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILAND_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h index 9adbf2e796..22c1b38550 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolCompilandDetails.h - PDB compiland details ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDDETAILS_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDDETAILS_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolCompilandDetails : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandDetails) -public: - void dump(PDBSymDumper &Dumper) const override; - - void getFrontEndVersion(VersionInfo &Version) const { - RawSymbol->getFrontEndVersion(Version); - } - - void getBackEndVersion(VersionInfo &Version) const { - RawSymbol->getBackEndVersion(Version); - } - - FORWARD_SYMBOL_METHOD(getCompilerName) - FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) - FORWARD_SYMBOL_METHOD(hasDebugInfo) - FORWARD_SYMBOL_METHOD(hasManagedCode) - FORWARD_SYMBOL_METHOD(hasSecurityChecks) - FORWARD_SYMBOL_METHOD(isCVTCIL) - FORWARD_SYMBOL_METHOD(isDataAligned) - FORWARD_SYMBOL_METHOD(isHotpatchable) - FORWARD_SYMBOL_METHOD(isLTCG) - FORWARD_SYMBOL_METHOD(isMSILNetmodule) - FORWARD_SYMBOL_METHOD(getLanguage) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getPlatform) - FORWARD_SYMBOL_METHOD(getSourceFileName) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBFUNCTION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolCompilandDetails.h - PDB compiland details ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDDETAILS_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDDETAILS_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolCompilandDetails : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandDetails) +public: + void dump(PDBSymDumper &Dumper) const override; + + void getFrontEndVersion(VersionInfo &Version) const { + RawSymbol->getFrontEndVersion(Version); + } + + void getBackEndVersion(VersionInfo &Version) const { + RawSymbol->getBackEndVersion(Version); + } + + FORWARD_SYMBOL_METHOD(getCompilerName) + FORWARD_SYMBOL_METHOD(isEditAndContinueEnabled) + FORWARD_SYMBOL_METHOD(hasDebugInfo) + FORWARD_SYMBOL_METHOD(hasManagedCode) + FORWARD_SYMBOL_METHOD(hasSecurityChecks) + FORWARD_SYMBOL_METHOD(isCVTCIL) + FORWARD_SYMBOL_METHOD(isDataAligned) + FORWARD_SYMBOL_METHOD(isHotpatchable) + FORWARD_SYMBOL_METHOD(isLTCG) + FORWARD_SYMBOL_METHOD(isMSILNetmodule) + FORWARD_SYMBOL_METHOD(getLanguage) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getPlatform) + FORWARD_SYMBOL_METHOD(getSourceFileName) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBFUNCTION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h index 49335d26ce..479f885961 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h @@ -1,43 +1,43 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolCompilandEnv.h - compiland environment variables *- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { -class PDBSymbolCompilandEnv : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandEnv) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) - std::string getValue() const; -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolCompilandEnv.h - compiland environment variables *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { +class PDBSymbolCompilandEnv : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CompilandEnv) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) + std::string getValue() const; +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCOMPILANDENV_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h index 8f994910a7..b486ad9688 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolCustom.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolCustom.h - compiler-specific types --------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" -#include "llvm/ADT/SmallVector.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { -/// PDBSymbolCustom represents symbols that are compiler-specific and do not -/// fit anywhere else in the lexical hierarchy. -/// https://msdn.microsoft.com/en-us/library/d88sf09h.aspx -class PDBSymbolCustom : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Custom) -public: - void dump(PDBSymDumper &Dumper) const override; - - void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes); -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolCustom.h - compiler-specific types --------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { +/// PDBSymbolCustom represents symbols that are compiler-specific and do not +/// fit anywhere else in the lexical hierarchy. +/// https://msdn.microsoft.com/en-us/library/d88sf09h.aspx +class PDBSymbolCustom : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Custom) +public: + void dump(PDBSymDumper &Dumper) const override; + + void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes); +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLCUSTOM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolData.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolData.h index e10e0a5ec3..13537fa913 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolData.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolData.h @@ -1,70 +1,70 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolData.h - PDB data (e.g. variable) accessors -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H - -#include "IPDBLineNumber.h" -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolData : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Data) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAccess) - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(getAddressTaken) - FORWARD_SYMBOL_METHOD(getBitPosition) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(isCompilerGenerated) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getDataKind) - FORWARD_SYMBOL_METHOD(isAggregated) - FORWARD_SYMBOL_METHOD(isSplitted) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(getRegisterId) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getSlot) - FORWARD_SYMBOL_METHOD(getToken) - FORWARD_SYMBOL_ID_METHOD(getType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(getValue) - FORWARD_SYMBOL_METHOD(getVirtualAddress) - FORWARD_SYMBOL_METHOD(isVolatileType) - - std::unique_ptr<IPDBEnumLineNumbers> getLineNumbers() const; - uint32_t getCompilandId() const; -}; -} // namespace pdb -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolData.h - PDB data (e.g. variable) accessors -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H + +#include "IPDBLineNumber.h" +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolData : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Data) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAccess) + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(getAddressTaken) + FORWARD_SYMBOL_METHOD(getBitPosition) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(isCompilerGenerated) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(getDataKind) + FORWARD_SYMBOL_METHOD(isAggregated) + FORWARD_SYMBOL_METHOD(isSplitted) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(getRegisterId) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getSlot) + FORWARD_SYMBOL_METHOD(getToken) + FORWARD_SYMBOL_ID_METHOD(getType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(getValue) + FORWARD_SYMBOL_METHOD(getVirtualAddress) + FORWARD_SYMBOL_METHOD(isVolatileType) + + std::unique_ptr<IPDBEnumLineNumbers> getLineNumbers() const; + uint32_t getCompilandId() const; +}; +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLDATA_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolExe.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolExe.h index 06b1bcb66f..806fbe2418 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolExe.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolExe.h @@ -1,55 +1,55 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolExe.h - Accessors for querying executables in a PDB ----*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolExe : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Exe) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAge) - FORWARD_SYMBOL_METHOD(getGuid) - FORWARD_SYMBOL_METHOD(hasCTypes) - FORWARD_SYMBOL_METHOD(hasPrivateSymbols) - FORWARD_SYMBOL_METHOD(getMachineType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getSignature) - FORWARD_SYMBOL_METHOD(getSymbolsFileName) - - uint32_t getPointerByteSize() const; - -private: - void dumpChildren(raw_ostream &OS, StringRef Label, PDB_SymType ChildType, - int Indent) const; -}; -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolExe.h - Accessors for querying executables in a PDB ----*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolExe : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Exe) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAge) + FORWARD_SYMBOL_METHOD(getGuid) + FORWARD_SYMBOL_METHOD(hasCTypes) + FORWARD_SYMBOL_METHOD(hasPrivateSymbols) + FORWARD_SYMBOL_METHOD(getMachineType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getSignature) + FORWARD_SYMBOL_METHOD(getSymbolsFileName) + + uint32_t getPointerByteSize() const; + +private: + void dumpChildren(raw_ostream &OS, StringRef Label, PDB_SymType ChildType, + int Indent) const; +}; +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLEXE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h index 67c5daa181..9423862e58 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h @@ -1,96 +1,96 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolFunc.h - class representing a function instance -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H - -#include "IPDBLineNumber.h" -#include "PDBSymbol.h" -#include "PDBSymbolTypeFunctionSig.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolFunc : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Function) -public: - void dump(PDBSymDumper &Dumper) const override; - - bool isDestructor() const; - - std::unique_ptr<IPDBEnumChildren<PDBSymbolData>> getArguments() const; - - FORWARD_SYMBOL_METHOD(getAccess) - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(isCompilerGenerated) - FORWARD_SYMBOL_METHOD(isConstructorVirtualBase) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(isCxxReturnUdt) - FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) - FORWARD_SYMBOL_METHOD(hasFarReturn) - FORWARD_SYMBOL_METHOD(hasAlloca) - FORWARD_SYMBOL_METHOD(hasEH) - FORWARD_SYMBOL_METHOD(hasEHa) - FORWARD_SYMBOL_METHOD(hasInlAsm) - FORWARD_SYMBOL_METHOD(hasLongJump) - FORWARD_SYMBOL_METHOD(hasSEH) - FORWARD_SYMBOL_METHOD(hasSecurityChecks) - FORWARD_SYMBOL_METHOD(hasSetJump) - FORWARD_SYMBOL_METHOD(hasInterruptReturn) - FORWARD_SYMBOL_METHOD(isIntroVirtualFunction) - FORWARD_SYMBOL_METHOD(hasInlineAttribute) - FORWARD_SYMBOL_METHOD(isNaked) - FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocalBasePointerRegisterId) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(hasFramePointer) - FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) - FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) - FORWARD_SYMBOL_METHOD(isUnreached) - FORWARD_SYMBOL_METHOD(getNoStackOrdering) - FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) - FORWARD_SYMBOL_METHOD(isPureVirtual) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getToken) - FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType, - getSignature) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(getUndecoratedName) - FORWARD_SYMBOL_METHOD(isVirtual) - FORWARD_SYMBOL_METHOD(getVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualBaseOffset) - FORWARD_SYMBOL_METHOD(isVolatileType) - - std::unique_ptr<IPDBEnumLineNumbers> getLineNumbers() const; - uint32_t getCompilandId() const; -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolFunc.h - class representing a function instance -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H + +#include "IPDBLineNumber.h" +#include "PDBSymbol.h" +#include "PDBSymbolTypeFunctionSig.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolFunc : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Function) +public: + void dump(PDBSymDumper &Dumper) const override; + + bool isDestructor() const; + + std::unique_ptr<IPDBEnumChildren<PDBSymbolData>> getArguments() const; + + FORWARD_SYMBOL_METHOD(getAccess) + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(isCompilerGenerated) + FORWARD_SYMBOL_METHOD(isConstructorVirtualBase) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(isCxxReturnUdt) + FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) + FORWARD_SYMBOL_METHOD(hasFarReturn) + FORWARD_SYMBOL_METHOD(hasAlloca) + FORWARD_SYMBOL_METHOD(hasEH) + FORWARD_SYMBOL_METHOD(hasEHa) + FORWARD_SYMBOL_METHOD(hasInlAsm) + FORWARD_SYMBOL_METHOD(hasLongJump) + FORWARD_SYMBOL_METHOD(hasSEH) + FORWARD_SYMBOL_METHOD(hasSecurityChecks) + FORWARD_SYMBOL_METHOD(hasSetJump) + FORWARD_SYMBOL_METHOD(hasInterruptReturn) + FORWARD_SYMBOL_METHOD(isIntroVirtualFunction) + FORWARD_SYMBOL_METHOD(hasInlineAttribute) + FORWARD_SYMBOL_METHOD(isNaked) + FORWARD_SYMBOL_METHOD(isStatic) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocalBasePointerRegisterId) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(hasFramePointer) + FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) + FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) + FORWARD_SYMBOL_METHOD(isUnreached) + FORWARD_SYMBOL_METHOD(getNoStackOrdering) + FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) + FORWARD_SYMBOL_METHOD(isPureVirtual) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getToken) + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeFunctionSig, getType, + getSignature) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(getUndecoratedName) + FORWARD_SYMBOL_METHOD(isVirtual) + FORWARD_SYMBOL_METHOD(getVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualBaseOffset) + FORWARD_SYMBOL_METHOD(isVolatileType) + + std::unique_ptr<IPDBEnumLineNumbers> getLineNumbers() const; + uint32_t getCompilandId() const; +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNC_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h index e8932907d5..67e424878e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h @@ -1,57 +1,57 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolFuncDebugEnd.h - function end bounds info -------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolFuncDebugEnd : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugEnd) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) - FORWARD_SYMBOL_METHOD(hasFarReturn) - FORWARD_SYMBOL_METHOD(hasInterruptReturn) - FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) - FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) - FORWARD_SYMBOL_METHOD(isUnreached) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualAddress) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolFuncDebugEnd.h - function end bounds info -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolFuncDebugEnd : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugEnd) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) + FORWARD_SYMBOL_METHOD(hasFarReturn) + FORWARD_SYMBOL_METHOD(hasInterruptReturn) + FORWARD_SYMBOL_METHOD(isStatic) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) + FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) + FORWARD_SYMBOL_METHOD(isUnreached) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualAddress) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGEND_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h index 77394c9a54..0c9c17b916 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h @@ -1,56 +1,56 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolFuncDebugStart.h - function start bounds info ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolFuncDebugStart : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugStart) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) - FORWARD_SYMBOL_METHOD(hasFarReturn) - FORWARD_SYMBOL_METHOD(hasInterruptReturn) - FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) - FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) - FORWARD_SYMBOL_METHOD(isUnreached) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualAddress) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolFuncDebugStart.h - function start bounds info ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolFuncDebugStart : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FuncDebugStart) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) + FORWARD_SYMBOL_METHOD(hasFarReturn) + FORWARD_SYMBOL_METHOD(hasInterruptReturn) + FORWARD_SYMBOL_METHOD(isStatic) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) + FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) + FORWARD_SYMBOL_METHOD(isUnreached) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualAddress) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLFUNCDEBUGSTART_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h index 053ec45663..9a1c5efc49 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolLabel.h @@ -1,56 +1,56 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolLabel.h - label info ----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolLabel : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Label) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) - FORWARD_SYMBOL_METHOD(hasFarReturn) - FORWARD_SYMBOL_METHOD(hasInterruptReturn) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) - FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) - FORWARD_SYMBOL_METHOD(isUnreached) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualAddress) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolLabel.h - label info ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolLabel : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Label) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(hasCustomCallingConvention) + FORWARD_SYMBOL_METHOD(hasFarReturn) + FORWARD_SYMBOL_METHOD(hasInterruptReturn) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(hasNoInlineAttribute) + FORWARD_SYMBOL_METHOD(hasNoReturnAttribute) + FORWARD_SYMBOL_METHOD(isUnreached) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(hasOptimizedCodeDebugInfo) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualAddress) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLLABEL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h index 79e7e9bc52..3cf5f88542 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h @@ -1,54 +1,54 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolPublicSymbol.h - public symbol info -------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolPublicSymbol : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PublicSymbol) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_METHOD(isCode) - FORWARD_SYMBOL_METHOD(isFunction) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getLocationType) - FORWARD_SYMBOL_METHOD(isManagedCode) - FORWARD_SYMBOL_METHOD(isMSILCode) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualAddress) - FORWARD_SYMBOL_METHOD(getUndecoratedName) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolPublicSymbol.h - public symbol info -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolPublicSymbol : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PublicSymbol) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_METHOD(isCode) + FORWARD_SYMBOL_METHOD(isFunction) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getLocationType) + FORWARD_SYMBOL_METHOD(isManagedCode) + FORWARD_SYMBOL_METHOD(isMSILCode) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualAddress) + FORWARD_SYMBOL_METHOD(getUndecoratedName) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLPUBLICSYMBOL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h index 3dd48f28b6..4c0e2229ab 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolThunk.h - Support for querying PDB thunks ---------------*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolThunk : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Thunk) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAccess) - FORWARD_SYMBOL_METHOD(getAddressOffset) - FORWARD_SYMBOL_METHOD(getAddressSection) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(isIntroVirtualFunction) - FORWARD_SYMBOL_METHOD(isStatic) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(isPureVirtual) - FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getTargetOffset) - FORWARD_SYMBOL_METHOD(getTargetRelativeVirtualAddress) - FORWARD_SYMBOL_METHOD(getTargetVirtualAddress) - FORWARD_SYMBOL_METHOD(getTargetSection) - FORWARD_SYMBOL_METHOD(getThunkOrdinal) - FORWARD_SYMBOL_ID_METHOD(getType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVirtual) - FORWARD_SYMBOL_METHOD(getVirtualAddress) - FORWARD_SYMBOL_METHOD(getVirtualBaseOffset) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolThunk.h - Support for querying PDB thunks ---------------*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolThunk : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Thunk) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAccess) + FORWARD_SYMBOL_METHOD(getAddressOffset) + FORWARD_SYMBOL_METHOD(getAddressSection) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(isIntroVirtualFunction) + FORWARD_SYMBOL_METHOD(isStatic) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(isPureVirtual) + FORWARD_SYMBOL_METHOD(getRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getTargetOffset) + FORWARD_SYMBOL_METHOD(getTargetRelativeVirtualAddress) + FORWARD_SYMBOL_METHOD(getTargetVirtualAddress) + FORWARD_SYMBOL_METHOD(getTargetSection) + FORWARD_SYMBOL_METHOD(getThunkOrdinal) + FORWARD_SYMBOL_ID_METHOD(getType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVirtual) + FORWARD_SYMBOL_METHOD(getVirtualAddress) + FORWARD_SYMBOL_METHOD(getVirtualBaseOffset) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTHUNK_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h index a80e6afd3b..976a96a4c8 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h @@ -1,51 +1,51 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeArray.h - array type information ------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeArray : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType) -public: - void dump(PDBSymDumper &Dumper) const override; - void dumpRight(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getArrayIndexType) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getCount) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getRank) - FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getElementType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeArray.h - array type information ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeArray : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ArrayType) +public: + void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getArrayIndexType) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(getCount) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getRank) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getElementType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEARRAY_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h index 8842b529da..1ebc44a917 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h @@ -1,70 +1,70 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeBaseClass.h - base class type information ---*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeBaseClass : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BaseClass) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getAccess) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(hasConstructor) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(hasAssignmentOperator) - FORWARD_SYMBOL_METHOD(hasCastOperator) - FORWARD_SYMBOL_METHOD(hasNestedTypes) - FORWARD_SYMBOL_METHOD(isIndirectVirtualBaseClass) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(isNested) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(hasOverloadedOperator) - FORWARD_SYMBOL_METHOD(isPacked) - FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_ID_METHOD(getType) - FORWARD_SYMBOL_METHOD(getUdtKind) - FORWARD_SYMBOL_METHOD(isUnalignedType) - - FORWARD_SYMBOL_METHOD(isVirtualBaseClass) - FORWARD_SYMBOL_METHOD(getVirtualBaseDispIndex) - FORWARD_SYMBOL_METHOD(getVirtualBasePointerOffset) - // FORWARD_SYMBOL_METHOD(getVirtualBaseTableType) - FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeBaseClass.h - base class type information ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeBaseClass : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BaseClass) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getAccess) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(hasConstructor) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(hasAssignmentOperator) + FORWARD_SYMBOL_METHOD(hasCastOperator) + FORWARD_SYMBOL_METHOD(hasNestedTypes) + FORWARD_SYMBOL_METHOD(isIndirectVirtualBaseClass) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(isNested) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(hasOverloadedOperator) + FORWARD_SYMBOL_METHOD(isPacked) + FORWARD_SYMBOL_METHOD(isScoped) + FORWARD_SYMBOL_ID_METHOD(getType) + FORWARD_SYMBOL_METHOD(getUdtKind) + FORWARD_SYMBOL_METHOD(isUnalignedType) + + FORWARD_SYMBOL_METHOD(isVirtualBaseClass) + FORWARD_SYMBOL_METHOD(getVirtualBaseDispIndex) + FORWARD_SYMBOL_METHOD(getVirtualBasePointerOffset) + // FORWARD_SYMBOL_METHOD(getVirtualBaseTableType) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBASECLASS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h index 3fd8548cc9..72ac32afa4 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h @@ -1,47 +1,47 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeBuiltin.h - builtin type information --------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeBuiltin : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getBuiltinType) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeBuiltin.h - builtin type information --------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeBuiltin : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::BuiltinType) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getBuiltinType) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEBUILTIN_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h index f60d162a0b..907b699471 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h @@ -1,43 +1,43 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeCustom.h - custom compiler type information -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeCustom : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CustomType) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getOemId) - FORWARD_SYMBOL_METHOD(getOemSymbolId) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeCustom.h - custom compiler type information -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeCustom : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::CustomType) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getOemId) + FORWARD_SYMBOL_METHOD(getOemSymbolId) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPECUSTOM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h index 225862e2ba..985f0dda67 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h @@ -1,43 +1,43 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeDimension.h - array dimension type info -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeDimension : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Dimension) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getLowerBoundId) - FORWARD_SYMBOL_METHOD(getUpperBoundId) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeDimension.h - array dimension type info -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeDimension : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Dimension) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getLowerBoundId) + FORWARD_SYMBOL_METHOD(getUpperBoundId) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEDIMENSION_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h index 9d19d7ff28..b5284a07a3 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h @@ -1,63 +1,63 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeEnum.h - enum type info ---------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H - -#include "IPDBLineNumber.h" -#include "PDBSymbol.h" -#include "PDBSymbolTypeBuiltin.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeEnum : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Enum) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getBuiltinType) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(hasConstructor) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(hasAssignmentOperator) - FORWARD_SYMBOL_METHOD(hasCastOperator) - FORWARD_SYMBOL_METHOD(hasNestedTypes) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn) - FORWARD_SYMBOL_METHOD(isNested) - FORWARD_SYMBOL_METHOD(hasOverloadedOperator) - FORWARD_SYMBOL_METHOD(isPacked) - FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeBuiltin, getType, - getUnderlyingType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeEnum.h - enum type info ---------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H + +#include "IPDBLineNumber.h" +#include "PDBSymbol.h" +#include "PDBSymbolTypeBuiltin.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeEnum : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Enum) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getBuiltinType) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(hasConstructor) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(hasAssignmentOperator) + FORWARD_SYMBOL_METHOD(hasCastOperator) + FORWARD_SYMBOL_METHOD(hasNestedTypes) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn) + FORWARD_SYMBOL_METHOD(isNested) + FORWARD_SYMBOL_METHOD(hasOverloadedOperator) + FORWARD_SYMBOL_METHOD(isPacked) + FORWARD_SYMBOL_METHOD(isScoped) + FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbolTypeBuiltin, getType, + getUnderlyingType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEENUM_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h index 730ae3042a..6359306633 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeFriend.h - friend type info -----------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeFriend : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Friend) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_ID_METHOD(getType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeFriend.h - friend type info -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeFriend : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Friend) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_ID_METHOD(getType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFRIEND_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h index 5afbcfbe2e..321fa5bbda 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeFunctionArg.h - function arg type info ------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeFunctionArg : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionArg) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_ID_METHOD(getType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeFunctionArg.h - function arg type info ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeFunctionArg : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionArg) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_ID_METHOD(getType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONARG_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h index 8333054855..c324623144 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h @@ -1,58 +1,58 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeFunctionSig.h - function signature type info *- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeFunctionSig : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionSig) -public: - std::unique_ptr<IPDBEnumSymbols> getArguments() const; - - void dump(PDBSymDumper &Dumper) const override; - void dumpRight(PDBSymDumper &Dumper) const override; - void dumpArgList(raw_ostream &OS) const; - - bool isCVarArgs() const; - - FORWARD_SYMBOL_METHOD(getCallingConvention) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getCount) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - // FORWARD_SYMBOL_METHOD(getObjectPointerType) - FORWARD_SYMBOL_METHOD(getThisAdjust) - FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getReturnType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeFunctionSig.h - function signature type info *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeFunctionSig : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::FunctionSig) +public: + std::unique_ptr<IPDBEnumSymbols> getArguments() const; + + void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; + void dumpArgList(raw_ostream &OS) const; + + bool isCVarArgs() const; + + FORWARD_SYMBOL_METHOD(getCallingConvention) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(getCount) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + // FORWARD_SYMBOL_METHOD(getObjectPointerType) + FORWARD_SYMBOL_METHOD(getThisAdjust) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getReturnType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEFUNCTIONSIG_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h index 958fbd9358..6710b3b5b1 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h @@ -1,42 +1,42 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeManaged.h - managed type info ---------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeManaged : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ManagedType) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getName) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeManaged.h - managed type info ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeManaged : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::ManagedType) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getName) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEMANAGED_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h index 38c9dcbe04..98d3d062c2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h @@ -1,54 +1,54 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypePointer.h - pointer type info ---------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypePointer : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType) -public: - void dump(PDBSymDumper &Dumper) const override; - void dumpRight(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(isReference) - FORWARD_SYMBOL_METHOD(isRValueReference) - FORWARD_SYMBOL_METHOD(isPointerToDataMember) - FORWARD_SYMBOL_METHOD(isPointerToMemberFunction) - FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getPointeeType) - FORWARD_SYMBOL_METHOD(isRestrictedType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypePointer.h - pointer type info ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypePointer : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::PointerType) +public: + void dump(PDBSymDumper &Dumper) const override; + void dumpRight(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(isReference) + FORWARD_SYMBOL_METHOD(isRValueReference) + FORWARD_SYMBOL_METHOD(isPointerToDataMember) + FORWARD_SYMBOL_METHOD(isPointerToMemberFunction) + FORWARD_SYMBOL_ID_METHOD_WITH_NAME(getType, getPointeeType) + FORWARD_SYMBOL_METHOD(isRestrictedType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEPOINTER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h index 908cb31205..f23ee23cc9 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h @@ -1,61 +1,61 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeTypedef.h - typedef type info ---------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeTypedef : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Typedef) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(getBuiltinType) - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(hasConstructor) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(hasAssignmentOperator) - FORWARD_SYMBOL_METHOD(hasCastOperator) - FORWARD_SYMBOL_METHOD(hasNestedTypes) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(isNested) - FORWARD_SYMBOL_METHOD(hasOverloadedOperator) - FORWARD_SYMBOL_METHOD(isPacked) - FORWARD_SYMBOL_METHOD(isReference) - FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_ID_METHOD(getType) - FORWARD_SYMBOL_METHOD(getUdtKind) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeTypedef.h - typedef type info ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeTypedef : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::Typedef) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(getBuiltinType) + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(hasConstructor) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(hasAssignmentOperator) + FORWARD_SYMBOL_METHOD(hasCastOperator) + FORWARD_SYMBOL_METHOD(hasNestedTypes) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(isNested) + FORWARD_SYMBOL_METHOD(hasOverloadedOperator) + FORWARD_SYMBOL_METHOD(isPacked) + FORWARD_SYMBOL_METHOD(isReference) + FORWARD_SYMBOL_METHOD(isScoped) + FORWARD_SYMBOL_ID_METHOD(getType) + FORWARD_SYMBOL_METHOD(getUdtKind) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPETYPEDEF_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h index 3af11caeac..8b5edf40ed 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h @@ -1,64 +1,64 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeUDT.h - UDT type info -----------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H - -#include "IPDBLineNumber.h" -#include "IPDBSession.h" -#include "PDBSymbol.h" -#include "PDBSymbolTypeBaseClass.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; - -namespace pdb { - -class PDBSymbolTypeUDT : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UDT) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) - FORWARD_SYMBOL_METHOD(hasConstructor) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(hasAssignmentOperator) - FORWARD_SYMBOL_METHOD(hasCastOperator) - FORWARD_SYMBOL_METHOD(hasNestedTypes) - FORWARD_SYMBOL_METHOD(getLength) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) - FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn) - FORWARD_SYMBOL_METHOD(isNested) - FORWARD_SYMBOL_METHOD(hasOverloadedOperator) - FORWARD_SYMBOL_METHOD(isPacked) - FORWARD_SYMBOL_METHOD(isScoped) - FORWARD_SYMBOL_METHOD(getUdtKind) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) - FORWARD_SYMBOL_METHOD(isVolatileType) - FORWARD_SYMBOL_METHOD(getAccess) -}; -} -} // namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeUDT.h - UDT type info -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H + +#include "IPDBLineNumber.h" +#include "IPDBSession.h" +#include "PDBSymbol.h" +#include "PDBSymbolTypeBaseClass.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; + +namespace pdb { + +class PDBSymbolTypeUDT : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UDT) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType) + FORWARD_SYMBOL_METHOD(hasConstructor) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(hasAssignmentOperator) + FORWARD_SYMBOL_METHOD(hasCastOperator) + FORWARD_SYMBOL_METHOD(hasNestedTypes) + FORWARD_SYMBOL_METHOD(getLength) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) + FORWARD_SYMBOL_METHOD(getSrcLineOnTypeDefn) + FORWARD_SYMBOL_METHOD(isNested) + FORWARD_SYMBOL_METHOD(hasOverloadedOperator) + FORWARD_SYMBOL_METHOD(isPacked) + FORWARD_SYMBOL_METHOD(isScoped) + FORWARD_SYMBOL_METHOD(getUdtKind) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_ID_METHOD(getVirtualTableShape) + FORWARD_SYMBOL_METHOD(isVolatileType) + FORWARD_SYMBOL_METHOD(getAccess) +}; +} +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEUDT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h index ba9e598637..fd507142cf 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h @@ -1,48 +1,48 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeVTable.h - VTable type info -----------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeVTable : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTable) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getClassParent) - FORWARD_SYMBOL_METHOD(getOffset) - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_ID_METHOD(getType) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeVTable.h - VTable type info -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeVTable : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTable) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getClassParent) + FORWARD_SYMBOL_METHOD(getOffset) + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_ID_METHOD(getType) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h index feac13d462..6e18384bce 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h @@ -1,46 +1,46 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolTypeVTableShape.h - VTable shape info -----------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolTypeVTableShape : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTableShape) -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_METHOD(isConstType) - FORWARD_SYMBOL_METHOD(getCount) - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(isUnalignedType) - FORWARD_SYMBOL_METHOD(isVolatileType) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolTypeVTableShape.h - VTable shape info -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolTypeVTableShape : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::VTableShape) +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_METHOD(isConstType) + FORWARD_SYMBOL_METHOD(getCount) + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(isUnalignedType) + FORWARD_SYMBOL_METHOD(isVolatileType) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLTYPEVTABLESHAPE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h index 9555626ba8..075592ee62 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUnknown.h @@ -1,41 +1,41 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolUnknown.h - unknown symbol type -----------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H - -#include "PDBSymbol.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolUnknown : public PDBSymbol { - DECLARE_PDB_SYMBOL_CUSTOM_TYPE(S->getSymTag() == PDB_SymType::None || - S->getSymTag() >= PDB_SymType::Max) - -public: - void dump(PDBSymDumper &Dumper) const override; -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolUnknown.h - unknown symbol type -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H + +#include "PDBSymbol.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolUnknown : public PDBSymbol { + DECLARE_PDB_SYMBOL_CUSTOM_TYPE(S->getSymTag() == PDB_SymType::None || + S->getSymTag() >= PDB_SymType::Max) + +public: + void dump(PDBSymDumper &Dumper) const override; +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLUNKNOWN_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h index ed08a0073e..59d56b45c2 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h @@ -1,44 +1,44 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBSymbolUsingNamespace.h - using namespace info ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H -#define LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H - -#include "PDBSymbol.h" -#include "PDBTypes.h" - -namespace llvm { - -class raw_ostream; -namespace pdb { - -class PDBSymbolUsingNamespace : public PDBSymbol { - DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UsingNamespace) - -public: - void dump(PDBSymDumper &Dumper) const override; - - FORWARD_SYMBOL_ID_METHOD(getLexicalParent) - FORWARD_SYMBOL_METHOD(getName) -}; - -} // namespace llvm -} - -#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBSymbolUsingNamespace.h - using namespace info ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H +#define LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H + +#include "PDBSymbol.h" +#include "PDBTypes.h" + +namespace llvm { + +class raw_ostream; +namespace pdb { + +class PDBSymbolUsingNamespace : public PDBSymbol { + DECLARE_PDB_SYMBOL_CONCRETE_TYPE(PDB_SymType::UsingNamespace) + +public: + void dump(PDBSymDumper &Dumper) const override; + + FORWARD_SYMBOL_ID_METHOD(getLexicalParent) + FORWARD_SYMBOL_METHOD(getName) +}; + +} // namespace llvm +} + +#endif // LLVM_DEBUGINFO_PDB_PDBSYMBOLUSINGNAMESPACE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBTypes.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBTypes.h index a27c8e5925..9618691546 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBTypes.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -1,621 +1,621 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- PDBTypes.h - Defines enums for various fields contained in PDB ----====// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H -#define LLVM_DEBUGINFO_PDB_PDBTYPES_H - -#include "llvm/ADT/APFloat.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" -#include "llvm/DebugInfo/PDB/IPDBFrameData.h" -#include "llvm/DebugInfo/PDB/Native/RawTypes.h" -#include <cctype> -#include <cstddef> -#include <cstdint> -#include <cstring> -#include <functional> - -namespace llvm { -namespace pdb { - -typedef uint32_t SymIndexId; - -class IPDBDataStream; -class IPDBInjectedSource; -class IPDBLineNumber; -class IPDBSectionContrib; -class IPDBSession; -class IPDBSourceFile; -class IPDBTable; -class PDBSymDumper; -class PDBSymbol; -class PDBSymbolExe; -class PDBSymbolCompiland; -class PDBSymbolCompilandDetails; -class PDBSymbolCompilandEnv; -class PDBSymbolFunc; -class PDBSymbolBlock; -class PDBSymbolData; -class PDBSymbolAnnotation; -class PDBSymbolLabel; -class PDBSymbolPublicSymbol; -class PDBSymbolTypeUDT; -class PDBSymbolTypeEnum; -class PDBSymbolTypeFunctionSig; -class PDBSymbolTypePointer; -class PDBSymbolTypeArray; -class PDBSymbolTypeBuiltin; -class PDBSymbolTypeTypedef; -class PDBSymbolTypeBaseClass; -class PDBSymbolTypeFriend; -class PDBSymbolTypeFunctionArg; -class PDBSymbolFuncDebugStart; -class PDBSymbolFuncDebugEnd; -class PDBSymbolUsingNamespace; -class PDBSymbolTypeVTableShape; -class PDBSymbolTypeVTable; -class PDBSymbolCustom; -class PDBSymbolThunk; -class PDBSymbolTypeCustom; -class PDBSymbolTypeManaged; -class PDBSymbolTypeDimension; -class PDBSymbolUnknown; - -using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>; -using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>; -using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>; -using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>; -using IPDBEnumTables = IPDBEnumChildren<IPDBTable>; -using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>; -using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>; -using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>; - -/// Specifies which PDB reader implementation is to be used. Only a value -/// of PDB_ReaderType::DIA is currently supported, but Native is in the works. -enum class PDB_ReaderType { - DIA = 0, - Native = 1, -}; - -/// An enumeration indicating the type of data contained in this table. -enum class PDB_TableType { - TableInvalid = 0, - Symbols, - SourceFiles, - LineNumbers, - SectionContribs, - Segments, - InjectedSources, - FrameData, - InputAssemblyFiles, - Dbg -}; - -/// Defines flags used for enumerating child symbols. This corresponds to the -/// NameSearchOptions enumeration which is documented here: -/// https://msdn.microsoft.com/en-us/library/yat28ads.aspx -enum PDB_NameSearchFlags { - NS_Default = 0x0, - NS_CaseSensitive = 0x1, - NS_CaseInsensitive = 0x2, - NS_FileNameExtMatch = 0x4, - NS_Regex = 0x8, - NS_UndecoratedName = 0x10, - - // For backward compatibility. - NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch, - NS_CaseRegex = NS_Regex | NS_CaseSensitive, - NS_CaseInRex = NS_Regex | NS_CaseInsensitive -}; - -/// Specifies the hash algorithm that a source file from a PDB was hashed with. -/// This corresponds to the CV_SourceChksum_t enumeration and are documented -/// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx -enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 }; - -/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx -using PDB_Cpu = codeview::CPUType; - -enum class PDB_Machine { - Invalid = 0xffff, - Unknown = 0x0, - Am33 = 0x13, - Amd64 = 0x8664, - Arm = 0x1C0, - Arm64 = 0xaa64, - ArmNT = 0x1C4, - Ebc = 0xEBC, - x86 = 0x14C, - Ia64 = 0x200, - M32R = 0x9041, - Mips16 = 0x266, - MipsFpu = 0x366, - MipsFpu16 = 0x466, - PowerPC = 0x1F0, - PowerPCFP = 0x1F1, - R4000 = 0x166, - SH3 = 0x1A2, - SH3DSP = 0x1A3, - SH4 = 0x1A6, - SH5 = 0x1A8, - Thumb = 0x1C2, - WceMipsV2 = 0x169 -}; - -// A struct with an inner unnamed enum with explicit underlying type resuls -// in an enum class that can implicitly convert to the underlying type, which -// is convenient for this enum. -struct PDB_SourceCompression { - enum : uint32_t { - // No compression. Produced e.g. by `link.exe /natvis:foo.natvis`. - None, - // Not known what produces this. - RunLengthEncoded, - // Not known what produces this. - Huffman, - // Not known what produces this. - LZ, - // Produced e.g. by `csc /debug`. The encoded data is its own mini-stream - // with the following layout (in little endian): - // GUID LanguageTypeGuid; - // GUID LanguageVendorGuid; - // GUID DocumentTypeGuid; - // GUID HashFunctionGuid; - // uint32_t HashDataSize; - // uint32_t CompressedDataSize; - // Followed by HashDataSize bytes containing a hash checksum, - // followed by CompressedDataSize bytes containing source contents. - // - // CompressedDataSize can be 0, in this case only the hash data is present. - // (CompressedDataSize is != 0 e.g. if `/embed` is passed to csc.exe.) - // The compressed data format is: - // uint32_t UncompressedDataSize; - // If UncompressedDataSize is 0, the data is stored uncompressed and - // CompressedDataSize stores the uncompressed size. - // If UncompressedDataSize is != 0, then the data is in raw deflate - // encoding as described in rfc1951. - // - // A GUID is 16 bytes, stored in the usual - // uint32_t - // uint16_t - // uint16_t - // uint8_t[24] - // layout. - // - // Well-known GUIDs for LanguageTypeGuid are: - // 63a08714-fc37-11d2-904c-00c04fa302a1 C - // 3a12d0b7-c26c-11d0-b442-00a0244a1dd2 C++ - // 3f5162f8-07c6-11d3-9053-00c04fa302a1 C# - // af046cd1-d0e1-11d2-977c-00a0c9b4d50c Cobol - // ab4f38c9-b6e6-43ba-be3b-58080b2ccce3 F# - // 3a12d0b4-c26c-11d0-b442-00a0244a1dd2 Java - // 3a12d0b6-c26c-11d0-b442-00a0244a1dd2 JScript - // af046cd2-d0e1-11d2-977c-00a0c9b4d50c Pascal - // 3a12d0b8-c26c-11d0-b442-00a0244a1dd2 Visual Basic - // - // Well-known GUIDs for LanguageVendorGuid are: - // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft - // - // Well-known GUIDs for DocumentTypeGuid are: - // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text - // - // Well-known GUIDs for HashFunctionGuid are: - // 406ea660-64cf-4c82-b6f0-42d48172a799 MD5 (HashDataSize is 16) - // ff1816ec-aa5e-4d10-87f7-6f4963833460 SHA1 (HashDataSize is 20) - // 8829d00f-11b8-4213-878b-770e8597ac16 SHA256 (HashDataSize is 32) - DotNet = 101, - }; -}; - -/// These values correspond to the CV_call_e enumeration, and are documented -/// at the following locations: -/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx -/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx -using PDB_CallingConv = codeview::CallingConvention; - -/// These values correspond to the CV_CFL_LANG enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx -using PDB_Lang = codeview::SourceLanguage; - -/// These values correspond to the DataKind enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx -enum class PDB_DataKind { - Unknown, - Local, - StaticLocal, - Param, - ObjectPtr, - FileStatic, - Global, - Member, - StaticMember, - Constant -}; - -/// These values correspond to the SymTagEnum enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx -enum class PDB_SymType { - None, - Exe, - Compiland, - CompilandDetails, - CompilandEnv, - Function, - Block, - Data, - Annotation, - Label, - PublicSymbol, - UDT, - Enum, - FunctionSig, - PointerType, - ArrayType, - BuiltinType, - Typedef, - BaseClass, - Friend, - FunctionArg, - FuncDebugStart, - FuncDebugEnd, - UsingNamespace, - VTableShape, - VTable, - Custom, - Thunk, - CustomType, - ManagedType, - Dimension, - CallSite, - InlineSite, - BaseInterface, - VectorType, - MatrixType, - HLSLType, - Caller, - Callee, - Export, - HeapAllocationSite, - CoffGroup, - Inlinee, - Max -}; - -/// These values correspond to the LocationType enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx -enum class PDB_LocType { - Null, - Static, - TLS, - RegRel, - ThisRel, - Enregistered, - BitField, - Slot, - IlRel, - MetaData, - Constant, - RegRelAliasIndir, - Max -}; - -/// These values correspond to the UdtKind enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx -enum class PDB_UdtType { Struct, Class, Union, Interface }; - -/// These values correspond to the StackFrameTypeEnum enumeration, and are -/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx. -enum class PDB_StackFrameType : uint16_t { - FPO, - KernelTrap, - KernelTSS, - EBP, - FrameData, - Unknown = 0xffff -}; - -/// These values correspond to the MemoryTypeEnum enumeration, and are -/// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx. -enum class PDB_MemoryType : uint16_t { - Code, - Data, - Stack, - HeapCode, - Any = 0xffff -}; - -/// These values correspond to the Basictype enumeration, and are documented -/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx -enum class PDB_BuiltinType { - None = 0, - Void = 1, - Char = 2, - WCharT = 3, - Int = 6, - UInt = 7, - Float = 8, - BCD = 9, - Bool = 10, - Long = 13, - ULong = 14, - Currency = 25, - Date = 26, - Variant = 27, - Complex = 28, - Bitfield = 29, - BSTR = 30, - HResult = 31, - Char16 = 32, - Char32 = 33 -}; - -/// These values correspond to the flags that can be combined to control the -/// return of an undecorated name for a C++ decorated name, and are documented -/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx -enum PDB_UndnameFlags : uint32_t { - Undname_Complete = 0x0, - Undname_NoLeadingUnderscores = 0x1, - Undname_NoMsKeywords = 0x2, - Undname_NoFuncReturns = 0x4, - Undname_NoAllocModel = 0x8, - Undname_NoAllocLang = 0x10, - Undname_Reserved1 = 0x20, - Undname_Reserved2 = 0x40, - Undname_NoThisType = 0x60, - Undname_NoAccessSpec = 0x80, - Undname_NoThrowSig = 0x100, - Undname_NoMemberType = 0x200, - Undname_NoReturnUDTModel = 0x400, - Undname_32BitDecode = 0x800, - Undname_NameOnly = 0x1000, - Undname_TypeOnly = 0x2000, - Undname_HaveParams = 0x4000, - Undname_NoECSU = 0x8000, - Undname_NoIdentCharCheck = 0x10000, - Undname_NoPTR64 = 0x20000 -}; - -enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 }; - -struct VersionInfo { - uint32_t Major; - uint32_t Minor; - uint32_t Build; - uint32_t QFE; -}; - -enum PDB_VariantType { - Empty, - Unknown, - Int8, - Int16, - Int32, - Int64, - Single, - Double, - UInt8, - UInt16, - UInt32, - UInt64, - Bool, - String -}; - -struct Variant { - Variant() = default; - - explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; } - explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; } - explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) { - Value.Int16 = V; - } - explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) { - Value.Int32 = V; - } - explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) { - Value.Int64 = V; - } - explicit Variant(float V) : Type(PDB_VariantType::Single) { - Value.Single = V; - } - explicit Variant(double V) : Type(PDB_VariantType::Double) { - Value.Double = V; - } - explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) { - Value.UInt8 = V; - } - explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) { - Value.UInt16 = V; - } - explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) { - Value.UInt32 = V; - } - explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) { - Value.UInt64 = V; - } - - Variant(const Variant &Other) { - *this = Other; - } - - ~Variant() { - if (Type == PDB_VariantType::String) - delete[] Value.String; - } - - PDB_VariantType Type = PDB_VariantType::Empty; - union { - bool Bool; - int8_t Int8; - int16_t Int16; - int32_t Int32; - int64_t Int64; - float Single; - double Double; - uint8_t UInt8; - uint16_t UInt16; - uint32_t UInt32; - uint64_t UInt64; - char *String; - } Value; - - bool isIntegralType() const { - switch (Type) { - case Bool: - case Int8: - case Int16: - case Int32: - case Int64: - case UInt8: - case UInt16: - case UInt32: - case UInt64: - return true; - default: - return false; - } - } - -#define VARIANT_WIDTH(Enum, NumBits) \ - case PDB_VariantType::Enum: \ - return NumBits; - - unsigned getBitWidth() const { - switch (Type) { - VARIANT_WIDTH(Bool, 1u) - VARIANT_WIDTH(Int8, 8u) - VARIANT_WIDTH(Int16, 16u) - VARIANT_WIDTH(Int32, 32u) - VARIANT_WIDTH(Int64, 64u) - VARIANT_WIDTH(Single, 32u) - VARIANT_WIDTH(Double, 64u) - VARIANT_WIDTH(UInt8, 8u) - VARIANT_WIDTH(UInt16, 16u) - VARIANT_WIDTH(UInt32, 32u) - VARIANT_WIDTH(UInt64, 64u) - default: - assert(false && "Variant::toAPSInt called on non-numeric type"); - return 0u; - } - } - -#undef VARIANT_WIDTH - -#define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \ - case PDB_VariantType::Enum: \ - return APSInt(APInt(NumBits, Value.Enum), IsUnsigned); - - APSInt toAPSInt() const { - switch (Type) { - VARIANT_APSINT(Bool, 1u, true) - VARIANT_APSINT(Int8, 8u, false) - VARIANT_APSINT(Int16, 16u, false) - VARIANT_APSINT(Int32, 32u, false) - VARIANT_APSINT(Int64, 64u, false) - VARIANT_APSINT(UInt8, 8u, true) - VARIANT_APSINT(UInt16, 16u, true) - VARIANT_APSINT(UInt32, 32u, true) - VARIANT_APSINT(UInt64, 64u, true) - default: - assert(false && "Variant::toAPSInt called on non-integral type"); - return APSInt(); - } - } - -#undef VARIANT_APSINT - - APFloat toAPFloat() const { - // Float constants may be tagged as integers. - switch (Type) { - case PDB_VariantType::Single: - case PDB_VariantType::UInt32: - case PDB_VariantType::Int32: - return APFloat(Value.Single); - case PDB_VariantType::Double: - case PDB_VariantType::UInt64: - case PDB_VariantType::Int64: - return APFloat(Value.Double); - default: - assert(false && "Variant::toAPFloat called on non-floating-point type"); - return APFloat::getZero(APFloat::IEEEsingle()); - } - } - -#define VARIANT_EQUAL_CASE(Enum) \ - case PDB_VariantType::Enum: \ - return Value.Enum == Other.Value.Enum; - - bool operator==(const Variant &Other) const { - if (Type != Other.Type) - return false; - switch (Type) { - VARIANT_EQUAL_CASE(Bool) - VARIANT_EQUAL_CASE(Int8) - VARIANT_EQUAL_CASE(Int16) - VARIANT_EQUAL_CASE(Int32) - VARIANT_EQUAL_CASE(Int64) - VARIANT_EQUAL_CASE(Single) - VARIANT_EQUAL_CASE(Double) - VARIANT_EQUAL_CASE(UInt8) - VARIANT_EQUAL_CASE(UInt16) - VARIANT_EQUAL_CASE(UInt32) - VARIANT_EQUAL_CASE(UInt64) - VARIANT_EQUAL_CASE(String) - default: - return true; - } - } - -#undef VARIANT_EQUAL_CASE - - bool operator!=(const Variant &Other) const { return !(*this == Other); } - Variant &operator=(const Variant &Other) { - if (this == &Other) - return *this; - if (Type == PDB_VariantType::String) - delete[] Value.String; - Type = Other.Type; - Value = Other.Value; - if (Other.Type == PDB_VariantType::String && - Other.Value.String != nullptr) { - Value.String = new char[strlen(Other.Value.String) + 1]; - ::strcpy(Value.String, Other.Value.String); - } - return *this; - } -}; - -} // end namespace pdb -} // end namespace llvm - -namespace std { - -template <> struct hash<llvm::pdb::PDB_SymType> { - using argument_type = llvm::pdb::PDB_SymType; - using result_type = std::size_t; - - result_type operator()(const argument_type &Arg) const { - return std::hash<int>()(static_cast<int>(Arg)); - } -}; - -} // end namespace std - -#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- PDBTypes.h - Defines enums for various fields contained in PDB ----====// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H +#define LLVM_DEBUGINFO_PDB_PDBTYPES_H + +#include "llvm/ADT/APFloat.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/IPDBFrameData.h" +#include "llvm/DebugInfo/PDB/Native/RawTypes.h" +#include <cctype> +#include <cstddef> +#include <cstdint> +#include <cstring> +#include <functional> + +namespace llvm { +namespace pdb { + +typedef uint32_t SymIndexId; + +class IPDBDataStream; +class IPDBInjectedSource; +class IPDBLineNumber; +class IPDBSectionContrib; +class IPDBSession; +class IPDBSourceFile; +class IPDBTable; +class PDBSymDumper; +class PDBSymbol; +class PDBSymbolExe; +class PDBSymbolCompiland; +class PDBSymbolCompilandDetails; +class PDBSymbolCompilandEnv; +class PDBSymbolFunc; +class PDBSymbolBlock; +class PDBSymbolData; +class PDBSymbolAnnotation; +class PDBSymbolLabel; +class PDBSymbolPublicSymbol; +class PDBSymbolTypeUDT; +class PDBSymbolTypeEnum; +class PDBSymbolTypeFunctionSig; +class PDBSymbolTypePointer; +class PDBSymbolTypeArray; +class PDBSymbolTypeBuiltin; +class PDBSymbolTypeTypedef; +class PDBSymbolTypeBaseClass; +class PDBSymbolTypeFriend; +class PDBSymbolTypeFunctionArg; +class PDBSymbolFuncDebugStart; +class PDBSymbolFuncDebugEnd; +class PDBSymbolUsingNamespace; +class PDBSymbolTypeVTableShape; +class PDBSymbolTypeVTable; +class PDBSymbolCustom; +class PDBSymbolThunk; +class PDBSymbolTypeCustom; +class PDBSymbolTypeManaged; +class PDBSymbolTypeDimension; +class PDBSymbolUnknown; + +using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>; +using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>; +using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>; +using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>; +using IPDBEnumTables = IPDBEnumChildren<IPDBTable>; +using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>; +using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>; +using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>; + +/// Specifies which PDB reader implementation is to be used. Only a value +/// of PDB_ReaderType::DIA is currently supported, but Native is in the works. +enum class PDB_ReaderType { + DIA = 0, + Native = 1, +}; + +/// An enumeration indicating the type of data contained in this table. +enum class PDB_TableType { + TableInvalid = 0, + Symbols, + SourceFiles, + LineNumbers, + SectionContribs, + Segments, + InjectedSources, + FrameData, + InputAssemblyFiles, + Dbg +}; + +/// Defines flags used for enumerating child symbols. This corresponds to the +/// NameSearchOptions enumeration which is documented here: +/// https://msdn.microsoft.com/en-us/library/yat28ads.aspx +enum PDB_NameSearchFlags { + NS_Default = 0x0, + NS_CaseSensitive = 0x1, + NS_CaseInsensitive = 0x2, + NS_FileNameExtMatch = 0x4, + NS_Regex = 0x8, + NS_UndecoratedName = 0x10, + + // For backward compatibility. + NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch, + NS_CaseRegex = NS_Regex | NS_CaseSensitive, + NS_CaseInRex = NS_Regex | NS_CaseInsensitive +}; + +/// Specifies the hash algorithm that a source file from a PDB was hashed with. +/// This corresponds to the CV_SourceChksum_t enumeration and are documented +/// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx +enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 }; + +/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +using PDB_Cpu = codeview::CPUType; + +enum class PDB_Machine { + Invalid = 0xffff, + Unknown = 0x0, + Am33 = 0x13, + Amd64 = 0x8664, + Arm = 0x1C0, + Arm64 = 0xaa64, + ArmNT = 0x1C4, + Ebc = 0xEBC, + x86 = 0x14C, + Ia64 = 0x200, + M32R = 0x9041, + Mips16 = 0x266, + MipsFpu = 0x366, + MipsFpu16 = 0x466, + PowerPC = 0x1F0, + PowerPCFP = 0x1F1, + R4000 = 0x166, + SH3 = 0x1A2, + SH3DSP = 0x1A3, + SH4 = 0x1A6, + SH5 = 0x1A8, + Thumb = 0x1C2, + WceMipsV2 = 0x169 +}; + +// A struct with an inner unnamed enum with explicit underlying type resuls +// in an enum class that can implicitly convert to the underlying type, which +// is convenient for this enum. +struct PDB_SourceCompression { + enum : uint32_t { + // No compression. Produced e.g. by `link.exe /natvis:foo.natvis`. + None, + // Not known what produces this. + RunLengthEncoded, + // Not known what produces this. + Huffman, + // Not known what produces this. + LZ, + // Produced e.g. by `csc /debug`. The encoded data is its own mini-stream + // with the following layout (in little endian): + // GUID LanguageTypeGuid; + // GUID LanguageVendorGuid; + // GUID DocumentTypeGuid; + // GUID HashFunctionGuid; + // uint32_t HashDataSize; + // uint32_t CompressedDataSize; + // Followed by HashDataSize bytes containing a hash checksum, + // followed by CompressedDataSize bytes containing source contents. + // + // CompressedDataSize can be 0, in this case only the hash data is present. + // (CompressedDataSize is != 0 e.g. if `/embed` is passed to csc.exe.) + // The compressed data format is: + // uint32_t UncompressedDataSize; + // If UncompressedDataSize is 0, the data is stored uncompressed and + // CompressedDataSize stores the uncompressed size. + // If UncompressedDataSize is != 0, then the data is in raw deflate + // encoding as described in rfc1951. + // + // A GUID is 16 bytes, stored in the usual + // uint32_t + // uint16_t + // uint16_t + // uint8_t[24] + // layout. + // + // Well-known GUIDs for LanguageTypeGuid are: + // 63a08714-fc37-11d2-904c-00c04fa302a1 C + // 3a12d0b7-c26c-11d0-b442-00a0244a1dd2 C++ + // 3f5162f8-07c6-11d3-9053-00c04fa302a1 C# + // af046cd1-d0e1-11d2-977c-00a0c9b4d50c Cobol + // ab4f38c9-b6e6-43ba-be3b-58080b2ccce3 F# + // 3a12d0b4-c26c-11d0-b442-00a0244a1dd2 Java + // 3a12d0b6-c26c-11d0-b442-00a0244a1dd2 JScript + // af046cd2-d0e1-11d2-977c-00a0c9b4d50c Pascal + // 3a12d0b8-c26c-11d0-b442-00a0244a1dd2 Visual Basic + // + // Well-known GUIDs for LanguageVendorGuid are: + // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft + // + // Well-known GUIDs for DocumentTypeGuid are: + // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text + // + // Well-known GUIDs for HashFunctionGuid are: + // 406ea660-64cf-4c82-b6f0-42d48172a799 MD5 (HashDataSize is 16) + // ff1816ec-aa5e-4d10-87f7-6f4963833460 SHA1 (HashDataSize is 20) + // 8829d00f-11b8-4213-878b-770e8597ac16 SHA256 (HashDataSize is 32) + DotNet = 101, + }; +}; + +/// These values correspond to the CV_call_e enumeration, and are documented +/// at the following locations: +/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx +/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx +using PDB_CallingConv = codeview::CallingConvention; + +/// These values correspond to the CV_CFL_LANG enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx +using PDB_Lang = codeview::SourceLanguage; + +/// These values correspond to the DataKind enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx +enum class PDB_DataKind { + Unknown, + Local, + StaticLocal, + Param, + ObjectPtr, + FileStatic, + Global, + Member, + StaticMember, + Constant +}; + +/// These values correspond to the SymTagEnum enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx +enum class PDB_SymType { + None, + Exe, + Compiland, + CompilandDetails, + CompilandEnv, + Function, + Block, + Data, + Annotation, + Label, + PublicSymbol, + UDT, + Enum, + FunctionSig, + PointerType, + ArrayType, + BuiltinType, + Typedef, + BaseClass, + Friend, + FunctionArg, + FuncDebugStart, + FuncDebugEnd, + UsingNamespace, + VTableShape, + VTable, + Custom, + Thunk, + CustomType, + ManagedType, + Dimension, + CallSite, + InlineSite, + BaseInterface, + VectorType, + MatrixType, + HLSLType, + Caller, + Callee, + Export, + HeapAllocationSite, + CoffGroup, + Inlinee, + Max +}; + +/// These values correspond to the LocationType enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx +enum class PDB_LocType { + Null, + Static, + TLS, + RegRel, + ThisRel, + Enregistered, + BitField, + Slot, + IlRel, + MetaData, + Constant, + RegRelAliasIndir, + Max +}; + +/// These values correspond to the UdtKind enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx +enum class PDB_UdtType { Struct, Class, Union, Interface }; + +/// These values correspond to the StackFrameTypeEnum enumeration, and are +/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx. +enum class PDB_StackFrameType : uint16_t { + FPO, + KernelTrap, + KernelTSS, + EBP, + FrameData, + Unknown = 0xffff +}; + +/// These values correspond to the MemoryTypeEnum enumeration, and are +/// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx. +enum class PDB_MemoryType : uint16_t { + Code, + Data, + Stack, + HeapCode, + Any = 0xffff +}; + +/// These values correspond to the Basictype enumeration, and are documented +/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx +enum class PDB_BuiltinType { + None = 0, + Void = 1, + Char = 2, + WCharT = 3, + Int = 6, + UInt = 7, + Float = 8, + BCD = 9, + Bool = 10, + Long = 13, + ULong = 14, + Currency = 25, + Date = 26, + Variant = 27, + Complex = 28, + Bitfield = 29, + BSTR = 30, + HResult = 31, + Char16 = 32, + Char32 = 33 +}; + +/// These values correspond to the flags that can be combined to control the +/// return of an undecorated name for a C++ decorated name, and are documented +/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx +enum PDB_UndnameFlags : uint32_t { + Undname_Complete = 0x0, + Undname_NoLeadingUnderscores = 0x1, + Undname_NoMsKeywords = 0x2, + Undname_NoFuncReturns = 0x4, + Undname_NoAllocModel = 0x8, + Undname_NoAllocLang = 0x10, + Undname_Reserved1 = 0x20, + Undname_Reserved2 = 0x40, + Undname_NoThisType = 0x60, + Undname_NoAccessSpec = 0x80, + Undname_NoThrowSig = 0x100, + Undname_NoMemberType = 0x200, + Undname_NoReturnUDTModel = 0x400, + Undname_32BitDecode = 0x800, + Undname_NameOnly = 0x1000, + Undname_TypeOnly = 0x2000, + Undname_HaveParams = 0x4000, + Undname_NoECSU = 0x8000, + Undname_NoIdentCharCheck = 0x10000, + Undname_NoPTR64 = 0x20000 +}; + +enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 }; + +struct VersionInfo { + uint32_t Major; + uint32_t Minor; + uint32_t Build; + uint32_t QFE; +}; + +enum PDB_VariantType { + Empty, + Unknown, + Int8, + Int16, + Int32, + Int64, + Single, + Double, + UInt8, + UInt16, + UInt32, + UInt64, + Bool, + String +}; + +struct Variant { + Variant() = default; + + explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; } + explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; } + explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) { + Value.Int16 = V; + } + explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) { + Value.Int32 = V; + } + explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) { + Value.Int64 = V; + } + explicit Variant(float V) : Type(PDB_VariantType::Single) { + Value.Single = V; + } + explicit Variant(double V) : Type(PDB_VariantType::Double) { + Value.Double = V; + } + explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) { + Value.UInt8 = V; + } + explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) { + Value.UInt16 = V; + } + explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) { + Value.UInt32 = V; + } + explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) { + Value.UInt64 = V; + } + + Variant(const Variant &Other) { + *this = Other; + } + + ~Variant() { + if (Type == PDB_VariantType::String) + delete[] Value.String; + } + + PDB_VariantType Type = PDB_VariantType::Empty; + union { + bool Bool; + int8_t Int8; + int16_t Int16; + int32_t Int32; + int64_t Int64; + float Single; + double Double; + uint8_t UInt8; + uint16_t UInt16; + uint32_t UInt32; + uint64_t UInt64; + char *String; + } Value; + + bool isIntegralType() const { + switch (Type) { + case Bool: + case Int8: + case Int16: + case Int32: + case Int64: + case UInt8: + case UInt16: + case UInt32: + case UInt64: + return true; + default: + return false; + } + } + +#define VARIANT_WIDTH(Enum, NumBits) \ + case PDB_VariantType::Enum: \ + return NumBits; + + unsigned getBitWidth() const { + switch (Type) { + VARIANT_WIDTH(Bool, 1u) + VARIANT_WIDTH(Int8, 8u) + VARIANT_WIDTH(Int16, 16u) + VARIANT_WIDTH(Int32, 32u) + VARIANT_WIDTH(Int64, 64u) + VARIANT_WIDTH(Single, 32u) + VARIANT_WIDTH(Double, 64u) + VARIANT_WIDTH(UInt8, 8u) + VARIANT_WIDTH(UInt16, 16u) + VARIANT_WIDTH(UInt32, 32u) + VARIANT_WIDTH(UInt64, 64u) + default: + assert(false && "Variant::toAPSInt called on non-numeric type"); + return 0u; + } + } + +#undef VARIANT_WIDTH + +#define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \ + case PDB_VariantType::Enum: \ + return APSInt(APInt(NumBits, Value.Enum), IsUnsigned); + + APSInt toAPSInt() const { + switch (Type) { + VARIANT_APSINT(Bool, 1u, true) + VARIANT_APSINT(Int8, 8u, false) + VARIANT_APSINT(Int16, 16u, false) + VARIANT_APSINT(Int32, 32u, false) + VARIANT_APSINT(Int64, 64u, false) + VARIANT_APSINT(UInt8, 8u, true) + VARIANT_APSINT(UInt16, 16u, true) + VARIANT_APSINT(UInt32, 32u, true) + VARIANT_APSINT(UInt64, 64u, true) + default: + assert(false && "Variant::toAPSInt called on non-integral type"); + return APSInt(); + } + } + +#undef VARIANT_APSINT + + APFloat toAPFloat() const { + // Float constants may be tagged as integers. + switch (Type) { + case PDB_VariantType::Single: + case PDB_VariantType::UInt32: + case PDB_VariantType::Int32: + return APFloat(Value.Single); + case PDB_VariantType::Double: + case PDB_VariantType::UInt64: + case PDB_VariantType::Int64: + return APFloat(Value.Double); + default: + assert(false && "Variant::toAPFloat called on non-floating-point type"); + return APFloat::getZero(APFloat::IEEEsingle()); + } + } + +#define VARIANT_EQUAL_CASE(Enum) \ + case PDB_VariantType::Enum: \ + return Value.Enum == Other.Value.Enum; + + bool operator==(const Variant &Other) const { + if (Type != Other.Type) + return false; + switch (Type) { + VARIANT_EQUAL_CASE(Bool) + VARIANT_EQUAL_CASE(Int8) + VARIANT_EQUAL_CASE(Int16) + VARIANT_EQUAL_CASE(Int32) + VARIANT_EQUAL_CASE(Int64) + VARIANT_EQUAL_CASE(Single) + VARIANT_EQUAL_CASE(Double) + VARIANT_EQUAL_CASE(UInt8) + VARIANT_EQUAL_CASE(UInt16) + VARIANT_EQUAL_CASE(UInt32) + VARIANT_EQUAL_CASE(UInt64) + VARIANT_EQUAL_CASE(String) + default: + return true; + } + } + +#undef VARIANT_EQUAL_CASE + + bool operator!=(const Variant &Other) const { return !(*this == Other); } + Variant &operator=(const Variant &Other) { + if (this == &Other) + return *this; + if (Type == PDB_VariantType::String) + delete[] Value.String; + Type = Other.Type; + Value = Other.Value; + if (Other.Type == PDB_VariantType::String && + Other.Value.String != nullptr) { + Value.String = new char[strlen(Other.Value.String) + 1]; + ::strcpy(Value.String, Other.Value.String); + } + return *this; + } +}; + +} // end namespace pdb +} // end namespace llvm + +namespace std { + +template <> struct hash<llvm::pdb::PDB_SymType> { + using argument_type = llvm::pdb::PDB_SymType; + using result_type = std::size_t; + + result_type operator()(const argument_type &Arg) const { + return std::hash<int>()(static_cast<int>(Arg)); + } +}; + +} // end namespace std + +#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/UDTLayout.h b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/UDTLayout.h index ca5df474c5..58b6291f6c 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/UDTLayout.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/PDB/UDTLayout.h @@ -1,192 +1,192 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- UDTLayout.h - UDT layout info ----------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_PDB_UDTLAYOUT_H -#define LLVM_DEBUGINFO_PDB_UDTLAYOUT_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/BitVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/PDB/PDBSymbol.h" -#include "llvm/DebugInfo/PDB/PDBSymbolData.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" -#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" -#include "llvm/DebugInfo/PDB/PDBTypes.h" -#include <cstdint> -#include <memory> -#include <string> -#include <vector> - -namespace llvm { -namespace pdb { - -class BaseClassLayout; -class ClassLayout; -class UDTLayoutBase; - -class LayoutItemBase { -public: - LayoutItemBase(const UDTLayoutBase *Parent, const PDBSymbol *Symbol, - const std::string &Name, uint32_t OffsetInParent, - uint32_t Size, bool IsElided); - virtual ~LayoutItemBase() = default; - - uint32_t deepPaddingSize() const; - virtual uint32_t immediatePadding() const { return 0; } - virtual uint32_t tailPadding() const; - - const UDTLayoutBase *getParent() const { return Parent; } - StringRef getName() const { return Name; } - uint32_t getOffsetInParent() const { return OffsetInParent; } - uint32_t getSize() const { return SizeOf; } - uint32_t getLayoutSize() const { return LayoutSize; } - const PDBSymbol *getSymbol() const { return Symbol; } - const BitVector &usedBytes() const { return UsedBytes; } - bool isElided() const { return IsElided; } - virtual bool isVBPtr() const { return false; } - - uint32_t containsOffset(uint32_t Off) const { - uint32_t Begin = getOffsetInParent(); - uint32_t End = Begin + getSize(); - return (Off >= Begin && Off < End); - } - -protected: - const PDBSymbol *Symbol = nullptr; - const UDTLayoutBase *Parent = nullptr; - BitVector UsedBytes; - std::string Name; - uint32_t OffsetInParent = 0; - uint32_t SizeOf = 0; - uint32_t LayoutSize = 0; - bool IsElided = false; -}; - -class VBPtrLayoutItem : public LayoutItemBase { -public: - VBPtrLayoutItem(const UDTLayoutBase &Parent, - std::unique_ptr<PDBSymbolTypeBuiltin> Sym, uint32_t Offset, - uint32_t Size); - - bool isVBPtr() const override { return true; } - -private: - std::unique_ptr<PDBSymbolTypeBuiltin> Type; -}; - -class DataMemberLayoutItem : public LayoutItemBase { -public: - DataMemberLayoutItem(const UDTLayoutBase &Parent, - std::unique_ptr<PDBSymbolData> DataMember); - - const PDBSymbolData &getDataMember(); - bool hasUDTLayout() const; - const ClassLayout &getUDTLayout() const; - -private: - std::unique_ptr<PDBSymbolData> DataMember; - std::unique_ptr<ClassLayout> UdtLayout; -}; - -class VTableLayoutItem : public LayoutItemBase { -public: - VTableLayoutItem(const UDTLayoutBase &Parent, - std::unique_ptr<PDBSymbolTypeVTable> VTable); - - uint32_t getElementSize() const { return ElementSize; } - -private: - uint32_t ElementSize = 0; - std::unique_ptr<PDBSymbolTypeVTable> VTable; -}; - -class UDTLayoutBase : public LayoutItemBase { - template <typename T> using UniquePtrVector = std::vector<std::unique_ptr<T>>; - -public: - UDTLayoutBase(const UDTLayoutBase *Parent, const PDBSymbol &Sym, - const std::string &Name, uint32_t OffsetInParent, uint32_t Size, - bool IsElided); - - uint32_t tailPadding() const override; - ArrayRef<LayoutItemBase *> layout_items() const { return LayoutItems; } - ArrayRef<BaseClassLayout *> bases() const { return AllBases; } - ArrayRef<BaseClassLayout *> regular_bases() const { return NonVirtualBases; } - ArrayRef<BaseClassLayout *> virtual_bases() const { return VirtualBases; } - uint32_t directVirtualBaseCount() const { return DirectVBaseCount; } - ArrayRef<std::unique_ptr<PDBSymbolFunc>> funcs() const { return Funcs; } - ArrayRef<std::unique_ptr<PDBSymbol>> other_items() const { return Other; } - -protected: - bool hasVBPtrAtOffset(uint32_t Off) const; - void initializeChildren(const PDBSymbol &Sym); - - void addChildToLayout(std::unique_ptr<LayoutItemBase> Child); - - uint32_t DirectVBaseCount = 0; - - UniquePtrVector<PDBSymbol> Other; - UniquePtrVector<PDBSymbolFunc> Funcs; - UniquePtrVector<LayoutItemBase> ChildStorage; - std::vector<LayoutItemBase *> LayoutItems; - - std::vector<BaseClassLayout *> AllBases; - ArrayRef<BaseClassLayout *> NonVirtualBases; - ArrayRef<BaseClassLayout *> VirtualBases; - - VTableLayoutItem *VTable = nullptr; - VBPtrLayoutItem *VBPtr = nullptr; -}; - -class BaseClassLayout : public UDTLayoutBase { -public: - BaseClassLayout(const UDTLayoutBase &Parent, uint32_t OffsetInParent, - bool Elide, std::unique_ptr<PDBSymbolTypeBaseClass> Base); - - const PDBSymbolTypeBaseClass &getBase() const { return *Base; } - bool isVirtualBase() const { return IsVirtualBase; } - bool isEmptyBase() { return SizeOf == 1 && LayoutSize == 0; } - -private: - std::unique_ptr<PDBSymbolTypeBaseClass> Base; - bool IsVirtualBase; -}; - -class ClassLayout : public UDTLayoutBase { -public: - explicit ClassLayout(const PDBSymbolTypeUDT &UDT); - explicit ClassLayout(std::unique_ptr<PDBSymbolTypeUDT> UDT); - - ClassLayout(ClassLayout &&Other) = default; - - const PDBSymbolTypeUDT &getClass() const { return UDT; } - uint32_t immediatePadding() const override; - -private: - BitVector ImmediateUsedBytes; - std::unique_ptr<PDBSymbolTypeUDT> OwnedStorage; - const PDBSymbolTypeUDT &UDT; -}; - -} // end namespace pdb -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_PDB_UDTLAYOUT_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- UDTLayout.h - UDT layout info ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_UDTLAYOUT_H +#define LLVM_DEBUGINFO_PDB_UDTLAYOUT_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" +#include "llvm/DebugInfo/PDB/PDBSymbolData.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" +#include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" +#include "llvm/DebugInfo/PDB/PDBTypes.h" +#include <cstdint> +#include <memory> +#include <string> +#include <vector> + +namespace llvm { +namespace pdb { + +class BaseClassLayout; +class ClassLayout; +class UDTLayoutBase; + +class LayoutItemBase { +public: + LayoutItemBase(const UDTLayoutBase *Parent, const PDBSymbol *Symbol, + const std::string &Name, uint32_t OffsetInParent, + uint32_t Size, bool IsElided); + virtual ~LayoutItemBase() = default; + + uint32_t deepPaddingSize() const; + virtual uint32_t immediatePadding() const { return 0; } + virtual uint32_t tailPadding() const; + + const UDTLayoutBase *getParent() const { return Parent; } + StringRef getName() const { return Name; } + uint32_t getOffsetInParent() const { return OffsetInParent; } + uint32_t getSize() const { return SizeOf; } + uint32_t getLayoutSize() const { return LayoutSize; } + const PDBSymbol *getSymbol() const { return Symbol; } + const BitVector &usedBytes() const { return UsedBytes; } + bool isElided() const { return IsElided; } + virtual bool isVBPtr() const { return false; } + + uint32_t containsOffset(uint32_t Off) const { + uint32_t Begin = getOffsetInParent(); + uint32_t End = Begin + getSize(); + return (Off >= Begin && Off < End); + } + +protected: + const PDBSymbol *Symbol = nullptr; + const UDTLayoutBase *Parent = nullptr; + BitVector UsedBytes; + std::string Name; + uint32_t OffsetInParent = 0; + uint32_t SizeOf = 0; + uint32_t LayoutSize = 0; + bool IsElided = false; +}; + +class VBPtrLayoutItem : public LayoutItemBase { +public: + VBPtrLayoutItem(const UDTLayoutBase &Parent, + std::unique_ptr<PDBSymbolTypeBuiltin> Sym, uint32_t Offset, + uint32_t Size); + + bool isVBPtr() const override { return true; } + +private: + std::unique_ptr<PDBSymbolTypeBuiltin> Type; +}; + +class DataMemberLayoutItem : public LayoutItemBase { +public: + DataMemberLayoutItem(const UDTLayoutBase &Parent, + std::unique_ptr<PDBSymbolData> DataMember); + + const PDBSymbolData &getDataMember(); + bool hasUDTLayout() const; + const ClassLayout &getUDTLayout() const; + +private: + std::unique_ptr<PDBSymbolData> DataMember; + std::unique_ptr<ClassLayout> UdtLayout; +}; + +class VTableLayoutItem : public LayoutItemBase { +public: + VTableLayoutItem(const UDTLayoutBase &Parent, + std::unique_ptr<PDBSymbolTypeVTable> VTable); + + uint32_t getElementSize() const { return ElementSize; } + +private: + uint32_t ElementSize = 0; + std::unique_ptr<PDBSymbolTypeVTable> VTable; +}; + +class UDTLayoutBase : public LayoutItemBase { + template <typename T> using UniquePtrVector = std::vector<std::unique_ptr<T>>; + +public: + UDTLayoutBase(const UDTLayoutBase *Parent, const PDBSymbol &Sym, + const std::string &Name, uint32_t OffsetInParent, uint32_t Size, + bool IsElided); + + uint32_t tailPadding() const override; + ArrayRef<LayoutItemBase *> layout_items() const { return LayoutItems; } + ArrayRef<BaseClassLayout *> bases() const { return AllBases; } + ArrayRef<BaseClassLayout *> regular_bases() const { return NonVirtualBases; } + ArrayRef<BaseClassLayout *> virtual_bases() const { return VirtualBases; } + uint32_t directVirtualBaseCount() const { return DirectVBaseCount; } + ArrayRef<std::unique_ptr<PDBSymbolFunc>> funcs() const { return Funcs; } + ArrayRef<std::unique_ptr<PDBSymbol>> other_items() const { return Other; } + +protected: + bool hasVBPtrAtOffset(uint32_t Off) const; + void initializeChildren(const PDBSymbol &Sym); + + void addChildToLayout(std::unique_ptr<LayoutItemBase> Child); + + uint32_t DirectVBaseCount = 0; + + UniquePtrVector<PDBSymbol> Other; + UniquePtrVector<PDBSymbolFunc> Funcs; + UniquePtrVector<LayoutItemBase> ChildStorage; + std::vector<LayoutItemBase *> LayoutItems; + + std::vector<BaseClassLayout *> AllBases; + ArrayRef<BaseClassLayout *> NonVirtualBases; + ArrayRef<BaseClassLayout *> VirtualBases; + + VTableLayoutItem *VTable = nullptr; + VBPtrLayoutItem *VBPtr = nullptr; +}; + +class BaseClassLayout : public UDTLayoutBase { +public: + BaseClassLayout(const UDTLayoutBase &Parent, uint32_t OffsetInParent, + bool Elide, std::unique_ptr<PDBSymbolTypeBaseClass> Base); + + const PDBSymbolTypeBaseClass &getBase() const { return *Base; } + bool isVirtualBase() const { return IsVirtualBase; } + bool isEmptyBase() { return SizeOf == 1 && LayoutSize == 0; } + +private: + std::unique_ptr<PDBSymbolTypeBaseClass> Base; + bool IsVirtualBase; +}; + +class ClassLayout : public UDTLayoutBase { +public: + explicit ClassLayout(const PDBSymbolTypeUDT &UDT); + explicit ClassLayout(std::unique_ptr<PDBSymbolTypeUDT> UDT); + + ClassLayout(ClassLayout &&Other) = default; + + const PDBSymbolTypeUDT &getClass() const { return UDT; } + uint32_t immediatePadding() const override; + +private: + BitVector ImmediateUsedBytes; + std::unique_ptr<PDBSymbolTypeUDT> OwnedStorage; + const PDBSymbolTypeUDT &UDT; +}; + +} // end namespace pdb +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_UDTLAYOUT_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/DIPrinter.h index b32eacce61..d5c9cb8be5 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/DIPrinter.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/DIPrinter.h @@ -1,70 +1,70 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- llvm/DebugInfo/Symbolize/DIPrinter.h ---------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file declares the DIPrinter class, which is responsible for printing -// structures defined in DebugInfo/DIContext.h -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H -#define LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H - -#include <string> - -namespace llvm { -struct DILineInfo; -class DIInliningInfo; -struct DIGlobal; -struct DILocal; -class raw_ostream; - -namespace symbolize { - -class DIPrinter { -public: - enum class OutputStyle { LLVM, GNU }; - -private: - raw_ostream &OS; - bool PrintFunctionNames; - bool PrintPretty; - int PrintSourceContext; - bool Verbose; - OutputStyle Style; - - void print(const DILineInfo &Info, bool Inlined); - void printContext(const std::string &FileName, int64_t Line); - -public: - DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true, - bool PrintPretty = false, int PrintSourceContext = 0, - bool Verbose = false, OutputStyle Style = OutputStyle::LLVM) - : OS(OS), PrintFunctionNames(PrintFunctionNames), - PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext), - Verbose(Verbose), Style(Style) {} - - DIPrinter &operator<<(const DILineInfo &Info); - DIPrinter &operator<<(const DIInliningInfo &Info); - DIPrinter &operator<<(const DIGlobal &Global); - DIPrinter &operator<<(const DILocal &Local); -}; -} -} - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- llvm/DebugInfo/Symbolize/DIPrinter.h ---------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the DIPrinter class, which is responsible for printing +// structures defined in DebugInfo/DIContext.h +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H +#define LLVM_DEBUGINFO_SYMBOLIZE_DIPRINTER_H + +#include <string> + +namespace llvm { +struct DILineInfo; +class DIInliningInfo; +struct DIGlobal; +struct DILocal; +class raw_ostream; + +namespace symbolize { + +class DIPrinter { +public: + enum class OutputStyle { LLVM, GNU }; + +private: + raw_ostream &OS; + bool PrintFunctionNames; + bool PrintPretty; + int PrintSourceContext; + bool Verbose; + OutputStyle Style; + + void print(const DILineInfo &Info, bool Inlined); + void printContext(const std::string &FileName, int64_t Line); + +public: + DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true, + bool PrintPretty = false, int PrintSourceContext = 0, + bool Verbose = false, OutputStyle Style = OutputStyle::LLVM) + : OS(OS), PrintFunctionNames(PrintFunctionNames), + PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext), + Verbose(Verbose), Style(Style) {} + + DIPrinter &operator<<(const DILineInfo &Info); + DIPrinter &operator<<(const DIInliningInfo &Info); + DIPrinter &operator<<(const DIGlobal &Global); + DIPrinter &operator<<(const DILocal &Local); +}; +} +} + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h index f34aacad12..9273fde00e 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h @@ -1,61 +1,61 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SymbolizableModule.h -------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file declares the SymbolizableModule interface. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H -#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H - -#include "llvm/DebugInfo/DIContext.h" -#include <cstdint> - -namespace llvm { -namespace symbolize { - -using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; - -class SymbolizableModule { -public: - virtual ~SymbolizableModule() = default; - - virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset, - DILineInfoSpecifier LineInfoSpecifier, - bool UseSymbolTable) const = 0; - virtual DIInliningInfo - symbolizeInlinedCode(object::SectionedAddress ModuleOffset, - DILineInfoSpecifier LineInfoSpecifier, - bool UseSymbolTable) const = 0; - virtual DIGlobal - symbolizeData(object::SectionedAddress ModuleOffset) const = 0; - virtual std::vector<DILocal> - symbolizeFrame(object::SectionedAddress ModuleOffset) const = 0; - - // Return true if this is a 32-bit x86 PE COFF module. - virtual bool isWin32Module() const = 0; - - // Returns the preferred base of the module, i.e. where the loader would place - // it in memory assuming there were no conflicts. - virtual uint64_t getModulePreferredBase() const = 0; -}; - -} // end namespace symbolize -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SymbolizableModule.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the SymbolizableModule interface. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H +#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H + +#include "llvm/DebugInfo/DIContext.h" +#include <cstdint> + +namespace llvm { +namespace symbolize { + +using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; + +class SymbolizableModule { +public: + virtual ~SymbolizableModule() = default; + + virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset, + DILineInfoSpecifier LineInfoSpecifier, + bool UseSymbolTable) const = 0; + virtual DIInliningInfo + symbolizeInlinedCode(object::SectionedAddress ModuleOffset, + DILineInfoSpecifier LineInfoSpecifier, + bool UseSymbolTable) const = 0; + virtual DIGlobal + symbolizeData(object::SectionedAddress ModuleOffset) const = 0; + virtual std::vector<DILocal> + symbolizeFrame(object::SectionedAddress ModuleOffset) const = 0; + + // Return true if this is a 32-bit x86 PE COFF module. + virtual bool isWin32Module() const = 0; + + // Returns the preferred base of the module, i.e. where the loader would place + // it in memory assuming there were no conflicts. + virtual uint64_t getModulePreferredBase() const = 0; +}; + +} // end namespace symbolize +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/Symbolize.h b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/Symbolize.h index 9f1730d03b..d141990421 100644 --- a/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/contrib/libs/llvm12/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -1,152 +1,152 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- Symbolize.h ----------------------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Header for LLVM symbolization library. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H -#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H - -#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" -#include "llvm/Object/Binary.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Object/ELFObjectFile.h" -#include "llvm/Support/Error.h" -#include <algorithm> -#include <cstdint> -#include <map> -#include <memory> -#include <string> -#include <utility> -#include <vector> - -namespace llvm { -namespace symbolize { - -using namespace object; - -using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; -using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind; - -class LLVMSymbolizer { -public: - struct Options { - FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName; - FileLineInfoKind PathStyle = FileLineInfoKind::AbsoluteFilePath; - bool UseSymbolTable = true; - bool Demangle = true; - bool RelativeAddresses = false; - bool UntagAddresses = false; +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- Symbolize.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Header for LLVM symbolization library. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H +#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H + +#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" +#include "llvm/Object/Binary.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Object/ELFObjectFile.h" +#include "llvm/Support/Error.h" +#include <algorithm> +#include <cstdint> +#include <map> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +namespace llvm { +namespace symbolize { + +using namespace object; + +using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; +using FileLineInfoKind = DILineInfoSpecifier::FileLineInfoKind; + +class LLVMSymbolizer { +public: + struct Options { + FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName; + FileLineInfoKind PathStyle = FileLineInfoKind::AbsoluteFilePath; + bool UseSymbolTable = true; + bool Demangle = true; + bool RelativeAddresses = false; + bool UntagAddresses = false; bool UseDIA = false; - std::string DefaultArch; - std::vector<std::string> DsymHints; - std::string FallbackDebugPath; - std::string DWPName; - std::vector<std::string> DebugFileDirectory; - }; - - LLVMSymbolizer() = default; - LLVMSymbolizer(const Options &Opts) : Opts(Opts) {} - - ~LLVMSymbolizer() { - flush(); - } - - Expected<DILineInfo> symbolizeCode(const ObjectFile &Obj, - object::SectionedAddress ModuleOffset); - Expected<DILineInfo> symbolizeCode(const std::string &ModuleName, - object::SectionedAddress ModuleOffset); - Expected<DIInliningInfo> - symbolizeInlinedCode(const std::string &ModuleName, - object::SectionedAddress ModuleOffset); - Expected<DIGlobal> symbolizeData(const std::string &ModuleName, - object::SectionedAddress ModuleOffset); - Expected<std::vector<DILocal>> - symbolizeFrame(const std::string &ModuleName, - object::SectionedAddress ModuleOffset); - void flush(); - - static std::string - DemangleName(const std::string &Name, - const SymbolizableModule *DbiModuleDescriptor); - -private: - // Bundles together object file with code/data and object file with - // corresponding debug info. These objects can be the same. - using ObjectPair = std::pair<const ObjectFile *, const ObjectFile *>; - - Expected<DILineInfo> - symbolizeCodeCommon(SymbolizableModule *Info, - object::SectionedAddress ModuleOffset); - - /// 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 reported once. Subsequent calls to get module info for a module that - /// failed to load will return nullptr. - Expected<SymbolizableModule *> - getOrCreateModuleInfo(const std::string &ModuleName); - - Expected<SymbolizableModule *> - createModuleInfo(const ObjectFile *Obj, - std::unique_ptr<DIContext> Context, - StringRef ModuleName); - - ObjectFile *lookUpDsymFile(const std::string &Path, - const MachOObjectFile *ExeObj, - const std::string &ArchName); - ObjectFile *lookUpDebuglinkObject(const std::string &Path, - const ObjectFile *Obj, - const std::string &ArchName); - ObjectFile *lookUpBuildIDObject(const std::string &Path, - const ELFObjectFileBase *Obj, - const std::string &ArchName); - - /// Returns pair of pointers to object and debug object. - Expected<ObjectPair> getOrCreateObjectPair(const std::string &Path, - const std::string &ArchName); - - /// Return a pointer to object file at specified path, for a specified - /// architecture (e.g. if path refers to a Mach-O universal binary, only one - /// object file from it will be returned). - Expected<ObjectFile *> getOrCreateObject(const std::string &Path, - const std::string &ArchName); - - std::map<std::string, std::unique_ptr<SymbolizableModule>, std::less<>> - Modules; - - /// Contains cached results of getOrCreateObjectPair(). - std::map<std::pair<std::string, std::string>, ObjectPair> - ObjectPairForPathArch; - - /// Contains parsed binary for each path, or parsing error. - std::map<std::string, OwningBinary<Binary>> BinaryForPath; - - /// Parsed object file for path/architecture pair, where "path" refers - /// to Mach-O universal binary. - std::map<std::pair<std::string, std::string>, std::unique_ptr<ObjectFile>> - ObjectForUBPathAndArch; - - Options Opts; -}; - -} // end namespace symbolize -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + std::string DefaultArch; + std::vector<std::string> DsymHints; + std::string FallbackDebugPath; + std::string DWPName; + std::vector<std::string> DebugFileDirectory; + }; + + LLVMSymbolizer() = default; + LLVMSymbolizer(const Options &Opts) : Opts(Opts) {} + + ~LLVMSymbolizer() { + flush(); + } + + Expected<DILineInfo> symbolizeCode(const ObjectFile &Obj, + object::SectionedAddress ModuleOffset); + Expected<DILineInfo> symbolizeCode(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); + Expected<DIInliningInfo> + symbolizeInlinedCode(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); + Expected<DIGlobal> symbolizeData(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); + Expected<std::vector<DILocal>> + symbolizeFrame(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); + void flush(); + + static std::string + DemangleName(const std::string &Name, + const SymbolizableModule *DbiModuleDescriptor); + +private: + // Bundles together object file with code/data and object file with + // corresponding debug info. These objects can be the same. + using ObjectPair = std::pair<const ObjectFile *, const ObjectFile *>; + + Expected<DILineInfo> + symbolizeCodeCommon(SymbolizableModule *Info, + object::SectionedAddress ModuleOffset); + + /// 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 reported once. Subsequent calls to get module info for a module that + /// failed to load will return nullptr. + Expected<SymbolizableModule *> + getOrCreateModuleInfo(const std::string &ModuleName); + + Expected<SymbolizableModule *> + createModuleInfo(const ObjectFile *Obj, + std::unique_ptr<DIContext> Context, + StringRef ModuleName); + + ObjectFile *lookUpDsymFile(const std::string &Path, + const MachOObjectFile *ExeObj, + const std::string &ArchName); + ObjectFile *lookUpDebuglinkObject(const std::string &Path, + const ObjectFile *Obj, + const std::string &ArchName); + ObjectFile *lookUpBuildIDObject(const std::string &Path, + const ELFObjectFileBase *Obj, + const std::string &ArchName); + + /// Returns pair of pointers to object and debug object. + Expected<ObjectPair> getOrCreateObjectPair(const std::string &Path, + const std::string &ArchName); + + /// Return a pointer to object file at specified path, for a specified + /// architecture (e.g. if path refers to a Mach-O universal binary, only one + /// object file from it will be returned). + Expected<ObjectFile *> getOrCreateObject(const std::string &Path, + const std::string &ArchName); + + std::map<std::string, std::unique_ptr<SymbolizableModule>, std::less<>> + Modules; + + /// Contains cached results of getOrCreateObjectPair(). + std::map<std::pair<std::string, std::string>, ObjectPair> + ObjectPairForPathArch; + + /// Contains parsed binary for each path, or parsing error. + std::map<std::string, OwningBinary<Binary>> BinaryForPath; + + /// Parsed object file for path/architecture pair, where "path" refers + /// to Mach-O universal binary. + std::map<std::pair<std::string, std::string>, std::unique_ptr<ObjectFile>> + ObjectForUBPathAndArch; + + Options Opts; +}; + +} // end namespace symbolize +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif |