From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21735 invoked by alias); 15 Dec 2010 16:21:21 -0000 Received: (qmail 21650 invoked by uid 22791); 15 Dec 2010 16:21:18 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Dec 2010 16:21:12 +0000 Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id oBFGLAJq016554 for ; Wed, 15 Dec 2010 08:21:10 -0800 Received: from qyk27 (qyk27.prod.google.com [10.241.83.155]) by wpaz24.hot.corp.google.com with ESMTP id oBFGJhun027856 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Wed, 15 Dec 2010 08:21:09 -0800 Received: by qyk27 with SMTP id 27so2311461qyk.15 for ; Wed, 15 Dec 2010 08:21:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.60.148 with SMTP id p20mr6599926qah.48.1292430069069; Wed, 15 Dec 2010 08:21:09 -0800 (PST) Received: by 10.220.210.12 with HTTP; Wed, 15 Dec 2010 08:21:08 -0800 (PST) In-Reply-To: References: Date: Wed, 15 Dec 2010 16:21:00 -0000 Message-ID: Subject: Re: [patch] Add an evaluation function hook to Python breakpoints. From: Doug Evans To: Tom Tromey Cc: pmuldoon@redhat.com, gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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/msg00303.txt.bz2 On Tue, Dec 14, 2010 at 9:28 AM, Tom Tromey wrote: > This patch addresses two bits of functionality we have needed in Python. > > First, we need a clean way to run some code at a given breakpoint > location -- but with the caveats that the code always be run, regardless > of other breakpoints, and that the code not interfere with stepping. > > By "clean" I just mean that we want it not to have user-visible effects > other than the effects we intend. =A0Yes, we can do it using a python > convenience function -- but the convenience function's name is visible > and in a flat namespace. The reference to convenience functions was *not* a serious attempt at arguing against doing something. It was just an off the cuff comment regarding hacky solutions. > The use case for this is something like gdb-heap, where we want to > install a breakpoint that collects some information but doesn't > interfere with ordinary debugging. > > > Second, we want a way to stop the inferior when such the data collection > step decides. =A0Our use case here is a (to-be-written) mutex-tracking > extension, that collects information about pthread locking and > unlocking, and stops when a deadlock is detected. Right. These are the "existing needs" I was referring to. > Doug> I realize the _p convention mightn't be sufficiently common to use = in > Doug> the Python API, but for example a better name might be stop_p. > Doug> And then one would have another method (I don't have a good name for > Doug> it ATM) to use to collect data. > Doug> Setting aside name choices, I like that API better. > > Having two methods seems worse to me. =A0It is more complicated without > any added benefits. One thought I had was that maybe one might have a situation where it'd be useful to run all the collect methods first, and then run all the stop_p methods. Plus I still like the API design of keeping data collection separate from stop/don't-stop. > First, both such methods will be called in the same place in gdb. =A0This > is necessary to implement the needed features. =A0But then .. why call two > methods when you can just call one? > > Second, consider the mutex-watching use case. =A0To implement this in the > two-method case, you must have the data collector set a flag, which is > then returned by the condition method. =A0Or ... just do all the work in > the condition method -- which is where we are now. Setting a flag seems hardly onerous. But don't let my $0.02 cents get in the way ... btw ... If you *really* want to go this route, go for it. Btw, if some mutex-checker or whatever detected a condition that it wanted to report to the user, IWBN to be able to throw an error that some higher level construct could recognize and deal with. Is a simple boolean result from stop_p (I'm only calling that for clarity's sake) going to be sufficient? [Heh. And if one bkpt did throw an error in stop_p, one might have wished one could have collected one's own data first. 1/2 :-)]