如何让“GDB”在“踏入”时不打印功能参数值?

时间:2009-04-08 17:59:49

标签: debugging gdb

当遇到断点并单步执行函数时,gdb版本6.8会打印函数的名称,后跟函数参数。

就是这样,在我正在调试的程序中,其中一个参数值是通过引用传递的巨大记录。 gdb 打印变量名,后跟其所有成员变量。它实际上需要一两分钟才能打印 gdb 来打印类中包含的所有成员变量...这在调试时非常烦人。

我很确定有一个设置可以禁用此行为,该设置是什么?

2 个答案:

答案 0 :(得分:11)

最后找到它。要完全禁用输出:

set print frame-arguments none 

仅打印标量值并忽略数组&结构:

set print frame-arguments scalars 

重新开启打印:

set print frame-arguments all

答案 1 :(得分: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)