From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Initial implementation of Debugger Adapter Protocol
Date: Thu, 5 Jan 2023 12:35:56 +0100 [thread overview]
Message-ID: <16a7949d-4a65-28a4-732e-44e6b99f9478@suse.de> (raw)
In-Reply-To: <20220901163059.3678708-1-tromey@adacore.com>
On 9/1/22 18:30, Tom Tromey via Gdb-patches wrote:
> +def read_json(stream):
> + """Read a JSON-RPC message from STREAM.
> + The decoded object is returned."""
> + # First read and parse the header.
> + content_length = None
> + while True:
> + line = stream.readline()
> + line = line.strip()
> + if line == b"":
> + break
> + if line.startswith(b"Content-Length:"):
> + line = line[15:].strip()
> + content_length = int(line)
> + data = bytes()
> + while len(data) < content_length:
> + new_data = stream.read(content_length - len(data))
> + data += new_data
> + result = json.loads(data)
> + return result
Hi,
In case you haven't seen it, on IRC someone mentioned:
...
[10:53] <john3> does -i dap already something usable? I get a python
exception on startup: /usr/local/share/gdb/python/gdb/dap/io.py while
len(data) < content_length: "TypeError: '<' not supported between
instances of 'int' and 'NoneType'\n
...
I didn't manage to reproduce this, but looking at the code I think it's
possible that this could be triggered, and that this would fix it:
...
diff --git a/gdb/python/lib/gdb/dap/io.py b/gdb/python/lib/gdb/dap/io.py
index 656ac08b4ec..1d561f07665 100644
--- a/gdb/python/lib/gdb/dap/io.py
+++ b/gdb/python/lib/gdb/dap/io.py
@@ -22,7 +22,7 @@ def read_json(stream):
"""Read a JSON-RPC message from STREAM.
The decoded object is returned."""
# First read and parse the header.
- content_length = None
+ content_length = 0
while True:
line = stream.readline()
line = line.strip()
...
Thanks,
- Tom
next prev parent reply other threads:[~2023-01-05 11:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-01 16:30 Tom Tromey
2022-09-01 16:38 ` Eli Zaretskii
2022-09-12 19:54 ` Tom Tromey
2022-09-13 2:26 ` Eli Zaretskii
2022-10-06 14:27 ` Tom Tromey
2023-01-02 16:54 ` Tom Tromey
2023-01-03 8:04 ` Tom de Vries
2023-01-03 14:14 ` Tom Tromey
2023-01-04 11:59 ` Tom de Vries
2023-01-04 12:27 ` Tom de Vries
2023-01-05 9:49 ` [PATCH] [gdb/python] Avoid queue.SimpleQueue for python 3.6 Tom de Vries
2023-01-05 15:19 ` Tom Tromey
2023-01-05 16:34 ` Tom de Vries
2023-01-05 17:07 ` Tom Tromey
2023-01-05 11:35 ` Tom de Vries [this message]
2023-01-05 15:24 ` [PATCH] Initial implementation of Debugger Adapter Protocol Tom Tromey
2023-01-05 16:17 ` Tom de Vries
2023-01-06 14:12 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16a7949d-4a65-28a4-732e-44e6b99f9478@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).