[RFC,1/3,gdb/dap] Add logging of ignored lines

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

Commit Message

Tom de Vries March 14, 2023, 1:05 p.m. UTC
  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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Tom Tromey March 14, 2023, 2:12 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> This input sequence is accepted by DAP:
Tom> ...
Tom> {"seq": 4, "type": "request", "command": "configurationDone"}Content-Length: 84
Tom> ...

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

This is ok.  Thank you.

Tom
  
Tom de Vries March 24, 2023, 8:10 a.m. UTC | #2
On 3/14/23 15:12, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> This input sequence is accepted by DAP:
> Tom> ...
> Tom> {"seq": 4, "type": "request", "command": "configurationDone"}Content-Length: 84
> Tom> ...
> 
> Tom> This input sequence has the same effect:
> Tom> ...
> Tom> {"seq": 4, "type": "request", "command": "configurationDone"}ignorethis
> Tom> Content-Length: 84
> Tom> ...
> Tom> but the 'ignorethis' part is silently ignored.
> 
> This is ok.  Thank you.

Thanks for the review.

Committed after dropping the superfluous "import sys".

Thanks,
- Tom
  

Patch

diff --git a/gdb/python/lib/gdb/dap/io.py b/gdb/python/lib/gdb/dap/io.py
index 74cc82301d7..28f4d93ba46 100644
--- a/gdb/python/lib/gdb/dap/io.py
+++ b/gdb/python/lib/gdb/dap/io.py
@@ -14,8 +14,9 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import json
+import sys
 
-from .startup import start_thread, send_gdb
+from .startup import start_thread, send_gdb, log
 
 
 def read_json(stream):
@@ -31,6 +32,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))