From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2650 invoked by alias); 13 Dec 2010 15:07:51 -0000 Received: (qmail 2641 invoked by uid 22791); 13 Dec 2010 15:07:50 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout22.012.net.il (HELO mtaout22.012.net.il) (80.179.55.172) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 15:07:45 +0000 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0LDD00A00EV66A00@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Mon, 13 Dec 2010 17:07:42 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.229.167.122]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LDD008WNGORH4P0@a-mtaout22.012.net.il>; Mon, 13 Dec 2010 17:07:41 +0200 (IST) Date: Mon, 13 Dec 2010 15:07:00 -0000 From: Eli Zaretskii Subject: Re: [patch] Add an evaluation function hook to Python breakpoints. In-reply-to: To: pmuldoon@redhat.com Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83zks9hfsz.fsf@gnu.org> References: <8362uxiwmc.fsf@gnu.org> 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/msg00186.txt.bz2 > From: Phil Muldoon > Cc: gdb-patches@sourceware.org > Date: Mon, 13 Dec 2010 14:47:33 +0000 > > +class MyBreakpoint (gdb.Breakpoint): > + def evaluate (self): > + inf_val = gdb.parse_and_eval("foo") > + if inf_val == 3: > + return True > + return False > > There are two scenarios where the breakpoints would be executed. The first > is where you would end up instantiating two instances of the above > breakpoint at the same location: > > python bp1 = MyBreakPoint("myfile.c:42") > python bp2 = MyBreakpoint("myfile.c:42", internal=True) So I would rephrase the text in question like this: If this function is defined in a sub-class of @code{gdb.Breakpoint}, it will be called when the inferior reaches any breakpoint which instantiates that sub-class. Does this describe correctly what will happen? > >> + The @code{evaluate} function should not > >> +attempt to influence the state of the inferior (e.g., step) or > >> +otherwise alter its data. > > > > Sounds like a non-trivial limitation; is it really necessary? > > I mentioned it as it was a non-trivial limitation? It is something the user > should not do in the evaluate function. The most pressing reason is > that there may be other breakpoints to be checked at that location so > the state of the inferior should remain. The other is it is just bad > business influencing the inferior position (i.e., stepping) when > breakpoint evaluation is being performed. We allow that from the CLI, FWIW. > This is all well and good, but we cannot prevent the user from doing > it; just tell them it is very bad idea. ;) But if there's only one breakpoint at that location, there doesn't seem to be any reasons to disallow this, right? Anyway, this is not really related to the manual; if the modified text above is okay with you, the patch for the manual is approved. Thanks.