xref: /aosp_15_r20/external/bpftool/src/xlated_dumper.h (revision 858ea5e570667251cdc31d3fe7b846b591105938)
1*858ea5e5SAndroid Build Coastguard Worker /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2*858ea5e5SAndroid Build Coastguard Worker /* Copyright (C) 2018 Netronome Systems, Inc. */
3*858ea5e5SAndroid Build Coastguard Worker 
4*858ea5e5SAndroid Build Coastguard Worker #ifndef __BPF_TOOL_XLATED_DUMPER_H
5*858ea5e5SAndroid Build Coastguard Worker #define __BPF_TOOL_XLATED_DUMPER_H
6*858ea5e5SAndroid Build Coastguard Worker 
7*858ea5e5SAndroid Build Coastguard Worker #define SYM_MAX_NAME	256
8*858ea5e5SAndroid Build Coastguard Worker #define MODULE_MAX_NAME	64
9*858ea5e5SAndroid Build Coastguard Worker 
10*858ea5e5SAndroid Build Coastguard Worker struct bpf_prog_linfo;
11*858ea5e5SAndroid Build Coastguard Worker 
12*858ea5e5SAndroid Build Coastguard Worker struct kernel_sym {
13*858ea5e5SAndroid Build Coastguard Worker 	unsigned long address;
14*858ea5e5SAndroid Build Coastguard Worker 	char name[SYM_MAX_NAME];
15*858ea5e5SAndroid Build Coastguard Worker 	char module[MODULE_MAX_NAME];
16*858ea5e5SAndroid Build Coastguard Worker };
17*858ea5e5SAndroid Build Coastguard Worker 
18*858ea5e5SAndroid Build Coastguard Worker struct dump_data {
19*858ea5e5SAndroid Build Coastguard Worker 	unsigned long address_call_base;
20*858ea5e5SAndroid Build Coastguard Worker 	struct kernel_sym *sym_mapping;
21*858ea5e5SAndroid Build Coastguard Worker 	__u32 sym_count;
22*858ea5e5SAndroid Build Coastguard Worker 	__u64 *jited_ksyms;
23*858ea5e5SAndroid Build Coastguard Worker 	__u32 nr_jited_ksyms;
24*858ea5e5SAndroid Build Coastguard Worker 	struct btf *btf;
25*858ea5e5SAndroid Build Coastguard Worker 	void *func_info;
26*858ea5e5SAndroid Build Coastguard Worker 	__u32 finfo_rec_size;
27*858ea5e5SAndroid Build Coastguard Worker 	const struct bpf_prog_linfo *prog_linfo;
28*858ea5e5SAndroid Build Coastguard Worker 	char scratch_buff[SYM_MAX_NAME + 8];
29*858ea5e5SAndroid Build Coastguard Worker };
30*858ea5e5SAndroid Build Coastguard Worker 
31*858ea5e5SAndroid Build Coastguard Worker void kernel_syms_load(struct dump_data *dd);
32*858ea5e5SAndroid Build Coastguard Worker void kernel_syms_destroy(struct dump_data *dd);
33*858ea5e5SAndroid Build Coastguard Worker struct kernel_sym *kernel_syms_search(struct dump_data *dd, unsigned long key);
34*858ea5e5SAndroid Build Coastguard Worker void dump_xlated_json(struct dump_data *dd, void *buf, unsigned int len,
35*858ea5e5SAndroid Build Coastguard Worker 		       bool opcodes, bool linum);
36*858ea5e5SAndroid Build Coastguard Worker void dump_xlated_plain(struct dump_data *dd, void *buf, unsigned int len,
37*858ea5e5SAndroid Build Coastguard Worker 		       bool opcodes, bool linum);
38*858ea5e5SAndroid Build Coastguard Worker void dump_xlated_for_graph(struct dump_data *dd, void *buf, void *buf_end,
39*858ea5e5SAndroid Build Coastguard Worker 			   unsigned int start_index,
40*858ea5e5SAndroid Build Coastguard Worker 			   bool opcodes, bool linum);
41*858ea5e5SAndroid Build Coastguard Worker 
42*858ea5e5SAndroid Build Coastguard Worker #endif
43