On Mon, Feb 16, 2026 at 2:41 PM Tao Liu <ltao@redhat.com> wrote:
On Sat, Feb 14, 2026 at 8:43 PM Lianbo Jiang <lijiang@redhat.com> wrote:
>
> On 1/28/26 9:42 AM, devel-request@lists.crash-utility.osci.io wrote:
>
> > Date: Mon, 15 Dec 2025 17:15:15 +0800
> > From: neilfsun<loyou85@gmail.com>
> > Subject: [Crash-utility] [PATCH] Fix dis -lr xxx+0x1 not showing
> >       target address instruction
> > To:devel@lists.crash-utility.osci.io
> > Cc: neilfsun<neilfsun@tencent.com>, Feng Sun<loyou85@gmail.com>
> > Message-ID:<20251215091515.36428-1-neilfsun@tencent.com>
> >
> > When using "dis -lr xxx+0x1", it is not correctly shown, for example:
> >    crash> dis -lr rb_next+0x1
> >    /kernel/lib/rbtree.c: 445
> >    0xffffffff8133ff60 <rb_next>:   push   %rbp
> >
> > However, dis -lr rb+next+0x4 is correctly shown,
> >    crash> dis -lr rb_next+0x4
> >    /kernel/lib/rbtree.c: 445
> >    0xffffffff8133ff60 <rb_next>:   push   %rbp
> >    /kernel/lib/rbtree.c: 448
> >    0xffffffff8133ff61 <rb_next+0x1>:       mov    (%rdi),%rdx
> >    /kernel/lib/rbtree.c: 445
> >    0xffffffff8133ff64 <rb_next+0x4>:       mov    %rsp,%rbp
> >
> > The reverse mode only disassembled (target - function_start) bytes, which
> > was insufficient to reach the target instruction.
> >
> > Signed-off-by: neilfsun<neilfsun@tencent.com>
> > Signed-off-by: Feng Sun<loyou85@gmail.com>
> > ---
> >   kernel.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel.c b/kernel.c
> > index bb148d0..93ea7a6 100644
> > --- a/kernel.c
> > +++ b/kernel.c
> > @@ -2120,7 +2120,7 @@ cmd_dis(void)
> >
> >               if (reverse)
> >                       sprintf(buf5, "x/%ldi 0x%lx",
> > -                             (target - req->addr) ? target - req->addr : 1,
> > +                             req->addr2 - req->addr,
>
> This will always ask gdb to disassemble a lot of asm instructions, can

Indeed. We will disassemble all instructions of the function, but only
take the first few instructions for output, that would be a waste.

> you help try this one?
>
> diff --git a/kernel.c b/kernel.c
> index ccc4b3d..550f61a 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -2124,8 +2124,7 @@ cmd_dis(void)
>                  open_tmpfile();
>
>                  if (reverse)
> -                       sprintf(buf5, "x/%ldi 0x%lx",
> -                               (target - req->addr) ? target -
> req->addr : 1,
> +                       sprintf(buf5, "x/%ldi 0x%lx", roundup(abs(target
> - req->addr), 2),

This one also have some problems:

crash> dis -r rb_next+0 <<----should output 1 instruction to include "rb_next+0"
crash> dis -r rb_next+1 <<---- OK
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
crash> dis -r rb_next+2 <<---- should output 3 instruction, because
"rb_next+2" is not included by any outputted instructions.
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
crash> dis -r rb_next+3 <<---- OK
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
crash> dis -r rb_next+4 <<---- OK
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
crash> dis -r rb_next+5 <<---- OK
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
0xffffffff81329607 <rb_next+7>: cmp    %rdx,%rdi

In addition, the 2 in roundup() is a magic number to me.

Good findings, Tao.
 
How about the following modification:

                if (reverse)
                        sprintf(buf5, "x/%ldi 0x%lx",
-                               (target - req->addr) ? target - req->addr : 1,
+                               abs(target - req->addr) + 1,
                                req->addr);

 
This looks good to me, but I have one question: the "x/-2i 0xaddr" is also meaningful, not sure if the current change is reasonable(hope not deviate from original intention).
Anyway I did not get the history, can you also double check?

crash> x/-2i 0xffffd72a52d3ea48
   0xffffd72a52d3ea40 <__rb_insert_augmented+416>:      b       0xffffd72a52d3e934 <__rb_insert_augmented+148>
   0xffffd72a52d3ea44:  nop
crash> x/2i 0xffffd72a52d3ea48
   0xffffd72a52d3ea48 <rb_next>:        mov     x2, x0
   0xffffd72a52d3ea4c <rb_next+4>:      ldr     x0, [x0]
crash> x/4i 0xffffd72a52d3ea40
   0xffffd72a52d3ea40 <__rb_insert_augmented+416>:      b       0xffffd72a52d3e934 <__rb_insert_augmented+148>
   0xffffd72a52d3ea44:  nop
   0xffffd72a52d3ea48 <rb_next>:        mov     x2, x0
   0xffffd72a52d3ea4c <rb_next+4>:      ldr     x0, [x0]
crash>

Thanks
Lianbo

crash> dis -r rb_next+0
0xffffffff81329600 <rb_next>:   push   %rbp
crash> dis -r rb_next+1
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
crash> dis -r rb_next+2
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
crash> dis -r rb_next+3
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
crash> dis -r rb_next+4
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
crash> dis -r rb_next+5
0xffffffff81329600 <rb_next>:   push   %rbp
0xffffffff81329601 <rb_next+1>: mov    (%rdi),%rdx
0xffffffff81329604 <rb_next+4>: mov    %rsp,%rbp
0xffffffff81329607 <rb_next+7>: cmp    %rdx,%rdi

Thanks,
Tao Liu

>                                  req->addr);
>                  else
>                          sprintf(buf5, "x/%ldi 0x%lx",
>
> Thanks
>
> Lianbo
>
> >                               req->addr);
> >               else
> >                       sprintf(buf5, "x/%ldi 0x%lx",
> > -- 2.50.1
> --
> Crash-utility mailing list -- devel@lists.crash-utility.osci.io
> To unsubscribe send an email to devel-leave@lists.crash-utility.osci.io
> https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
> Contribution Guidelines: https://github.com/crash-utility/crash/wiki