From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wDNqB+0VWGSQ9AEAWB0awg (envelope-from ) for ; Sun, 07 May 2023 17:19:41 -0400 Received: by simark.ca (Postfix, from userid 112) id EAB8C1E11D; Sun, 7 May 2023 17:19:40 -0400 (EDT) Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=R1szaJmL; 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=-6.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 465851E114 for ; Sun, 7 May 2023 17:19:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B96753858291 for ; Sun, 7 May 2023 21:19:39 +0000 (GMT) Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 5CD4F3858D28 for ; Sun, 7 May 2023 21:19:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5CD4F3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id C714310042E33 for ; Sun, 7 May 2023 21:19:27 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id vlmxpAc6nFYkivlmxpVIsu; Sun, 07 May 2023 21:19:27 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MdupB7zf c=1 sm=1 tr=0 ts=645815df a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=P0xRbXHiH_UA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=CCpqsmhAAAAA:8 a=7kOaVxXhJpE0UsX0z0wA:9 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r4IATnqa4p4LMGgoUL4+sRj/y0r/Afm/6YZPQ6ZF34k=; b=R1szaJmLnSAJtYvHrMEaUohq81 UvmcSg9uHxDzT6utKfCsb0g6LFnMOjtBOkfBSnWrG2UTQF4kqxdcoS5ptCNzmK/aZS+fewckZm5IJ KEtceISapGfP1yJuKGsJVSjAi; Received: from 71-211-191-82.hlrn.qwest.net ([71.211.191.82]:41676 helo=prentzel) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pvlmx-000X7s-E8; Sun, 07 May 2023 15:19:27 -0600 From: Tom Tromey To: Simon Farre via Gdb-patches Cc: Simon Farre Subject: Re: [PATCH] gdb/DAP: Add customRequest References: <20230507094144.894866-1-simon.farre.cx@gmail.com> X-Attribution: Tom Date: Sun, 07 May 2023 15:19:26 -0600 In-Reply-To: <20230507094144.894866-1-simon.farre.cx@gmail.com> (Simon Farre via Gdb-patches's message of "Sun, 7 May 2023 11:41:44 +0200") Message-ID: <871qjr6dr5.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.191.82 X-Source-L: No X-Exim-ID: 1pvlmx-000X7s-E8 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-191-82.hlrn.qwest.net (prentzel) [71.211.191.82]:41676 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" >>>>> "Simon" == Simon Farre via Gdb-patches writes: Simon> This patch introduces the customRequest, which allows for DA's (debug adapters) Simon> that want to use the full extent of GDB's functionality by working a bit Simon> like the extension of `gdb.Command` Seems reasonable to me. Simon> Unfortunately, there's nothing about such a request in the Simon> DAP-spec, but I'd argue that's really irrelevant; the largest Simon> code editor for debug adapter protocol implementers, has a notion Simon> of it, though it's up to DA-implementers to make sure they Simon> understand their own requests. Makes sense. Simon> Beyond this patch, documentation would be needed also, to document how Simon> to create customRequests, like the one above. I'm hoping Eli can provide me with Simon> some direction here. There's a DAP node in the docs where I think it would make sense to document the existence of the custom request. For implementing requests themselves, I think a new node in python.texi would be appropriate. >> @server.custom_request("foo") >> def fooRequestHandler(argumentBaz): >> # full Python interpreter access, full access to all of GDB, like we're @ the CLI >> # say goodbye to MI! Yay! :P >> return { "bar": gdb.execute("print foo", to_string=True), "someParam": argumentBaz } Simon> +@request("customRequest") Simon> +def custom_request_handler(**args): Simon> + global _custom_requests Simon> + cmd = args["command"] Simon> + if _custom_requests.get(cmd) is not None: Simon> + return _custom_requests[cmd](args["args"]) An issue here is that the DAP thread can't directly invoke code in gdb -- basically the 'gdb' module is off-limits. This is why there are decorators to assert that a given function is on the DAP thread or gdb thread. This rule is in place because the core of gdb isn't thread-safe. Probably the fix is as simple as wrapping the call with send_gdb_with_response, and having the custom_request decorator use in_gdb_thread. Tom