14#ifndef LLVM_LIB_TARGET_BPF_BTFDEBUG_H
15#define LLVM_LIB_TARGET_BPF_BTFDEBUG_H
104 std::vector<struct BTF::BTFEnum> EnumValues;
129 std::vector<const DINode *> Elements;
131 std::vector<struct BTF::BTFMember> Members;
135 bool IsStruct,
bool HasBitField,
uint32_t NumMembers);
149 bool UseFilteredParams =
false;
150 std::vector<struct BTF::BTFParam> Parameters;
151 bool VoidReturn =
false;
156 bool UseFilteredParams =
false,
158 bool VoidReturn =
false);
193 std::vector<std::tuple<uint32_t, const MCSymbol *, uint32_t>> Vars;
201 Vars.push_back(std::make_tuple(
Id, Sym,
Size));
232 std::vector<struct BTF::BTFEnum64> EnumValues;
260 std::map<uint32_t, uint32_t> OffsetToIdMap;
262 std::vector<std::string> Table;
267 std::vector<std::string> &
getTable() {
return Table; }
299 bool SkipInstruction;
300 bool LineInfoGenerated;
303 bool MapDefNotCollected;
305 std::vector<std::unique_ptr<BTFTypeBase>> TypeEntries;
307 std::map<uint32_t, std::vector<BTFFuncInfo>> FuncInfoTable;
308 std::map<uint32_t, std::vector<BTFLineInfo>> LineInfoTable;
309 std::map<uint32_t, std::vector<BTFFieldReloc>> FieldRelocTable;
311 std::map<std::string, std::unique_ptr<BTFKindDataSec>, std::less<>>
313 std::vector<BTFTypeStruct *> StructTypes;
314 std::map<const GlobalVariable *, std::pair<int64_t, uint32_t>> PatchImms;
316 std::vector<std::pair<const DIDerivedType *, BTFTypeDerived *>>>
318 std::set<const Function *>ProtoFunctions;
323 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry,
const DIType *Ty);
325 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry);
330 void visitTypeEntry(
const DIType *Ty);
331 void visitTypeEntry(
const DIType *Ty,
uint32_t &TypeId,
bool CheckPointer,
337 uint32_t &TypeId,
bool VoidReturn =
false);
346 bool CheckPointer,
bool SeenPointer);
351 bool IsForwardDeclCandidate(
const DIType *
Base);
355 std::string populateFileContent(
const DIFile *File);
362 void processGlobals(
bool ProcessingMapDef);
366 void processGlobalInitializer(
const Constant *
C);
369 void processFuncPrototypes(
const Function *);
385 int genBTFTypeTags(
const DIDerivedType *DTy,
int BaseTypeId);
392 unsigned populateType(
const DIType *Ty);
399 void emitCommonHeader();
402 void emitBTFSection();
405 void emitBTFExtSection();
423 return ArrayIndexTypeId;
431 assert(Ty &&
"Invalid null Type");
432 assert(DIToIdMap.find(Ty) != DIToIdMap.end() &&
433 "DIType not added in the BDIToIdMap");
434 return DIToIdMap[Ty];
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file contains the layout of .BTF and .BTF.ext ELF sections.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseMap class.
Annotations lets you mark points and ranges inside source code, for tests:
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class is intended to be used as a driving class for all asm writers.
Collect and emit BTF information.
void endFunctionImpl(const MachineFunction *MF) override
Post process after all instructions in this function are processed.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
bool InstLower(const MachineInstr *MI, MCInst &OutMI)
Emit proper patchable instructions.
size_t addString(StringRef S)
Add string to the string table.
uint32_t getArrayIndexTypeId()
Get the special array index type id.
uint32_t getTypeId(const DIType *Ty)
Get the type id for a particular DIType.
void endModule() override
Complete all the types and emit the BTF sections.
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void addDataSecEntry(uint32_t Id, const MCSymbol *Sym, uint32_t Size)
BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName)
uint32_t getSize() override
Get the size of this BTF type entry.
BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t addString(StringRef S)
Add a string to the string table and returns its offset in the table.
std::vector< std::string > & getTable()
BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Represent a BTF array.
uint32_t getSize() override
Get the size of this BTF type entry.
struct BTF::CommonType BTFType
virtual uint32_t getSize()
Get the size of this BTF type entry.
virtual void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
virtual ~BTFTypeBase()=default
virtual void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
uint32_t roundupToBytes(uint32_t NumBits)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void setPointeeType(uint32_t PointeeType)
BTFTypeDerived(const DIDerivedType *Ty, unsigned Tag, bool NeedsFixup)
uint32_t getSize() override
Get the size of this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeEnum64(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
BTFTypeEnum(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeFloat(uint32_t SizeInBits, StringRef TypeName)
uint32_t getSize() override
Get the size of this BTF type entry.
BTFTypeFuncProto(const DISubroutineType *STy, uint32_t NumParams, const SmallDenseMap< uint32_t, StringRef > &FuncArgNames, bool UseFilteredParams=false, ArrayRef< uint32_t > AliveParamIndices={}, bool VoidReturn=false)
The Func kind represents both subprogram and pointee of function pointers.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId, uint32_t Scope)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeFwd(StringRef Name, bool IsUnion)
Represent a struct/union forward declaration.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits, uint32_t OffsetInBits, StringRef TypeName)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeStruct(const DICompositeType *STy, ArrayRef< const DINode * > Elements, bool IsStruct, bool HasBitField, uint32_t NumMembers)
Represent either a struct or a union.
uint32_t getSize() override
Get the size of this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeTypeTag(uint32_t NextTypeId, StringRef Tag)
This is an important base class in LLVM.
Basic type, like 'int' or 'float'.
Subprogram description. Uses SubclassData1.
Type array for a subprogram.
DebugHandlerBase(AsmPrinter *A)
Instances of this class represent a single low-level machine instruction.
Streaming machine code generation interface.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
Represent one field relocation.
uint32_t RelocKind
What to patch the instruction.
const MCSymbol * Label
MCSymbol identifying insn for the reloc.
uint32_t OffsetNameOff
The string to traverse types.
Represent one func and its type id.
uint32_t TypeId
Type id referring to .BTF type section.
const MCSymbol * Label
Func MCSymbol.
uint32_t LineOff
line offset in the .BTF string table
MCSymbol * Label
MCSymbol identifying insn for the lineinfo.
uint32_t ColumnNum
the column number
uint32_t FileNameOff
file name offset in the .BTF string table
uint32_t LineNum
the line number
BTF_KIND_ARRAY is followed by one "struct BTFArray".
The BTF common type definition.