From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22205 invoked by alias); 21 Mar 2011 14:20:00 -0000 Received: (qmail 22191 invoked by uid 22791); 21 Mar 2011 14:19:57 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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; Mon, 21 Mar 2011 14:19:49 +0000 Received: by vws4 with SMTP id 4so6278272vws.0 for ; Mon, 21 Mar 2011 07:19:47 -0700 (PDT) Received: by 10.220.195.1 with SMTP id ea1mr1108976vcb.272.1300717187129; Mon, 21 Mar 2011 07:19:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.200.3 with HTTP; Mon, 21 Mar 2011 07:19:00 -0700 (PDT) In-Reply-To: References: From: Kevin Pouget Date: Mon, 21 Mar 2011 14:20:00 -0000 Message-ID: Subject: Re: GDB Python API: stop/continue after breakpoint To: pmuldoon@redhat.com 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/msg00108.txt.bz2 cool, that's working perfectly now ! just one thing: > > > [Switching to Thread 0x7ffff7de1700 (LWP 2417)] > > Breakpoint -9, rdb_notify_event () at replay_db.c:11 > 11 void rdb_notify_event() {} is there any way / woudn't it be nice to have the ability to disable the breakpoint hit outputs? at least for the 'internal' breakpoints, which shouldn't be visible to the user ? Thanks, Kevin On Fri, Mar 11, 2011 at 11:25 AM, 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.numbe= r) > > =A0 =A0 =A0 =A0 if ( event.inferior_thread is not None) : > > =A0 =A0 =A0 =A0 =A0 =A0 print "thread num: %s" % (event.inferior_thread= .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 thi= s 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_RESU= ME_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