FH Remote Debug
Debugging of the feedhandlers on a remote test server with GDB over SSH.
This extension is a fork of Native Debug (WebFreak001/code-debug, public
domain). The only functional difference is the SSH connection: the debugger is run through the ssh command of the
system instead of a JavaScript SSH library, so that ~/.ssh/config (ProxyJump, User…), the SSH agent and all the
key formats supported by OpenSSH work exactly as in a terminal (needed on the STF network).
Usage
The debug configuration is generated by FH Remote Install in the launch.json of each feedhandler project
("Remote Debug GDB"); start it from the Run and Debug view or with the debug button of the FH Projects view.
{
"type": "fh-gdb",
"request": "launch",
"name": "Remote Debug GDB",
"target": "cme_mdp3_stream_server",
"arguments": "-s",
"ssh": {
"host": "lonld6-lxc-rnd01",
"user": "jdoe",
"cwd": "/home/jdoe/cme_mdp3_stream_server/",
"sourceFileMap": { "/home/jdoe/jdoe_feedos/feedos_feedhandler_cme_mdp3/": "/local/path/feedos_feedhandler_cme_mdp3" }
}
}
The debug type is fh-gdb (it was gdb before 3.0.1, the type of Native Debug: both extensions can now be installed
together). FH Remote Install regenerates the former configurations automatically.
SSH options
| Option |
Effect |
host, user, port |
ssh -p <port> <user>@<host>; without user, the User of ~/.ssh/config or the local user is used |
keyfile |
ssh -i <keyfile> |
useAgent |
the SSH agent (SSH_AUTH_SOCK) |
password |
given to sshpass -e through the environment (requires sshpass); prefer SSH keys |
forwardX11 |
ssh -X, to the local $DISPLAY (x11host/x11port are ignored) |
bootstrap |
command run before the debugger, e.g. source env.sh |
cwd, sourceFileMap |
working directory on the server and remote → local source paths |
Core dumps
An attach configuration with coreDumpPath (path on the SSH host) opens the core dump with executable instead of
attaching to target; the session starts stopped on the crash. FH Remote Install builds these configurations from the
FH Projects view (launch, attach to the running instance, core dump).
Without password, ssh runs with BatchMode=yes: a missing key fails immediately with the ssh error in the Debug Console
instead of waiting for a prompt. New host keys are accepted (StrictHostKeyChecking=accept-new).
All the other options (breakpoints, watch, registers, autorun, valuesFormatting, printCalls…) are those of Native
Debug: see its documentation.
Development
npm install
npm run lint
npm test # unit tests
npx @vscode/vsce package
Updating from Native Debug
The FH changes are kept in fh.patch, relative to the upstream commit written in UPSTREAM:
scripts/upstream.sh update # apply fh.patch on upstream master, then build, lint and test
scripts/upstream.sh update <commit> # or on a given commit
scripts/upstream.sh diff # after changing the FH sources: regenerate fh.patch
On conflicts the script stops and tells where to resolve them. The FH changes are limited to src/backend/mi2/system_ssh.ts, the ssh() function and the SSH
branch of stop() in src/backend/mi2/mi2.ts, the identifiers (fh-gdb type, fh-remote-debug.* commands,
fh-debugmemory scheme, fh-remote-debug-sockets folder), the core dump option (coreDumpPath in gdb.ts), the SSH
branch of detach() and package.json.