LLVM 20.0.0git
BTFContext.cpp
Go to the documentation of this file.
1//===- BTFContext.cpp ---------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implementation of the BTFContext interface, this is used by
10// llvm-objdump tool to print source code alongside disassembly.
11// In fact, currently it is a simple wrapper for BTFParser instance.
12//
13//===----------------------------------------------------------------------===//
14
16
17#define DEBUG_TYPE "debug-info-btf-context"
18
19using namespace llvm;
22
24 DILineInfoSpecifier Specifier) {
25 const BTF::BPFLineInfo *LineInfo = BTF.findLineInfo(Address);
26 DILineInfo Result;
27 if (!LineInfo)
28 return Result;
29
30 Result.LineSource = BTF.findString(LineInfo->LineOff);
31 Result.FileName = BTF.findString(LineInfo->FileNameOff);
32 Result.Line = LineInfo->getLine();
33 Result.Column = LineInfo->getCol();
34 return Result;
35}
36
38 // BTF does not convey such information.
39 return {};
40}
41
44 DILineInfoSpecifier Specifier) {
45 // This function is used only from llvm-rtdyld utility and a few
46 // JITEventListener implementations. Ignore it for now.
47 return {};
48}
49
52 DILineInfoSpecifier Specifier) {
53 // BTF does not convey such information
54 return {};
55}
56
58 // BTF does not convey such information
59 return {};
60}
61
62std::unique_ptr<BTFContext>
64 std::function<void(Error)> ErrorHandler) {
65 auto Ctx = std::make_unique<BTFContext>();
67 Opts.LoadLines = true;
68 if (Error E = Ctx->BTF.parse(Obj, Opts))
69 ErrorHandler(std::move(E));
70 return Ctx;
71}
uint64_t Size
static fatal_error_handler_t ErrorHandler
static std::unique_ptr< BTFContext > create(const object::ObjectFile &Obj, std::function< void(Error)> ErrorHandler=WithColor::defaultErrorHandler)
Definition: BTFContext.cpp:63
DILineInfo getLineInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
Definition: BTFContext.cpp:23
std::vector< DILocal > getLocalsForAddress(object::SectionedAddress Address) override
Definition: BTFContext.cpp:57
DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
Definition: BTFContext.cpp:43
DILineInfo getLineInfoForDataAddress(object::SectionedAddress Address) override
Definition: BTFContext.cpp:37
DIInliningInfo getInliningInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
Definition: BTFContext.cpp:51
StringRef findString(uint32_t Offset) const
Definition: BTFParser.cpp:427
const BTF::BPFLineInfo * findLineInfo(SectionedAddress Address) const
Definition: BTFParser.cpp:449
A format-neutral container for inlined code description.
Definition: DIContext.h:94
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
This class is the base class for all object file types.
Definition: ObjectFile.h:229
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Specifying one line info.
Definition: BTF.h:250
uint32_t getLine() const
Definition: BTF.h:256
uint32_t getCol() const
Definition: BTF.h:257
uint32_t FileNameOff
File name index in the .BTF string table.
Definition: BTF.h:252
uint32_t LineOff
Line index in the .BTF string table.
Definition: BTF.h:253
Controls which fields of DILineInfo container should be filled with data.
Definition: DIContext.h:146
A format-neutral container for source line information.
Definition: DIContext.h:32