Open WittonBell opened 1 year ago
gdb.exe
G:/msys64/opt/t/
Command Prompt
t
CMakeLists.txt:
cmake_minimum_required(VERSION 3.26) project(t) add_executable(t t.cpp)
t.cpp:
#include <iostream> using namespace std; int main(int argc, char* argv[]) { cout << "Hello, CMake" << endl; return 0; }
CMakePresets.json:
{ "version": 3, "configurePresets": [ { "name": "gcc-base", "hidden": true, "generator": "Ninja", "binaryDir": "${sourceDir}/build", "installDir": "${sourceDir}/install", "environment": { "MSYS2_ROOT": "G:/msys64", "MINGW64_ROOT": "$env{MSYS2_ROOT}/mingw64", "PATH": "$env{MINGW64_ROOT}/bin;$env{MSYS2_ROOT}/usr/bin;$penv{path}", "BIN_ROOT": "$env{MINGW64_ROOT}/bin", "FLAVOR": "x86_64-w64-mingw32", "TOOLSET_VERSION": "13.2.0", "INCLUDE": "$env{MINGW64_ROOT}/include;$env{MINGW64_ROOT}/lib/gcc/$env{FLAVOR}/$env{TOOLSET_VERSION}/include", "environment": "mingw_64" }, "cacheVariables": { "CMAKE_C_COMPILER": "gcc.exe", "CMAKE_CXX_COMPILER": "g++.exe" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "intelliSenseMode": "linux-gcc-x64", "intelliSenseOptions": { "useCompilerDefaults": true } } } }, { "name": "gcc-debug", "displayName": "gcc Debug", "inherits": "gcc-base", "architecture": { "value": "x64", "strategy": "external" }, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } } ] }
.vscode/settings.json
{ "cmake.debugConfig": { "MIMode": "gdb", "miDebuggerPath": "G:/msys64/opt/t/gdb.exe", "args": [], "stopAtEntry": false, "externalConsole": true, "cwd": "${workspaceFolder}", "environment": [ { "name": "PATH", "value": "G:/msys64/mingw64/bin/;G:/msys64/opt/t/;$penv{path}" } ] } }
.vscode/launch.json
{ "configurations": [ { "name": "(gdb) start", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/t.exe", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [ { "name": "PATH", "value": "G:/msys64/mingw64/bin/;G:/msys64/opt/t/;$penv{path}" } ], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "G:/msys64/opt/t/gdb.exe", "setupCommands": [ { "text": "-enable-pretty-printing", "ignoreFailures": true }, { "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] } ] }
press VSCode cmake debug button from status bar, cannot start debugging, output:
[proc] run command: G:/msys64/opt/t/gdb.exe --version [proc] command “G:/msys64/opt/t/gdb.exe --version” exited,code is 3221225781 [proc] run command: gdb --version [proc] command“gdb --version”exited,code is 1
press (gdb) start button from run and debug pannel, cannot start debugging, and then it got stuck, output:
(gdb) start
run and debug
cmd /C "c:\Users\Admin\.vscode\extensions\ms-vscode.cpptools-1.17.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-l44q34gi.smx --stdout=Microsoft-MIEngine-Out-l2bxdmon.wx2 --stderr=Microsoft-MIEngine-Error-atwk15nx.rdg --pid=Microsoft-MIEngine-Pid-44bj1vl5.xfn --dbgExe=G:/msys64/opt/t/gdb.exe --interpreter=mi "
Actually, it is because the PATH environment variable set does not take effect, resulting in the inability to find the dependent dynamic library when starting gdb.
PATH
@WittonBell Thanks for notifying us of this! I think that this is related to #1829 . Marking as a request.
Thanks!
reproduce step
gdb.exe
only to a separate directory, such asG:/msys64/opt/t/
.Command Prompt
.t
.CMakeLists.txt:
t.cpp:
CMakePresets.json:
.vscode/settings.json
.vscode/launch.json
press VSCode cmake debug button from status bar, cannot start debugging, output:
press
(gdb) start
button fromrun and debug
pannel, cannot start debugging, and then it got stuck, output:Actually, it is because the
PATH
environment variable set does not take effect, resulting in the inability to find the dependent dynamic library when starting gdb.