Luc*_*ncu 6 gdb backtracking linux-kernel
在反汇编函数时,gdb将在基数16中显示存储器地址,但在基数10中显示偏移量.
例:
(gdb) disassemble unregister_sysctl_table
Dump of assembler code for function unregister_sysctl_table:
0x00037080 <+0>: push %ebp
0x00037081 <+1>: mov %esp,%ebp
0x00037083 <+3>: sub $0x14,%esp
0x00037086 <+6>: mov %ebx,-0xc(%ebp)
0x00037089 <+9>: mov %esi,-0x8(%ebp)
0x0003708c <+12>:mov %eax,%ebx
0x0003708e <+14>:mov %edi,-0x4(%ebp)
Run Code Online (Sandbox Code Playgroud)
函数偏移量是<+N>地址的旁边,正如您所看到的,它们位于基数10中.
当Linux内核崩溃时,它会显示使用base 16的回溯:
[ 0.524380] [<c10381d5>] unregister_sysctl_table+0x65/0x70
Run Code Online (Sandbox Code Playgroud)
将回溯地址从基数16转换为基数10以便能够找到所需指令是非常烦人的.
可以告诉gdb显示基本16偏移的反汇编输出吗?
GDB 当前使用硬编码的“%d”作为偏移量。
必须转换回溯地址非常烦人......才能找到所需的指令
你确实意识到你可以简单地做
x/i 0xc10381d5 # the crashing instruction (if looking at the inner frame)
x/i 0xc10381d5-5 # the call (if looking at caller frame)
x/10i 0xc10381d5-20 # context around the desired location
Run Code Online (Sandbox Code Playgroud)