Re: [RFC bpf-next v1 4/8] selftests/bpf: extract utility function for BPF disassembly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2024-07-01 at 17:41 -0700, Andrii Nakryiko wrote:
> On Sat, Jun 29, 2024 at 2:48 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
> > 
> > uint32_t disasm_insn(struct bpf_insn *insn, char *buf, size_t buf_sz);
> 
> or you can return `struct bpf_insn *` which will point to the next
> hypothetical instruction?

Not sure if it simplifies clients, e.g. from this patch, the following:

+	for (i = skip_first_insn ? 1 : 0; i < cnt;) {
+		i += disasm_insn(buf + i, insn_buf, sizeof(insn_buf));
+		fprintf(prog_out, "%s\n", insn_buf);
+	}

Would become:

+	for (i = buf + skip_first_insn ? 1 : 0; i < buf + cnt;) {
+		i = disasm_insn(buf + i, insn_buf, sizeof(insn_buf));
+		fprintf(prog_out, "%s\n", insn_buf);
+	}

idk, can change if you insist.

[...]

> > +       sscanf(buf, "(%*[^)]) %n", &pfx_end);
> 
> let me simplify this a bit ;)
> 
> pfx_end = 5;
> 
> not as sophisticated, but equivalent

Okay :(

> 
> > +       sscanf(buf, "(%*[^)]) call %*[^#]%n", &sfx_start);
> 
> is it documented that sfx_start won't be updated if sscanf() doesn't
> successfully match?
> 
> if not, maybe let's do something like below
> 
> if (strcmp(buf + 5, "call ", 5) == 0 && (tmp = strrchr(buf, '#')))
>     sfx_start = tmp - buf;

Will change, the doc is obscure.

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux