What to in VScode do after launch JSON file C++ - c++

I'm learning a basic to c++ in Vscode but I'm having issues with debugging, I followed everything downloaded MinGW, edit the environment path variable value to C:\MingGW\Bin. I tried but when I try to run it opens a launch.JSON what do I do after that? When I run > start debugging I get two options, I click on C++(GDB/LLDB). It opens a JSON file it reads :
{
// 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": "enter program name, for example ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
I don't know what do to next please help...

Related

VSC C++ debugging keeps loading but never starts

In VSC, for a C++ program, I've configured the launch.json file for debuging as:
{
// 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": "my_target",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-ddad_fca/bazel-out/k8-dbg/bin/my_target",
"args": [
"input_file",
"output_file"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bazel-ddad_fca/bazel-out/k8-dbg/bin/my_target.runfiles/working_folder",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Skip std",
"text": "skip -rfu ^std::([a-zA-Z0-9_]+)\<.*\>::~?\\1 *\\(",
"ignoreFailures": true
},
{
"description": "Skip files std",
"text": "skip -gfi /usr/include/c++/*/bits/*.h",
"ignoreFailures": true
}
],
"sourceFileMap": {
"/proc/self/cwd/external/": "${workspaceFolder}//external",
"/proc/self/cwd/": "${workspaceFolder}"
}
},
]
}
but when I launch the debug, the vsc debugger keeps initialising but never starts.
I don't know what's causing it. I've tried to reinstall C++ extensions but it did not solve my issue.
Does anyone know what it could be related to or experience the same?

"program.exe doesn't exist" in VSCode when i try to use an external window

EDIT : the g++ is in my path, it isn't the problem.
I have been trying to use a launch.json to run my c++ programs in the external terminal, but every time it gives me an error program.exe doesn't exist although it works fine in the VS Code terminal.
Here is how the launch.json is configured:
{
"configurations": [
{
"name": "run and debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

Local Variables are not showing in VS Code while debugging

I am really sorry if this question is been asked before, but I couldn't get a solution.
The following is my launch.json and Adding a picture as well. And I am really sure about it that the Program file path and debugger path is correct. The main issue is that I can not see the values of local variables even though I have marked breakpoints.
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",//Program File path is correct
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",//And I am sure this is correct as well
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

GDB failed with message:"PATH_to_exe" not in executable format: file format not recognized

I have just installed VScode and msys2 to run C++ through the instruction here: https://code.visualstudio.com/docs/languages/cpp.
I wrote a simple code to print out "helloworld". However, when I tried to run it, it showed this message: [
enter image description here
But when I compiled it by DevC++, it run smoothly without any problem. I dont know what's wrong with my VScode installation or configuration.
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) Attach",
"type": "cppdbg",
"request": "attach",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Bash on Windows Attach",
"type": "cppdbg",
"request": "attach",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "${env:windir}\\system32\\bash.exe",
"pipeArgs": ["-c"],
"pipeCwd": ""
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "cpp.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: cpp.exe build active file"
}
]
}
I doubt that it might come from the Win32 configuration in Vscode, since my Window11 is 64-bit. But there is no other options in VScode, and for Python it ran well.
I will very appreciate if someone can help me fix this.

Debugging in VS Code in Ubuntu

so i have a problem with debugging a program in VS Code in Ubuntu. When i try that i get this message launch:program 'enter program name, for example /home/daniel/Desktop/OOP/Test/a.out'does not exist and i have an option to see the launch.json file. So any ideas what is the problem? And whats wrong?
Here is the 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": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAt`enter code here`Entry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Try changing the line
"program": "enter program name, for example ${workspaceFolder}/a.out",
to this
"program": "/home/daniel/Desktop/OOP/Test/a.out",