Repository navigation
feat: an attach can start the debug adapter, for GDB, edb, netcoredbg and perl-dap - #2375
Conversation
…debug adapter that attaches to the program itself
The Attach debug mode started no process: it connected to a debug adapter
which runs, at the address and port of the Attach tab. So a debug adapter
that talks DAP only over its standard input and output, and attaches to the
program itself, as GDB's, edb's, netcoredbg's and perl-dap's do, could
attach to nothing from LSP4IJ.
"Start the debug adapter, and send it the attach request", in the Attach
tab, makes an attach start the command of the Server tab, connect to it as a
launch does, and send it the attach request. The Address and the Port don't
apply then, and stopping the session ends the debug adapter's process. A
template sets it with "attach": {"startServer": true}. It is off by default,
so an attach which connects to a debug adapter keeps doing so.
Part of redhat-developer#2337
The template's "Attach to node mynode@localhost" configuration, as edb's README gives it, starts edb, which attaches to a node started with +D, and pauses it. Stopping the session detaches edb, and the node keeps running. Part of redhat-developer#2337
…p, and its TCP attach takes an IP address
"Attach by PID" and "Attach by TCP" are attach requests that perl-dap
handles itself, so they now start perl-dap, instead of connecting to a
perl-dap that the user started with --socket. perl-dap 0.17.0 refuses the
host "localhost" of "Attach by TCP" ("invalid socket address syntax"), so
that configuration never worked: it takes 127.0.0.1.
Part of redhat-developer#2337
…he netcoredbg template's attach starts netcoredbg GDB's debug adapter attaches itself, to a process by its pid or to a gdbserver by its target: the template's "Attach to a process" and "Attach to a gdbserver" start gdb -i dap and send it the attach request. Unlike launch, attach works with GDB 15 too. netcoredbg's "Attach to a .NET process" now starts netcoredbg too, instead of connecting to one that the user started with --server, which it still does once the setting is unchecked. Fixes redhat-developer#2337
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2375 +/- ##
==========================================
+ Coverage 59.58% 59.67% +0.08%
==========================================
Files 856 857 +1
Lines 37220 37281 +61
Branches 7716 7721 +5
==========================================
+ Hits 22178 22247 +69
+ Misses 11991 11984 -7
+ Partials 3051 3050 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
|
@coderabbitai review |
Action not completed
|
Fixes #2337.
The
Attachdebug mode started no process: it connected to a debug adapter that was already running, at the address and port of theAttachtab. GDB's, edb's, netcoredbg's and perl-dap's debug adapters talk DAP only over their standard input and output, and attach to the program themselves. So, from LSP4IJ, they could attach to nothing, or only to a copy that the user had started on a port.What changes
Attachtab: a new checkbox,Start the debug adapter, and send it the attach request, makes an attach start theCommandof theServertab, connect to it as a launch does, and send it the attach request. TheAddressandPortfields are disabled while it is checked. Stopping the session ends the debug adapter's process. LSP4IJ disconnects without asking the adapter to terminate the program."attach": {"startServer": true}. It's off by default, so every existing attach configuration keeps connecting as before.Attach to a process(pid) andAttach to a gdbserver(target, withprogramfrom theFilefield).Attach to node mynode@localhost, as edb's README gives it.Attach to a .NET processnow starts netcoredbg. Its$portstays, for a netcoredbg that the user starts with--serverand connects to once the setting is unchecked.Attach by PIDandAttach by TCPnow start perl-dap.Attach by TCPtakes127.0.0.1instead oflocalhost, which perl-dap 0.17.0 refuses with "invalid socket address syntax". So that configuration never worked.Attachsection in the DAP user guide, the template field, and the attach sections of the GDB, edb, netcoredbg and perl-dap pages.There are four commits, one change each, so that each gets its own line in the release notes: please rebase-merge.
Behaviour changes
Start the debug adapter, and send it the attach requestis checked, which the GDB, edb, netcoredbg and perl-dap templates doAttach by TCPsent"host": "localhost"127.0.0.1Live checks
Each debug adapter was started over its standard input and output, as an attach with the setting starts it. Each got
initializeand the template's attach configuration, thenconfigurationDone,threadsanddisconnect:gdb -i dap, Ubuntu 24.04 container)sleep, bypidattach, its thread listed; afterdisconnectthe process kept runninggdbserver :1234 /usr/bin/sleep, bytargeterl -sname mynode@localhost -setcookie mycookie +Ddisconnectthe node kept runningprocessIddisconnectthe program kept runningprocessIdattachAttach by TCP, nothing listeninglocalhostfails with "invalid socket address syntax",127.0.0.1with "Failed to connect", as expectedTests
DAPAttachStartsTheDebugAdapterSessionTest: a real debug session whose attach starts a small DAP adapter as a process of its own, over stdio (StdioAttachAdapter). The adapter getsattach {processId=4242}and nolaunch, and stopping the session ends its process.DAPCommandLineStateTest,DebugAdapterDescriptorTest,DAPRunConfigurationCheckTest:DebugAdapterManagerAttachSettingsTest: the setting is kept in the server definition and its settings, and a change of it is a change of the server.AttachStartServerTemplatesTest,BundledDebugAdapterTemplatesTest: the GDB, edb, netcoredbg and perl-dap templates start the debug adapter, with their attach configurations. go-delve, python-debugpy and vscode-js-debug don't.