From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: "Alexandra Hájková" <ahajkova@redhat.com>
Subject: Re: [PATCH v8] gdb: Add source-tracking breakpoints feature
Date: Fri, 17 Jul 2026 20:31:33 -0700 [thread overview]
Message-ID: <20260717203133.0b3abbde@f44-mesa-1> (raw)
In-Reply-To: <20260714094241.178097-1-ahajkova@redhat.com>
On Tue, 14 Jul 2026 11:40:52 +0200
Alexandra Hajkova <ahajkova@redhat.com> wrote:
> +/* Match BREAKPOINT_SRC_CTX_LINES lines of the initially stored source in a
> + BREAKPOINT_SRC_CTX_LINES * BREAKPOINT_SRC_SEARCH_MULTIPLIER lines current
> + source window.
> +
> + Returns new breakpoint line on success or -1 on failure. */
> +
> +static int
> +sliding_window_match (breakpoint_source *bp_source,
> + breakpoint_source *tmp_source)
> +{
> + /* The index into BP_SOURCE's lines where the breakpoint was placed. */
> + size_t bp_stored = bp_source->bp_line_stored;
> + size_t bp_size = bp_source->source_lines.size ();
> +
> + /* An empty string, used if the breakpoint line is at the start or end of
> + the context window. */
> + static std::string empty_string;
> +
> + /* The lines immediately before and after the breakpoint in BP_SOURCE.
> + If the breakpoint is the first or last line in BP_SOURCE then use
> + EMPTY_STRING as a stand in. */
> + const std::string &bp_prev
> + = (bp_stored == 0
> + ? empty_string : bp_source->source_lines[bp_stored - 1]);
> + const std::string &bp_next
> + = ((bp_stored + 1) == bp_size
> + ? empty_string : bp_source->source_lines[bp_stored + 1]);
> +
> + /* Now search TMP_SOURCE for the breakpoint line. */
> + size_t tmp_size = tmp_source->source_lines.size ();
> + for (size_t i = 0; i < tmp_size; i++)
> + {
> + if (bp_source->source_lines[bp_stored] == tmp_source->source_lines[i])
> + {
> + /* Found the breakpoint line. Capture the lines before and after
> + the breakpoint line from TMP_SOURCE. As above, if the
> + breakpoint is at the start or end of TMP_SOURCE then use
> + EMPTY_STRING as a stand in. */
> + const std::string &tmp_prev
> + = (i == 0 ? empty_string : tmp_source->source_lines[i - 1]);
> + const std::string &tmp_next
> + = ((i + 1) == tmp_size
> + ? empty_string : tmp_source->source_lines[i + 1]);
> +
> + /* If the previous and next lines match then this is the new
> + location of the breakpoint, calculate and return the updated
> + line number. */
> + if (bp_prev == tmp_prev && bp_next == tmp_next)
> + return tmp_source->bp_line + i - tmp_source->bp_line_stored;
If BREAKPOINT_SRC_CTX_LINES were changed from 3 to, say, 5 or 7, I
don't think that this code will attempt to match all of the lines.
It appears to me that it hard codes support for only 3.
If the intent is to match the full context window, the algorithm
should compare all captured lines, not just the lines before and after
the candidate line. If 3-line matching is intentional, the comment or
documentation should be updated to clarify that the matching is
limited to the breakpoint line and its immediate neighbors, regardless
of the BREAKPOINT_SRC_CTX_LINES constant.
Kevin
prev parent reply other threads:[~2026-07-18 3:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 9:40 Alexandra Hájková
2026-07-14 11:23 ` Andrew Burgess
2026-07-14 12:22 ` Eli Zaretskii
2026-07-18 3:31 ` Kevin Buettner [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=20260717203133.0b3abbde@f44-mesa-1 \
--to=kevinb@redhat.com \
--cc=ahajkova@redhat.com \
--cc=gdb-patches@sourceware.org \
/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