From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
"luis.machado@arm.com" <luis.machado@arm.com>
Cc: Rogerio Alves Cardoso <rogealve@br.ibm.com>,
"will_schmidt@vnet.ibm.com" <will_schmidt@vnet.ibm.com>,
"blarsen@redhat.com" <blarsen@redhat.com>,
"cel@us.ibm.com" <cel@us.ibm.com>
Subject: Re: [PATCH, v6] Fix reverse stepping multiple contiguous PC ranges over the line table
Date: Tue, 21 Jun 2022 16:52:04 +0000 [thread overview]
Message-ID: <8761ed60f570bee77d25043b49a2bccaa1b40886.camel@de.ibm.com> (raw)
In-Reply-To: <20220609130421.245260-1-luis.machado@arm.com>
Luis Machado <luis.machado@arm.com> wrote:
Carl asked me to look into this as well, so a couple of comments:
>When stepping forward from line 40, we skip both of these ranges and
>land on line 42. When stepping backward from line 42, we stop at the
>start PC of the second (or first, going backwards) range of line 40.
I've been wondering why the forward-stepping case works. It looks
like this is because of the code at the end of process_event_stop_test,
which verifies whether we have stepped to a different line, and if not,
just continues stepping.
It seems it would be preferable to have the same mechanism for both
forward- and reverse-stepping, but that doesn't work because of
this piece of code you point out:
>This happens because we have this check in
>infrun.c:process_event_stop_test:
>
> /* When stepping backward, stop at beginning of line range
> (unless it's the function entry point, in which case
> keep going back to the call point). */
> CORE_ADDR stop_pc = ecs->event_thread->stop_pc ();
> if (stop_pc == ecs->event_thread->control.step_range_start
> && stop_pc != ecs->stop_func_start
> && execution_direction == EXEC_REVERSE)
> end_stepping_range (ecs);
> else
> keep_going (ecs);
In my view, this code is already questionable. This is under the
overall control of "pc_in_thread_step_range", and the point of
this is to check that we're still supposed to step! But even
though the test returns true, we now add a special case where
we stop stepping after all ...
Maybe we should not hard-code the end_stepping_range call here, but
rath
er just fall through to the rest of process_event_step_test
to handle
whatever other case we may encounter? Or equivalently,
have
pc_in_thread_step_range do a
start < pc <= end
comparison in the
EXEC_REVERSE case, instead of
start <= pc < end
[ But maybe this is also better done as independent cleanup,
I'm not saying we necessarily have to do it this way ... ]
>Another solution I thought about is to merge the contiguous ranges
>when we are reading the line tables. Though I'm not sure if we
>really want to process that data as opposed to keeping it as the
>compiler created, and then working around that.
Maybe not immediately when reading the line tables; we might
want to actually use the column granularity at some point.
But at the point where we set up the stepping range in
prepare_one_step, we could increase the range *there*.
This might not only be somewhat simpler, but also improve
performance since the check is only done once and not every
time we run through process_event_stop_test (and it might
even also improve the performance of forward-stepping in
those cases if we increase the range downwards too).
>+ CORE_ADDR range_start = ecs->event_thread-
>>control.step_range_start;
>+ if (execution_direction == EXEC_REVERSE)
>+ {
>+ gdb::optional<CORE_ADDR> real_range_start
>+ = find_line_range_start (ecs->event_thread->stop_pc ());
>+
>+ if (real_range_start.has_value ())
>+ range_start = *real_range_start;
>+ }
>+
> /* When stepping backward, stop at beginning of line range
> (unless it's the function entry point, in which case
> keep going back to the call point). */
> CORE_ADDR stop_pc = ecs->event_thread->stop_pc ();
>- if (stop_pc == ecs->event_thread->control.step_range_start
>+ if (stop_pc == range_start
> && stop_pc != ecs->stop_func_start
> && execution_direction == EXEC_REVERSE)
> end_stepping_range (ecs);
As an aside, if we keep this approach, it would be cleaner
to have the whole logic under a single "if EXEC_REVERSE".
(There is no point in choosing a value for the "range_start"
variable in EXEC_FORWARD if it is never used.)
Bye,
Ulrich
prev parent reply other threads:[~2022-06-21 16:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 13:04 Luis Machado
2022-06-09 15:18 ` will schmidt
2022-06-16 21:13 ` [PING] " Carl Love
2022-06-21 16:52 ` Ulrich Weigand [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=8761ed60f570bee77d25043b49a2bccaa1b40886.camel@de.ibm.com \
--to=ulrich.weigand@de.ibm.com \
--cc=blarsen@redhat.com \
--cc=cel@us.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@arm.com \
--cc=rogealve@br.ibm.com \
--cc=will_schmidt@vnet.ibm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).