llvm/llvm/lib/Target/BPF/BTFDebug.cpp

//===- BTFDebug.cpp - BTF Generator ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache 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 contains support for writing BTF debug info.
//
//===----------------------------------------------------------------------===//

#include "BTFDebug.h"
#include "BPF.h"
#include "BPFCORE.h"
#include "MCTargetDesc/BPFMCTargetDesc.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include <optional>

usingnamespacellvm;

static const char *BTFKindStr[] =;

/// Emit a BTF common type.
void BTFTypeBase::emitType(MCStreamer &OS) {}

BTFTypeDerived::BTFTypeDerived(const DIDerivedType *DTy, unsigned Tag,
                               bool NeedsFixup)
    :{}

/// Used by DW_TAG_pointer_type only.
BTFTypeDerived::BTFTypeDerived(unsigned NextTypeId, unsigned Tag,
                               StringRef Name)
    :{}

void BTFTypeDerived::completeType(BTFDebug &BDebug) {}

void BTFTypeDerived::emitType(MCStreamer &OS) {}

void BTFTypeDerived::setPointeeType(uint32_t PointeeType) {}

/// Represent a struct/union forward declaration.
BTFTypeFwd::BTFTypeFwd(StringRef Name, bool IsUnion) :{}

void BTFTypeFwd::completeType(BTFDebug &BDebug) {}

void BTFTypeFwd::emitType(MCStreamer &OS) {}

BTFTypeInt::BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits,
                       uint32_t OffsetInBits, StringRef TypeName)
    :{}

void BTFTypeInt::completeType(BTFDebug &BDebug) {}

void BTFTypeInt::emitType(MCStreamer &OS) {}

BTFTypeEnum::BTFTypeEnum(const DICompositeType *ETy, uint32_t VLen,
    bool IsSigned) :{}

void BTFTypeEnum::completeType(BTFDebug &BDebug) {}

void BTFTypeEnum::emitType(MCStreamer &OS) {}

BTFTypeEnum64::BTFTypeEnum64(const DICompositeType *ETy, uint32_t VLen,
    bool IsSigned) :{}

void BTFTypeEnum64::completeType(BTFDebug &BDebug) {}

void BTFTypeEnum64::emitType(MCStreamer &OS) {}

BTFTypeArray::BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems) {}

/// Represent a BTF array.
void BTFTypeArray::completeType(BTFDebug &BDebug) {}

void BTFTypeArray::emitType(MCStreamer &OS) {}

/// Represent either a struct or a union.
BTFTypeStruct::BTFTypeStruct(const DICompositeType *STy, bool IsStruct,
                             bool HasBitField, uint32_t Vlen)
    :{}

void BTFTypeStruct::completeType(BTFDebug &BDebug) {}

void BTFTypeStruct::emitType(MCStreamer &OS) {}

std::string BTFTypeStruct::getName() {}

/// The Func kind represents both subprogram and pointee of function
/// pointers. If the FuncName is empty, it represents a pointee of function
/// pointer. Otherwise, it represents a subprogram. The func arg names
/// are empty for pointee of function pointer case, and are valid names
/// for subprogram.
BTFTypeFuncProto::BTFTypeFuncProto(
    const DISubroutineType *STy, uint32_t VLen,
    const std::unordered_map<uint32_t, StringRef> &FuncArgNames)
    :{}

void BTFTypeFuncProto::completeType(BTFDebug &BDebug) {}

void BTFTypeFuncProto::emitType(MCStreamer &OS) {}

BTFTypeFunc::BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId,
    uint32_t Scope)
    :{}

void BTFTypeFunc::completeType(BTFDebug &BDebug) {}

void BTFTypeFunc::emitType(MCStreamer &OS) {}

BTFKindVar::BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo)
    :{}

void BTFKindVar::completeType(BTFDebug &BDebug) {}

void BTFKindVar::emitType(MCStreamer &OS) {}

BTFKindDataSec::BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName)
    :{}

void BTFKindDataSec::completeType(BTFDebug &BDebug) {}

void BTFKindDataSec::emitType(MCStreamer &OS) {}

BTFTypeFloat::BTFTypeFloat(uint32_t SizeInBits, StringRef TypeName)
    :{}

void BTFTypeFloat::completeType(BTFDebug &BDebug) {}

BTFTypeDeclTag::BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentIdx,
                               StringRef Tag)
    :{}

void BTFTypeDeclTag::completeType(BTFDebug &BDebug) {}

void BTFTypeDeclTag::emitType(MCStreamer &OS) {}

BTFTypeTypeTag::BTFTypeTypeTag(uint32_t NextTypeId, StringRef Tag)
    :{}

BTFTypeTypeTag::BTFTypeTypeTag(const DIDerivedType *DTy, StringRef Tag)
    :{}

