From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100994 invoked by alias); 3 May 2019 15:26:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100975 invoked by uid 89); 3 May 2019 15:26:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*r:user, assurance, held X-HELO: relay.fit.cvut.cz Received: from relay.fit.cvut.cz (HELO relay.fit.cvut.cz) (147.32.232.237) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 15:26:54 +0000 Received: from imap.fit.cvut.cz (imap.fit.cvut.cz [147.32.232.238]) by relay.fit.cvut.cz (8.15.2/8.15.2) with ESMTPS id x43FQnWG094196 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 May 2019 17:26:51 +0200 (CEST) (envelope-from jan.vrany@fit.cvut.cz) Received: from sao (02791bac.bb.sky.com [2.121.27.172] (may be forged)) (authenticated bits=0 as user vranyj1) by imap.fit.cvut.cz (8.15.2/8.15.2) with ESMTPSA id x43FQkmF054051 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 3 May 2019 17:26:47 +0200 (CEST) (envelope-from jan.vrany@fit.cvut.cz) Message-ID: Subject: Re: [RFC 8/8] mi/python: Allow redefinition of python MI commands From: Jan Vrany To: Tom Tromey Cc: gdb-patches Date: Fri, 03 May 2019 15:26:00 -0000 In-Reply-To: <87h8al7tke.fsf@tromey.com> References: <20190418152337.6376-1-jan.vrany@fit.cvut.cz> <20190418152337.6376-9-jan.vrany@fit.cvut.cz> <87h8al7tke.fsf@tromey.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00071.txt.bz2 On Thu, 2019-04-25 at 13:50 -0600, Tom Tromey wrote: > > > > > > "Jan" == Jan Vrany writes: > > Jan> Redefining python MI commands is especially useful when developing > Jan> then. > > It seems like this could lead to difficulties with dangling pointers. > Some assurance on this would be good. I'm not sure what exactly do you mean. However, I changed mi_command_py to use gdbpy_ref<> instead of PyObject* (or even void*). Therefore when one redefines the command: + if (mi_cmd_table.find (name) != mi_cmd_table.end ()) + if (! mi_cmd_table[name]->can_be_redefined ()) + return false; + + mi_cmd_table[name] = std::move (command); then the old command (if any) is destructed so Py_DECREF() is called on Python objech held on by mi_command_py() instance. I double checked by tracing it in GDB - I don't know how to write the test for for this though. Does above address your concern? Thanks! Jan > > Tom