Skip to content

[llvm] annotate interfaces in llvm/DebugInfo for DLL export #140778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/DebugInfo/BTF/BTFContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

#include "llvm/DebugInfo/BTF/BTFParser.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

class BTFContext final : public DIContext {
class LLVM_ABI BTFContext final : public DIContext {
BTFParser BTF;

public:
Expand Down
18 changes: 10 additions & 8 deletions llvm/include/llvm/DebugInfo/BTF/BTFParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/BTF/BTF.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataExtractor.h"

namespace llvm {
Expand Down Expand Up @@ -74,32 +75,33 @@ class BTFParser {
public:
// Looks-up a string in the .BTF section's string table.
// Offset is relative to string table start.
StringRef findString(uint32_t Offset) const;
LLVM_ABI StringRef findString(uint32_t Offset) const;

// Search for line information for a specific address,
// address match is exact (contrary to DWARFContext).
// Return nullptr if no information found.
// If information is present, return a pointer to object
// owned by this class.
const BTF::BPFLineInfo *findLineInfo(SectionedAddress Address) const;
LLVM_ABI const BTF::BPFLineInfo *findLineInfo(SectionedAddress Address) const;

// Search for CO-RE relocation information for a specific address.
// Return nullptr if no information found.
// If information is present, return a pointer to object
// owned by this class.
const BTF::BPFFieldReloc *findFieldReloc(SectionedAddress Address) const;
LLVM_ABI const BTF::BPFFieldReloc *
findFieldReloc(SectionedAddress Address) const;

// Return a human readable representation of the CO-RE relocation
// record, this is for display purpose only.
// See implementation for details.
void symbolize(const BTF::BPFFieldReloc *Reloc,
SmallVectorImpl<char> &Result) const;
LLVM_ABI void symbolize(const BTF::BPFFieldReloc *Reloc,
SmallVectorImpl<char> &Result) const;

// Lookup BTF type definition with a specific index.
// Return nullptr if no information found.
// If information is present, return a pointer to object
// owned by this class.
const BTF::CommonType *findType(uint32_t Id) const;
LLVM_ABI const BTF::CommonType *findType(uint32_t Id) const;

// Return total number of known BTF types.
size_t typesCount() const { return Types.size(); }
Expand All @@ -120,11 +122,11 @@ class BTFParser {
// - state of the BTFParser might be incomplete but is not invalid,
// queries might be run against it, but some (or all) information
// might be unavailable;
Error parse(const ObjectFile &Obj, const ParseOptions &Opts);
LLVM_ABI Error parse(const ObjectFile &Obj, const ParseOptions &Opts);
Error parse(const ObjectFile &Obj) { return parse(Obj, {true, true, true}); }

// Return true if `Obj` has .BTF and .BTF.ext sections.
static bool hasBTFSections(const ObjectFile &Obj);
LLVM_ABI static bool hasBTFSections(const ObjectFile &Obj);
};

} // namespace llvm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
#include "llvm/DebugInfo/CodeView/TypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
#include <cstdint>

namespace llvm {
namespace codeview {

class ContinuationRecordBuilder;

class AppendingTypeTableBuilder : public TypeCollection {
class LLVM_ABI AppendingTypeTableBuilder : public TypeCollection {

BumpPtrAllocator &RecordStorage;
SimpleTypeSerializer SimpleSerializer;
Expand Down
16 changes: 9 additions & 7 deletions llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H

#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"

namespace llvm {
Expand All @@ -24,14 +25,15 @@ class CVSymbolVisitor {
std::optional<uint32_t> ChildRecursiveDepth;
};

CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks);
LLVM_ABI 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);
Error visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
const FilterOptions &Filter);
LLVM_ABI Error visitSymbolRecord(CVSymbol &Record);
LLVM_ABI Error visitSymbolRecord(CVSymbol &Record, uint32_t Offset);
LLVM_ABI Error visitSymbolStream(const CVSymbolArray &Symbols);
LLVM_ABI Error visitSymbolStream(const CVSymbolArray &Symbols,
uint32_t InitialOffset);
LLVM_ABI Error visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
const FilterOptions &Filter);

private:
SymbolVisitorCallbacks &Callbacks;
Expand Down
41 changes: 23 additions & 18 deletions llvm/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"

namespace llvm {
Expand All @@ -30,24 +31,28 @@ enum VisitorDataSource {
// 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);
LLVM_ABI Error visitTypeRecord(CVType &Record, TypeIndex Index,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source = VDS_BytesPresent);
LLVM_ABI Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source = VDS_BytesPresent);

LLVM_ABI Error visitMemberRecord(CVMemberRecord Record,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source = VDS_BytesPresent);
LLVM_ABI Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record,
TypeVisitorCallbacks &Callbacks);

LLVM_ABI Error visitMemberRecordStream(ArrayRef<uint8_t> FieldList,
TypeVisitorCallbacks &Callbacks);

LLVM_ABI Error visitTypeStream(const CVTypeArray &Types,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source = VDS_BytesPresent);
LLVM_ABI Error visitTypeStream(CVTypeRange Types,
TypeVisitorCallbacks &Callbacks);
LLVM_ABI Error visitTypeStream(TypeCollection &Types,
TypeVisitorCallbacks &Callbacks);

} // end namespace codeview
} // end namespace llvm
Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/DebugInfo/CodeView/CodeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H

#include "llvm/Support/Compiler.h"
#include <cinttypes>
#include <type_traits>

Expand Down Expand Up @@ -555,9 +556,10 @@ enum class EncodedFramePtrReg : uint8_t {
BasePtr = 3,
};

RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU);
LLVM_ABI RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg,
CPUType CPU);

EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);
LLVM_ABI EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);

/// These values correspond to the THUNK_ORDINAL enumeration.
enum class ThunkOrdinal : uint8_t {
Expand Down
5 changes: 3 additions & 2 deletions llvm/include/llvm/DebugInfo/CodeView/CodeViewError.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWERROR_H
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWERROR_H

#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"

namespace llvm {
Expand All @@ -31,7 +32,7 @@ struct is_error_code_enum<llvm::codeview::cv_error_code> : std::true_type {};

namespace llvm {
namespace codeview {
const std::error_category &CVErrorCategory();
LLVM_ABI 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());
Expand All @@ -43,7 +44,7 @@ class CodeViewError : public ErrorInfo<CodeViewError, StringError> {
using ErrorInfo<CodeViewError,
StringError>::ErrorInfo; // inherit constructors
CodeViewError(const Twine &S) : ErrorInfo(S, cv_error_code::unspecified) {}
static char ID;
LLVM_ABI static char ID;
};

} // namespace codeview
Expand Down
34 changes: 18 additions & 16 deletions llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <cassert>
#include <cstdint>
Expand Down Expand Up @@ -61,10 +62,10 @@ class CodeViewRecordIO {
explicit CodeViewRecordIO(CodeViewRecordStreamer &Streamer)
: Streamer(&Streamer) {}

Error beginRecord(std::optional<uint32_t> MaxLength);
Error endRecord();
LLVM_ABI Error beginRecord(std::optional<uint32_t> MaxLength);
LLVM_ABI Error endRecord();

Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = "");
LLVM_ABI Error mapInteger(TypeIndex &TypeInd, const Twine &Comment = "");

bool isStreaming() const {
return (Streamer != nullptr) && (Reader == nullptr) && (Writer == nullptr);
Expand All @@ -76,7 +77,7 @@ class CodeViewRecordIO {
return (Writer != nullptr) && (Streamer == nullptr) && (Reader == nullptr);
}

uint32_t maxFieldLength() const;
LLVM_ABI uint32_t maxFieldLength() const;

template <typename T> Error mapObject(T &Value) {
if (isStreaming()) {
Expand Down Expand Up @@ -130,14 +131,14 @@ class CodeViewRecordIO {
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 = "");
LLVM_ABI Error mapEncodedInteger(int64_t &Value, const Twine &Comment = "");
LLVM_ABI Error mapEncodedInteger(uint64_t &Value, const Twine &Comment = "");
LLVM_ABI Error mapEncodedInteger(APSInt &Value, const Twine &Comment = "");
LLVM_ABI Error mapStringZ(StringRef &Value, const Twine &Comment = "");
LLVM_ABI Error mapGuid(GUID &Guid, const Twine &Comment = "");

Error mapStringZVectorZ(std::vector<StringRef> &Value,
const Twine &Comment = "");
LLVM_ABI Error mapStringZVectorZ(std::vector<StringRef> &Value,
const Twine &Comment = "");

template <typename SizeType, typename T, typename ElementMapper>
Error mapVectorN(T &Items, const ElementMapper &Mapper,
Expand Down Expand Up @@ -197,12 +198,13 @@ class CodeViewRecordIO {
return Error::success();
}

Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes, const Twine &Comment = "");
Error mapByteVectorTail(std::vector<uint8_t> &Bytes,
const Twine &Comment = "");
LLVM_ABI Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes,
const Twine &Comment = "");
LLVM_ABI Error mapByteVectorTail(std::vector<uint8_t> &Bytes,
const Twine &Comment = "");

Error padToAlignment(uint32_t Align);
Error skipPadding();
LLVM_ABI Error padToAlignment(uint32_t Align);
LLVM_ABI Error skipPadding();

uint64_t getStreamedLen() {
if (isStreaming())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamWriter.h"
#include "llvm/Support/Compiler.h"
#include <cstdint>
#include <vector>

Expand All @@ -38,17 +39,17 @@ class ContinuationRecordBuilder {
std::optional<TypeIndex> RefersTo);

public:
ContinuationRecordBuilder();
~ContinuationRecordBuilder();
LLVM_ABI ContinuationRecordBuilder();
LLVM_ABI ~ContinuationRecordBuilder();

void begin(ContinuationRecordKind RecordKind);
LLVM_ABI 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);
LLVM_ABI std::vector<CVType> end(TypeIndex Index);
};
} // namespace codeview
} // namespace llvm
Expand Down
11 changes: 6 additions & 5 deletions llvm/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <vector>
Expand All @@ -42,8 +43,8 @@ template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
public:
using ContextType = void;

Error operator()(BinaryStreamRef Stream, uint32_t &Len,
codeview::FileChecksumEntry &Item);
LLVM_ABI Error operator()(BinaryStreamRef Stream, uint32_t &Len,
codeview::FileChecksumEntry &Item);
};

