From: Andrew Cagney <cagney@gnu.org>
To: Orjan Friberg <orjan.friberg@axis.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: STEP_SKIPS_DELAY question, sort of
Date: Mon, 25 Oct 2004 20:18:00 -0000 [thread overview]
Message-ID: <417D5F4E.5010403@gnu.org> (raw)
In-Reply-To: <415D3EC2.80804@axis.com>
Sorry, picking up old threads.
Orjan Friberg wrote:
> Andrew Cagney wrote:
>
>>
>> Can a simple, separate, more explicit logic like:
>> if (we just did a step and STEP_SKIPS_DELAY (pc))
>> set up for another step
>> return;
>> work? The [handle_inferior_event patch snipped] was nested within
>> other logic and that's not good from a readability / maintainability
>> point of view.
>
>
> Now that I've done a lot more testing, I'm picking this up again.
> (Below is just the infrun.c part; gdbarch.sh obviously needs a patch,
> and mips-tdep.c needs to have its current STEP_SKIPS_DELAY
> implementation converted - I'll post a complete patch if this part is
> approved of.)
>
> A few things:
> * I'm not sure how to reliably detect the situation "stepping off a
> breakpoint" in handle_inferior_event. I used stop_signal ==
> TARGET_SIGNAL_TRAP && trap_expected && currently_stepping (ecs)); could
> that be too inclusive?.
I think this is sufficient. Can you add something mentioning "stepping
off a breakpoint" to the comment - that makes the intent clear.
> * Distinguishing between "step" and "continue" (using step_range_end) is
> not necessary for it to work, but explicitly returning in the "continue"
> case is making things a bit clearer.
Always a good idea.
Andrew
> * As the comment suggests, in the "step" case we don't want to preclude
> the stop_after_trap check - I assume that whatever is in the delay slot
> could potentially correspond to a single line of code (if nothing else,
> then at least an asm("...") construct.)
>
> Index: infrun.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/infrun.c,v
> retrieving revision 1.177
> diff -u -r1.177 infrun.c
> --- infrun.c 13 Sep 2004 18:26:28 -0000 1.177
> +++ infrun.c 1 Oct 2004 11:22:42 -0000
> @@ -721,17 +721,12 @@
>
> if (read_pc () == stop_pc && breakpoint_here_p (read_pc ()))
> oneproc = 1;
> -
> -#ifndef STEP_SKIPS_DELAY
> -#define STEP_SKIPS_DELAY(pc) (0)
> -#define STEP_SKIPS_DELAY_P (0)
> -#endif
> - /* Check breakpoint_here_p first, because breakpoint_here_p is fast
> - (it just checks internal GDB data structures) and
> STEP_SKIPS_DELAY
> - is slow (it needs to read memory from the target). */
> - if (STEP_SKIPS_DELAY_P
> - && breakpoint_here_p (read_pc () + 4)
> - && STEP_SKIPS_DELAY (read_pc ()))
> +
> + /* If we stepped into something that needs to be stepped again
> before
> + before re-inserting the breakpoint, then do so. */
> + else if (gdbarch_single_step_through_delay_p (current_gdbarch)
> + && gdbarch_single_step_through_delay (current_gdbarch,
> + get_current_frame ()))
> oneproc = 1;
> }
> else
> @@ -1793,6 +1788,35 @@
> stopped_by_random_signal = 0;
> breakpoints_failed = 0;
>
> + if (gdbarch_single_step_through_delay_p (current_gdbarch)
> + && stop_signal == TARGET_SIGNAL_TRAP && trap_expected
> + && currently_stepping (ecs))
> + {
> + /* We are in the process of stepping off a breakpoint. If we
> stepped
> + into something that needs to be stepped again before re-inserting
> + the breakpoint, then do so. */
> + int step_through_delay
> + = gdbarch_single_step_through_delay (current_gdbarch,
> + get_current_frame ());
> + if (step_range_end == 0 && step_through_delay)
> + {
> + /* The user issued a continue when stopped at a breakpoint.
> + Set up for another trap and get out of here. */
> + ecs->another_trap = 1;
> + keep_going (ecs);
> + return;
> + }
> + else if (step_through_delay)
> + {
> + /* The user issued a step when stopped at a breakpoint.
> + Maybe we should stop, maybe we should not - the delay slot
> + *might* correspond to a line of source. In any case, don't
> decide
> + that here, just set ecs->another_trap, making sure we
> + single-step again before breakpoints are re-inserted. */
> + ecs->another_trap = 1;
> + }
> + }
> +
> /* Look at the cause of the stop, and decide what to do.
> The alternatives are:
> 1) break; to really stop and return to the debugger,
>
prev parent reply other threads:[~2004-10-25 20:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-21 17:14 Orjan Friberg
2004-05-21 20:25 ` Andrew Cagney
2004-05-24 9:15 ` Orjan Friberg
2004-05-24 18:15 ` Andrew Cagney
2004-05-25 11:53 ` Orjan Friberg
2004-05-25 21:14 ` Andrew Cagney
2004-05-26 9:39 ` Orjan Friberg
2004-05-26 17:39 ` Andrew Cagney
2004-06-07 12:12 ` Orjan Friberg
2004-06-07 12:42 ` Orjan Friberg
2004-06-07 13:09 ` Orjan Friberg
2004-06-07 15:08 ` Andrew Cagney
2004-06-09 9:48 ` Orjan Friberg
2004-06-09 16:00 ` Andrew Cagney
2004-06-14 12:09 ` Orjan Friberg
2004-06-16 14:53 ` Orjan Friberg
2004-06-24 18:25 ` Andrew Cagney
2004-10-01 11:26 ` Orjan Friberg
2004-10-25 20:18 ` Andrew Cagney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=417D5F4E.5010403@gnu.org \
--to=cagney@gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=orjan.friberg@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox