Skip to content

Commit 1771ba5

Browse files
yonghong-songkernel-patches-bot
authored andcommitted
bpftool: print subprog address properly
With later hashmap example, using bpftool xlated output may look like: int dump_task(struct bpf_iter__task * ctx): ; struct task_struct *task = ctx->task; 0: (79) r2 = *(u64 *)(r1 +8) ; if (task == (void *)0 || called > 0) ... 19: (18) r2 = subprog[+17] 30: (18) r2 = subprog[+25] ... 36: (95) exit __u64 check_hash_elem(struct bpf_map * map, __u32 * key, __u64 * val, struct callback_ctx * data): ; struct bpf_iter__task *ctx = data->ctx; 37: (79) r5 = *(u64 *)(r4 +0) ... 55: (95) exit __u64 check_percpu_elem(struct bpf_map * map, __u32 * key, __u64 * val, void * unused): ; check_percpu_elem(struct bpf_map *map, __u32 *key, __u64 *val, void *unused) 56: (bf) r6 = r3 ... 83: (18) r2 = subprog[-47] Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Yonghong Song <[email protected]>
1 parent dc24a63 commit 1771ba5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/bpf/bpftool/xlated_dumper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ static const char *print_imm(void *private_data,
196196
else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
197197
snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
198198
"map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
199+
else if (insn->src_reg == BPF_PSEUDO_FUNC)
200+
snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
201+
"subprog[%+d]", insn->imm);
199202
else
200203
snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
201204
"0x%llx", (unsigned long long)full_imm);

0 commit comments

Comments
 (0)