I am trying to write a launch configuration for VS Code that can start gdbserver
as a preLaunchTask.
When I start debugging, everything just stalls when gdbserver says "Listening on port XXXX"
I found many examples online of methods for other debuggers, but nothing specific for gdbserver.
I have tried setting isBackground
to true
to no avail, along with trying to set up a problemMatcher
I couldn't find any documentation that seemed to explain how to write your own problemMatcher
either.
So, how do I write a task that can start gdbserver as part of a preLaunchTask for my debugger?
Here is my task to start gdbserver
{
"label": "run",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated"
},
"options": {
"cwd": "${workspaceRoot}/build"
},
"command": "ssh",
"args": [
"root@remote",
"'gdbserver localhost:9091 program'"
]
}
Here is my launch configuration
{
"name": "Remote Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/program",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "run",
"miDebuggerServerAddress": "remote:9091",
"miDebuggerPath": "aarch64-sbs-linux-gdb"
}
]
I had the same issues as you. I got it running using a pattern matcher and running it in the background. The task only starts the gdbserver on the remote target. It doesn't compiles or send the files to the remote target.
{
"type": "shell",
"label": "Start gdbserver",
"command": "ssh",
"args": [
"root@remote",
"gdbserver localhost:3000 ${fileBasenameNoExtension}"
],
// "dependsOn": [
// "optional build task"
// ],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"group": "build",
"detail": "Starts the gdbserver and waits for success",
"isBackground": true,
"problemMatcher": {
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "^.*Process*",
"endsPattern": "^.*Listening*"
}
}
},