Multiple threads open in call-stack of vscode debugger - c++

As you can see in the call stack section, three threads are opened when there is no need for them? I think they are making the process slower. Can someone help me fix this please?
Thank you.
P.S.
Here is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\MinGW\\lib\\gcc\\mingw32\\9.2.0\\include\\c++"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Here is my launch.json file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"preLaunchTask": "C/C++: cpp.exe build active file",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
And here is my tasks.json file:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: cpp.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
I am trying to get vscode working for the first time. I really liked the debugging features and the cool UI but this multiple thread opening everytime is making things difficult. Any help is appreciated.

Related

vscode include error when remotely debugging c++ program

problem
I'm using vscode to remotely connect to linux server. When I try to debug on my cpp program, which includes these header files under one directory
#include "codec_def.h"
#include "codec_app_def.h"
#include "codec_api.h"
it always come up with an include error:
codec_def.h: No such file or directory
the same error shows up to codec_app_def.h when I comment out the first header file codec_def.h
I have tried
I googled on this problem and find one solution-include path to the c_cpp_properties.json file.
Here is the path screenshot,
path screenshot
and my newly updated c_cpp_properties.json file is like this, I added ${workspaceFolder}/codec/api/svc/ to includePath,
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/codec/api/svc/",
"/usr/include",
"${workspaceFolder}/**",
"${workspaceFolder}/codec/decoder/core/inc",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include",
"/usr/local/include",
"/opt/rh/devtoolset-7/root/usr/include"
],
"defines": [],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
but I still get the same error and I can't figure out why and how to solve it.
in case of other problems, here are tasks.json file
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/opt/rh/devtoolset-7/root/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/opt/rh/devtoolset-7/root/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/rh/devtoolset-7/root/usr/bin/g++"
}
],
"version": "2.0.0"
}
and launch.json file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) run and debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [
"/root/compress/losslessh264/tibby.264",
"/fordebug/b.pip"
],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "set up pretty printing",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "set desassembly flavor Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (select script from list of sh files)",
"cwd": "${workspaceFolder}",
"program": "${command:SelectScriptName}",
"args": []
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}"
}
]
}
I have been stuck in this problems for days, it will be a great help if you know the answer, thank you in advance :)

Debug with F5 fails on VSCode saying "Unable to establish a connection to GDB"

When I press F5 key to run a C++ program on Visual Studio Code, I get the message
"Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information."
I use g++.exe and MinGW for compiling.
Until an hour ago, the debugging with F5 key was done properly, and I've never touched launch.json. Could you tell me what is wrong?
Below is the launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - アクティブ ファイルのビルドとデバッグ",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe アクティブなファイルのビルド"
}
]
}
Below is the tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe アクティブなファイルのビルド",
"command": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "コンパイラ: C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe"
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe アクティブなファイルのビルド ver(1)",
"command": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "デバッガーによって生成されたタスク。"
}
]
}
Below is the c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${vcpkgRoot}/x86-windows-static/include",
"C:\\Users\\SonicTheHedgehog\\Desktop\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Addition:
I found an error message on launch.json
Property console is not allowed
and console is marked with wavy line.
Check out this link: https://github.com/microsoft/vscode-cpptools/issues/2889
There is some problem with PowerShell being run as in internal console (running within VSCode).
I made the following change in launch.json:
before:
"environment": [],
"externalConsole": **false**,
"MIMode": "gdb",
after:
"environment": [],
"externalConsole": **true**,
"MIMode": "gdb",
Now, I see the output of the program in cmd.exe outside VSCode. But, the debugger runs fine inside VSCode.
I recommend using a different compiler-based extension such as code runner etc, sometimes, extensions are compatibility issues in visual studio code. I faced the same problem when I started to use visual studio code.

vsCode c++ minGW no such file or directory error

I'm first time learning c++ and have followed the guide on https://code.visualstudio.com/docs/cpp/config-mingw but I still cannot successfully compile and run a basic program. Here are my configurations, launch and tasks files.
The only issue I think could be occurring is that I have the code in my E: drive. Although I don't think this should be an issue. Any and all help appreciated.
Configurations:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Launch:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Tasks:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"-o",
"helloworld",
".vscode"
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Output is:
> Executing task: gcc -g -o helloworld .vscode helloworld.cpp <
gcc.exe: error: helloworld.cpp: No such file or directory
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.

Importing external header files into VS Code

I've been wrestling with the .json settings in VS Code for some hours now and I'm pretty lost. All I want to do is link pdcurses to my project so I can start coding. I have intellisense set up, but the #include statement is throwing "curses.h: No such file or directory":
The .jsons:
settings.json:
{
"files.associations": {
"iostream": "cpp",
"vector": "cpp"
}
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Visual Studio Code Projects\\pdcurs39/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Mingw-w64\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"forcedInclude": [],
"browse": {
"path": []
}
}
],
"version": 4
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build RL Test",
"type": "shell",
"command": "g++",
"args": ["-g", "-o", "RLTest", "RLTest.cpp"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/RLTest.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Mingw-w64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Normal C++ packages are working fine. pdcurses is installed at C:\Visual Studio Code Projects\pdcurs39\ with a default mingw-w64 make in the wincon folder.
I think the issue is with not including the pdcurses.a file, but im not sure how to go about linking that...

How to fix some errors while setting up Visual Studio Code for C++?

I'm setting up an IDE using Visual Studio Code for C++ and I have already downloaded and installed all the packages in MinGW Compiler and Git for using bash shell.
I followed this tutorial--> https://code.visualstudio.com/docs/cpp/config-mingw#_configure-debug-settings
However, there were several small details that differed in my case as i progressed through the tutorial for which I'm not aware of their impact(as I am a beginner):
c_cpp_properties.json was a little different in my case.
My code was this:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c11",
"intelliSenseMode": "gcc-x64",
"compilerPath": "C:\\MinGW\\bin\\g++.exe"
}
],
"version": 4
}
In tutorial under configure debug settings, it states: 'Note that the program name helloworld.exe matches what you specified in tasks.json'. On the contrary I had specified 'helloworld.cpp' instead of 'helloworld.exe' in tasks.json
Still I finished the tutorial, and while debugging as said in the tutorial, I got an error stating, helloworld.exe does not exist.
I'd be grateful if someone can provide some insights and ways to deal with these errors.
Please keep in mind that I'm a beginner while answering. Thank You.
Edit: The code for the file tasks.json that I'm using:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"helloworld",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
The code for the file launch.json that I'm using:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}