14#ifndef LLVM_LIB_TARGET_BPF_BTFDEBUG_H
15#define LLVM_LIB_TARGET_BPF_BTFDEBUG_H
23#include <unordered_map>
103 std::vector<struct BTF::BTFEnum> EnumValues;
129 std::vector<struct BTF::BTFMember> Members;
147 bool UseFilteredParams =
false;
148 std::vector<struct BTF::BTFParam> Parameters;
149 bool VoidReturn =
false;
154 bool UseFilteredParams =
false,
156 bool VoidReturn =
false);
191 std::vector<std::tuple<uint32_t, const MCSymbol *, uint32_t>> Vars;
199 Vars.push_back(std::make_tuple(
Id, Sym,
Size));
230 std::vector<struct BTF::BTFEnum64> EnumValues;
258 std::map<uint32_t, uint32_t> OffsetToIdMap;
260 std::vector<std::string> Table;
265 std::vector<std::string> &
getTable() {
return Table; }
297 bool SkipInstruction;
298 bool LineInfoGenerated;
301 bool MapDefNotCollected;
303 std::vector<std::unique_ptr<BTFTypeBase>> TypeEntries;
304 std::unordered_map<const DIType *, uint32_t> DIToIdMap;
305 std::map<uint32_t, std::vector<BTFFuncInfo>> FuncInfoTable;
306 std::map<uint32_t, std::vector<BTFLineInfo>> LineInfoTable;
307 std::map<uint32_t, std::vector<BTFFieldReloc>> FieldRelocTable;
309 std::map<std::string, std::unique_ptr<BTFKindDataSec>, std::less<>>
311 std::vector<BTFTypeStruct *> StructTypes;
312 std::map<const GlobalVariable *, std::pair<int64_t, uint32_t>> PatchImms;
314 std::vector<std::pair<const DIDerivedType *, BTFTypeDerived *>>>
316 std::set<const Function *>ProtoFunctions;
321 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry,
const DIType *Ty);
323 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry);
328 void visitTypeEntry(
const DIType *Ty);
329 void visitTypeEntry(
const DIType *Ty,
uint32_t &TypeId,
bool CheckPointer,
335 uint32_t &TypeId,
bool VoidReturn =
false);
344 bool CheckPointer,
bool SeenPointer);
349 bool IsForwardDeclCandidate(
const DIType *
Base);
353 std::string populateFileContent(
const DIFile *File);
360 void processGlobals(
bool ProcessingMapDef);
364 void processGlobalInitializer(
const Constant *
C);
367 void processFuncPrototypes(
const Function *);
383 int genBTFTypeTags(
const DIDerivedType *DTy,
int BaseTypeId);
390 unsigned populateType(
const DIType *Ty);
397 void emitCommonHeader();
400 void emitBTFSection();
403 void emitBTFExtSection();
421 return ArrayIndexTypeId;
429 assert(Ty &&
"Invalid null Type");
430 assert(DIToIdMap.find(Ty) != DIToIdMap.end() &&
431 "DIType not added in the BDIToIdMap");
432 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.
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.
uint32_t getSize() override
Get the size of this BTF type entry.
BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, uint32_t NumMembers)
Represent either a struct or a union.
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.
@ C
The default llvm calling convention, compatible with C.
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.