From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mpGbG7JmW2QTYQUAWB0awg (envelope-from ) for ; Wed, 10 May 2023 05:41:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 5E6E31E11D; Wed, 10 May 2023 05:41:06 -0400 (EDT) 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=On2asNAl; 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=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 F2AF31E0D4 for ; Wed, 10 May 2023 05:41:04 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7067A385734E for ; Wed, 10 May 2023 09:41:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7067A385734E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683711663; bh=yKFA9EHXP0FgISbmbNiz2TLqr9fCGJCGIOqOGwyhG0s=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=On2asNAlEneivJrTBdWBQFqBagXxJY/lg0Brfw4bfFL7QmBWcuJ7n+SSzJu0bOzNY mch67AKEerWzIiM2wWQlDipCD3Cd/ftY39rxd7xFjWZ0Wb/dx37+UrPKKa4LLC5kwS tD7Rjg3ktKy4/smVtCIEh5kYRygjWxIS2aRykmc0= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 8CC833858C31 for ; Wed, 10 May 2023 09:40:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CC833858C31 Received: from octopus (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 2261980791; Wed, 10 May 2023 09:40:39 +0000 (UTC) Date: Wed, 10 May 2023 10:40:35 +0100 To: Simon Farre Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/DAP: Add customRequest Message-ID: <20230510094035.x7po26hd6c5dgsqt@octopus> References: <20230507094144.894866-1-simon.farre.cx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230507094144.894866-1-simon.farre.cx@gmail.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Wed, 10 May 2023 09:40:40 +0000 (UTC) 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: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi Simon, I have a couple of remarks below. > +@request("customRequest") > +def custom_request_handler(**args): It looks like the args dict must contain the "command" and "args". I would find it clearer if this was stated in the function definition like so: def custom_request_handler(*, command, args): If args can contain more keys (which will be ignored by the implementation), it could be: def custom_request_handler(*, command, args, **kwargs): > + global _custom_requests > + cmd = args["command"] > + if _custom_requests.get(cmd) is not None: > + return _custom_requests[cmd](args["args"]) Just a nit, but the cmd lookup could be done just once: cmd = _custom_requests.get(command) if cmd is not None: return cmd(args) Also see Tom's comment regarding which thread you want this to execute in. This part could become return send_gdb_with_response(lambda: cmd(args)) > + else: > + raise Exception(f"Unrecognized customRequest {cmd}") I am not sure we guarantee python >= 3.6, so f-strings might not be available. That being said, as python-3.6 istelf is not supported anymore we could maybe just bump the required version. Best, Lancelot.