From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31269 invoked by alias); 11 Mar 2011 17:52:50 -0000 Received: (qmail 31261 invoked by uid 22791); 11 Mar 2011 17:52:49 -0000 X-SWARE-Spam-Status: No, hits=0.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MISSING_HEADERS,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Mar 2011 17:52:43 +0000 Received: by vws4 with SMTP id 4so1021658vws.0 for ; Fri, 11 Mar 2011 09:52:41 -0800 (PST) Received: by 10.220.186.195 with SMTP id ct3mr2666496vcb.84.1299865959163; Fri, 11 Mar 2011 09:52:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.185.140 with HTTP; Fri, 11 Mar 2011 09:52:19 -0800 (PST) In-Reply-To: References: From: Kevin Pouget Date: Fri, 11 Mar 2011 17:52:00 -0000 Message-ID: Subject: Re: GDB Python API: stop/continue after breakpoint Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00090.txt.bz2 thanks for your answer, the patch seems to feature what I was looking for. I'm a bit surprised that the stop/continue decision can't be done in this breakpoint_stop handler, but I guess that was too complicated ? > On Fri, Mar 11, 2011 at 5:25 PM, Phil Muldoon wrote: >> >> Kevin Pouget writes: >> >> > Hello, >> > >> > I've tried the GDB python interface today, which seems quite >> > efficient, but there is one important thing I couldn't figure out by >> > myself: >> > >> > how to restart GDB when a[n internal] breakpoint is hit ? >> > from the testsuite I've got this code: >> >> >> You almost can. One part is pending: >> >> http://sourceware.org/ml/gdb-patches/2011-03/msg00656.html >> >> The implementation of the "stop" API. =A0The idea behind this is that if= a >> breakpoint is hit, that is tracked from Python and has an implemented >> stop method, that method would be called. =A0You can do what you like in >> that method. =A0If you want the inferior process to continue, return True >> otherwise return False (and print out/do whatever else you need to do in >> Python). >> >> Because internal breakpoints are not tracked by default in the Python >> Breakpoint API, you would have to create your breakpoint by >> instantiating a gdb.Breakpoint class, and pass the keyword >> internal=3DTrue. >> >> So, long story short soon. =A0OTOH I'm not sure if there is a unhacky way >> of doing it now. =A0You could use a convenience function, but that patch >> is replacing that hacky way. >> >> Cheers >> >> Phil >> > >> > def breakpoint_stop_handler (event): >> > =A0 =A0 if (isinstance (event, gdb.StopEvent)): >> > =A0 =A0 =A0 =A0 print "event type: stop" >> > =A0 =A0 if (isinstance (event, gdb.BreakpointEvent)): >> > =A0 =A0 =A0 =A0 print "stop reason: breakpoint" >> > =A0 =A0 =A0 =A0 print "breakpoint number: %s" % (event.breakpoint.numb= er) >> > =A0 =A0 =A0 =A0 if ( event.inferior_thread is not None) : >> > =A0 =A0 =A0 =A0 =A0 =A0 print "thread num: %s" % (event.inferior_threa= d.num); >> > =A0 =A0 =A0 =A0 else: >> > =A0 =A0 =A0 =A0 =A0 =A0 print "all threads stopped" >> > >> > gdb.events.stop.connect (breakpoint_stop_handler) >> > >> > >> > which where I get the notification of the stop, but I'd to be able to >> > tell GDB something like >> > >> > enum bpstat_what_main_action { >> > =A0 =A0 /* Remove breakpoints, single step once, then put them back in= and >> > =A0 =A0 =A0 =A0go back to what we were doing. =A0It's possible that th= is should >> > =A0 =A0 =A0 =A0be removed from the main_action and put into a separate= field, >> > =A0 =A0 =A0 =A0to more cleanly handle =A0BPSTAT_WHAT_CLEAR_LONGJMP_RES= UME_SINGLE. =A0*/ >> > =A0 =A0 BPSTAT_WHAT_SINGLE, >> > =A0 =A0 /* Stop silently. =A0*/ >> > =A0 =A0 BPSTAT_WHAT_STOP_SILENT, >> > >> > =A0 =A0 /* Stop and print. =A0*/ >> > =A0 =A0 BPSTAT_WHAT_STOP_NOISY, >> > ... >> > } >> > >> > to continue silently, stop silently or print the breakpoint hit. >> > >> > is it possible at this stage ? >> > >> > Thanks, >> > >> > Kevin >