From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10812 invoked by alias); 9 Oct 2008 00:36:34 -0000 Received: (qmail 10801 invoked by uid 22791); 9 Oct 2008 00:36:33 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 09 Oct 2008 00:35:58 +0000 Received: (qmail 32536 invoked from network); 9 Oct 2008 00:35:56 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Oct 2008 00:35:56 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFA] Resubmit reverse debugging [4/5] Date: Thu, 09 Oct 2008 00:36:00 -0000 User-Agent: KMail/1.9.9 Cc: Michael Snyder References: <48EC18B9.5050209@vmware.com> In-Reply-To: <48EC18B9.5050209@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200810090135.56035.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: 2008-10/txt/msg00265.txt.bz2 A Wednesday 08 October 2008 03:19:37, Michael Snyder escreveu: > 2008-10-07 =C2=A0Michael Snyder =C2=A0 >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* breakpoint.c (make_brea= kpoint_silent): New function. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* breakpoint.h (make_brea= kpoint_silent): Export. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* infcmd.c (finish_comman= d): Check for reverse exec direction. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(finish_backward): New fu= nction, handle finish cmd in reverse. >=20 > Index: breakpoint.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/breakpoint.c,v > retrieving revision 1.352 > diff -u -p -r1.352 breakpoint.c > --- breakpoint.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A016 Sep 20= 08 18:55:01 -0000=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01.352 > +++ breakpoint.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A08 Oct 200= 8 01:25:26 -0000 > @@ -7741,6 +7741,13 @@ breakpoint_clear_ignore_counts (void) > =C2=A0 =C2=A0 =C2=A0b->ignore_count =3D 0; > =C2=A0} > =C2=A0 > +void > +make_breakpoint_silent (struct breakpoint *b) > +{ > + =C2=A0/* Silence the breakpoint. =C2=A0*/ > + =C2=A0b->silent =3D 1; > +} > + > =C2=A0/* Command to set ignore-count of breakpoint N to COUNT. =C2=A0*/ > =C2=A0 > =C2=A0static void > Index: breakpoint.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/breakpoint.h,v > retrieving revision 1.79 > diff -u -p -r1.79 breakpoint.h > --- breakpoint.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A022 Sep 20= 08 15:26:53 -0000=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A01.79 > +++ breakpoint.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A08 Oct 200= 8 01:25:26 -0000 > @@ -884,4 +884,7 @@ extern int breakpoints_always_inserted_m > =C2=A0 =C2=A0 in our opinion won't ever trigger. =C2=A0*/ > =C2=A0extern void breakpoint_retire_moribund (void); > =C2=A0 > +/* Tell a breakpoint to be quiet. =C2=A0*/ > +extern void make_breakpoint_silent (struct breakpoint *); > + > =C2=A0#endif /* !defined (BREAKPOINT_H) */ > Index: infcmd.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/infcmd.c,v > retrieving revision 1.212 > diff -u -p -r1.212 infcmd.c > --- infcmd.c=C2=A0=C2=A0=C2=A0=C2=A022 Sep 2008 15:20:08 -0000=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A01.212 > +++ infcmd.c=C2=A0=C2=A0=C2=A0=C2=A08 Oct 2008 01:25:26 -0000 > @@ -1366,6 +1366,67 @@ finish_command_continuation_free_arg (vo > =C2=A0 =C2=A0xfree (arg); > =C2=A0} > =C2=A0 > +/* finish_backward -- helper function for finish_command. =C2=A0*/ > + > +static void > +finish_backward (struct symbol *function, struct thread_info *tp) > +{ > + =C2=A0struct symtab_and_line sal; > + =C2=A0struct breakpoint *breakpoint; > + =C2=A0struct cleanup *old_chain; > + =C2=A0CORE_ADDR func_addr; > + =C2=A0int back_up; > + > + =C2=A0if (find_pc_partial_function (get_frame_pc (get_current_frame ()), > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0NULL, &func_addr, NULL) =3D=3D 0) > + =C2=A0 =C2=A0internal_error (__FILE__, __LINE__, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0_("Finish: couldn't find function.")); > + Still internal_error? > + =C2=A0sal =3D find_pc_line (func_addr, 0); > + > + =C2=A0/* TODO: Let's not worry about async until later. =C2=A0*/ > + Should be an error here instead of on finish_command ... (keep reading) > + =C2=A0/* We don't need a return value. =C2=A0*/ > + =C2=A0tp->proceed_to_finish =3D 0; > + =C2=A0/* Special case: if we're sitting at the function entry point, > + =C2=A0 =C2=A0 then all we need to do is take a reverse singlestep. =C2= =A0We > + =C2=A0 =C2=A0 don't need to set a breakpoint, and indeed it would do us > + =C2=A0 =C2=A0 no good to do so. > + > + =C2=A0 =C2=A0 Note that this can only happen at frame #0, since there's > + =C2=A0 =C2=A0 no way that a function up the stack can have a return add= ress > + =C2=A0 =C2=A0 that's equal to its entry point. =C2=A0*/ > + > + =C2=A0if (sal.pc !=3D read_pc ()) > + =C2=A0 =C2=A0{ > + =C2=A0 =C2=A0 =C2=A0/* Set breakpoint and continue. =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0breakpoint =3D > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0set_momentary_breakpoint (sal, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0get_frame_id (get_selected_fr= ame (NULL)), > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0bp_breakpoint); > + =C2=A0 =C2=A0 =C2=A0/* Tell the breakpoint to keep quiet. =C2=A0We won'= t be done > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 until we've done another reverse single-ste= p. =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0make_breakpoint_silent (breakpoint); > + =C2=A0 =C2=A0 =C2=A0old_chain =3D make_cleanup_delete_breakpoint (break= point); > + =C2=A0 =C2=A0 =C2=A0proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); > + =C2=A0 =C2=A0 =C2=A0/* We will be stopped when proceed returns. =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0back_up =3D bpstat_find_breakpoint (tp->stop_bpstat= , breakpoint) !=3D NULL; > + =C2=A0 =C2=A0 =C2=A0do_cleanups (old_chain); > + =C2=A0 =C2=A0} > + =C2=A0else > + =C2=A0 =C2=A0back_up =3D 1; > + =C2=A0if (back_up) > + =C2=A0 =C2=A0{ > + =C2=A0 =C2=A0 =C2=A0/* If in fact we hit the step-resume breakpoint (an= d not > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 some other breakpoint), then = we're almost there -- > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 we just need to back up by on= e more single-step. =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0/* (Kludgy way of letting wait_for_inferior know...= ) */ > + =C2=A0 =C2=A0 =C2=A0tp->step_range_start =3D tp->step_range_end =3D 1; > + =C2=A0 =C2=A0 =C2=A0proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); > + =C2=A0 =C2=A0} I guess calling step_once doesn't help then? Otherwise, "kludgy" here sounds unfair... This is, after all, the interface used to request a single-step even in forward direction ... > + =C2=A0return; Useless. > +} > + > =C2=A0/* "finish": Set a temporary breakpoint at the place the selected > =C2=A0 =C2=A0 frame will return to, then continue. =C2=A0*/ > =C2=A0 > @@ -1391,6 +1452,10 @@ finish_command (char *arg, int from_tty) > =C2=A0 =C2=A0if (async_exec && !target_can_async_p ()) > =C2=A0 =C2=A0 =C2=A0error (_("Asynchronous execution not supported on thi= s target.")); > =C2=A0 > + =C2=A0/* Don't try to async in reverse. =C2=A0*/ > + =C2=A0if (async_exec && execution_direction =3D=3D EXEC_REVERSE) > + =C2=A0 =C2=A0error (_("Asynchronous 'finish' not supported in reverse."= )); > + > =C2=A0 =C2=A0/* If we are not asked to run in the bg, then prepare to run= in the > =C2=A0 =C2=A0 =C2=A0 foreground, synchronously. =C2=A0*/ > =C2=A0 =C2=A0if (!async_exec && target_can_async_p ()) > @@ -1412,13 +1477,6 @@ finish_command (char *arg, int from_tty) > =C2=A0 > =C2=A0 =C2=A0clear_proceed_status (); > =C2=A0 > - =C2=A0sal =3D find_pc_line (get_frame_pc (frame), 0); > - =C2=A0sal.pc =3D get_frame_pc (frame); > - > - =C2=A0breakpoint =3D set_momentary_breakpoint (sal, get_frame_id (frame= ), bp_finish); > - > - =C2=A0old_chain =3D make_cleanup_delete_breakpoint (breakpoint); > - > =C2=A0 =C2=A0/* Find the function we will return from. =C2=A0*/ > =C2=A0 > =C2=A0 =C2=A0function =3D find_pc_function (get_frame_pc (get_selected_fr= ame (NULL))); > @@ -1427,10 +1485,29 @@ finish_command (char *arg, int from_tty) > =C2=A0 =C2=A0 =C2=A0 source. =C2=A0*/ > =C2=A0 =C2=A0if (from_tty) > =C2=A0 =C2=A0 =C2=A0{ > - =C2=A0 =C2=A0 =C2=A0printf_filtered (_("Run till exit from ")); > + =C2=A0 =C2=A0 =C2=A0if (execution_direction =3D=3D EXEC_REVERSE) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0printf_filtered (_("Run back t= o call of ")); > + =C2=A0 =C2=A0 =C2=A0else > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0printf_filtered (_("Run till e= xit from ")); > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0print_stack_frame (get_selected_frame (NULL), = 1, LOCATION); > =C2=A0 =C2=A0 =C2=A0} > =C2=A0 > + =C2=A0if (execution_direction =3D=3D EXEC_REVERSE) > + =C2=A0 =C2=A0{ > + =C2=A0 =C2=A0 =C2=A0/* Split off at this point. =C2=A0*/ > + =C2=A0 =C2=A0 =C2=A0finish_backward (function, tp); > + =C2=A0 =C2=A0 =C2=A0return; > + =C2=A0 =C2=A0} Didn't Joel request you to not do this, but do, finish_command if (execution_direction =3D=3D EXEC_REVERSE) finish_backward (); else finish_forward (); instead ? (then, it makes sense to put the async + reverse error inside finish_backward, IMHO.) > + > + =C2=A0sal =3D find_pc_line (get_frame_pc (frame), 0); > + =C2=A0sal.pc =3D get_frame_pc (frame); > + > + =C2=A0breakpoint =3D set_momentary_breakpoint (sal, get_frame_id (frame= ),=20 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 bp_finish); > + > + =C2=A0old_chain =3D make_cleanup_delete_breakpoint (breakpoint); > + > =C2=A0 =C2=A0tp->proceed_to_finish =3D 1;=C2=A0=C2=A0=C2=A0/* We want sto= p_registers, please... =C2=A0*/ > =C2=A0 =C2=A0make_cleanup_restore_integer (&suppress_stop_observer); > =C2=A0 =C2=A0suppress_stop_observer =3D 1; --=20 Pedro Alves