namespace codeview {
Expand All @@ -62,8 +63,8 @@ class DebugChecksumsSubsectionRef final : public DebugSubsectionRef {

bool valid() const { return Checksums.valid(); }

Error initialize(BinaryStreamReader Reader);
Error initialize(BinaryStreamRef Stream);
LLVM_ABI Error initialize(BinaryStreamReader Reader);
LLVM_ABI Error initialize(BinaryStreamRef Stream);

Iterator begin() const { return Checksums.begin(); }
Iterator end() const { return Checksums.end(); }
Expand All @@ -74,7 +75,7 @@ class DebugChecksumsSubsectionRef final : public DebugSubsectionRef {
FileChecksumArray Checksums;
};

class DebugChecksumsSubsection final : public DebugSubsection {
class LLVM_ABI DebugChecksumsSubsection final : public DebugSubsection {
public:
explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings);

Expand Down
8 changes: 5 additions & 3 deletions llvm/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <map>
Expand All @@ -34,8 +35,8 @@ class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef {
return S->kind() == DebugSubsectionKind::CrossScopeExports;
}

Error initialize(BinaryStreamReader Reader);
Error initialize(BinaryStreamRef Stream);
LLVM_ABI Error initialize(BinaryStreamReader Reader);
LLVM_ABI Error initialize(BinaryStreamRef Stream);

Iterator begin() const { return References.begin(); }
Iterator end() const { return References.end(); }
Expand All @@ -44,7 +45,8 @@ class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef {
FixedStreamArray<CrossModuleExport> References;
};

class DebugCrossModuleExportsSubsection final : public DebugSubsection {
class LLVM_ABI DebugCrossModuleExportsSubsection final
: public DebugSubsection {
public:
DebugCrossModuleExportsSubsection()
: DebugSubsection(DebugSubsectionKind::CrossScopeExports) {}
Expand Down
Loading
Loading