microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

windows MinGW gdb and there is an error when call gdb #684

Closed qingzhu521 closed 7 years ago

qingzhu521 commented 7 years ago

{ "version": "0.2.0", "configurations": [ { "name": "C++ Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/main.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "miDebuggerPath": "C:\\runenv\\MinGW\\bin\\gdb.exe", "environment": [], "externalConsole": true, "windows": { "MIMode": "gdb" } } ] }
this is my launch.json and when I use debug there is a error Unable to start debugging. Unexpected GDB output from command "-gdb-set solib-search-path c:\Users\xxxx\Documents;". No symbol table is loaded. Use the "file" command. I think program mistake to give gdb command "the set solib-search-path to windows gdb"

pieandcakes commented 7 years ago

@qingzhu521 I can't duplicate this. Are you running MinGW 32bit or 64bit? did you make sure you compiled with -g to enable symbols? Below is my simple test app.

main.cpp

#include <iostream>

int main()
{
    std::cout << "Hello World" << std::endl;
}

My compile command: c:\mingw\mingw64\bin\g++ -g main.cpp

launch.json

        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "c:\\MinGW\\mingw64\\bin\\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        },
qingzhu521 commented 7 years ago

I'm sure I use "version": "0.1.0", "command": "g++", "args": [ "-g", "${file}", "-o", "main.exe" ] in task.json and in mingw32 maybe i need to try mingw64. Many thanks and I use your script and retry I failed again. ps I use surface windows 10 and I can use gdb in command line. I think there is some parameters give gdb by extension like set so-lib, this is linux command. I don't know why I have this problem. And if i use gdb ./a.exe list gdb can load symbol. And this is my g++ -v Reading specs from C:/runenv/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shar ed --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw special)

qingzhu521 commented 7 years ago

now I'm sure that the version of gcc complier get some thing wrong. I recomend that the version of g++ higher than 4.x. After I update my g++ complier and gdb tools I got correctly run.

pieandcakes commented 7 years ago

@qingzhu521 Thanks for the update. I'll go ahead and close this issue.