From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XYazGzK2tmPc3g8AWB0awg (envelope-from ) for ; Thu, 05 Jan 2023 06:36:18 -0500 Received: by simark.ca (Postfix, from userid 112) id 631B81E222; Thu, 5 Jan 2023 06:36:18 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=hb78gZRn; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 19B3B1E0D3 for ; Thu, 5 Jan 2023 06:36:18 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30E153858C5E for ; Thu, 5 Jan 2023 11:36:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30E153858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672918577; bh=e6WwGBnWIJOUu1GZjRc0A56AY1nUPpBd5tpmRzxvLWY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hb78gZRn9RSGdPcO6m7jYLf4fhbhvw1w1ogb1/ziWkSu+F7m9/dLddzUfWZ/Om5ZO 0U0Aw1p90K9alHaqWqu+JBksqZkEfqubPZRNcNlkyaAuTlBKzv60/n0/8/45yj+aUr wPe5+cBJCJhFzGu1dEcZQu38Uh9R384HUCxd++lY= Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 045E13858D28 for ; Thu, 5 Jan 2023 11:35:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 045E13858D28 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 235F16ABDD; Thu, 5 Jan 2023 11:35:57 +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 0F01913338; Thu, 5 Jan 2023 11:35:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mZV4Ah22tmM6NAAAMHmgww (envelope-from ); Thu, 05 Jan 2023 11:35:57 +0000 Message-ID: <16a7949d-4a65-28a4-732e-44e6b99f9478@suse.de> Date: Thu, 5 Jan 2023 12:35:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] Initial implementation of Debugger Adapter Protocol To: Tom Tromey , gdb-patches@sourceware.org References: <20220901163059.3678708-1-tromey@adacore.com> Content-Language: en-US In-Reply-To: <20220901163059.3678708-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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] 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