如何在clion中调试下捕获控制台输出?

时间:2015-05-18 05:02:41

标签: c++ clion

我正在使用clion来编写控制台应用程序。如果我只是运行程序,我可以看到cout次调用的结果。但是如果我调试它,除了我的exe名称和Process finished with exit code 0之外,调试控制台选项卡下不会输出任何内容。是否有额外的步骤让控制台输出显示在clion中的调试下?

或者这甚至不是clion特定的,一般情况下使用gdb的人已经知道了吗?

2 个答案:

答案 0 :(得分:0)

根据takes the priority over variables defined in any other place,您可以通过单击" Console"来查看调试输出。选项卡,它位于"调试器"旁边。标签:

JetBrains'post on clion debugger

答案 1 :(得分:-3)

GDB操纵程序的运行过程。

GDB会话的一个例子:

% cat hello.c
#include<stdio.h>

main() {
    int count;

    for (count=0;count<10;count++)
       printf("Hello from CETS!\n");
}

% gcc -g hello.c
% gdb ./a.out
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.13 (sparc-sun-solaris2.3), 
Copyright 1994 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x10784: file hello.c, line 6.
(gdb) r
Starting program: /home1/b/bozo/./a.out 


Breakpoint 1, main () at hello.c:6
6           for (count=0;count<10;count++)
(gdb) s
7              printf("Hello from CETS!\n");
(gdb) p count
$1 = 0
(gdb) disp count
1: count = 0
(gdb) set count=8
(gdb) s
Hello from CETS!
6           for (count=0;count<10;count++)
1: count = 8
(gdb) 
7              printf("Hello from CETS!\n");
1: count = 9
(gdb) c
Continuing.
Hello from CETS!

Program exited with code 01.
(gdb) q
%

可能对您有所帮助的内容:

http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_gdb.html

http://www.ifp.illinois.edu/~nakazato/tips/xgcc.html#GDB

http://www.seas.upenn.edu/cets/answers/gcc.html