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 043873888825 for ; Fri, 18 Mar 2022 19:57:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 043873888825 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7FAEE1F0D2; Fri, 18 Mar 2022 15:57:41 -0400 (EDT) Message-ID: Date: Fri, 18 Mar 2022 15:57:40 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCHv5] gdb/python/mi: create MI commands using python Content-Language: tl To: Andrew Burgess Cc: Jan Vrany , gdb-patches@sourceware.org References: <20220224103749.1719761-1-aburgess@redhat.com> <20220228164801.1276366-1-aburgess@redhat.com> <20220318161243.GQ1212730@redhat.com> From: Simon Marchi In-Reply-To: <20220318161243.GQ1212730@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3639.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 18 Mar 2022 19:57:43 -0000 On 2022-03-18 12:12, Andrew Burgess via Gdb-patches wrote: > * Simon Marchi [2022-03-18 11:06:43 -0400]: > >>> + /* Lookup the gdb.MICommand object in the dictionary of all Python MI >>> + commands, this is gdb._mi_command, and remove it. */ >>> + PyObject *curr = PyDict_GetItemWithError (mi_cmd_dict.get (), >>> + name_obj.get ()); >> >> This doesn't build with Python 2: >> >> /home/simark/src/binutils-gdb/gdb/python/py-micmd.c: In function ‘int micmdpy_uninstall_command(micmdpy_object*)’: >> /home/simark/src/binutils-gdb/gdb/python/py-micmd.c:430:20: error: ‘PyDict_GetItemWithError’ was not declared in this scope; did you mean ‘PyDict_GetItemString’? >> 430 | PyObject *curr = PyDict_GetItemWithError (mi_cmd_dict.get (), >> | ^~~~~~~~~~~~~~~~~~~~~~~ >> | PyDict_GetItemString >> > > Simon, > > After discussion on IRC, I believe you are working on a patch that > switches this code to make use of a C++ map (or some other > container). If/when that patch is ready then that has my +1 as a > better solution. > > However, just in case you don't have time for that, below is a work > around which I believe should be acceptable. I believe this patch is > OK only because I know that in a couple of weeks Py2 support is going > to be removed from master, so this work around would only live on in > the GDB 12 branch. Hi, Here's my patch: https://sourceware.org/pipermail/gdb-patches/2022-March/186799.html In the end I think it's simpler if we don't use a separate container at all, just make the mi_command_py objects hold the reference to the Python objects. Simon