Skip to content

Commit eb8a15a

Browse files
laoarqmonnet
authored andcommitted
bpftool: Dump the kernel symbol's module name
If the kernel symbol is in a module, we will dump the module name as well. The square brackets around the module name are trimmed. Signed-off-by: Yafang Shao <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 8756623 commit eb8a15a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/xlated_dumper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ void kernel_syms_load(struct dump_data *dd)
4646
}
4747
dd->sym_mapping = tmp;
4848
sym = &dd->sym_mapping[dd->sym_count];
49-
if (sscanf(buff, "%p %*c %s", &address, sym->name) != 2)
49+
50+
/* module is optional */
51+
sym->module[0] = '\0';
52+
/* trim the square brackets around the module name */
53+
if (sscanf(buff, "%p %*c %s [%[^]]s", &address, sym->name, sym->module) < 2)
5054
continue;
5155
sym->address = (unsigned long)address;
5256
if (!strcmp(sym->name, "__bpf_call_base")) {

src/xlated_dumper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
#define __BPF_TOOL_XLATED_DUMPER_H
66

77
#define SYM_MAX_NAME 256
8+
#define MODULE_MAX_NAME 64
89

910
struct bpf_prog_linfo;
1011

1112
struct kernel_sym {
1213
unsigned long address;
1314
char name[SYM_MAX_NAME];
15+
char module[MODULE_MAX_NAME];
1416
};
1517

1618
struct dump_data {

0 commit comments

Comments
 (0)