[gdb/dap] Add logging of ignored lines
authorTom de Vries <tdevries@suse.de>
Fri, 24 Mar 2023 08:08:10 +0000 (09:08 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 24 Mar 2023 08:08:10 +0000 (09:08 +0100)
This input sequence is accepted by DAP:
...
{"seq": 4, "type": "request", "command": "configurationDone"}Content-Length: 84
...

This input sequence has the same effect:
...
{"seq": 4, "type": "request", "command": "configurationDone"}ignorethis
Content-Length: 84
...
but the 'ignorethis' part is silently ignored.

Log the ignored bit, such that we have:
...
READ: <<<{"seq": 4, "type": "request", "command": "configurationDone"}>>>
WROTE: <<<{"request_seq": 4, "type": "response", "command": "configurationDone"
, "success": true}>>>
+++ run
IGNORED: <<<b'ignorethis'>>>
...

gdb/python/lib/gdb/dap/io.py

index 74cc82301d747936d0219b92cf78973523e458d9..7cec7b032e3c12438b5073743c8d803ed14bbe0b 100644 (file)
@@ -15,7 +15,7 @@
 
 import json
 
-from .startup import start_thread, send_gdb
+from .startup import start_thread, send_gdb, log
 
 
 def read_json(stream):
@@ -31,6 +31,8 @@ def read_json(stream):
         if line.startswith(b"Content-Length:"):
             line = line[15:].strip()
             content_length = int(line)
+            continue
+        log("IGNORED: <<<%s>>>" % line)
     data = bytes()
     while len(data) < content_length:
         new_data = stream.read(content_length - len(data))