Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/BTF/BTFContext.cpp
35269 views
//===- BTFContext.cpp ---------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Implementation of the BTFContext interface, this is used by9// llvm-objdump tool to print source code alongside disassembly.10// In fact, currently it is a simple wrapper for BTFParser instance.11//12//===----------------------------------------------------------------------===//1314#include "llvm/DebugInfo/BTF/BTFContext.h"1516#define DEBUG_TYPE "debug-info-btf-context"1718using namespace llvm;19using object::ObjectFile;20using object::SectionedAddress;2122DILineInfo BTFContext::getLineInfoForAddress(SectionedAddress Address,23DILineInfoSpecifier Specifier) {24const BTF::BPFLineInfo *LineInfo = BTF.findLineInfo(Address);25DILineInfo Result;26if (!LineInfo)27return Result;2829Result.LineSource = BTF.findString(LineInfo->LineOff);30Result.FileName = BTF.findString(LineInfo->FileNameOff);31Result.Line = LineInfo->getLine();32Result.Column = LineInfo->getCol();33return Result;34}3536DILineInfo BTFContext::getLineInfoForDataAddress(SectionedAddress Address) {37// BTF does not convey such information.38return {};39}4041DILineInfoTable42BTFContext::getLineInfoForAddressRange(SectionedAddress Address, uint64_t Size,43DILineInfoSpecifier Specifier) {44// This function is used only from llvm-rtdyld utility and a few45// JITEventListener implementations. Ignore it for now.46return {};47}4849DIInliningInfo50BTFContext::getInliningInfoForAddress(SectionedAddress Address,51DILineInfoSpecifier Specifier) {52// BTF does not convey such information53return {};54}5556std::vector<DILocal> BTFContext::getLocalsForAddress(SectionedAddress Address) {57// BTF does not convey such information58return {};59}6061std::unique_ptr<BTFContext>62BTFContext::create(const ObjectFile &Obj,63std::function<void(Error)> ErrorHandler) {64auto Ctx = std::make_unique<BTFContext>();65BTFParser::ParseOptions Opts;66Opts.LoadLines = true;67if (Error E = Ctx->BTF.parse(Obj, Opts))68ErrorHandler(std::move(E));69return Ctx;70}717273