10

関数を逆アセンブルすると、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)

関数オフセットは<+N>アドレスの隣にあり、ご覧のとおり、10進数になっています。

Linuxカーネルがクラッシュすると、ベース16を使用してバックトレースが表示されます。

 [    0.524380]  [<c10381d5>] unregister_sysctl_table+0x65/0x70

目的の命令を見つけるために、バックトレースアドレスを基数16から基数10に変換する必要があるのは非常に面倒です。

gdbにベース16オフセットで逆アセンブル出力を表示するように指示できますか?

4

2 に答える 2

6

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
于 2011-05-18T15:10:38.877 に答える
1

オフセットを16進数で表示するには、gdbにパッチを適用する必要があります。

たとえば、gdb 6.8では、

cli-out.c、mi / mi-out.c、tui/tui-out.cの*_field_intを変更します

void
cli_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alignment,
const char *fldname, int value)
{
char buffer[40]; /* FIXME: how many chars long a %d can become? */


cli_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
    return;
sprintf (buffer, "%d:%X", value, value);
cli_field_string (uiout, fldno, width, alignment, fldname, buffer);
于 2015-05-19T07:34:43.253 に答える