如何在 clion 调试下捕获控制台输出?
How do you capture console output under debug in clion?
我正在使用 clion 编写控制台应用程序。如果我只是 运行 程序,我可以看到 cout
调用的结果。但是,如果我对其进行调试,除了我的 exe 名称和 Process finished with exit code 0
之外,“调试控制台”选项卡下不会出现任何输出。是否有额外的步骤让控制台输出显示在 clion 的调试下?
或者这甚至不是特定于 clion 的,并且是使用 gdb 的人已经知道的一般事情?
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
= 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
根据 JetBrains'post on clion debugger,您可以通过单击 "Debugger" 选项卡旁边的 "Console" 选项卡来查看调试输出:
我正在使用 clion 编写控制台应用程序。如果我只是 运行 程序,我可以看到 cout
调用的结果。但是,如果我对其进行调试,除了我的 exe 名称和 Process finished with exit code 0
之外,“调试控制台”选项卡下不会出现任何输出。是否有额外的步骤让控制台输出显示在 clion 的调试下?
或者这甚至不是特定于 clion 的,并且是使用 gdb 的人已经知道的一般事情?
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
= 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
根据 JetBrains'post on clion debugger,您可以通过单击 "Debugger" 选项卡旁边的 "Console" 选项卡来查看调试输出: