[RFC,0/3,gdb/dap] Handle DAP command files

Message ID 20230314130535.6369-1-tdevries@suse.de
Headers
Series Handle DAP command files |

Message

Tom de Vries March 14, 2023, 1:05 p.m. UTC
  After reporting a failure in test-case gdb.dap/bt-nodebug.exp, I tried to
reproduce the failure in the usual way, using "-q -batch -x gdb.in":
...
$ gdb -q -batch -iex "set debug dap-log-file dap.log" -i dap -x gdb.in
...
but that didn't work.  It seems that the interpreter reading in gdb.in doesn't
use DAP despite the "-i dap".  I also tried modifying gdb.in to use
interpreter-exec dap, but that didn't work for me, maybe it's possible though,
I don't know.

Then I tried:
...
$ gdb -q -iex "set debug dap-log-file dap.log" -i dap < gdb.in
...
which sort of works, but didn't reproduce the failure due to not waiting for
events, something that is dealt with in the test-case using
dap_wait_for_event_and_check.

So, I've added processing of an input line "WAIT_FOR_EVENTS: <n>" to fix that
problem (patch 3).

With editing gdb.in came the need to make it a bit more readable, so I made
it possible to start Content-Length at a new line (patch 2).

Also I've added a patch to log ignored input, which helps to debug parsing
issues (patch 1).

Using this patch series, and the following gdb.in, I managed to reproduce the
problem:
...
Content-Length: 54
WAIT_FOR_EVENTS: 1
{"seq": 1, "type": "request", "command": "initialize"}
Content-Length: 163
WAIT_FOR_EVENTS: 0
{"seq": 2, "type": "request", "command": "launch", "arguments": {"program": "bt-nodebug"}}
Content-Length: 136
WAIT_FOR_EVENTS: 2
{"seq": 3, "type": "request", "command": "setFunctionBreakpoints", "arguments": {"breakpoints": [{"name": "function_breakpoint_here"}]}}
Content-Length: 61
WAIT_FOR_EVENTS: 1
{"seq": 4, "type": "request", "command": "configurationDone"}
Content-Length: 84

{"seq": 5, "type": "request", "command": "stackTrace", "arguments": {"threadId": 1}}
Content-Length: 54

{"seq": 6, "type": "request", "command": "disconnect"}
...

Sofar, this hasn't actually helped me to investigate, when doing:
...
$ gdb --args gdb -q -iex "set debug dap-log-file dap.log" -i dap
...
followed by:
...
(gdb) run < gdb.in
...
I end up with:
...
(gdb) Undefined command: "Content-Length".  Try "help".
...
which AFAICT means that the input from gdb.in does end up in the inner gdb, but
is not parsed as DAP.

Tom de Vries (3):
  [gdb/dap] Add logging of ignored lines
  [gdb/dap] Allow Content-Length on separate line
  [gdb/dap] Allow WAIT_FOR_EVENTS input

 gdb/python/lib/gdb/dap/io.py     | 17 ++++++++++++++---
 gdb/python/lib/gdb/dap/server.py | 12 +++++++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)


base-commit: c8b3d02c49943d1fef2cc060dd7115a5ae5f7afe