From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0kQXAWLLrmo/0iEAWB0awg (envelope-from ) for ; Sat, 19 Sep 2026 13:50:26 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JODiH98K; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D06791E06B; Sat, 19 Sep 2026 13:50:25 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7988C1E01F for ; Sat, 19 Sep 2026 13:50:24 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5AF94BAE7C7 for ; Sat, 19 Sep 2026 17:50:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5AF94BAE7C7 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JODiH98K Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 798C64BA23F1 for ; Sat, 19 Sep 2026 17:49:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 798C64BA23F1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 798C64BA23F1 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789840198; cv=none; b=Ja7dc/oShSelbBEhgXkB1AK+PemVIqOVE2kLAyer8vwiq6RzT7XeO98F+3MZ9QZGGTweGDrBqA/Ny+TbeqKTuG7FUWKhh7uCVTr67gsLT65RVFsHTc5bYty5piOpY/jiYhkIuk+mCUkD4Wz49iKUBfrLHpGsJ7Kg5dNq9vf2d4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789840198; c=relaxed/simple; bh=uDaHLmbTHdKDDT+CwintGaBSOBisGDqRIYyZ9krkVNQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=jhgdd5287hf1ropRwtbBmXdlOv5Iiz4ntJRJGQOBm3bmcNrd5HbXkF6V91Z0ZY6WdteY6qtp9wdivsAOjEwKd3zrmJ3Eylu7Cnb1CsRfyjTsdbeWxdtM6gXljqfpjlYrWO/Crw5PYprXg/9Hml/bjE4tIHLZB2EFNCVUEeUr/kU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JODiH98K DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 798C64BA23F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789840198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t5u1rew99OGIjj6/Aq/v075mGCplzoNF4sPSNYNQT/g=; b=JODiH98KW+aT1i5qxJI+KeW76xfoQ4JJZIUICe50bLhSac9dA0FGXVimXo35W7LvL756tA +x1OM9v0KJqinvIrNAL1+TwrL+xGStPxTi4IcrfOeiyZPO5cK41Lhwx+ONHgmKvqMQ4qfH ZbNHXr5URczcYQMg68Qso7I3nGxXC4c= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-jieXWy7vOtKu62_a9Ip6gQ-1; Sat, 19 Sep 2026 13:49:56 -0400 X-MC-Unique: jieXWy7vOtKu62_a9Ip6gQ-1 X-Mimecast-MFC-AGG-ID: jieXWy7vOtKu62_a9Ip6gQ_1789840196 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD66E1955DA7 for ; Sat, 19 Sep 2026 17:49:55 +0000 (UTC) Received: from f44-mesa-1 (unknown [10.22.80.33]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9D5401956095; Sat, 19 Sep 2026 17:49:54 +0000 (UTC) Date: Sat, 19 Sep 2026 10:49:52 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Alexandra =?ISO-8859-1?Q?H=E1jkov=E1?= Subject: Re: [PATCH v12] gdb: Add source-tracking breakpoints feature Message-ID: <20260919104952.156363c6@f44-mesa-1> In-Reply-To: <20260918114906.37069-1-ahajkova@redhat.com> References: <20260918114906.37069-1-ahajkova@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: otCMyVkxdILx1lVmlgsvMlx7WJBCEPtELBdZIKEtYso_1789840196 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi Sasha, I had my AI driven code review tool look for changes that you might have missed making from earlier reviews. It found two... On Fri, 18 Sep 2026 13:49:06 +0200 Alexandra H=C3=A1jkov=C3=A1 wrote: > + std::string line; > + scoped_restore restore_styling =3D make_scoped_restore (&source_stylin= g, false); > + if (!g_source_cache.get_source_lines (expanded[0].symtab, > +=09=09=09=09=09expanded[0].line, > +=09=09=09=09=09expanded[0].line, &line)) > + { > + /* Source is unreadable after reload - drop tracking. */ > + bp_source.reset (); > + warning (_("could not re-capture source lines, " > +=09=09 "breakpoint %d no longer source tracked"), > +=09 number); > + return; > + } > + > + if (line =3D=3D bp_source->source_lines[bp_source->bp_line_stored]) > + { > + /* Line unchanged - just refresh the capture with the new BFD. */ > + bp_source =3D std::make_unique > +=09(breakpoint_source_capture (expanded, BREAKPOINT_SRC_CTX_LINES)); > + return; > + } Back in his review of your v11 patch, Andrew wrote: This call to breakpoint_source_capture could, in theory, fail, though I don't know why it ever would. But still, you should handle this case like you do all the other breakpoint_source_capture calls: if (!breakpoint_source_is_tracked (b->bp_source.get ())) =09{ =09 warning (_("unable to refresh source tracking for breakpoint %d, " =09=09 "source tracking disabled"), =09=09 number); =09 b->bp_source.reset (); =09} This still needs to be done. [...] > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 0bb0a46738f..635509f5409 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -4661,6 +4661,27 @@ program. > On some systems, you can set breakpoints in shared libraries before > the executable is run. > =20 > +@cindex source-tracking breakpoints > +@cindex breakpoints, automatic adjustment when source changes > +@value{GDBN} supports @dfn{source-tracking breakpoints}, which > +automatically adjust their location when source code changes between > +recompilations. When enabled with @kbd{set breakpoint source-tracking > +enabled on}, breakpoints set by file and line number capture a small > +window of surrounding source lines centered on the breakpoint line. > +If the source file is modified and the executable is rebuilt, > +@value{GDBN} searches a window of approximately 12 lines centered on the > +breakpoint's original position for the best match. For each candidate > +line that matches the original breakpoint line, @value{GDBN} compares > +all captured context lines at their corresponding offsets and scores the > +match by how many lines agree. The candidate with the highest score is > +selected, provided a majority of the context lines match, reducing false > +positives from short or repeated lines. If no match meets the threshold= , > +@value{GDBN} issues a warning and keeps the breakpoint at its original > +location, disabling source tracking for that breakpoint. Note that > +breakpoints set by function name or address are not affected by source > +tracking. > +@xref{Set Breaks}. > + > @cindex watchpoints > @cindex data breakpoints > @cindex memory tracing > @@ -42092,6 +42113,13 @@ Shared library events. > =20 > @end table > =20 > +@kindex maint info source-tracking-context > +@item maint info source-tracking-context @var{num} > +For source-tracking breakpoints (@pxref{Breakpoints}), print the > +tracked source code context for breakpoint @var{num}. If breakpoint > +@var{num} is not source tracked, or @var{num} is not a valid > +breakpoint number, then the command gives an error. > + > @kindex maint info btrace > @item maint info btrace > Pint information about raw branch tracing data. > @@ -42960,6 +42988,22 @@ Control whether to show all non zero areas withi= n a 1k block starting > at thread local base, when using the @samp{info w32 thread-information-b= lock} > command. > =20 > +@kindex set breakpoint source-tracking enabled > +@kindex show breakpoint source-tracking enabled > +@item set breakpoint source-tracking enabled @r{[}on@r{|}off@r{]} > +@itemx show breakpoint source-tracking enabled > +Control whether to enable source-tracking for breakpoints set by file an= d > +line number. Use @code{on} to enable, @code{off} to disable. When > +enabled, @value{GDBN} captures a window of source lines around each > +new file:line breakpoint and uses it to relocate the breakpoint if the > +source is modified and the executable is rebuilt. @xref{Breakpoints}, > +for a full description of the matching algorithm and its limitations. > +The default is @code{off}. Breakpoints set by function name or address > +are not affected by this setting. > + > +If this setting is changed from @samp{on} to @samp{off}, then any > +existing source tracking information will be discarded. > + In v8, Eli asked you to update the manual mentioning the preconditions for this new feature to work. You might just say something like this: Source tracking requires that source files be accessible and that the executable contain line-number debug information. Kevin