Hi Neilfsun,
Thanks for the fix.
On Wed, Jan 28, 2026 at 2:49 PM neilfsun <loyou85(a)gmail.com> wrote:
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(a)tencent.com>
Signed-off-by: Feng Sun <loyou85(a)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,
req->addr);
This does look like a bug to me. It uses the distance(target -
req->addr) as the instruction quantity(x/%ldi). So xxx+0x1 turns out
to be disassembling 1 instruction, but xxx+0x1 might contain 2
instructions(one in xxx+0 and one in xxx+1). So you see there is one
inst missing.
How about we do it as:
if (reverse)
sprintf(buf5, "x/%ldi 0x%lx",
- (target - req->addr) ? target - req->addr : 1,
+ req->flags & GNU_FUNCTION_ONLY ?
req->addr2 - req->addr : 1,
req->addr);
This will follow the same logic in "else" block of "if(reverse)":
if (reverse)
sprintf(buf5, "x/%ldi 0x%lx",
(target - req->addr) ? target - req->addr : 1,
req->addr);
else
sprintf(buf5, "x/%ldi 0x%lx",
count_entered && req->count ? req->count :
forward || req->flags & GNU_FUNCTION_ONLY ?
req->addr2 - req->addr : 1,
req->addr);
Thanks,
Tao Liu
else
sprintf(buf5, "x/%ldi 0x%lx",
--
2.50.1
--
Crash-utility mailing list -- devel(a)lists.crash-utility.osci.io
To unsubscribe send an email to devel-leave(a)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