gdb implements the "repl" context for the "evaluate" request by passing the string to gdb as a command. However, if the command is something like "continue", gdb will simply continue -- but the DAP thread will presumably wait, because eval_request uses send_gdb_with_response. At least... I think this should happen. Step 1 would be to write a test for this. Then, if it fails, some solution would have to be found. Perhaps a global flag to automatically treat continue commands as if they had a "&" would work.
It occurs to me that this could also happen with the "target" command, and for that one, "&" isn't implemented.
See bug#7251. Bug #7253 is also maybe relevant. Maybe it would be enough to use send_gdb and then have any output from the command be sent as output events, not in the response. Then the reader thread could accept interrupt requests.
Most of the problem could be solved by noticing when the inferior continues and telling the DAP response that it is done. This wouldn't help with the "target" problem though.
I realized somewhat belatedly that this problem also affects evaluation of expressions that involve an inferior call. These can't be handled by changing how the output is directed.
I was thinking this could be handled by implementing cancellation, but that will give weird results when used to interrupt an inferior call. Like, I suppose it would work, but the inferior will be left in a somewhat weird state. Also it seems a little strange to use cancellation to interrupt a gdb CLI "continue" but not a DAP "continue".
(In reply to Tom Tromey from comment #5) > Also it seems a little strange to use cancellation to interrupt > a gdb CLI "continue" but not a DAP "continue". I go back and forth on this, but I suppose the difference is that a repl evaluation of "continue" won't return a result, so cancel would be correct.
I'm working on this.
https://sourceware.org/pipermail/gdb-patches/2023-December/204689.html
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c79c8dad90e4382100b51694a2b9ee7e913a04a commit 1c79c8dad90e4382100b51694a2b9ee7e913a04a Author: Tom Tromey <tromey@adacore.com> Date: Tue Nov 7 10:56:07 2023 -0700 Implement DAP cancellation This implements DAP cancellation. A new object is introduced that handles the details of cancellation. While cancellation is inherently racy, this code attempts to make it so that gdb doesn't inadvertently cancel the wrong request. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30472 Approved-By: Eli Zaretskii <eliz@gnu.org> Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Fixed.