From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 210A03858D28 for ; Thu, 26 Jan 2023 03:29:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 210A03858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 78C291E112; Wed, 25 Jan 2023 22:29:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1674703747; bh=ywUykwgpRQxfROj4BE5BqP9ADKz/+SCuuCaEAaJzMa8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nxwujW2uhQ4wvYdLC8d8c+J2/cJgI9Be8Ugen2eG37ANBRVr1PBRdRcsPYqO3ePmb V8/RE2MTsjV/I7iOyr0GBrRXJ7+1hT1CrGWGXTXpb0hD0wsYDbtE4st0E3ziSoWvlx VxdHVzJlHpBX4MIcFy1OeHYdIBVvvoiB+3MCY+ZE= Message-ID: <99e8075c-3f94-5b51-dc43-b74d2ad84cbd@simark.ca> Date: Wed, 25 Jan 2023 22:29:06 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH 6/9] gdb/testsuite/dap: pass around dicts instead of ton objects Content-Language: en-US To: Tom Tromey , Simon Marchi via Gdb-patches Cc: Simon Marchi References: <20230106185729.42372-1-simon.marchi@efficios.com> <20230106185729.42372-7-simon.marchi@efficios.com> <87a626tgnj.fsf@tromey.com> From: Simon Marchi In-Reply-To: <87a626tgnj.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,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 List-Id: On 1/25/23 17:04, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi via Gdb-patches writes: > > Simon> Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f > > Probably could use a commit message. Oops, that was a mistake. I always put at least a little something in the commit messages, except for the extremely obvious commits. > The main issue with this is that dicts lose type information from the > JSON. So, if we ever need to check the type of some value sent by gdb, > we won't be able to. Ah, interesting. > But I suppose we could always just add some new proc that returns the > TON form and go from there. I don't recall if I've needed any such > tests yet. Arguably maybe we should write one. The idea of my change was that we currently did `namespace eval ton::2dict` pretty much everywhere. So I thought it would be nice to make it easier on callers and to the ton::2dict for them, that makes the tests less verbose. I think we can indeed add intermediary functions that return ton objects as needed. For instance, have dap_request_and_response_ton can do most of the work, and have dap_request_and_response be a small wrapper around it to do the ton::2dict. Based on this, my commit message would be: The DAP helper functions generally return TON objects. However, callers almost all immediately use ton::2dict to convert them to dicts, to access their contents. This commits makes things a bit simpler for them by having function return dicts directly instead. The downside is that the TON objects contain type information. For instance, a "2" in a TCL dict could have been the integer 2 or the string "2" in JSON. By converting to TCL dicts, we lose that information. If some tests specifically want to check the types of some fields, I think we can add intermediary functions that return TON objects, without having to complicate other callers who don't care. Simon