13

I've created a c++ project on ubuntu in visual studio code. It launches the program using gdb mode, but does not show anything in Output. When I launch program from console, the output is present. I tried inserting "console" property, but vscode tells me, that it is forbidden (from similar issue with node https://github.com/Microsoft/vscode/issues/30842).

How can I enable vscode to show the output from my program?

{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] } 

3 Answers 3

11

You config is correct. The program output should be in the DEBUG CONSOLE.

Menu | Debug Console or Ctrl+Shift+Y.

Sign up to request clarification or add additional context in comments.

5 Comments

Unfortunately, it does not show the data, that program outputs to cout. Just the gdb data. And debugging works correctly - it stops on breakpoints, etc. Maybe it is not possible to achieve printing program output with gdb?
Thanks, I found the terminal window.
Why does it give output in the debug console? How do I shift it to the integrated one? Also, how do I handle input(cin) for debugging? I don't think i can give input in the debug console
@JatinSharma You can. Don't think, just try.
for me it was in the terminal window under "cppdbg: (programname)". Odd because i'm used to the output being under Debug Console under lldb, but there it is.
1

The program was launched in external terminal and due to the configuration of my screen I didn't see it. Everything works fine.

3 Comments

Is such behavior on Windows?
No, I'm using Ubuntu with Unity. Did not try in Windows.
can you elaborate ? how did you access your config ? what parameters had you have to change ?
-2

Add this line in setting.json in code-runner.executorMap

"cpp": "g++ -o $fileNameWithoutExt $fileNameWithoutExt.cpp && ./$fileNameWithoutExt" 

3 Comments

Please add further context to your answer.
Please add further details to expand on your answer, such as working code or documentation citations.
This is NOT a solution. It will mess up the debug mode, because debug mode will also execute these commands of args.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.