Re: [PATCH bpf-next v1 05/11] bpf: Add dump_stack() analogue to print to BPF stderr

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

 



On Fri, 9 May 2025 at 00:38, Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> On Wed, 2025-05-07 at 10:17 -0700, Kumar Kartikeya Dwivedi wrote:
>
> [...]
>
> > +static bool dump_stack_cb(void *cookie, u64 ip, u64 sp, u64 bp)
> > +{
> > +     struct dump_stack_ctx *ctxp = cookie;
> > +     const char *file = "", *line = "";
> > +     struct bpf_prog *prog;
> > +     int num;
> > +
> > +     if (is_bpf_text_address(ip)) {
> > +             prog = bpf_prog_ksym_find(ip);
> > +             num = bpf_prog_get_file_line(prog, ip, &file, &line);
> > +             if (num == -1)
> > +                     goto end;
>
> Should this be `num < 0` ?
> bpf_prog_get_file_line() can return -EINVAL and -ENOENT.

My bad, I modified the error code when cleaning it up but forgot to
change caller, thanks for catching it.

>
> > +             ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n  %s @ %s:%d\n",
> > +                                                 (void *)ip, line, file, num);
> > +             return !ctxp->err;
> > +     }
> > +end:
> > +     ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)ip);
> > +     return !ctxp->err;
> > +}
>
> [...]
>




[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