Setting up VSCode for C/C++ debugging on Window 7 with gcc, g++ and gdb

后端 未结 3 687
一生所求
一生所求 2021-01-14 06:33

I was following instructions from here. Installed cpptools. Created tasks.json with following contents:

{
    \"version\": \"0.1.0\",
    \"comm         


        
相关标签:
3条回答
  • 2021-01-14 06:52

    I have faced this issue before. In my case, the compiler generated a release application as default. It has no symbols for debugging.

    So, please make sure that you are generated a debug app for debugging.

    good luck!

    0 讨论(0)
  • 2021-01-14 07:01

    If you want command.PickProcess to work..

    It should be a ':' not a '.' - therefore:

    {
        "name": ".NET Core Attach",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command:pickProcess}"
    }
    

    Should sort you out :)

    0 讨论(0)
  • 2021-01-14 07:08

    I believe you are trying to use the VS Code debugger (cppvsdbg) instead of gdb (cppdbg.) This modified launch.json works for me with TDM-GCC and gdb as the debugger:

    {
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
    
            "linux": {
                "program": "${workspaceRoot}/a.out",
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
                "program": "${workspaceRoot}\\a.exe",
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        },
        {
            "name": "C++ Attach",
            "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceRoot}/a.exe",
            "processId": "${command:pickProcess}",
            "linux": {
                "MIMode": "gdb",
                "program": "${workspaceRoot}/a.out",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        }
        ]
    }
    
    0 讨论(0)
提交回复
热议问题