VSCode Output Capture when using GDB Remote Targets

101 Views Asked by At

I am attempting to capture the stdout/stderr of an application launched via SSH in the VSCode console. Although I can see the output in the debug log if I enable "logging": { "engineLogging": true }, it doesn't appear to show up in the Debug Console or the Terminal.

I am not using the seemingly more preferred method of pipeTransport due to https://github.com/microsoft/vscode-cpptools/issues/103 and this being an embedded board where it will be difficult to update the onboard version of GDB.

Here's the offending launch configuration:

{
    "name": "foo",
    "type": "cppdbg",
    "request": "launch",
    "stopAtEntry": true,
    "program": "${workspaceFolder}/build/debug/TheExecutable",
    "miDebuggerPath": "/opt/compilers/arm-none-linux-gnueabihf-10.2-2020.11/bin/arm-none-linux-gnueabihf-gdb",
    "cwd": "${workspaceFolder}",
    "MIMode": "gdb",
    "setupCommands": [
        { "text": "-enable-pretty-printing", },
        { "text": "target remote | ssh -T ${config:user}@${config:host} sudo gdbserver - /opt/bin/TheExecutable" }
    ],
},

When I set "logging": { "engineLogging": true, "exceptions": true, "programOutput": true }, the debug console emits lines that look like 1: (1836) ->&"<output from stdout/stderr>", so I know the MI debug engine is receiving the content. The leading ampersand seems to be the indicator GDB uses to differentiate MI output from captured output stream content.

You'll notice that I'm also not using VSCode's native understanding of debug servers, e.g. miDebuggerServerAddress and friends, because as far as I can tell there's no way to get a VSCode launched debug server to run as root which is needed for this application.

I've attempted all sorts of variants of explicitly setting "logging": { "programOutput": true }, filterStdout/filterStderr, and externalConsole but no joy -- nothing appears in the debug console or the terminal. With an external console enabled, it remains stubbornly blank.

That all being said, if anyone has any thoughts on why output isn't going somewhere I can see it, it would be mighty helpful.

(And it it's helpful, this is under VSCode v1.84.1 on Ubuntu 22.04)

0

There are 0 best solutions below