From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31967 invoked by alias); 13 Dec 2010 14:33:54 -0000 Received: (qmail 31959 invoked by uid 22791); 13 Dec 2010 14:33:53 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 14:33:48 +0000 Received: (qmail 16877 invoked from network); 13 Dec 2010 14:33:47 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 Dec 2010 14:33:47 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, pmuldoon@redhat.com Subject: Re: [patch] Add an evaluation function hook to Python breakpoints. Date: Mon, 13 Dec 2010 14:33:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.33-29-realtime; KDE/4.4.5; x86_64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201012131433.44512.pedro@codesourcery.com> 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: 2010-12/txt/msg00182.txt.bz2 On Monday 13 December 2010 13:50:36, Phil Muldoon wrote: > + /* Evaluate Python breakpoints that have an "evaluate" > + function implemented. */ > +#if HAVE_PYTHON > + if (b->py_bp_object) > + { > + struct cleanup *cleanup = ensure_python_env (get_current_arch (), > + current_language); > + PyObject *gdbpy_bp_eval = PyString_FromString ("evaluate"); > + PyObject *py_bp = (PyObject *) b->py_bp_object; > + > + if (PyObject_HasAttr (py_bp, gdbpy_bp_eval)) > + { > + PyObject *result = PyObject_CallMethodObjArgs (py_bp, > + gdbpy_bp_eval, > + NULL); > + > + if (result) > + { > + int evaluate = PyObject_IsTrue (result); > + > + if (evaluate == -1) > + gdbpy_print_stack (); > + > + /* If the evaluate function returns False that means the > + Python breakpoint wants GDB to continue. */ > + if (!evaluate) > + bs->stop = 0; > + } > + else > + gdbpy_print_stack (); > + } > + do_cleanups (cleanup); > + } > +#endif > + Can you factor out the PyObject manipulations and the actual evaluation of the condition to pythong/py-breakpoint.c? Say, to a new "py_breakpoint_evaluate (struct breakpoint_object *, ...)" function. The driving idea being to get rid of the need to now include python-internal.h. My first reaction was 'why not call the field "condition"? "evaluate" sounds like it's about watchpoint evaluation or some such to me. Point being, that there are several different things that are evaluated, and so it kind of sounds ambiguous. OTOH, there's chance of confusion with the condition expression set with the "condition" command. Is that one exposed to python? It may be worth it to think a bit about that, so to make sure the docs and api doesn't end up confusing when you end up exposing that condition too. I'm okay with whatever you guys come up with, just pointing it out. -- Pedro Alves