Skip to content

Commit

Permalink
x86_64: Fix invalid input "=>" for bt command
Browse files Browse the repository at this point in the history
There may be extra "=>" prefix before gdb disassembly, as a result,
parse_line() will return string "=>" as arglist[0], which will be
converted to number by htol() and fails. E.g.:

crash> gdb x/40i __list_del_entry
   ...
   0xffffffff8133c384 <__list_del_entry+36>:    cmp    %rcx,%rax
   0xffffffff8133c387 <__list_del_entry+39>:    je     0xffffffff8133c403 <__list_del_entry+163>
=> 0xffffffff8133c389 <__list_del_entry+41>:    mov    (%rax),%r8
   0xffffffff8133c38c <__list_del_entry+44>:    cmp    %r8,%rdi
   0xffffffff8133c38f <__list_del_entry+47>:    jne    0xffffffff8133c3e4 <__list_del_entry+132>
   0xffffffff8133c391 <__list_del_entry+49>:    mov    0x8(%rdx),%r8

Before the patch:

crash> bt
 ...
 #10 [ffff880095647c00] async_page_fault at ffffffff816a8638
    [exception RIP: __list_del_entry+41]
    RIP: ffffffff8133c389  RSP: ffff880095647cb0  RFLAGS: 00010207
    RAX: 0000000000000000  RBX: ffffea0400408020  RCX: dead000000000200
    RDX: 0000000000000000  RSI: 0000000000000246  RDI: ffffea0400408020
    RBP: ffff880095647cb0   R8: 0000000080000431   R9: ffffffff81e835c0
    R10: 0000000000000000  R11: 0000000000000400  R12: ffff880138795b58
    R13: 0000000010010201  R14: ffff880095647d70  R15: 0000000400408040
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
 bt: invalid input: "=>"
 #11 [ffff880095647cb8] list_del at ffffffff8133c43d
 #12 [ffff880095647cd0] devm_memremap_pages at ffffffff81180c53

After the patch:

No string as 'bt: invalid input: "=>"' of output.

Signed-off-by: Tao Liu <[email protected]>
  • Loading branch information
liutgnu authored and lian-bo committed Nov 4, 2024
1 parent 21e0a34 commit c4db469
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -8703,6 +8703,8 @@ x86_64_get_framesize(struct bt_info *bt, ulong textaddr, ulong rsp, char *stack_

rewind(pc->tmpfile2);
while (fgets(buf, BUFSIZE, pc->tmpfile2)) {
if (STRNEQ(buf, "=>"))
shift_string_left(buf, 2);
strcpy(buf2, buf);

if (CRASHDEBUG(3))
Expand Down

0 comments on commit c4db469

Please sign in to comment.