Message ID | 20230314130535.6369-3-tdevries@suse.de |
---|---|
State | Changes Requested |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35C8E38582BC for <patchwork@sourceware.org>; Tue, 14 Mar 2023 13:05:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35C8E38582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678799158; bh=yxZAzzp77GfbO4/HrSkurbyKxgrbGYvuVSRLgl2o9n4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nUYbu7rub4P/2jYe0zy8Cw/MLpOkraxYzDMzRUiB7e91jDnltB4iyXxfIVLCdKeQC xKIJFHqUBpwPrRuV40cd+UoHJ92YraJ4n3ISnmiiuLlqgm4gWX6X8cB7Nf7SX2hihd NqRi+6Dder0m150njArdkxf7FJxMdOW7OiDi7F2Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id E6C393858D39 for <gdb-patches@sourceware.org>; Tue, 14 Mar 2023 13:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6C393858D39 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EDA67219C6; Tue, 14 Mar 2023 13:05:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D7D5313A1B; Tue, 14 Mar 2023 13:05:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sNe8Mx5xEGQibAAAMHmgww (envelope-from <tdevries@suse.de>); Tue, 14 Mar 2023 13:05:34 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> Subject: [RFC 2/3] [gdb/dap] Allow Content-Length on separate line Date: Tue, 14 Mar 2023 14:05:34 +0100 Message-Id: <20230314130535.6369-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230314130535.6369-1-tdevries@suse.de> References: <20230314130535.6369-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tom de Vries <tdevries@suse.de> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Handle DAP command files
|
|
Commit Message
Tom de Vries
March 14, 2023, 1:05 p.m. UTC
Currently this DAP input is accepted: ... Content-Length: 54 {"seq": 1, ...}Content-Length: 163 {"seq": 2, ...}Content-Length: 136 ... Also allow: ... Content-Length: 54 {"seq": 1, ...} Content-Length: 163 {"seq": 2, ...} Content-Length: 136 ... which makes command files a bit easier to read. --- gdb/python/lib/gdb/dap/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Also allow:
Tom> ...
Tom> Content-Length: 54
Tom> {"seq": 1, ...}
Tom> Content-Length: 163
Tom> {"seq": 2, ...}
Tom> Content-Length: 136
Tom> ...
Tom> which makes command files a bit easier to read.
Doesn't this violate the XML-RPC protocol? The issue being that the
header is terminated by a blank line, but now this ignores the blank
line. Though of course it's also bad to not have a Content-Length.
Tom
On 3/14/23 15:13, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes: > > Tom> Also allow: > Tom> ... > Tom> Content-Length: 54 > > Tom> {"seq": 1, ...} > Tom> Content-Length: 163 > > Tom> {"seq": 2, ...} > Tom> Content-Length: 136 > Tom> ... > Tom> which makes command files a bit easier to read. > > Doesn't this violate the XML-RPC protocol? The issue being that the > header is terminated by a blank line, but now this ignores the blank > line. Though of course it's also bad to not have a Content-Length. OK, let's try the example from here ( https://microsoft.github.io/debug-adapter-protocol/overview ), two after each other, as confirming DAP: ... Content-Length: 119\r\n \r\n { "seq": <n>, ... }Content-Length: 119\r\n \r\n { "seq": <n>, ... } ... What I'm proposing with this patch allows in addition: ... Content-Length: 119\r\n \r\n { "seq": <n>, ... }\r\n Content-Length: 119\r\n \r\n { "seq": <n>, ... } ... So the \r\n that terminates the header is still there. And the blank line (^\r\n) that separates header and content is still there. Whether this is still confirming DAP, I can't tell from the specification. I can imagine that it makes sense for GDB to be as strict as possible to flush out problems in actual clients. OTOH, the mock-up client we create by feeding a text file into gdb doesn't actually need to conform to DAP, and there's something to win by making this text file easy to read and edit, which is what the goal of this patch is. So, perhaps we want to enable this selectively, say with a setting dap-parse-strict, and perhaps have some "set dap-cmd-input gdb.in" that automatically sets dap-parse-strict to 0. Alternatively, we could move this into the command-sphere and do something like: ... interpreter-exec dap-wrap { "seq": <n>, ... } ... and let dap-wrap take care of adding a header with the correct size. But this all might be overkill, I'm not sure. Thanks, - Tom
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Sorry about the delay in replying to this.
Tom> What I'm proposing with this patch allows in addition:
Tom> ...
Tom> Content-Length: 119\r\n
Tom> \r\n
Tom> { "seq": <n>, ... }\r\n
Tom> Content-Length: 119\r\n
Tom> \r\n
Tom> { "seq": <n>, ... }
Tom> ...
Tom> So the \r\n that terminates the header is still there.
Tom> And the blank line (^\r\n) that separates header and content is still there.
Tom> Whether this is still confirming DAP, I can't tell from the specification.
Yeah, the text says:
Since both the last header field and the overall header itself are each
terminated with \r\n, and since the header is mandatory, the content
part of a message is always preceded (and uniquely identified) by two
\r\n sequences.
which to me means that they didn't consider the possibility of a blank
line as the first line of the header part. Oops.
Tom> So, perhaps we want to enable this selectively, say with a setting
Tom> dap-parse-strict, and perhaps have some "set dap-cmd-input gdb.in"
Tom> that automatically sets dap-parse-strict to 0.
I'd be fine with this.
Tom
diff --git a/gdb/python/lib/gdb/dap/io.py b/gdb/python/lib/gdb/dap/io.py index 28f4d93ba46..fd9953a7aaa 100644 --- a/gdb/python/lib/gdb/dap/io.py +++ b/gdb/python/lib/gdb/dap/io.py @@ -28,7 +28,10 @@ def read_json(stream): line = stream.readline() line = line.strip() if line == b"": - break + if content_length != None: + break + else: + continue if line.startswith(b"Content-Length:"): line = line[15:].strip() content_length = int(line)