From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XfskFvSKtWr3jj4AWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 16:41:24 -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=BH+KZEnk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 32FFC1E01F; Thu, 24 Sep 2026 16:41:24 -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 5E9A01E01F for ; Thu, 24 Sep 2026 16:41:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE37B4BB58C9 for ; Thu, 24 Sep 2026 20:41:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE37B4BB58C9 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=BH+KZEnk Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 07A324BB58AC for ; Thu, 24 Sep 2026 20:40:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07A324BB58AC 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 07A324BB58AC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790282458; cv=none; b=lSTjXOknnEi+ZyFQu1ThGNGw5YaTgtaeqO6FFDDOQCaiiOSAESEWHH8gXBfIjL70lv9kUQsLq0EYyhYaQu3kNpsbFe6xWRkDKXmW2mhJu+Uss4MIKLDuLpdxxXcLGcB5OMQfn3cR96ho+hnE7o7nSCHRphAwukHwHVGKDMExst4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790282458; c=relaxed/simple; bh=7gZlRbPWekgonTQBosILW0T9LRhTa1FngIhHFMfy4+M=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=mB5TdyH7UU/ueSdfHEywDqH8Vts7Ar8+qhzPhmmC9E4obQX7YHBwghnx1vd27HBj4bwz4XWZNccvTAGXIPjnSjKgs63asfOMI7dG+cRH/JPGvbA1/33RfmhVd0GaZihFWL9m579YhrFPcUUKkjhFepiFQinJIsJ4eAwb2Cl1JGw= 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=BH+KZEnk DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07A324BB58AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790282457; 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=5+htB4urGwrBVTZYbWhMRghHsjpnxX1MapPzJvmgDxM=; b=BH+KZEnkQpmWa35zPO8HUjssQcUvloQLMqNV94shjpS8xdjyuadNnpJXhK6f7I02/7D0UQ xb8wuXtpw120S5ghatdCcuczoqiUO9VamnoCH3o4FR6HP+U26p9UDtZ2lYSbFDbkW0c1vq El7kb0n54lefzqzoDn81mfGTWxYIHCo= Received: from mx-prod-mc-05.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-511-115uioOPOt-kI3KxtEC6Hg-1; Thu, 24 Sep 2026 16:40:55 -0400 X-MC-Unique: 115uioOPOt-kI3KxtEC6Hg-1 X-Mimecast-MFC-AGG-ID: 115uioOPOt-kI3KxtEC6Hg_1790282454 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6D639195607C for ; Thu, 24 Sep 2026 20:40:54 +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 D1C771956047; Thu, 24 Sep 2026 20:40:52 +0000 (UTC) Date: Thu, 24 Sep 2026 13:40:49 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Alexandra =?ISO-8859-1?Q?H=E1jkov=E1?= Subject: Re: [PATCH v13] gdb: Add source-tracking breakpoints feature Message-ID: <20260924134049.48f0a66f@f44-mesa-1> In-Reply-To: <20260924145146.172604-1-ahajkova@redhat.com> References: <20260924145146.172604-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: 7k95d3yGfIsdK7M4KJNDGujh183ULvr_9M_Gzs8wJIo_1790282454 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 On Thu, 24 Sep 2026 16:51:36 +0200 Alexandra H=C3=A1jkov=C3=A1 wrote: > 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. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > If source tracking is disabled after breakpoints have been tracked, > all existing source tracking information is discarded and a message > is printed. >=20 > 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 >=20 > 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 >=20 > adjust_breakpoint-missing-source.exp covers the edge case where source > files are unavailable, verifying GDB falls back to non-tracking breakpoin= ts. >=20 > source-tracking-inline.exp covers source tracking with inline functions. >=20 > test_source_tracking.exp verifies that source context is correctly captur= ed > when the breakpoint is on the last line of the file. >=20 > Add maintenance command to print tracked source code. > Add documentation for the new source-tracking breakpoints feature. >=20 > Limitations of the current implementation: >=20 > 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. >=20 > 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. >=20 > Reviewed-By: Eli Zaretskii > --- Looks good now! There are, of course, some improvements that could be made, but I think it makes sense to get this initial version in so that it can be easily tested by the community in the course of doing day-to-day work. Approved-By: Kevin Buettner