void BTFTypeTypeTag::completeType(BTFDebug &BDebug) {}

uint32_t BTFStringTable::addString(StringRef S) {}

BTFDebug::BTFDebug(AsmPrinter *AP)
    :{}

uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry,
                           const DIType *Ty) {}

uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry) {}

void BTFDebug::visitBasicType(const DIBasicType *BTy, uint32_t &TypeId) {}

/// Handle subprogram or subroutine types.
void BTFDebug::visitSubroutineType(
    const DISubroutineType *STy, bool ForSubprog,
    const std::unordered_map<uint32_t, StringRef> &FuncArgNames,
    uint32_t &TypeId) {}

void BTFDebug::processDeclAnnotations(DINodeArray Annotations,
                                      uint32_t BaseTypeId,
                                      int ComponentIdx) {}

uint32_t BTFDebug::processDISubprogram(const DISubprogram *SP,
                                       uint32_t ProtoTypeId, uint8_t Scope) {}

/// Generate btf_type_tag chains.
int BTFDebug::genBTFTypeTags(const DIDerivedType *DTy, int BaseTypeId) {}

/// Handle structure/union types.
void BTFDebug::visitStructType(const DICompositeType *CTy, bool IsStruct,
                               uint32_t &TypeId) {}

void BTFDebug::visitArrayType(const DICompositeType *CTy, uint32_t &TypeId) {}

void BTFDebug::visitEnumType(const DICompositeType *CTy, uint32_t &TypeId) {}

/// Handle structure/union forward declarations.
void BTFDebug::visitFwdDeclType(const DICompositeType *CTy, bool IsUnion,
                                uint32_t &TypeId) {}

/// Handle structure, union, array and enumeration types.
void BTFDebug::visitCompositeType(const DICompositeType *CTy,
                                  uint32_t &TypeId) {}

bool BTFDebug::IsForwardDeclCandidate(const DIType *Base) {}

/// Handle pointer, typedef, const, volatile, restrict and member types.
void BTFDebug::visitDerivedType(const DIDerivedType *DTy, uint32_t &TypeId,
                                bool CheckPointer, bool SeenPointer) {}

/// Visit a type entry. CheckPointer is true if the type has
/// one of its predecessors as one struct/union member. SeenPointer
/// is true if CheckPointer is true and one of its predecessors
/// is a pointer. The goal of CheckPointer and SeenPointer is to
/// do pruning for struct/union types so some of these types
/// will not be emitted in BTF and rather forward declarations
/// will be generated.
void BTFDebug::visitTypeEntry(const DIType *Ty, uint32_t &TypeId,
                              bool CheckPointer, bool SeenPointer) {}

void BTFDebug::visitTypeEntry(const DIType *Ty) {}

void BTFDebug::visitMapDefType(const DIType *Ty, uint32_t &TypeId) {}

/// Read file contents from the actual file or from the source
std::string BTFDebug::populateFileContent(const DIFile *File) {}

void BTFDebug::constructLineInfo(MCSymbol *Label, const DIFile *File,
                                 uint32_t Line, uint32_t Column) {}

void BTFDebug::emitCommonHeader() {}

void BTFDebug::emitBTFSection() {}

void BTFDebug::emitBTFExtSection() {}

void BTFDebug::beginFunctionImpl(const MachineFunction *MF) {}

void BTFDebug::endFunctionImpl(const MachineFunction *MF) {}

/// On-demand populate types as requested from abstract member
/// accessing or preserve debuginfo type.
unsigned BTFDebug::populateType(const DIType *Ty) {}

/// Generate a struct member field relocation.
void BTFDebug::generatePatchImmReloc(const MCSymbol *ORSym, uint32_t RootId,
                                     const GlobalVariable *GVar, bool IsAma) {}

void BTFDebug::processGlobalValue(const MachineOperand &MO) {}

void BTFDebug::beginInstruction(const MachineInstr *MI) {}

void BTFDebug::processGlobals(bool ProcessingMapDef) {}

/// Process global variable initializer in pursuit for function
/// pointers. Add discovered (extern) functions to BTF. Some (extern)
/// functions might have been missed otherwise. Every symbol needs BTF
/// info when linking with bpftool. Primary use case: "static"
/// initialization of BPF maps.
///
/// struct {
///   __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
///   ...
/// } prog_map SEC(".maps") = { .values = { extern_func } };
///
void BTFDebug::processGlobalInitializer(const Constant *C) {}

/// Emit proper patchable instructions.
bool BTFDebug::InstLower(const MachineInstr *MI, MCInst &OutMI) {}

void BTFDebug::processFuncPrototypes(const Function *F) {}

void BTFDebug::endModule() {}