This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Reverse Debugging, 4/5


On Wednesday 01 October 2008 20:19:28, Michael Snyder wrote:
> Â
> +static void finish_backwards (struct symbol *, struct thread_info *);
> +

Minor nit.  If you put the new function here, you don't
need the forward declaration.

> Â Âfunction = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
> @@ -1427,10 +1422,29 @@ finish_command (char *arg, int from_tty)
> Â Â Â source. Â*/
> Â Âif (from_tty)
> Â Â Â{
> - Â Â Âprintf_filtered (_("Run till exit from "));
> + Â Â Âif (target_get_execution_direction () == EXEC_REVERSE)
> +ÂÂÂÂÂÂÂprintf_filtered ("Run back to call of ");
> + Â Â Âelse
> +ÂÂÂÂÂÂÂprintf_filtered ("Run till exit from ");
> +
> Â Â Â Âprint_stack_frame (get_selected_frame (NULL), 1, LOCATION);
> Â Â Â}


i18n.

> +
> +static void
> +finish_backwards (struct symbol *function, struct thread_info *tp)
> +{
> + Âstruct symtab_and_line sal;
> + Âstruct breakpoint *breakpoint;
> + Âstruct cleanup *old_chain;
> + ÂCORE_ADDR func_addr;
> + Âint back_up;
> +
> + Âif (find_pc_partial_function (get_frame_pc (get_current_frame ()),
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂNULL, &func_addr, NULL) == 0)
> + Â Âinternal_error (__FILE__, __LINE__,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ Â Â"Finish: couldn't find function.");

Can't this happen in some circunstances, like the user hitting
finish after stepi through
no-debug-info-at-all-not-even-minimal-symbols code?

> +
> + Âsal = find_pc_line (func_addr, 0);
> +
> + Â/* TODO: Let's not worry about async until later. Â*/

If you don't want to think about it now, could you error out
in the async+reverse case ?

> +
> + Â/* We don't need a return value. Â*/
> + Âtp->proceed_to_finish = 0;
> + Â/* Special case: if we're sitting at the function entry point,
> + Â Â then all we need to do is take a reverse singlestep. ÂWe
> + Â Â don't need to set a breakpoint, and indeed it would do us
> + Â Â no good to do so.
> +
> + Â Â Note that this can only happen at frame #0, since there's
> + Â Â no way that a function up the stack can have a return address
> + Â Â that's equal to its entry point. Â*/
> +
> + Âif (sal.pc != read_pc ())
> + Â Â{
> + Â Â Â/* Set breakpoint and continue. Â*/
> + Â Â Âbreakpoint =
> +ÂÂÂÂÂÂÂset_momentary_breakpoint (sal,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ Âget_frame_id (get_selected_frame (NULL)),
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ Âbp_breakpoint);
> + Â Â Â/* Tell the breakpoint to keep quiet. ÂWe won't be done
> + Â Â Â Â until we've done another reverse single-step. Â*/
> + Â Â Âbreakpoint_silence (breakpoint);
> + Â Â Âold_chain = make_cleanup_delete_breakpoint (breakpoint);
> + Â Â Âproceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
> + Â Â Â/* We will be stopped when proceed returns. Â*/
> + Â Â Âback_up = bpstat_find_breakpoint (tp->stop_bpstat, breakpoint) != NULL;
> + Â Â Âdo_cleanups (old_chain);
> + Â Â}
> + Âelse
> + Â Âback_up = 1;
> + Âif (back_up)
> + Â Â{
> + Â Â Â/* If in fact we hit the step-resume breakpoint (and not
> +ÂÂÂÂÂÂÂ some other breakpoint), then we're almost there --
> +ÂÂÂÂÂÂÂ we just need to back up by one more single-step. Â*/
> + Â Â Â/* (Kludgy way of letting wait_for_inferior know...) */
> + Â Â Âtp->step_range_start = tp->step_range_end = 1;
> + Â Â Âproceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);

Would calling step_1 or step_once instead work here?  It would
probably avoid the kludge.

I'm no reverse guru, but your comments made sense to me.


> + Â Â}
> + Âreturn;
> +}
> +
> Â
> Âstatic void
> Âenvironment_info (char *var, int from_tty)



-- 
Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]