2015-05-18 62 views
9

我正在使用clion編寫控制檯應用程序。如果我只是運行程序,我可以看到我的cout調用的結果。但是,如果我調試它,除了我的exe名稱和Process finished with exit code 0之外,在調試控制檯選項卡下不會出現任何輸出。是否有一個額外的步驟讓控制檯輸出顯示在clion調試下?如何在clion下的調試中捕獲控制檯輸出?

或者,這甚至沒有特定的clion,是一個普通的事情誰已經使用gdb的人已經知道?

回答

-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

+0

我怕我不真的看到這是如何回答這個問題的。當你使用clion時,你不會直接與gdb進行交互。這是一個IDE。 – jep

+0

@jep,對不起。只是試圖幫助(: – Alex29954

+0

沒關係,只是確保我沒有錯過任何東西,或者在我的問題中不夠清楚。 – jep

相關問題