From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12918 invoked by alias); 27 Jan 2011 09:42:19 -0000 Received: (qmail 12889 invoked by uid 22791); 27 Jan 2011 09:42:17 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Thu, 27 Jan 2011 09:42:11 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0R9fvAq020314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Jan 2011 04:41:58 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0R9ftfA026660; Thu, 27 Jan 2011 04:41:56 -0500 From: Phil Muldoon To: Tom Tromey Cc: Doug Evans , pedro@codesourcery.com, eliz@gnu.org, gdb-patches@sourceware.org Subject: Re: [patch] Add an evaluation function hook to Python breakpoints. References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Thu, 27 Jan 2011 12:44:00 -0000 In-Reply-To: (Tom Tromey's message of "Wed, 15 Dec 2010 13:51:33 -0700") 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 X-IsSubscribed: yes 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: 2011-01/txt/msg00517.txt.bz2 Tom Tromey writes: >>>>>> "Phil" == Phil Muldoon writes: Sorry for the delay in replying. I just noticed this email has been pending for awhile. > Phil> + struct cleanup *cleanup = ensure_python_env (get_current_arch (), > Phil> + current_language); > > I didn't notice this before. I think this should use the breakpoint's > arch and language. Two odd things I noticed here. ensure_python_env requires: const struct language_defn *language But struct breakpoint only stores: language_defn->la_language So we only have the enum la_language available when we have the breakpoint. Not sure if there is a way to backtrack back to language_defn, and if not, we are stuck with current_language. Also the b->gdbarch member is NULL with watchpoints, so we have to do: PyObject *py_bp = (PyObject *) bp_obj; struct breakpoint *b = bp_obj->bp; struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch (); struct cleanup *cleanup = ensure_python_env (garch, current_language); I'm not sure why watchpoints have a NULL gdbarch, but if you grep watch_command_1, the watchpoint is eventually created with: /* Now set up the breakpoint. */ b = set_raw_breakpoint_without_location (NULL, bp_type); Where that NULL is the architecture. It never seems to be updated. Anyway we need the architecture later when we call convert_value_from_python. Without it we get: Program received signal SIGSEGV, Segmentation fault. 0x00000000005a99ab in gdbarch_data (gdbarch=0x0, data=0xbb1820) at ../../archer/gdb/gdbarch.c:3924 3924 gdb_assert (data->index < gdbarch->nr_data); (gdb) bt #0 0x00000000005a99ab in gdbarch_data (gdbarch=0x0, data=0xbb1820) at ../../archer/gdb/gdbarch.c:3924 #1 0x00000000005b3a74 in builtin_type (gdbarch=0x0) at ../../archer/gdb/gdbtypes.c:3650 #2 0x000000000050ef84 in convert_value_from_python (obj=0xc93ff0) at ../../archer/gdb/python/py-value.c:1116 #3 0x000000000050e86a in valpy_richcompare (self=0x7ffff202ee30, other=0xc93ff0, op=2) at ../../archer/gdb/python/py-value.c:907 > Phil> + if (PyObject_HasAttrString (py_bp, method)) > Phil> + { > Phil> + PyObject *result = PyObject_CallMethod (py_bp, method, NULL); > > Since we're now overloading the "condition" member, what happens if the > user sets a condition on the breakpoint? > > I think we may need an additional check here, to see if the "condition" > member is a callable object. I cannot find a way to test if an attribute is callable or not. There is: PyCallable_Check but that only refers to the object itself. I think there is only a check to see if the attribute exists (which we do), but as you correctly point out, as we are overloading "condition" that will always return True. For now, as we are waiting for other bits of the breakpoint puzzle to fall in place, I've returned the name to "eval". It is trivial to change it in the code and tests at a later date. Cheers Phil