// t.c
int main()
{
int x = 2;
x++;
x += 3;
x += 5;
return x - 11;
}
gcc -g t.c && gdb -q ./a.out
(gdb) start
(gdb) define hook-next
Type commands for definition of "hook-next".
End with a line saying just "end".
>printf "%08d\n", x
>end
(gdb) next
00032767 # <<-- x hasn't been initialized yet.
4 x++;
(gdb) next
00000002
5 x += 3;
(gdb)
00000003
6 x += 5;
(gdb)
00000006
7 return x - 11;
(gdb)
00000011
8 }
(gdb) q
您可以使用
hook-next
. 文档。例子: