2015-05-18 10 views
9

Ich benutze Clion, um eine Konsolenanwendung zu schreiben. Wenn ich das Programm einfach ausführe, kann ich die Ergebnisse meiner cout Anrufe sehen. Aber wenn ich es debugge, tritt keine Ausgabe auf der Registerkarte Debug Console anders als der Name meiner exe und Process finished with exit code 0. Gibt es einen zusätzlichen Schritt, damit die Konsolenausgabe unter Debug in Clion angezeigt wird?Wie erfassen Sie Konsolenausgabe unter Debug in Clion?

Oder ist das nicht sogar Clion spezifisch und ist eine allgemeine Sache, die Leute, die gdb schon verwendet haben, bereits kennen?

Antwort

-3

GDB manipuliert den Prozess zum Ausführen eines Programms.

Ein Beispiel für GDB-Sitzung:

% 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 
% 

Inhalte, die für Sie nützlich sein könnten:

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

Ich fürchte, ich don‘ Ich sehe wirklich, wie das die Frage beantwortet. Sie interagieren nicht direkt mit gdb, wenn Sie clion verwenden. Es ist eine IDE. – jep

+0

@jep, sorry dann. Ich habe versucht zu helfen (: – Alex29954

+0

) Das ist okay, nur um sicherzustellen, dass ich etwas nicht vermisse oder nicht klar genug in meiner Frage war. – jep