From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2iQmB9pIrWqLvxsAWB0awg (envelope-from ) for ; Fri, 18 Sep 2026 10:21:14 -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=BANetOsD; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id ECC641E06B; Fri, 18 Sep 2026 10:21:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 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 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 B42161E01F for ; Fri, 18 Sep 2026 10:21:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B1464BB1C3F for ; Fri, 18 Sep 2026 14:21:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B1464BB1C3F 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=BANetOsD 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 D29EC4BA2E33 for ; Fri, 18 Sep 2026 14:20:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D29EC4BA2E33 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 D29EC4BA2E33 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=1789741244; cv=none; b=aYP8z6CFOpfr3IY7KYw29/UHJRcFWjA+5BP51sT//IGriuhtZWiZailJJSKbbBMXlpaIcTFqYw44C0VWcAii07iOgparW1mdbQrg0c1cMAQ9UR5cIolk+6Z1ajKsVXywWweFGKzrbODslQ+ukRSAaNyoPj2WynLtf3iRawjuxms= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789741244; c=relaxed/simple; bh=KBBTuoZL2kUAuo7jqel6baytiUCIxLrW6Ibtl95uQF4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XkgNzpjNVst5lx7JcdF/y7WeCshpBqLPh3SxNABFl4hlxO7nmwAZN38691iNs4lvwvsH6UdHzexocEesjUDsJU/oqappRVOMQ3kzmpC3xydMw1+CdPXoxXbchQ6t7aRQ3SC6dfdC+A3+TpLApHFA+ZzvUXd2xbVBFoQee49vs8o= 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=BANetOsD DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D29EC4BA2E33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789741244; 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=pxkiYOpq9XKTWQ9UEPSUmnsdYtf7hwe2zcAKlIo9W+k=; b=BANetOsDQXtWPxCQ/TKYbBHExgTzDiQq9wJcxp9uqOF4F/qLoe2qD+zNLAYzXbJ1tB0wE+ vUw8E326GRqyAa62lAztt0qxFHasS/DvYET6wcWqQAH3xWvtVahnZXGamMpM6wpw9CTqCn EEnL6QkbUlUQm0YUY0bap+TIi8+hJgA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-yoaFDxzKPSyQ9vLuPSxGIg-1; Fri, 18 Sep 2026 10:20:43 -0400 X-MC-Unique: yoaFDxzKPSyQ9vLuPSxGIg-1 X-Mimecast-MFC-AGG-ID: yoaFDxzKPSyQ9vLuPSxGIg_1789741242 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49e6c17ec1dso10146325e9.2 for ; Fri, 18 Sep 2026 07:20:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789741242; x=1790346042; h=content-transfer-encoding:content-type:mime-version:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=48S1vxUXkH+RTRHVQyG6wkoyGkFndcwCWomPadQ/Crg=; b=bXobcAS2YGl7MWBeKPOwJeV+49w9NqOaVD8g8Mr15nHWb2WgFF7EJNkDb5RyjN/DxV OSs77gq5hnHd4fqBLNpf7h+rBZZxUesOPRo2F4TH6Nz/QJOeVM4WN0/qLEpwUG1YDUKY jwOtAV3OW1r3xF4CyjZyN6BRXabiPRhT5yq4GuhCilKmrf8w6Fd6oSdyz6wVjoKX+Eyf uZmuCIYhAsLsqnvuZ4IRv03GgH1raSNQBrIxdKaNV/7EgXeSIhHwGYwL3U81OwMM0fPF t7pfO4w9Hf4J7n4UuRK19cfxP2y+tqEQX96k01OvRFA62osC9oNVHJBFk+0R5XsAqZeD tRpw== X-Forwarded-Encrypted: i=1; AKwUvBw/dQzOW+2qslYaNHiIqHu+TNiGNNuULxzt2nSAQVSsv6SLX07PN1WbH5JjvXCGELtuTZCJWA7LX6ia4w==@sourceware.org X-Gm-Message-State: AFuF++lMqimokdKORt3xbQ6alupQ7TOYbBc8Aohe1B2j1CsP72fy3VFZ ec/4sAJfwN4jMcunvvBhrefT/ei1IyoerMtdRuDh77+nasG4NpeL/+RP0/oL0pCYBrfSxm1BRZW +ABIzUsfsoCEFJKnEYzZVsjtPJ8yiRW4Ro/c3Zq5TiLiC1nBjPKLGdLJaI5Zcy7OrtCf2gFw= X-Gm-Gg: AYBFou3r9NO7sHYTZr4V9SnxDevybhJ4r39QujgX790a/IGgUsqM2ZdefqfAXiJIn6P aRqOTluiUZ/hnW55Zixmh3IAUlaU312qoaKs0IRzGTVAVW2GmimHWQ9Fe9fQCvjLae/hGK6bgv7 mJMtVcpgn16gmMThKonEzPMQFjpsafYjvb0N1cbQHefX3SA+oZnYOtDvpJ++M/lc0n++4wUYqSg 3gNUzwv7kUzlnb97UH0TM6UB+sHyZDLprp37/FyzcB6h4HI0KU48aHcSG/q1ljsA+6vCI5F4B/g 7MlzBFyH+8PviWtVI23qdsSaNgMxuaeOouEEz4nJVpNxp1mwBsOvBEeAkJxMXtJ8bAEnsLw= X-Received: by 2002:a05:600c:154c:b0:49f:c451:b4ab with SMTP id 5b1f17b1804b1-49fc5743c34mr34532285e9.29.1789741241839; Fri, 18 Sep 2026 07:20:41 -0700 (PDT) X-Received: by 2002:a05:600c:154c:b0:49f:c451:b4ab with SMTP id 5b1f17b1804b1-49fc5743c34mr34531875e9.29.1789741241307; Fri, 18 Sep 2026 07:20:41 -0700 (PDT) Received: from localhost ([83.216.138.214]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fc59286b6sm48541895e9.4.2026.09.18.07.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 07:20:40 -0700 (PDT) From: Andrew Burgess To: Alexandra =?utf-8?B?SMOhamtvdsOh?= , gdb-patches@sourceware.org Cc: ahajkova@redhat.com Subject: Re: [PATCH v12] gdb: Add source-tracking breakpoints feature In-Reply-To: <20260918114906.37069-1-ahajkova@redhat.com> References: <20260918114906.37069-1-ahajkova@redhat.com> Date: Fri, 18 Sep 2026 15:20:39 +0100 Message-ID: <871paqbpzc.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: exkDuOqhy7GK3cAIxPeWAlGHiDHjJFzC6UYD9LVaH_4_1789741242 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 Alexandra H=C3=A1jkov=C3=A1 writes: > When we rerun the executable after changing its source files, > GDB would re-set all previously set breakpoints. The > breakpoints set to the function names would remain at their initial > locations. But the breakpoints which used filename:line notation would > be silently shifted following the source code changes. > > To address this, GDB now optionally captures a small window of source > code lines around each breakpoint set with filename:line notation, > when it is first set. When the binary is reloaded, GDB detects the BFD > change and tries to locate the same source context in the new file, > and if successful, re-sets the breakpoint to the matched source code > line. > > The breakpoint_source structure stores captured source code lines > around a breakpoint location, along with a reference to the BFD > that was current when the source was captured. > > When source tracking is enabled (via 'set breakpoint source-tracking > enabled on'), GDB captures 3 lines of source context > (BREAKPOINT_SRC_CTX_LINES) along with the current BFD when a > breakpoint is first set. On executable reload (detected by comparing > BFDs), it searches within a 12-line window > (BREAKPOINT_SRC_CTX_LINES * BREAKPOINT_SRC_SEARCH_MULTIPLIER) for > the best match and adjusts the breakpoint location if needed. > > If source tracking is disabled after breakpoints have been tracked, > all existing source tracking information is discarded and a message > is printed. > > Tests added: > gdb.base/adjust_breakpoint.exp > gdb.base/adjust_breakpoint-missing-source.exp > gdb.base/source-tracking-inline.exp > gdb.base/test_source_tracking.exp > > adjust_breakpoint.exp covers four scenarios: > - adjust the breakpoint when lines are deleted > - adjust the breakpoint when lines are inserted > - the tracked line disappears entirely > - verify the tracking can be disabled > > adjust_breakpoint-missing-source.exp covers the edge case where source > files are unavailable, verifying GDB falls back to non-tracking breakpoin= ts. > > source-tracking-inline.exp covers source tracking with inline functions. > > test_source_tracking.exp verifies that source context is correctly captur= ed > when the breakpoint is on the last line of the file. > > Add maintenance command to print tracked source code. > Add documentation for the new source-tracking breakpoints feature. > > Limitations of the current implementation: > > Source tracking is not enabled for pending breakpoints that become > non-pending. When a breakpoint is created pending (e.g. with 'set > breakpoint pending on'), source context is not captured at creation > time since no symtab is available yet. When the breakpoint later > resolves to a location, re_set_default() only updates existing tracked > breakpoints and does not initiate tracking for newly resolved ones. > This could be fixed in the future by initiating source tracking in > re_set_default() when a breakpoint transitions from pending to > non-pending. > > Source tracking for ranged breakpoints is not currently supported. > Ranged breakpoints have a start and end location spec, and tracking > both independently raises questions about whether to preserve the > range length or track each end separately. For now, ranged > breakpoints will never be source-tracked. > > Reviewed-By: Eli Zaretskii > --- > gdb/NEWS | 19 + > gdb/breakpoint.c | 488 ++++++++++++++++++ > gdb/breakpoint.h | 14 + > gdb/doc/gdb.texinfo | 44 ++ > .../gdb.base/adjust_breakpoint-2.cpp | 39 ++ > .../gdb.base/adjust_breakpoint-3.cpp | 41 ++ > .../gdb.base/adjust_breakpoint-4.cpp | 37 ++ > .../adjust_breakpoint-missing-source.exp | 55 ++ > gdb/testsuite/gdb.base/adjust_breakpoint.cpp | 40 ++ > gdb/testsuite/gdb.base/adjust_breakpoint.exp | 167 ++++++ > .../gdb.base/source-tracking-inline-1.c | 50 ++ > .../gdb.base/source-tracking-inline-2.c | 50 ++ > .../gdb.base/source-tracking-inline.exp | 80 +++ > gdb/testsuite/gdb.base/test_source_tracking.c | 18 + > .../gdb.base/test_source_tracking.exp | 42 ++ > 15 files changed, 1184 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint-2.cpp > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint-3.cpp > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint-4.cpp > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint-missing-sour= ce.exp > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint.cpp > create mode 100644 gdb/testsuite/gdb.base/adjust_breakpoint.exp > create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-1.c > create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-2.c > create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline.exp > create mode 100644 gdb/testsuite/gdb.base/test_source_tracking.c > create mode 100644 gdb/testsuite/gdb.base/test_source_tracking.exp > > diff --git a/gdb/NEWS b/gdb/NEWS > index bce3b358c3f..13437acbcec 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -47,6 +47,25 @@ info locals > The new "-shadowed on|off" option overrides the "set print shadowed" > setting for a single invocation of the command. > =20 > +* GDB now supports source-tracking breakpoints, which automatically > + adjust their location when source code changes between rebuilds. > + When enabled, file and line breakpoints capture the surrounding > + source code context and use it to adjust the breakpoint line if the > + source is modified. Source tracking can be enabled with 'set > + breakpoint source-tracking enabled on'. You've added this into the 'Changed commands' section. > + > +* New commands You've added a second 'New commands' section now, which isn't correct. > + > +set breakpoint source-tracking enabled [on|off] > +show breakpoint source-tracking enabled > + Enable or disable source-tracking for file and line breakpoints. > + When enabled, breakpoints capture surrounding source code and > + automatically adjust their location when the source changes between > + recompilations. Still missing a blank line just here. > +maintenance info source-tracking-context BPNUM > + Displays the captured source context that GDB uses to track and > + adjust a breakpoint when source changes. > + > *** Changes in GDB 18 > =20 > * Support for the Common Trace Format (CTF) has been removed. GDB now > + if (new_bp_line !=3D bp_source->bp_line) > + { > + gdb_printf (_("Breakpoint %d adjusted from line %d to line %d.\n")= , > +=09=09 number, bp_source->bp_line, new_bp_line); > + notify_breakpoint_modified (this); > + } > + > + bp_source =3D std::make_unique > + (breakpoint_source_capture (expanded, BREAKPOINT_SRC_CTX_LINES)); > + if (!breakpoint_source_is_tracked (bp_source.get ())) { The '{' needs to be on a line by itself. If you can get the NEWS file sorted out, then I think we're basically ready to get this merged. I'd like to give this a little time so that anyone who would like to weigh in has a chance to do so, but I plan to give an approval for this next week. Thanks, Andrew