Search code examples
debugginggdbserver

Problem setting up debug configuration to attach to a gdbserver in Vis.Code


I was trying to setup debug configuration to attach to already running gdbserver.

(ref used: https://code.visualstudio.com/docs/cpp/launch-json-reference)

[Note. I can attach and debug with an arch specific gdb instance fine to the gdbserver]

That's the template that has logic check deadlock.

{
    "name": "(gdb) Attach to gdbserver in QEMU",
    "type": "cppdbg",
    "request": "attach",
    "MIMode": "gdb",
    "miDebuggerPath": "/path/to/gdb/../../bin/mips-mti-linux-gnu-gdb",
    "miDebuggerServerAddress": "localhost: 1234",
    "program": "${workspaceFolder}/__out--MIPS64r6_MTI/vmlinux",
    // "processId": "${command:none}",
    // "processId": "${command:pickProcess}",
    // "processId": "23739",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        }
    ]
},

When no "processId" given, it complains: unable to parse process id

When some valid "processId" given (and then some process also selected from the list, if demanded by UI), it complains: 'processId' cannot be used with miDebuggerServerAddress

Does anyone know how to resolve this deadlock in VC debug config parsing logic or this is a bug?

Thank you.


Solution

  • Ok. After several tries it worked ;)

    Using the "request": "launch" (despite sounds a bit illogical, as we're attaching to already running process, just supplied with gdbserver i-face) without "processId" as advised in #577 bug discussion, the DB session was braking up initially with complain: remote replied unexpectedly to 'vMustReplyEmpty': timeout, but eventually worked after repeated tries ;)

    Note. For "lanuch" case, VC demanded also adding: "cwd": "${workspaceRoot}"

    The VC+CPP-plugin support needs updating the instructions then (https://code.visualstudio.com/docs/cpp/launch-json-reference). It sounds really illogical to use "request": "launch" to actually do the attach action :).