2

I want to debug my C++ code in VSCode, but after I pressed F5, the external console didn't pop up as expected.

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": true,
            "internalConsoleOptions": "neverOpen",
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\MinGW\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
            "preLaunchTask": "Compile for Debug"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile for Debug",
            "type": "shell",
            "command": "g++",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}",
                "-g",
                "-Wall",
                "-Wextra",
                "-Wl,--stack=1024000000"
            ]
        }
    ]
}

When I press F5, the window looks like this: enter image description here

It seems that the debug session runs normally (the bar in the red box), but as you can see, the external console doesn't appear.

P.S. My system is Windows 10 (x64), and the vscode is the latest.

4
  • Did you wait long enough? gdb might need some time to start, and I see a loading bar in the top-left corner. Commented Aug 24, 2019 at 23:29
  • Yes of course. I waited for almost 5 minutes but nothing happened, and that's why I'm asking this question. Commented Aug 25, 2019 at 4:20
  • Huh. Does gdb work if you start it from the terminal? Commented Aug 25, 2019 at 7:43
  • @HolyBlackCat Of course. Commented Aug 25, 2019 at 18:26

3 Answers 3

2

Finally, I know how to solve that. It seems a bug of C/C++ extension.

I just set the option "Beta: Use Unicode UTF-8 for worldwide language support" in Windows OFF, and everything works.

More details can be found here. Thanks a lot to Github user @everything411.

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

Comments

0

From what I can tell looking at your picture, is that I the program stopped at your break point (I don't use the same version so I'm not entirely sure). You have to click next for your program to finish compiling. If you just want to see what your output is, no break points or anything, hit Crtl + F5.

Comments

0

You can follow this link to learn how to use C++ debugger in Linux:

VS Code Debugger for C++

This tutorial is the official tutorial by the Microsoft VS Code Community.

Follow the steps and you will get to know how to debug C++ files.

Note: You need to have a project folder and keep you .cpp inside it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.