2009-04-08 33 views
6

当碰到断点并进入函数时,gdb版本6.8将打印函数的名称,后跟函数参数。如何让GDB在“踏入”时不打印函数参数值?

恰恰如此,在我正在调试的程序中,其中一个参数值是通过引用传递的巨大记录。 gdb打印变量名称,后跟所有其成员变量。它真的需要一分钟或两分钟打印所有包含在类中的成员变量......这在调试时真的很烦人。

我很确定有一个设置来禁用这种行为,那是什么设置?

回答

10

发现了它,终于。要完全禁用输出:

set print frame-arguments none 

要只打印标量值而忽视阵列&结构:

set print frame-arguments scalars 

要打开打印背面上:

set print frame-arguments all 
1

我有办法一直这样做,但看到你的问题让我好奇,看看是否有更好的机制。我没有找到任何东西。

您可以随时在正在进入的函数中设置断点,但在执行此步骤之前,请使用'commands'命令告诉gdb您不希望打印任何内容该断点。一个例子会让事情变得更加清晰......

您会注意到当我运行程序时,我停在第10行(调用foo)的断点处,并打印出当前的上下文。在发出'commands 2'命令并告诉gdb在该断点处保持沉默之后,当我点击它时什么都不打印。我做了回溯(bt)只是为了表明我是我想成为的地方。

希望这有助于:

> cat tmp.cpp 

#include <stdio.h> 

void foo(int a) 
{ 
     printf ("%d\n", a); 
} 

int main() 
{ 
     foo(0); 

     return 0; 
} 

> g++ -g tmp.cpp 
> gdb a.out 
GNU gdb Fedora (6.8-27.el5) 
Copyright (C) 2008 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "i386-redhat-linux-gnu"... 
(gdb) break 10 
Breakpoint 1 at 0x8048491: file tmp.cpp, line 10. 
(gdb) break 5 
Breakpoint 2 at 0x804846a: file tmp.cpp, line 5. 
(gdb) run 
Starting program: /home/ronb/software/a.out 

Breakpoint 1, main() at tmp.cpp:10 
10    foo(0); 
(gdb) commands 2 
Type commands for when breakpoint 2 is hit, one per line. 
End with a line saying just "end". 
>silent 
>end 
(gdb) c 
Continuing. 
(gdb) bt 
#0 foo (a=0) at tmp.cpp:5 
#1 0x0804849d in main() at tmp.cpp:10 
(gdb)