6

每次我使用n它时都会打印出要执行的下一条语句。

我如何看到要执行的下一条语句,就好像我已经键入了一样n,但实际上没有单步执行代码?

目前我正在使用where,这给了我下一条语句的行号,我可以用它list来查看一些源代码。是否需要两个单独的命令才能获得我想要的东西?

4

3 回答 3

2

尝试“框架”命令。你会看到这样的东西:

   (gdb) frame
   #0 main () at dummy.c:11
   11    FILE*f = fopen("somefile","r");
   (gdb)
于 2013-08-07T07:11:03.690 回答
1

macro.gdbinit你的主目录中定义你自己。

define shownext
where
list
end

好吧,我不确定我所说的是否有效,但请参阅此处了解如何执行此类操作。

于 2013-03-08T11:45:20.317 回答
0

如果您的 gdb 是使用 Python 支持构建的,则此list.current.py脚本将添加一个新的list-current gdb 命令来执行您想要的操作。

示例会话:

$ gdb -x list-current.py /bin/true
(gdb) start
Temporary breakpoint 1 at 0x4014c0: file true.c, line 59.
Starting program: /usr/bin/true 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffde88) at true.c:59
59    if (argc == 2)
(gdb) list-current 
59    if (argc == 2)
(gdb) list-current  3
59    if (argc == 2)
60      {
61        initialize_main (&argc, &argv);
(gdb) list-current  -2
58       argument.  */
59    if (argc == 2)
(gdb) 
于 2013-03-08T22:12:01.193 回答