Following the documentation provided by VSCode for C++ provided on this link: https://code.visualstudio.com/docs/languages/cpp, I ran into trouble when checking the MinGW installation. When I ran gdb --version I got this:
$ gdb --version
-bash: gdb: command not found
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
You should add the same Installation Folder used in step 3 of installation instruction to the system PATH variable or if you have used installer to install the MinGW find the MinGW installation directory by opening your C drive and add that path to system PATH (in my case Ex: C:\msys64\mingw64\bin)
Make sure the C:\msys64\mingw64\bin is not empty, if it's empty mostly you haven't continued from the step 5 after installing MYSYS from installer
After adding system PATH, close and open cmd window just type path in cmd and enter to make sure your MinGW path is addedd to system PATH, (you can copy paste the output to notepad/notepad++ and search MinGW to find the path)
Once MinGW is in the path your gdb command should work (please provide this screenshot of path command output, if it's still didn't work)