From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25872 invoked by alias); 12 Oct 2010 21:34:59 -0000 Received: (qmail 25776 invoked by uid 22791); 12 Oct 2010 21:34:59 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_WB,T_FILL_THIS_FORM_SHORT,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Oct 2010 21:34:54 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9CLYkC0020971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Oct 2010 17:34:46 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9CLYkmr016214; Tue, 12 Oct 2010 17:34:46 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9CLYja3029294; Tue, 12 Oct 2010 17:34:45 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 059223780FB; Tue, 12 Oct 2010 15:34:44 -0600 (MDT) From: Tom Tromey To: pmuldoon@redhat.com Cc: Pedro Alves , gdb-patches@sourceware.org, dan@codesourcery.com Subject: Re: [patch] Add visible flag to breakpoints. References: <201009301741.32379.pedro@codesourcery.com> <201010081435.15174.pedro@codesourcery.com> Date: Tue, 12 Oct 2010 21:34:00 -0000 In-Reply-To: (Phil Muldoon's message of "Tue, 12 Oct 2010 21:24:49 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 X-SW-Source: 2010-10/txt/msg00207.txt.bz2 >>>>> "Phil" == Phil Muldoon writes: Phil> In this patch iteration I removed any form of storage/tracking of Phil> breakpoints. Instead, as above, I placed a reference in the breakpoint Phil> struct. I like this better. Phil> There are two disadvantages that stem from this: Phil> * I had to extern breakpoint_chain Phil> * I had to move the ALL_BREAKPOINTS macro to breakpoint.h Phil> I'm not sure how to get around those, or, if indeed they are perceived Phil> as disadvantages. It is definitely bad to do this. I think it is fixable, though. It is a little odd that the observer passes the number and not the breakpoint itself. Phil> + if (internal && PyObject_IsTrue (internal)) Phil> + internal_bp = 1; PyObject_IsTrue can return -1 on failure, so this code must account for that. I see we have a case where we don't check this in py-prettyprint.c :( I will fix that. Phil> + int i = 0; Phil> + ALL_BREAKPOINTS (b) This instance of ALL_BREAKPOINTS should probably be replaced with some kind of callback API, like the other iterate_over_* functions in gdb. Phil> + { Phil> + /* Not all breakpoints will have a companion Python object. Phil> + Only breakpoints that were created via bppy_new, or Phil> + breakpoints that were created externally and are tracked by Phil> + the Python Scripting API. */ Phil> + if (b->py_bp_object) Phil> + { Phil> + if (PyTuple_SetItem (result, i, (PyObject *) b->py_bp_object) != 0) I think that cast to PyObject is unnecessary. Phil> + { Phil> + Py_DECREF (result); Phil> + return NULL; Phil> + } Phil> + Py_INCREF (b->py_bp_object); This incref should come before the call to PyTuple_SetItem. Phil> @@ -667,9 +673,7 @@ gdbpy_breakpoint_created (int num) Phil> breakpoint_object *newbp; Phil> struct breakpoint *bp = NULL; Phil> PyGILState_STATE state; Phil> - Phil> - if (num < 0) Phil> - return; Phil> + int error = 0; I am not certain that we want a new breakpoint object to be created for internal breakpoints set by other modules. It seems potentially harmful. I think one way to do this would be to rephrase this check as if (num < 0 && bppy_pending_object == NULL) Phil> + newbp->bp->py_bp_object = (PyObject *)newbp; No cast. Phil> + if (! error) Phil> + ++bppy_live; You can get rid of the 'error' local and just push this back up into the "ok" branch of the preceding 'if'. Phil> /* Just ignore errors here. */ Phil> PyErr_Clear (); I think this is redundant now. Phil> + ALL_BREAKPOINTS (b) Phil> + { Phil> + if (b->number == num) Phil> + { Phil> + breakpoint_object *bp_obj = Phil> + ((breakpoint_object *)b->py_bp_object); I think you can replace this ALL_BREAKPOINTS with a call to get_breakpoint. Space after the close paren in the cast. Tom