From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ERZLL81+BGt0zy8AWB0awg (envelope-from ) for ; Mon, 23 Nov 2026 12:58:37 -0500 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=H47ECUFr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BBD871E167; Mon, 23 Nov 2026 12:58:37 -0500 (EST) 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 [38.145.34.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 2E0CD1E023 for ; Mon, 23 Nov 2026 12:58:35 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4839F444AB29 for ; Mon, 23 Nov 2026 17:58:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4839F444AB29 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=H47ECUFr 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 B4ED2444AB33 for ; Mon, 23 Nov 2026 17:57:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4ED2444AB33 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 B4ED2444AB33 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=1795456674; cv=none; b=tqS4uUUI3mdcFZ6ZLnC3KxFpuwsV26kiDB9AJY3IISQ8TR/BicRY8keMBm1FiHfyqGZvy6OVGfwRXv2yTIQo8quMorHKoUwccDFHPInlgcRBLAZOkDzLO0dLCQ4Dqqc6UFKaBw6Pu2xosq6F1+L/IH0kyEk5v/JASABy8Nq680Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795456674; c=relaxed/simple; bh=BcofzGxeOxvEaAqFKheUdTpKZIMRAn+QYiI41BvdcoY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PABmajaTR9WDdJ0/a6ErKtbQFaNo5CgsQlKEPJAE4UtuwEy0R6gU730B5q0dLyYYOJW0F6u2KeadL1wYRd1Nz5lGgB3gxKVmk8CzW+GNPJ7YcOpO2V8Pw7nX+tEJaz4IUKpvIeG+KJjL+hHbadCrVrsEyhF/SNgoVlg20RlPivs= 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=H47ECUFr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4ED2444AB33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795456674; 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=Ix4mVQ8B6u/T/Z+9923/tqn04p+YO2CKybpcxi/19tw=; b=H47ECUFranaSeYIAjvX5cq7A2lWraIH0d1UrD1uJsQyIzGPkFO1M2SNqB7sX36J1L94BeE YKEcsGhW+efTBOKYIqPeQOpyK3XdY/duBqf2L71WlLY4zR1paAqV4UpiUUMiZ5cyL1MASq DeEe5b2DBfeJ+j/gz4vVtXaKQc5JBe0= 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-620-OVJywsjdPHWDj6fAmDH3sg-1; Mon, 23 Nov 2026 17:57:52 +0000 X-MC-Unique: OVJywsjdPHWDj6fAmDH3sg-1 X-Mimecast-MFC-AGG-ID: OVJywsjdPHWDj6fAmDH3sg_1795456671 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a0284121c6so26043205e9.3 for ; Mon, 23 Nov 2026 09:57:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795456671; x=1796061471; 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=HX3qW7nZD/sa0icX+ZylJgjJjzZ9haFO7JScVFMtH68=; b=QQ88uTqC7Lo+M6ceR3h9gCA3d11/aowFS+HnaJXUTCOjVZxfCMrY0napCk+GAB8asR DF42kx8J/ZDpSDlQMoAxMaDbMTz+mHyNpiefMejDJbVPdgGoL1P6Ma/gr9Oud3SlKSDR b1bLSm9cT99L2rDEIQgAQg6h9offLP75CdyluRMWscDOUorLNYuR0N0gfjx6RaUqmn3h Pd2C8dfUkcszPgGWnG3aeQD1mE6Zb9Hn2oiDjTFeg0tW1A9xqG8+YVPTXw0AEfvC3CNS u089QdPdjBbtKimIuZI54j3inS0bM8lWVAGIH/bY4oK7L6wcnZzh0/TGGqZfjUwmNA0c mKfA== X-Gm-Message-State: APuU4Z8Pa4gS4N9fQJsoYn9PE/ePiefF89v6RbOx6nWpLeFP+jIvzi/J 89h87XlOySRrdECJZrm4iSIiFkJxzMVJ3AgJpXW9UG6CTKadtwtdwv48JWJ/flxKMExvFag0hJC zX5M29g/XcCPuffbI35LqA8cS5YgMsShV/uuGQQE3Ichcc5srYrZEAazgfWXpVX8zgGQB18s= X-Gm-Gg: AZFdTZdS9PsTihnmUbt7/6wu9tZpHdcirQXgQHXKV8Mr71KS8eoSqXRzkYV4Mamc6A1 vqnUbtPPlW1c9uAUKJLzf7+JjvyUDX7+fofk+vveIXYW/oinoOjXjq90Vbg9dxSQdTTylpzPB5G YeTfUPUs2CkCVJO5Nfu5T7CiRnISQE1PwcYFVXqJYoiqdhk9fFCJ36MPGBLucfmM3/aG5DAmRrv m8kFv3GSpqCAphcDjNQii1/O+SzmZfDretREWei7o1ls21ANXcaZT1ECWqunKAtcfZAkdZ4N7Rb bRhqhjRluC1+J2odmJasXLOK4Fmkc4xw2gBxyDqAguP0leubbNSOZuHqGUd6OyKO+U46yQHsC8j cKfPuy+JyCbZ89PaJIGvHvywQuUBgjh7Y6rBKKDgpijK82g== X-Received: by 2002:a05:600c:1547:b0:4a2:397:73f6 with SMTP id 5b1f17b1804b1-4bb8880974amr283594895e9.8.1795456670299; Mon, 23 Nov 2026 09:57:50 -0800 (PST) X-Received: by 2002:a05:600c:1547:b0:4a2:397:73f6 with SMTP id 5b1f17b1804b1-4bb8880974amr283594205e9.8.1795456669569; Mon, 23 Nov 2026 09:57:49 -0800 (PST) Received: from localhost ([83.216.138.189]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb9066f6e6sm149568515e9.3.2026.11.23.09.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 09:57:49 -0800 (PST) From: Andrew Burgess To: Alexandra Petlanova Hajkova Cc: gdb-patches@sourceware.org Subject: Re: [PATCHv2] gdb: support source tracking for multi-location breakpoints In-Reply-To: References: <5d354be53ea21f4da7b446c6337d694c06c475f3.1791027408.git.aburgess@redhat.com> <9d85474c038ae3af4775b77158dc2441de72dc6a.1792675799.git.aburgess@redhat.com> Date: Mon, 23 Nov 2026 17:57:47 +0000 Message-ID: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gUK347n5xqObKORSq5VDyC8o-M3TxYErzt7MAlxsy_I_1795456671 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 Petlanova Hajkova writes: > On Thu, Oct 22, 2026 at 3:35=E2=80=AFPM Andrew Burgess wrote: > >> In v2: >> >> * Replaced strcmp with filename_cmp when comparing filenames. I >> think this could make a difference if different CUs were compiled >> with different filename cases on a case insensitive filesystem. >> But I suspect this is a pretty unlikely edge case. Still, doesn't >> hurt to do it right. >> >> * Now handle, or rather, spot and deliberately don't handle, the >> case where a multi-location breakpoint is in multiple different >> objfiles. >> >> * New tests for the multi-objfile case. >> >> * Some minor grammar issues fixed in comments and commit message. >> >> ~~~~~ >> >> Currently, when breakpoint source tracking is enabled (see 'set >> breakpoint source-tracking enabled on'), GDB will not source track >> multi-location breakpoints. >> >> As a first take this was fine, but I think that we can support source >> tracking for some multi-location breakpoints. >> >> Source tracking only applies to breakpoints set based on a file and >> line number, so the rest of this discussion is only concerned with >> this case. This includes things like 'break file:line' and also >> 'break line'. In the latter case GDB uses the current source file to >> provide the filename, so the two cases are really equivalent. >> >> If we consider 'break file:line' then there are a few ways that this >> can resolve to multiple locations. >> >> First, if 'file:line' lands in an inline function, and the inline >> function is inlined multiple times (or has an out-of-line >> instantiation) then there can be multiple locations. However, there >> is only a single source line for all of these breakpoint locations, >> the original line in the single original file. >> >> A second way that 'file:line' can result in multiple locations is if >> file is not an absolute filename, and the partial filename matches >> multiple source files in the executable, and each source file has >> source code on the requested line number. In this case we have a >> single breakpoint, but multiple source files. GDB can only track a >> single source line per breakpoint, so in this case source tracking is >> not possible. >> >> You might think that this second case indicates that the source >> tracking information should be per-breakpoint location, not per >> breakpoint. However, this would not be a good idea. >> >> The breakpoint spec, i.e. the 'file:line' is part of the breakpoint >> itself. When source tracking indicates that a source line has moved >> this spec is updated. If we source tracked per-location what would we >> do when one source file changed but not the other? This would leave >> us in a situation where one location might be left at 'file:line' >> while another needs to change to 'file:(line + 1)'. Supporting this >> would require the actual breakpoint spec to be per-location, and >> would, I think, have much bigger implications for how GDB handles >> breakpoints. >> >> For now then, I propose sticking with the current approach, the >> breakpoint spec and the source tracking are per-breakpoint. >> >> A third way in which 'file:line' breakpoints can result in multiple >> locations is when an inferior has multiple objfiles loaded, for >> example, when using shared libraries. The same source file can be >> compiled into multiple objfiles, in which case, a breakpoint placed on >> a source line can result in a breakpoint in each objfile. Obviously, >> the previous two issues: inline functions, and partial filename >> matching, can also trigger with multiple objfiles. >> >> But, in the simple multi-objfile case, where a single source file is >> compiled into multiple objfiles, if there is just a single source >> file, then source tracking is possible. However, this case is more >> complex than the single objfile case. We need to consider what >> happens if the source file changes, but only one of the objfiles is >> updated. For this commit I plan to continue to prevent source code >> tracking for the multi-objfile case, as this keeps the commit more >> focused. >> >> This commit then aims to address a specific problem; a breakpoint >> placed on an inline function, which expands to multiple locations >> within a single objfile, will not be tracked before this commit, but >> will be tracked after this commit. >> >> To support this, after generating the breakpoint symtab_and_line >> vector, instead of rejecting any vector with more than one entry, we >> look through all of the entries. If every location is from the same >> objfile, source file, and line number then we will now source track >> this breakpoint. >> >> I've updated an existing test which had an inline function; this test >> now correctly source tracks the breakpoint. I extended the test to >> cover two cases, the inline function is defined and used in a single >> source file, and the inline function is in a header file and is used >> in multiple source files. >> >> I then added a new test, this test covers the case where a 'file:line' >> breakpoint matches multiple different source files. In this case the >> breakpoint should not be source tracked. >> >> I also added a new test that compiles a single source file into >> multiple objfiles, a breakpoint placed within the shared source file >> is multi-location, but is not source tracked. >> --- >> gdb/breakpoint.c | 92 ++++++++-- >> .../gdb.base/source-tracking-inline-1.c | 9 +- >> .../gdb.base/source-tracking-inline-2.c | 10 +- >> .../gdb.base/source-tracking-inline-hdr-1.h | 33 ++++ >> .../gdb.base/source-tracking-inline-hdr-2.h | 34 ++++ >> .../gdb.base/source-tracking-inline-other.c | 25 +++ >> .../gdb.base/source-tracking-inline.exp | 163 ++++++++++++++---- >> .../source-tracking-multi-loc-other.c | 36 ++++ >> .../gdb.base/source-tracking-multi-loc.c | 35 ++++ >> .../gdb.base/source-tracking-multi-loc.exp | 101 +++++++++++ >> .../source-tracking-multi-objfile-common.c | 24 +++ >> .../source-tracking-multi-objfile-lib.c | 25 +++ >> .../gdb.base/source-tracking-multi-objfile.c | 31 ++++ >> .../source-tracking-multi-objfile.exp | 82 +++++++++ >> 14 files changed, 644 insertions(+), 56 deletions(-) >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-hdr-1.= h >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-hdr-2.= h >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-other.= c >> create mode 100644 >> gdb/testsuite/gdb.base/source-tracking-multi-loc-other.c >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-loc.c >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-loc.exp >> create mode 100644 >> gdb/testsuite/gdb.base/source-tracking-multi-objfile-common.c >> create mode 100644 >> gdb/testsuite/gdb.base/source-tracking-multi-objfile-lib.c >> create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-objfile= .c >> create mode 100644 >> gdb/testsuite/gdb.base/source-tracking-multi-objfile.exp >> >> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c >> index 0f5360c4ce5..0bec2f9384d 100644 >> --- a/gdb/breakpoint.c >> +++ b/gdb/breakpoint.c >> @@ -706,6 +706,76 @@ breakpoint_source_get_start_line (const >> breakpoint_source *src) >> return src->bp_line - src->bp_line_stored; >> } >> >> +/* Are SALS suitable for breakpoint source tracking? >> + >> + SALS are the locations that GDB found for the location spec the user >> + provided for the breakpoint. >> + >> + If SALS is a single location which was created with an explicit line >> + number, e.g. 'break file:line' or just 'break line' then we can sour= ce >> + track this location. >> + >> + If there are no locations in SALS then obviously we cannot track the >> + source. >> + >> + Also if the locations were not created from an explicit line number, >> + e.g. 'break function_name' then we don't want to source track this >> + breakpoint. >> + >> + If there are multiple locations in SALS, and they are all created us= ing >> + an explicit line, then we can source track this breakpoint so long a= s >> the >> + same source file is used for each location. This distinguishes betw= een >> + 'break foo.c:10' matching a single inline function in foo.c which is >> + inlined at multiple locations, and 'break foo.c:10' which matches >> + multiple files called 'foo.c' each of which has a line 10 that we ca= n >> + break on. The former case can be source tracked, while the latter c= an >> + not. */ >> + >> +static bool >> +breakpoint_sals_suitable_for_tracking >> + (gdb::array_view sals) >> +{ >> + /* Easy case first. If there is a single sal, and it uses an explici= t >> + line number, then we can potentially track this breakpoint. */ >> + if (sals.size () =3D=3D 1 && sals[0].explicit_line) >> + return true; >> + >> + /* Cannot track this breakpoint if it has no locations. Or if we hav= e >> + multiple locations, but the first doesn't use an explicit line >> + number, then we cannot track this breakpoint. */ >> + if (sals.empty () || !sals[0].explicit_line) >> + return false; >> + >> + /* For multiple locations, we can track the breakpoint so long as eve= ry >> + location refers to the same symtab and line as the first sal. Thi= s >> + would correspond to a single inline function in the source code be= ing >> + inlined at multiple locations. >> + >> + We also place the restriction that every breakpoint needs to be in >> the >> + same objfile. This means that we (currently) don't allow tracking >> of a >> + source line that is compiled into, for example, the main executabl= e >> and >> + a shared library. The reason for this restriction is that checkin= g >> if >> + the breakpoint should be updated becomes harder. What if the sour= ce >> + file changes, but only the executable is recompiled, leaving the >> shared >> + library using the original line number? */ >> + for (std::size_t i =3D 1; i < sals.size (); ++i) >> + { >> + /* If any sal is different to the first then we cannot track this >> + breakpoint. */ >> + if ((sals[i].symtab !=3D sals[0].symtab >> + && filename_cmp (symtab_to_fullname (sals[i].symtab), >> + symtab_to_fullname (sals[0].symtab)) !=3D 0) >> + || sals[i].explicit_line !=3D sals[0].explicit_line >> + || sals[i].line !=3D sals[0].line >> + || (sals[i].symtab->compunit ().objfile () >> + !=3D sals[0].symtab->compunit ().objfile ())) >> + return false; >> + } >> + >> + /* All sals match. */ >> + return true; >> +} >> + >> /* Return true if SPEC is suitable for source tracking, otherwise false= . >> A >> location spec is suitable for tracking if it is an explicit location >> spec, and the line offset is an absolute line number. We also don't >> @@ -9186,18 +9256,10 @@ create_breakpoint_sal (struct gdbarch *gdbarch, >> enabled, flags, >> display_canonical); >> >> - /* Only capture source lines for file:line breakpoints when source >> - tracking is enabled. We check explicit_line to ensure the user >> - explicitly specified a line number (e.g., "break file.c:23" or >> - "break 23"), as opposed to "break function_name" or temporary >> - breakpoints set by commands like "start". >> - >> - We also only track single-location breakpoints. Multi-location >> - breakpoints (e.g., breakpoints on inline functions that are inline= d >> - in multiple places) are too complex to track reliably as each >> location >> - may have moved differently. */ >> - if (source_tracking_breakpoints && sals.size () =3D=3D 1 >> - && sals[0].explicit_line >> + /* Are source tracking breakpoints enabled? If they are, is this >> + breakpoint suitable for source tracking? */ >> + if (source_tracking_breakpoints >> + && breakpoint_sals_suitable_for_tracking (sals) >> && breakpoint_locspec_suitable_for_tracking (b->locspec.get ())) >> { >> /* Capture source if we have valid symtab and line info. >> @@ -13541,10 +13603,10 @@ code_breakpoint::adjust_bp_for_source_tracking >> return; >> >> /* BFD changed - executable was reloaded. */ >> - if (expanded.size () !=3D 1) >> + if (!breakpoint_sals_suitable_for_tracking (expanded)) >> { >> - warning (_("Breakpoint %d now has multiple locations after reload= , " >> - "disabling source tracking."), number); >> + warning (_("Breakpoint %d is no longer suitable for source tracki= ng >> " >> + "after reload, disabling source tracking."), number); >> bp_source.reset (); >> return; >> } >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-1.c >> b/gdb/testsuite/gdb.base/source-tracking-inline-1.c >> index 1f096af225f..16f581a2dda 100644 >> --- a/gdb/testsuite/gdb.base/source-tracking-inline-1.c >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline-1.c >> @@ -15,12 +15,16 @@ >> You should have received a copy of the GNU General Public License >> along with this program. If not, see = . >> */ >> >> +#include "source-tracking-inline-hdr.h" >> + >> volatile int global_var =3D 0; >> >> static inline void __attribute__ ((__always_inline__)) >> inline_func (void) >> { >> - ++global_var; /* Breakpoint here. */ >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 2; /* Breakpoint here. */ >> + global_var =3D global_var + 3; >> } >> >> int __attribute__ ((noinline, noclone)) >> @@ -46,5 +50,6 @@ main (void) >> >> ++global_var; >> >> - return answer - global_var; >> + header_func (); >> + return answer - other_func (global_var); >> } >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-2.c >> b/gdb/testsuite/gdb.base/source-tracking-inline-2.c >> index 451593f3b54..c7b58752fd5 100644 >> --- a/gdb/testsuite/gdb.base/source-tracking-inline-2.c >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline-2.c >> @@ -15,12 +15,17 @@ >> You should have received a copy of the GNU General Public License >> along with this program. If not, see = . >> */ >> >> +#include "source-tracking-inline-hdr.h" >> + >> volatile int global_var =3D 0; >> >> static inline void __attribute__ ((__always_inline__)) >> inline_func (void) >> { >> - global_var +=3D 2; /* Breakpoint here. */ >> + global_var =3D global_var + 5; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 2; /* Breakpoint here. */ >> + global_var =3D global_var + 3; >> } >> >> int __attribute__ ((noinline, noclone)) >> @@ -46,5 +51,6 @@ main (void) >> >> ++global_var; >> >> - return answer - global_var; >> + header_func (); >> + return answer - other_func (global_var); >> } >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-hdr-1.h >> b/gdb/testsuite/gdb.base/source-tracking-inline-hdr-1.h >> new file mode 100644 >> index 00000000000..42e8d051aaf >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline-hdr-1.h >> @@ -0,0 +1,33 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +#ifndef SOURCE_TRACKING_INLINE_HDR_H >> +#define SOURCE_TRACKING_INLINE_HDR_H >> + >> +static inline void __attribute__ ((__always_inline__)) >> +header_func (void) >> +{ >> + static int header_var =3D 0; >> + >> + header_var =3D header_var + 1; >> + header_var =3D header_var + 2; /* Header breakpoint location.= */ >> + header_var =3D header_var + 3; >> +} >> + >> +extern int other_func (int arg); >> + >> +#endif /* SOURCE_TRACKING_INLINE_HDR_H */ >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-hdr-2.h >> b/gdb/testsuite/gdb.base/source-tracking-inline-hdr-2.h >> new file mode 100644 >> index 00000000000..ac68e9949be >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline-hdr-2.h >> @@ -0,0 +1,34 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +#ifndef SOURCE_TRACKING_INLINE_HDR_H >> +#define SOURCE_TRACKING_INLINE_HDR_H >> + >> +static inline void __attribute__ ((__always_inline__)) >> +header_func (void) >> +{ >> + static int header_var =3D 0; >> + >> + header_var =3D header_var + 5; >> + header_var =3D header_var + 1; >> + header_var =3D header_var + 2; /* Header breakpoint location.= */ >> + header_var =3D header_var + 3; >> +} >> + >> +extern int other_func (int arg); >> + >> +#endif /* SOURCE_TRACKING_INLINE_HDR_H */ >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-other.c >> b/gdb/testsuite/gdb.base/source-tracking-inline-other.c >> new file mode 100644 >> index 00000000000..7eb324a02a9 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline-other.c >> @@ -0,0 +1,25 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +#include "source-tracking-inline-hdr.h" >> + >> +int >> +other_func (int arg) >> +{ >> + header_func (); >> + return arg + 1; >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-inline.exp >> b/gdb/testsuite/gdb.base/source-tracking-inline.exp >> index 96849dd1bb6..966aa03f700 100644 >> --- a/gdb/testsuite/gdb.base/source-tracking-inline.exp >> +++ b/gdb/testsuite/gdb.base/source-tracking-inline.exp >> @@ -13,17 +13,50 @@ >> # You should have received a copy of the GNU General Public License >> # along with this program. If not, see . >> >> -# Test of the source tracking breakpoint feature when trying to place >> -# a breakpoint on inline functions. As the breakpoint resolves to >> -# multiple locations we don't currently source track these >> -# breakpoints. >> +# Place a breakpoint on an inline function. As the inline function >> +# comes from a single source location then GDB will source track this >> +# location; when the source line within the inline function moves GDB >> +# will update which line the breakpoint is on. >> +# >> +# This test covers the case where the inline function and its uses are >> +# within a single source file, and the case where the inline function >> +# is in a header file and used in multiple source files. >> >> -standard_testfile -1.c -2.c >> +# This test restarts the inferior with 'start'. This doesn't work >> +# when using plain 'gdbserver'. >> +require !use_gdb_stub >> >> -set build_srcfile [standard_output_file ${testfile}.c] >> +# This test has a main source file, there are two copies of this (-1.c >> +# and -2.c), then a header file of which there are also two copies >> +# (-hdr-1.h and -hdr-2.h). Then there is the "other" source file, >> +# this never changes, there is just one copy of this. >> +standard_testfile -1.c -2.c -hdr-1.h -hdr-2.h -other.c >> >> +# We need to copy the main source file and the header file into the >> +# build directory so we can rename them. As both these files and the >> +# "other" source file all need to include the renamed header file it >> +# is easier if the "other" source file is also copied to the build >> +# directory, even though this file is never renamed. The alternative >> +# would be to setup include search paths. >> +set build_other_srcfile [standard_output_file [file tail $srcfile5]] >> + >> +# These are the names given to the main source file and the header >> +# file within the build directory. >> +set testfile_src ${testfile}.c >> +set testfile_hdr ${testfile}-hdr.h >> +set build_srcfile [standard_output_file $testfile_src] >> +set build_header [standard_output_file $testfile_hdr] >> + >> +# Copy the "other" source file into the build directory now. This >> +# only needs doing once as this file never changes. >> +remote_exec build "cp $srcdir/$subdir/$srcfile5 $build_other_srcfile" >> + >> +# Copy the original source files into the build directory. >> remote_exec build "cp $srcdir/$subdir/$srcfile $build_srcfile" >> -if { [prepare_for_testing "failed to prepare" $testfile $build_srcfile]= } >> { >> +remote_exec build "cp $srcdir/$subdir/$srcfile3 $build_header" >> + >> +if { [prepare_for_testing "failed to prepare" $testfile \ >> + [list $build_srcfile $build_other_srcfile]] } { >> return >> } >> >> @@ -34,47 +67,103 @@ if {![runto_main]} { >> gdb_test_no_output "set breakpoint source-tracking enabled on" \ >> "enable source tracking breakpoints" >> >> -set lineno [gdb_get_line_number "Breakpoint here." $build_srcfile] >> +# Get initial breakpoint line numbers. >> +set lineno_src [gdb_get_line_number "Breakpoint here." $build_srcfile] >> +set lineno_hdr [gdb_get_line_number "Header breakpoint location." \ >> + $build_header] >> >> -# The breakpoint is on an inline function called from two places, >> -# so it resolves to 2 locations. >> -gdb_test "break ${testfile}.c:$lineno" \ >> - "^Breakpoint $decimal at $hex: ${testfile}.c:$lineno\\. \\(2 >> locations\\)" >> +# Create a breakpoint on an inline function within the main source >> +# file. This breakpoint is called from two places, so it resolves to >> +# 2 locations. >> +gdb_test "break ${testfile_src}:$lineno_src" \ >> + "^Breakpoint $decimal at $hex: ${testfile_src}:$lineno_src\\. \\(2 >> locations\\)" >> +set bp_num_src [get_integer_valueof "\$bpnum" "*UNKNOWN*" \ >> + "get number for main source breakpoint"] >> >> -# Check that we are tracking the expected number of lines. >> -# >> -# With the multi-location fix, this breakpoint should NOT be tracked >> -# because it has 2 locations (inline function called from two places). >> -# The output should show but NOT "source-tracking enabled". >> -gdb_test_multiple "info breakpoints" \ >> - "multi-location breakpoint not tracked" { >> - -re -wrap "source-tracking enabled.*" { >> - fail "$gdb_test_name (tracking incorrectly enabled)" >> - } >> - -re -wrap ".*" { >> - pass $gdb_test_name >> +# Create a breakpoint on an inline function within the header file. >> +# This breakpoint is also called from two places, so it also resolves >> +# to 2 locations. >> +gdb_test "break ${testfile_hdr}:$lineno_hdr" \ >> + "^Breakpoint $decimal at $hex: ${testfile_hdr}:$lineno_hdr\\. \\(2 >> locations\\)" >> +set bp_num_hdr [get_integer_valueof "\$bpnum" "*UNKNOWN*" \ >> + "get number for header breakpoint"] >> + >> +# Run 'info breakpoints BP_NUM' and check that the breakpoint is >> +# source tracked around LINENO. Use TESTNAME as the name of the test >> +# being run. >> +proc check_bp_tracked { bp_num lineno testname } { >> + gdb_test_multiple "info breakpoints $bp_num" $testname { >> + -re -wrap "source-tracking enabled \\(tracking $::decimal lines >> around line $lineno\\).*" { >> + pass $gdb_test_name >> + } >> + -re -wrap "" { >> + fail "$gdb_test_name (source tracking not enabled)" >> + } >> } >> } >> >> +# Check that the breakpoint on the inline function from the main >> +# source file is being source tracked. >> +check_bp_tracked $bp_num_src $lineno_src \ >> + "inline function within source file is tracked" >> + >> +# And check that the breakpoint on the inline function from the header >> +# file is also being source tracked. >> +check_bp_tracked $bp_num_hdr $lineno_hdr \ >> + "inline function within header file is tracked" >> + >> +# Change the main source file, this changes the inline function within >> +# that source file, but the header breakpoint is unchanged. >> + >> sleep 1 >> remote_exec build "cp $srcdir/$subdir/$srcfile2 $build_srcfile" >> -if { [build_executable "failed to build" $testfile $build_srcfile] } { >> +if { [build_executable "failed to build" $testfile \ >> + [list $build_srcfile $build_other_srcfile]] } { >> return >> } >> >> # Reload the executable. 'start' internally uses 'tbreak main', which >> # is not a file:line breakpoint, so it will not be source-tracked. >> -gdb_test "with confirm off -- start" >> +gdb_test "with confirm off -- start" ".*" \ >> + "start after changing main source file" >> >> -# After reload, the breakpoint should still NOT be tracked because it >> -# still has 2 locations. This verifies we don't try to track >> -# multi-location breakpoints even after reload. >> -gdb_test_multiple "info breakpoints" \ >> - "multi-location breakpoint still not tracked after reload" { >> - -re -wrap "source-tracking enabled.*" { >> - fail "$gdb_test_name (tracking incorrectly enabled)" >> - } >> - -re -wrap ".*" { >> - pass $gdb_test_name >> - } >> +# Update our understanding of where the breakpoint should be. >> +set lineno_src [gdb_get_line_number "Breakpoint here." $build_srcfile] >> + >> +# The breakpoint should still be source tracked, but its location >> +# should have been updated. >> +check_bp_tracked $bp_num_src $lineno_src \ >> + "main source file breakpoint has moved" >> + >> +# The header file breakpoint should not have moved, but should still >> +# be tracked. >> +check_bp_tracked $bp_num_hdr $lineno_hdr \ >> + "header file breakpoint has not moved" >> + >> +# Change the header file, this moves the breakpoint line for the >> +# inline function in the header file. >> +sleep 1 >> +remote_exec build "cp $srcdir/$subdir/$srcfile4 $build_header" >> +if { [build_executable "failed to build" $testfile \ >> + [list $build_srcfile $build_other_srcfile]] } { >> + return >> } >> + >> +# Reload the executable. 'start' internally uses 'tbreak main', which >> +# is not a file:line breakpoint, so it will not be source-tracked. >> +gdb_test "with confirm off -- start" ".*" \ >> + "start after changing header file" >> + >> +# Update our understanding of where the breakpoint should be. >> +set lineno_hdr [gdb_get_line_number "Header breakpoint location." \ >> + $build_header] >> + >> +# The main file breakpoint should still be tracked, but should not >> +# have moved. >> +check_bp_tracked $bp_num_src $lineno_src \ >> + "main source file breakpoint has not moved" >> + >> +# The header file breakpoint should have moved, and should still be >> +# tracked. >> +check_bp_tracked $bp_num_hdr $lineno_hdr \ >> + "header file breakpoint has moved" >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-loc-other.c >> b/gdb/testsuite/gdb.base/source-tracking-multi-loc-other.c >> new file mode 100644 >> index 00000000000..1b086147f6e >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-loc-other.c >> @@ -0,0 +1,36 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +extern int other_func (void); >> + >> +volatile int other_var =3D 0; >> + >> +/* This comment exists just to force the function below >> + into the correct location. It has no other job. */ >> + >> +int >> +other_func (void) >> +{ >> + other_var =3D other_var + 1; >> + other_var =3D other_var + 1; >> + other_var =3D other_var + 1; /* Breakpoint here. */ >> + other_var =3D other_var + 1; >> + other_var =3D other_var + 1; >> + other_var =3D other_var + 1; >> + >> + return other_var; >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-loc.c >> b/gdb/testsuite/gdb.base/source-tracking-multi-loc.c >> new file mode 100644 >> index 00000000000..fbf02178844 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-loc.c >> @@ -0,0 +1,35 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +extern int other_func (void); >> + >> +volatile int global_var =3D 0; >> + >> +int >> +main (void) >> +{ >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; /* Breakpoint here. */ >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + >> + return other_func (); >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-loc.exp >> b/gdb/testsuite/gdb.base/source-tracking-multi-loc.exp >> new file mode 100644 >> index 00000000000..1d875ff4bf4 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-loc.exp >> @@ -0,0 +1,101 @@ >> +# Copyright 2026 Free Software Foundation, Inc. >> +# >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . >> + >> +# Create a multi-location breakpoint using file and line syntax where >> +# the multiple locations come from different source files. This >> +# requires having two source files aa/foo.c and bb/foo.c, then placing >> +# a breakpoint on 'foo.c:10' or similar. GDB will find both 'foo.c' >> +# files, and try to create breakpoints on line 10 in both. >> +# >> +# The point of this test is that breakpoint source tracking should not >> +# activate for this breakpoint due to the locations coming from >> +# different source files. >> + >> +standard_testfile .c -other.c >> + >> +# Create two sub-directories of the build directory in which our two >> +# source files can be placed. >> +set directory_aa [standard_output_file aa] >> +set directory_bb [standard_output_file bb] >> +remote_exec build "mkdir -p \"$directory_aa\" \"$directory_bb\"" >> + >> +# Now copy the two source files into the two directories, give them >> +# the same basename. >> +remote_exec build "cp $srcdir/$subdir/$srcfile $directory_aa/$srcfile" >> +remote_exec build "cp $srcdir/$subdir/$srcfile2 $directory_bb/$srcfile" >> + >> +# Now build the executable. >> +if { [prepare_for_testing "failed to prepare" $testfile \ >> + [list $directory_aa/$srcfile $directory_bb/$srcfile]] } { >> + return >> +} >> + >> +if {![runto_main]} { >> + return >> +} >> + >> +gdb_test_no_output "set breakpoint source-tracking enabled on" \ >> + "enable source tracking breakpoints" >> + >> +# Sanity check our source files. Both have a 'Breakpoint here' >> +# marker, these should be on the same line number within the two >> +# files. This isn't a "test" as this isn't checking GDB >> +# functionality, this is checking a developer hasn't broken the test. >> +set lineno1 [gdb_get_line_number "Breakpoint here." >> $directory_aa/$srcfile] >> +set lineno2 [gdb_get_line_number "Breakpoint here." >> $directory_bb/$srcfile] >> +if { $lineno1 !=3D $lineno2 } { >> + error "line numbers don't match between source files" >> +} >> +set lineno $lineno1 >> + >> +# Create a breakpoint using the filename and line number. The >> +# filename will match two files, so this will result in two locations >> +# being created. >> +gdb_test "break ${srcfile}:$lineno" \ >> + "^Breakpoint $decimal at $hex: ${srcfile}:$lineno\\. \\(2 >> locations\\)" >> +set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \ >> + "get bp_num for multi-location breakpoint"] >> + >> +# As the two locations are from two different files this breakpoint >> +# should not be source tracked. >> +gdb_test_multiple "info breakpoints $bp_num" \ >> + "multi-location breakpoint not tracked" { >> + -re -wrap "source-tracking enabled.*" { >> + fail "$gdb_test_name (tracking incorrectly enabled)" >> + } >> + -re -wrap "" { >> + pass $gdb_test_name >> + } >> + } >> + >> +# Now for a sanity check, lets make sure we can create source tracked >> +# breakpoints on the files individually. >> +foreach_with_prefix dir { aa bb } { >> + delete_breakpoints >> + gdb_test "break $dir/${srcfile}:$lineno" \ >> + "^Breakpoint $decimal at $hex: file \[^\r\n\]+/$dir/${srcfile}, >> line $lineno\\." >> + set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" \ >> + "get bp_num for breakpoint in $dir/$srcfile"] >> + >> + gdb_test_multiple "info breakpoints $bp_num" \ >> + "single location breakpoint from $dir/$srcfile is tracked" { >> + -re -wrap "source-tracking enabled \\(tracking $::decimal >> lines around line $lineno\\).*" { >> + pass $gdb_test_name >> + } >> + -re -wrap "" { >> + fail $gdb_test_name >> + } >> + } >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile-common= .c >> b/gdb/testsuite/gdb.base/source-tracking-multi-objfile-common.c >> new file mode 100644 >> index 00000000000..c9ec1c5d88b >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-objfile-common.c >> @@ -0,0 +1,24 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +extern int common_func (void); >> + >> +int >> +common_func (void) >> +{ >> + return 0; /* Breakpoint here. */ >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile-lib.c >> b/gdb/testsuite/gdb.base/source-tracking-multi-objfile-lib.c >> new file mode 100644 >> index 00000000000..10ecca1ee24 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-objfile-lib.c >> @@ -0,0 +1,25 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +extern int common_func (void); >> +extern int lib_func (void); >> + >> +int >> +lib_func (void) >> +{ >> + return common_func (); >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile.c >> b/gdb/testsuite/gdb.base/source-tracking-multi-objfile.c >> new file mode 100644 >> index 00000000000..4a3fa96da6b >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-objfile.c >> @@ -0,0 +1,31 @@ >> +/* This testcase is part of GDB, the GNU debugger. >> + >> + Copyright 2026 Free Software Foundation, Inc. >> + >> + This program is free software; you can redistribute it and/or modify >> + it under the terms of the GNU General Public License as published by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see = . >> */ >> + >> +extern int common_func (void); >> +extern int lib_func (void); >> + >> +volatile int global_var; >> + >> +int >> +main (void) >> +{ >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + global_var =3D global_var + 1; >> + >> + return lib_func () + common_func (); /* Breakpoint here. */ >> +} >> diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile.exp >> b/gdb/testsuite/gdb.base/source-tracking-multi-objfile.exp >> new file mode 100644 >> index 00000000000..e1e212242fa >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/source-tracking-multi-objfile.exp >> @@ -0,0 +1,82 @@ >> +# Copyright 2026 Free Software Foundation, Inc. >> +# >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . >> + >> +# Create a multi-location breakpoint where the two locations are in >> +# two different objfiles; the main executable and a shared library. >> +# >> +# Turn on source tracking, and place a breakpoint on the source of the >> +# multi-location breakpoint. The breakpoint should not be tracked as >> +# GDB does not currently source track breakpoints that are in multiple >> +# objfiles. >> + >> +require allow_shlib_tests >> + >> +standard_testfile .c -common.c -lib.c >> + >> +set libname lib$::testfile.so >> +set objlib [standard_output_file $libname] >> +if {[build_executable "build solib" $libname \ >> + [list $srcfile3 $srcfile2] {debug shlib}] =3D=3D -1} { >> + return >> +} >> + >> +if {[prepare_for_testing "prepare" $testfile \ >> + [list $srcfile $srcfile2] [list debug shlib=3D$objlib]] =3D=3D = -1} { >> + return >> +} >> + >> +if {![runto_main]} { >> + return >> +} >> + >> +# Enable the source tracking feature. >> +gdb_test_no_output "set breakpoint source-tracking enabled on" \ >> + "enable source tracking breakpoints" >> + >> +# Create a breakpoint that appears in multiple objfiles, GDB will not >> +# currently source track this breakpoint. >> +with_test_prefix "untracked b/p" { >> + set lineno [gdb_get_line_number "/* Breakpoint here. */" $srcfile2= ] >> + >> + gdb_breakpoint $srcfile2:$lineno >> + set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] >> + >> + gdb_test "info breakpoint $bp_num" \ >> + "\r\n$bp_num\\.1\\s+\[^\r\n\]+\r\n$bp_num\\.2\\s+\[^\r\n\]+" \ >> + "check there are two locations for the breakpoint" >> + >> + gdb_test "maintenance info source-tracking-context $bp_num" \ >> + "Breakpoint $bp_num does not have source tracking enabled\\." \ >> + "check breakpoint is not source tracked" >> +} >> + >> +# Now try creating a source tracked breakpoint in a single objfile to >> +# confirm that source tracking has been correctly enabled. >> +with_test_prefix "tracked b/p" { >> + set lineno [gdb_get_line_number "/* Breakpoint here. */" $srcfile] >> + >> + gdb_breakpoint $srcfile:$lineno >> + set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"] >> + >> + gdb_test "info breakpoint $bp_num" \ >> + [multi_line \ >> + "\r\n$bp_num\\s+\[^\r\n\]+" \ >> + "\\s+source-tracking enabled\[^\r\n\]*"] \ >> + "check there is just one location for the breakpoint" >> + >> + gdb_test "maintenance info source-tracking-context $bp_num" \ >> + "/\\* Breakpoint here\\. \\*/.*" \ >> + "check breakpoint is source tracked" >> +} >> >> base-commit: abcacfa2875d31480637ac082ce4862d518992f2 >> -- >> 2.25.4 >> >> > This patch looks great. > Reviewed-by: Alexandra Hajkova I've pushed this to master now. Thanks, Andrew