From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tyhVGkoB7mqf3SgAWB0awg (envelope-from ) for ; Fri, 06 Nov 2026 11:33:14 -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=XiWYYjzM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 35EEC1E023; Fri, 06 Nov 2026 11:33:14 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED 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 02C891E023 for ; Fri, 06 Nov 2026 11:33:06 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D83F4BA2E28 for ; Fri, 6 Nov 2026 16:33:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D83F4BA2E28 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=XiWYYjzM 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 C2F544BA2E09 for ; Fri, 6 Nov 2026 16:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2F544BA2E09 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 C2F544BA2E09 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=1793982733; cv=none; b=cCZ37FPhX1gGbf2gXk0M4WEtR8wkST5gBMVNdYThcNTslhmVqQ+WBhXD/Ci55w5VBukABxbT36csm+qFC8Oz4kEvdOEb9xSVZmPJ0LNh8BgnkG9xMC2ErLbld95dN9fU4V8j28pU6ian35p7riD/wrk/J2H1cfpKxpP8eAMBbVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793982733; c=relaxed/simple; bh=oyKqeZUahkLxlQ1xPMdnk+wxaImcw88rZFgj4lOcyIo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=TcupkPjAJfT3YVcWY0F+b+d3QueezPq5ghF6/8aDThS2i3VUDJaoBCEBoYbCRQlxhzxoCCeDpuryPqR7/xK+53SZoA7AA/2Kqiec5XE1QJLcImPxgUaeX8ZHkec1hOwQe2BjVMDMUfb6/xE/865vax90u/t1kq229i5TKnCof+o= 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=XiWYYjzM DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2F544BA2E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793982732; 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: in-reply-to:in-reply-to:references:references; bh=63Hh6Y6R+YbvoOAzk3Y4jMeJqaHAtmTUU5ijvpmncGo=; b=XiWYYjzMkt1vbCLe1/XKxteEeYYJEj6CIJD5aprPDgX3FklD8LW+SoswezpLuqM92p6pfg FAWRP2c8W7lvUxrPgfpDsujnK7HOvz6AIArKYXchsaP+rWnOWuAUziIzRAkVR8avmrSfyW LkwIvjFVi+r+o3ns1QDmlsca4ZOkkqg= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-uBH6KbBkO7Czaks-aYuBGQ-1; Fri, 06 Nov 2026 11:32:10 -0500 X-MC-Unique: uBH6KbBkO7Czaks-aYuBGQ-1 X-Mimecast-MFC-AGG-ID: uBH6KbBkO7Czaks-aYuBGQ_1793982730 Received: by mail-vk1-f200.google.com with SMTP id 71dfb90a1353d-5eab2a9a633so824656e0c.2 for ; Fri, 06 Nov 2026 08:32:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793982730; x=1794587530; h=content-type:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=63Hh6Y6R+YbvoOAzk3Y4jMeJqaHAtmTUU5ijvpmncGo=; b=rXb7pa22bxpQ6l7pNEOBHoJ2qA1yPFjKU7nNcVL8t3L9Kayic6OM0PrDLAXYJR3rAW kLEy7hExp9jFZv8VOvEFhRgKFBDVG9CLbunDDR8LiL1zEoi0I4DfKfJzavhBIXnFNjCF BNnnao6jF3R/qWTjjwjVPWzQnWjBW0PwoNXoUzjg/dW1Gmy00KdqJeH031WZ8MCJtUsJ Fc8Huz1q561XhYyNQq64GL5lWrEZTkb+SapQ3ciM+/G7gAx0P9tNWfF632KA4fSfJ6pb 0iesUInRtVEVpmJJ+t3KYqSPFig8YhLX5gPQLOEZDcejocYkDhVMlJrhhPkEN811mQUp 2CHg== X-Gm-Message-State: APuU4Z9YrSWknvqlsQjeJhqkZzjC8ceKm9FrU17RZn+heTU+sBw79Xcp ++KwKa/irbcdlXNYzFbxBtwVE6US7VFMzSCOIPaTEzO3NXinD+PBK8bBPbbVV0644F4ZkwIt4O3 IWxb3f1GLCwJWIg9nKfpHC3Nfh9AxihFcDcwDuNhtvj0trY1mHxj5igF0ls66iZZD9OKVrf00rm msI5M1Mn2BgHfLbkeGhg8l7v9Qu9tXc8yPBcMA5YvAX1xi1dGW X-Gm-Gg: AYBFou1E6Yd5VFe9cg0+tIdHhJgkhFFxend1LMmC65aJmTBC1Xpyxj8xeEXTdFS9Hfb AXzV6XmQqWK7qtjU+2MAQRyCPjE42qX1qufm79qFXU2NGfRPagLwsbA6b6VqJ9bALQFxmCYMHLi +9T5LpubYLhiF2FB0G+T3kdKKpajpGhH67BGNg5qgnoDFj8lpEPdSIGhjgKiyt1C0m7EyYTdM1t fPx1a6m2f3PMlt+Rg== X-Received: by 2002:a05:6122:ca8:b0:5ea:c722:b3a with SMTP id 71dfb90a1353d-5ecc43a4d82mr1603249e0c.7.1793982729100; Fri, 06 Nov 2026 08:32:09 -0800 (PST) X-Received: by 2002:a05:6122:ca8:b0:5ea:c722:b3a with SMTP id 71dfb90a1353d-5ecc43a4d82mr1603103e0c.7.1793982728052; Fri, 06 Nov 2026 08:32:08 -0800 (PST) MIME-Version: 1.0 References: <5d354be53ea21f4da7b446c6337d694c06c475f3.1791027408.git.aburgess@redhat.com> <9d85474c038ae3af4775b77158dc2441de72dc6a.1792675799.git.aburgess@redhat.com> In-Reply-To: <9d85474c038ae3af4775b77158dc2441de72dc6a.1792675799.git.aburgess@redhat.com> From: Alexandra Petlanova Hajkova Date: Fri, 6 Nov 2026 17:31:56 +0100 X-Gm-Features: AclHuK-XYAMoR6Sxb4Ee6FnUYfKjW5s73ciVtCzxzbuhEbhq_Qdrmy6Ui8GgY_s Message-ID: Subject: Re: [PATCHv2] gdb: support source tracking for multi-location breakpoints To: Andrew Burgess Cc: gdb-patches@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2C7x5bSgQEREWYl3KLgOtB-eqwRpE7dE-hJEVC-eoGg_1793982730 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="0000000000003da880065f9e27a8" 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 --0000000000003da880065f9e27a8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 sourc= e > + 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 usi= ng > + an explicit line, then we can source track this breakpoint so long as > the > + same source file is used for each location. This distinguishes betwe= en > + '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 can > + break on. The former case can be source tracked, while the latter ca= n > + 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 explicit > + 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 have > + 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 ever= y > + location refers to the same symtab and line as the first sal. This > + would correspond to a single inline function in the source code bei= ng > + 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 executable > and > + a shared library. The reason for this restriction is that checking > if > + the breakpoint should be updated becomes harder. What if the sourc= e > + 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 inlined > - 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 trackin= g > " > + "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 --0000000000003da880065f9e27a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Oct 22,= 2026 at 3:35=E2=80=AFPM Andrew Burgess <aburgess@redhat.com> wrote:
In v2:

=C2=A0 * Replaced strcmp with filename_cmp when comparing filenames.=C2=A0 = I
=C2=A0 =C2=A0 think this could make a difference if different CUs were comp= iled
=C2=A0 =C2=A0 with different filename cases on a case insensitive filesyste= m.
=C2=A0 =C2=A0 But I suspect this is a pretty unlikely edge case.=C2=A0 Stil= l, doesn't
=C2=A0 =C2=A0 hurt to do it right.

=C2=A0 * Now handle, or rather, spot and deliberately don't handle, the=
=C2=A0 =C2=A0 case where a multi-location breakpoint is in multiple differe= nt
=C2=A0 =C2=A0 objfiles.

=C2=A0 * New tests for the multi-objfile case.

=C2=A0 * 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.=C2=A0 This includes things like 'break file:line' and al= so
'break line'.=C2=A0 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 thi= s
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.=C2=A0 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 i= f
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.=C2=A0 In this case we have a
single breakpoint, but multiple source files.=C2=A0 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.=C2=A0 However, this would not be a good idea.

The breakpoint spec, i.e. the 'file:line' is part of the breakpoint=
itself.=C2=A0 When source tracking indicates that a source line has moved this spec is updated.=C2=A0 If we source tracked per-location what would we=
do when one source file changed but not the other?=C2=A0 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)'.=C2=A0 Supportin= g 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.=C2=A0 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.=C2=A0 Obviously,<= br> 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.=C2=A0 However, this case is more complex than the single objfile case.=C2=A0 We need to consider what
happens if the source file changes, but only one of the objfiles is
updated.=C2=A0 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.=C2=A0 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.=C2=A0 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&#= 39;
breakpoint matches multiple different source files.=C2=A0 In this case the<= br> 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.
---
=C2=A0gdb/breakpoint.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 92 ++++++++--<= br> =C2=A0.../gdb.base/source-tracking-inline-1.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 =C2=A09 +-
=C2=A0.../gdb.base/source-tracking-inline-2.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 10 +-
=C2=A0.../gdb.base/source-tracking-inline-hdr-1.h=C2=A0 =C2=A0|=C2=A0 33 ++= ++
=C2=A0.../gdb.base/source-tracking-inline-hdr-2.h=C2=A0 =C2=A0|=C2=A0 34 ++= ++
=C2=A0.../gdb.base/source-tracking-inline-other.c=C2=A0 =C2=A0|=C2=A0 25 ++= +
=C2=A0.../gdb.base/source-tracking-inline.exp=C2=A0 =C2=A0 =C2=A0 =C2=A0| 1= 63 ++++++++++++++----
=C2=A0.../source-tracking-multi-loc-other.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0|=C2=A0 36 ++++
=C2=A0.../gdb.base/source-tracking-multi-loc.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 = 35 ++++
=C2=A0.../gdb.base/source-tracking-multi-loc.exp=C2=A0 =C2=A0 | 101 +++++++= ++++
=C2=A0.../source-tracking-multi-objfile-common.c=C2=A0 =C2=A0 |=C2=A0 24 ++= +
=C2=A0.../source-tracking-multi-objfile-lib.c=C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 25 +++
=C2=A0.../gdb.base/source-tracking-multi-objfile.c=C2=A0 |=C2=A0 31 ++++ =C2=A0.../source-tracking-multi-objfile.exp=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0|=C2=A0 82 +++++++++
=C2=A014 files changed, 644 insertions(+), 56 deletions(-)
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-hdr-= 1.h
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-hdr-= 2.h
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-inline-othe= r.c
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-loc-o= ther.c
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-loc.c=
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-loc.e= xp
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-objfi= le-common.c
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-objfi= le-lib.c
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-objfi= le.c
=C2=A0create mode 100644 gdb/testsuite/gdb.base/source-tracking-multi-objfi= le.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_sou= rce *src)
=C2=A0 =C2=A0return src->bp_line - src->bp_line_stored;
=C2=A0}

+/* Are SALS suitable for breakpoint source tracking?
+
+=C2=A0 =C2=A0SALS are the locations that GDB found for the location spec t= he user
+=C2=A0 =C2=A0provided for the breakpoint.
+
+=C2=A0 =C2=A0If SALS is a single location which was created with an explic= it line
+=C2=A0 =C2=A0number, e.g. 'break file:line' or just 'break lin= e' then we can source
+=C2=A0 =C2=A0track this location.
+
+=C2=A0 =C2=A0If there are no locations in SALS then obviously we cannot tr= ack the
+=C2=A0 =C2=A0source.
+
+=C2=A0 =C2=A0Also if the locations were not created from an explicit line = number,
+=C2=A0 =C2=A0e.g. 'break function_name' then we don't want to = source track this
+=C2=A0 =C2=A0breakpoint.
+
+=C2=A0 =C2=A0If there are multiple locations in SALS, and they are all cre= ated using
+=C2=A0 =C2=A0an explicit line, then we can source track this breakpoint so= long as the
+=C2=A0 =C2=A0same source file is used for each location.=C2=A0 This distin= guishes between
+=C2=A0 =C2=A0'break foo.c:10' matching a single inline function in= foo.c which is
+=C2=A0 =C2=A0inlined at multiple locations, and 'break foo.c:10' w= hich matches
+=C2=A0 =C2=A0multiple files called 'foo.c' each of which has a lin= e 10 that we can
+=C2=A0 =C2=A0break on.=C2=A0 The former case can be source tracked, while = the latter can
+=C2=A0 =C2=A0not.=C2=A0 */
+
+static bool
+breakpoint_sals_suitable_for_tracking
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(gdb::array_view<const symtab_and_line> s= als)
+{
+=C2=A0 /* Easy case first.=C2=A0 If there is a single sal, and it uses an = explicit
+=C2=A0 =C2=A0 =C2=A0line number, then we can potentially track this breakp= oint.=C2=A0 */
+=C2=A0 if (sals.size () =3D=3D 1 && sals[0].explicit_line)
+=C2=A0 =C2=A0 return true;
+
+=C2=A0 /* Cannot track this breakpoint if it has no locations.=C2=A0 Or if= we have
+=C2=A0 =C2=A0 =C2=A0multiple locations, but the first doesn't use an e= xplicit line
+=C2=A0 =C2=A0 =C2=A0number, then we cannot track this breakpoint.=C2=A0 */=
+=C2=A0 if (sals.empty () || !sals[0].explicit_line)
+=C2=A0 =C2=A0 return false;
+
+=C2=A0 /* For multiple locations, we can track the breakpoint so long as e= very
+=C2=A0 =C2=A0 =C2=A0location refers to the same symtab and line as the fir= st sal.=C2=A0 This
+=C2=A0 =C2=A0 =C2=A0would correspond to a single inline function in the so= urce code being
+=C2=A0 =C2=A0 =C2=A0inlined at multiple locations.
+
+=C2=A0 =C2=A0 =C2=A0We also place the restriction that every breakpoint ne= eds to be in the
+=C2=A0 =C2=A0 =C2=A0same objfile.=C2=A0 This means that we (currently) don= 't allow tracking of a
+=C2=A0 =C2=A0 =C2=A0source line that is compiled into, for example, the ma= in executable and
+=C2=A0 =C2=A0 =C2=A0a shared library.=C2=A0 The reason for this restrictio= n is that checking if
+=C2=A0 =C2=A0 =C2=A0the breakpoint should be updated becomes harder.=C2=A0= What if the source
+=C2=A0 =C2=A0 =C2=A0file changes, but only the executable is recompiled, l= eaving the shared
+=C2=A0 =C2=A0 =C2=A0library using the original line number?=C2=A0 */
+=C2=A0 for (std::size_t i =3D 1; i < sals.size (); ++i)
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 /* If any sal is different to the first then we canno= t track this
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 breakpoint.=C2=A0 */
+=C2=A0 =C2=A0 =C2=A0 if ((sals[i].symtab !=3D sals[0].symtab
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && filename_cmp (symtab_to_full= name (sals[i].symtab),
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0symtab_to_fullname (sals[0].symtab)) !=3D 0)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| sals[i].explicit_line !=3D sals[0].ex= plicit_line
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| sals[i].line !=3D sals[0].line
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| (sals[i].symtab->compunit ().objfi= le ()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0!=3D sals[0].symtab->co= mpunit ().objfile ()))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return false;
+=C2=A0 =C2=A0 }
+
+=C2=A0 /* All sals match.=C2=A0 */
+=C2=A0 return true;
+}
+
=C2=A0/* Return true if SPEC is suitable for source tracking, otherwise fal= se.=C2=A0 A
=C2=A0 =C2=A0 location spec is suitable for tracking if it is an explicit l= ocation
=C2=A0 =C2=A0 spec, and the line offset is an absolute line number.=C2=A0 W= e also don't
@@ -9186,18 +9256,10 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 enabled, flags,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 display_canonical);

-=C2=A0 /* Only capture source lines for file:line breakpoints when source<= br> -=C2=A0 =C2=A0 =C2=A0tracking is enabled.=C2=A0 We check explicit_line to e= nsure the user
-=C2=A0 =C2=A0 =C2=A0explicitly specified a line number (e.g., "break = file.c:23" or
-=C2=A0 =C2=A0 =C2=A0"break 23"), as opposed to "break funct= ion_name" or temporary
-=C2=A0 =C2=A0 =C2=A0breakpoints set by commands like "start". -
-=C2=A0 =C2=A0 =C2=A0We also only track single-location breakpoints.=C2=A0 = Multi-location
-=C2=A0 =C2=A0 =C2=A0breakpoints (e.g., breakpoints on inline functions tha= t are inlined
-=C2=A0 =C2=A0 =C2=A0in multiple places) are too complex to track reliably = as each location
-=C2=A0 =C2=A0 =C2=A0may have moved differently.=C2=A0 */
-=C2=A0 if (source_tracking_breakpoints && sals.size () =3D=3D 1 -=C2=A0 =C2=A0 =C2=A0 && sals[0].explicit_line
+=C2=A0 /* Are source tracking breakpoints enabled?=C2=A0 If they are, is t= his
+=C2=A0 =C2=A0 =C2=A0breakpoint suitable for source tracking?=C2=A0 */
+=C2=A0 if (source_tracking_breakpoints
+=C2=A0 =C2=A0 =C2=A0 && breakpoint_sals_suitable_for_tracking (sal= s)
=C2=A0 =C2=A0 =C2=A0 =C2=A0&& breakpoint_locspec_suitable_for_track= ing (b->locspec.get ()))
=C2=A0 =C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0/* Capture source if we have valid symtab and li= ne info.
@@ -13541,10 +13603,10 @@ code_breakpoint::adjust_bp_for_source_tracking =C2=A0 =C2=A0 =C2=A0return;

=C2=A0 =C2=A0/* BFD changed - executable was reloaded.=C2=A0 */
-=C2=A0 if (expanded.size () !=3D 1)
+=C2=A0 if (!breakpoint_sals_suitable_for_tracking (expanded))
=C2=A0 =C2=A0 =C2=A0{
-=C2=A0 =C2=A0 =C2=A0 warning (_("Breakpoint %d now has multiple locat= ions after reload, "
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "disabling so= urce tracking."), number);
+=C2=A0 =C2=A0 =C2=A0 warning (_("Breakpoint %d is no longer suitable = for source tracking "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "after reload= , disabling source tracking."), number);
=C2=A0 =C2=A0 =C2=A0 =C2=A0bp_source.reset ();
=C2=A0 =C2=A0 =C2=A0 =C2=A0return;
=C2=A0 =C2=A0 =C2=A0}
diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-1.c b/gdb/testsu= ite/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 @@
=C2=A0 =C2=A0 You should have received a copy of the GNU General Public Lic= ense
=C2=A0 =C2=A0 along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */

+#include "source-tracking-inline-hdr.h"
+
=C2=A0volatile int global_var =3D 0;

=C2=A0static inline void __attribute__ ((__always_inline__))
=C2=A0inline_func (void)
=C2=A0{
-=C2=A0 ++global_var;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 /* Breakpoint here.=C2=A0 */
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 2;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* = Breakpoint here.=C2=A0 */
+=C2=A0 global_var =3D global_var + 3;
=C2=A0}

=C2=A0int __attribute__ ((noinline, noclone))
@@ -46,5 +50,6 @@ main (void)

=C2=A0 =C2=A0++global_var;

-=C2=A0 return answer - global_var;
+=C2=A0 header_func ();
+=C2=A0 return answer - other_func (global_var);
=C2=A0}
diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-2.c b/gdb/testsu= ite/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 @@
=C2=A0 =C2=A0 You should have received a copy of the GNU General Public Lic= ense
=C2=A0 =C2=A0 along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */

+#include "source-tracking-inline-hdr.h"
+
=C2=A0volatile int global_var =3D 0;

=C2=A0static inline void __attribute__ ((__always_inline__))
=C2=A0inline_func (void)
=C2=A0{
-=C2=A0 global_var +=3D 2;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/= * Breakpoint here.=C2=A0 */
+=C2=A0 global_var =3D global_var + 5;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 2;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* = Breakpoint here.=C2=A0 */
+=C2=A0 global_var =3D global_var + 3;
=C2=A0}

=C2=A0int __attribute__ ((noinline, noclone))
@@ -46,5 +51,6 @@ main (void)

=C2=A0 =C2=A0++global_var;

-=C2=A0 return answer - global_var;
+=C2=A0 header_func ();
+=C2=A0 return answer - other_func (global_var);
=C2=A0}
diff --git a/gdb/testsuite/gdb.base/source-tracking-inline-hdr-1.h b/gdb/te= stsuite/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+#ifndef SOURCE_TRACKING_INLINE_HDR_H
+#define SOURCE_TRACKING_INLINE_HDR_H
+
+static inline void __attribute__ ((__always_inline__))
+header_func (void)
+{
+=C2=A0 static int header_var =3D 0;
+
+=C2=A0 header_var =3D header_var + 1;
+=C2=A0 header_var =3D header_var + 2;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* = Header breakpoint location.=C2=A0 */
+=C2=A0 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/te= stsuite/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+#ifndef SOURCE_TRACKING_INLINE_HDR_H
+#define SOURCE_TRACKING_INLINE_HDR_H
+
+static inline void __attribute__ ((__always_inline__))
+header_func (void)
+{
+=C2=A0 static int header_var =3D 0;
+
+=C2=A0 header_var =3D header_var + 5;
+=C2=A0 header_var =3D header_var + 1;
+=C2=A0 header_var =3D header_var + 2;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* = Header breakpoint location.=C2=A0 */
+=C2=A0 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/te= stsuite/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+#include "source-tracking-inline-hdr.h"
+
+int
+other_func (int arg)
+{
+=C2=A0 header_func ();
+=C2=A0 return arg + 1;
+}
diff --git a/gdb/testsuite/gdb.base/source-tracking-inline.exp b/gdb/testsu= ite/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 @@
=C2=A0# You should have received a copy of the GNU General Public License =C2=A0# along with this program.=C2=A0 If not, see <http://www.gnu.or= g/licenses/>.

-# Test of the source tracking breakpoint feature when trying to place
-# a breakpoint on inline functions.=C2=A0 As the breakpoint resolves to -# multiple locations we don't currently source track these
-# breakpoints.
+# Place a breakpoint on an inline function.=C2=A0 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'.=C2=A0 This doesn&#= 39;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).=C2=A0 Then there is the "other" sourc= e 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.=C2=A0 As both these files and the=
+# "other" source file all need to include the renamed header fil= e it
+# is easier if the "other" source file is also copied to the bui= ld
+# directory, even though this file is never renamed.=C2=A0 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.=C2= =A0 This
+# only needs doing once as this file never changes.
+remote_exec build "cp $srcdir/$subdir/$srcfile5 $build_other_srcfile&= quot;
+
+# Copy the original source files into the build directory.
=C2=A0remote_exec build "cp $srcdir/$subdir/$srcfile $build_srcfile&qu= ot;
-if { [prepare_for_testing "failed to prepare" $testfile $build_s= rcfile] } {
+remote_exec build "cp $srcdir/$subdir/$srcfile3 $build_header" +
+if { [prepare_for_testing "failed to prepare" $testfile \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[list $build_srcfile $build_other_srcfil= e]] } {
=C2=A0 =C2=A0 =C2=A0return
=C2=A0}

@@ -34,47 +67,103 @@ if {![runto_main]} {
=C2=A0gdb_test_no_output "set breakpoint source-tracking enabled on&qu= ot; \
=C2=A0 =C2=A0 =C2=A0"enable source tracking breakpoints"

-set lineno [gdb_get_line_number "Breakpoint here." $build_srcfil= e]
+# Get initial breakpoint line numbers.
+set lineno_src [gdb_get_line_number "Breakpoint here." $build_sr= cfile]
+set lineno_hdr [gdb_get_line_number "Header breakpoint location."= ; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$buil= d_header]

-# The breakpoint is on an inline function called from two places,
-# so it resolves to 2 locations.
-gdb_test "break ${testfile}.c:$lineno" \
-=C2=A0 =C2=A0 "^Breakpoint $decimal at $hex: ${testfile}.c:$lineno\\.= \\(2 locations\\)"
+# Create a breakpoint on an inline function within the main source
+# file.=C2=A0 This breakpoint is called from two places, so it resolves to=
+# 2 locations.
+gdb_test "break ${testfile_src}:$lineno_src" \
+=C2=A0 =C2=A0 "^Breakpoint $decimal at $hex: ${testfile_src}:$lineno_= src\\. \\(2 locations\\)"
+set bp_num_src [get_integer_valueof "\$bpnum" "*UNKNOWN*&qu= ot; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "get n= umber 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 <MULTIPLE> but NOT "source-tracking en= abled".
-gdb_test_multiple "info breakpoints" \
-=C2=A0 "multi-location breakpoint not tracked" {
-=C2=A0 =C2=A0 -re -wrap "source-tracking enabled.*" {
-=C2=A0 =C2=A0 =C2=A0 fail "$gdb_test_name (tracking incorrectly enabl= ed)"
-=C2=A0 =C2=A0 }
-=C2=A0 =C2=A0 -re -wrap "<MULTIPLE>.*" {
-=C2=A0 =C2=A0 =C2=A0 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" \
+=C2=A0 =C2=A0 "^Breakpoint $decimal at $hex: ${testfile_hdr}:$lineno_= hdr\\. \\(2 locations\\)"
+set bp_num_hdr [get_integer_valueof "\$bpnum" "*UNKNOWN*&qu= ot; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "get n= umber for header breakpoint"]
+
+# Run 'info breakpoints BP_NUM' and check that the breakpoint is +# source tracked around LINENO.=C2=A0 Use TESTNAME as the name of the test=
+# being run.
+proc check_bp_tracked { bp_num lineno testname } {
+=C2=A0 =C2=A0 gdb_test_multiple "info breakpoints $bp_num" $test= name {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "source-tracking enabled \\(trac= king $::decimal lines around line $lineno\\).*" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pass $gdb_test_name
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fail "$gdb_test_name (source= tracking not enabled)"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0}
=C2=A0}

+# 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 \
+=C2=A0 =C2=A0 "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 \
+=C2=A0 =C2=A0 "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.
+
=C2=A0sleep 1
=C2=A0remote_exec build "cp $srcdir/$subdir/$srcfile2 $build_srcfile&q= uot;
-if { [build_executable "failed to build" $testfile $build_srcfil= e] } {
+if { [build_executable "failed to build" $testfile \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[list $build_srcfile $build_other_srcfil= e]] } {
=C2=A0 =C2=A0 =C2=A0return
=C2=A0}

=C2=A0# Reload the executable.=C2=A0 'start' internally uses 't= break main', which
=C2=A0# 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" ".*" \
+=C2=A0 =C2=A0 "start after changing main source file"

-# After reload, the breakpoint should still NOT be tracked because it
-# still has 2 locations.=C2=A0 This verifies we don't try to track
-# multi-location breakpoints even after reload.
-gdb_test_multiple "info breakpoints" \
-=C2=A0 =C2=A0 "multi-location breakpoint still not tracked after relo= ad" {
-=C2=A0 =C2=A0 -re -wrap "source-tracking enabled.*" {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0fail "$gdb_test_name (tracking incorrectly= enabled)"
-=C2=A0 =C2=A0 }
-=C2=A0 =C2=A0 -re -wrap "<MULTIPLE>.*" {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0pass $gdb_test_name
-=C2=A0 =C2=A0 }
+# Update our understanding of where the breakpoint should be.
+set lineno_src [gdb_get_line_number "Breakpoint here." $build_sr= cfile]
+
+# The breakpoint should still be source tracked, but its location
+# should have been updated.
+check_bp_tracked $bp_num_src $lineno_src \
+=C2=A0 =C2=A0 "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 \
+=C2=A0 =C2=A0 "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 \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[list $build_srcfile $build_other_srcfil= e]] } {
+=C2=A0 =C2=A0 return
=C2=A0}
+
+# Reload the executable.=C2=A0 '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" ".*" \
+=C2=A0 =C2=A0 "start after changing header file"
+
+# Update our understanding of where the breakpoint should be.
+set lineno_hdr [gdb_get_line_number "Header breakpoint location."= ; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$buil= d_header]
+
+# The main file breakpoint should still be tracked, but should not
+# have moved.
+check_bp_tracked $bp_num_src $lineno_src \
+=C2=A0 =C2=A0 "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 \
+=C2=A0 =C2=A0 "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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+extern int other_func (void);
+
+volatile int other_var =3D 0;
+
+/* This comment exists just to force the function below
+=C2=A0 =C2=A0into the correct location.=C2=A0 It has no other job.=C2=A0 *= /
+
+int
+other_func (void)
+{
+=C2=A0 other_var =3D other_var + 1;
+=C2=A0 other_var =3D other_var + 1;
+=C2=A0 other_var =3D other_var + 1;=C2=A0 =C2=A0/* Breakpoint here.=C2=A0 = */
+=C2=A0 other_var =3D other_var + 1;
+=C2=A0 other_var =3D other_var + 1;
+=C2=A0 other_var =3D other_var + 1;
+
+=C2=A0 return other_var;
+}
diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-loc.c b/gdb/tests= uite/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+extern int other_func (void);
+
+volatile int global_var =3D 0;
+
+int
+main (void)
+{
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* = Breakpoint here.=C2=A0 */
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+
+=C2=A0 return other_func ();
+}
diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-loc.exp b/gdb/tes= tsuite/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.=C2=A0 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.=C2=A0 If not, see <http://www.gnu.org/lic= enses/>.
+
+# Create a multi-location breakpoint using file and line syntax where
+# the multiple locations come from different source files.=C2=A0 This
+# requires having two source files aa/foo.c and bb/foo.c, then placing
+# a breakpoint on 'foo.c:10' or similar.=C2=A0 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\" \"$direc= tory_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/$srcfil= e"
+
+# Now build the executable.
+if { [prepare_for_testing "failed to prepare" $testfile \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[list $directory_aa/$srcfile $directory_= bb/$srcfile]] } {
+=C2=A0 =C2=A0 return
+}
+
+if {![runto_main]} {
+=C2=A0 =C2=A0 return
+}
+
+gdb_test_no_output "set breakpoint source-tracking enabled on" \=
+=C2=A0 =C2=A0 "enable source tracking breakpoints"
+
+# Sanity check our source files.=C2=A0 Both have a 'Breakpoint here= 9;
+# marker, these should be on the same line number within the two
+# files.=C2=A0 This isn't a "test" as this isn't checkin= g GDB
+# functionality, this is checking a developer hasn't broken the test.<= br> +set lineno1 [gdb_get_line_number "Breakpoint here." $directory_a= a/$srcfile]
+set lineno2 [gdb_get_line_number "Breakpoint here." $directory_b= b/$srcfile]
+if { $lineno1 !=3D $lineno2 } {
+=C2=A0 =C2=A0 error "line numbers don't match between source file= s"
+}
+set lineno $lineno1
+
+# Create a breakpoint using the filename and line number.=C2=A0 The
+# filename will match two files, so this will result in two locations
+# being created.
+gdb_test "break ${srcfile}:$lineno" \
+=C2=A0 =C2=A0 "^Breakpoint $decimal at $hex: ${srcfile}:$lineno\\. \\= (2 locations\\)"
+set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*" = \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"get bp_num fo= r 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" \
+=C2=A0 =C2=A0 "multi-location breakpoint not tracked" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "source-tracking enabled.*"= {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fail "$gdb_test_name (tracki= ng incorrectly enabled)"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pass $gdb_test_name
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 }
+
+# Now for a sanity check, lets make sure we can create source tracked
+# breakpoints on the files individually.
+foreach_with_prefix dir { aa bb } {
+=C2=A0 =C2=A0 delete_breakpoints
+=C2=A0 =C2=A0 gdb_test "break $dir/${srcfile}:$lineno" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"^Breakpoint $decimal at $hex: file \[^\r\= n\]+/$dir/${srcfile}, line $lineno\\."
+=C2=A0 =C2=A0 set bp_num [get_integer_valueof "\$bpnum" "*U= NKNOWN*" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= ;get bp_num for breakpoint in $dir/$srcfile"]
+
+=C2=A0 =C2=A0 gdb_test_multiple "info breakpoints $bp_num" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"single location breakpoint from $dir/$src= file is tracked" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "source-tracking e= nabled \\(tracking $::decimal lines around line $lineno\\).*" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pass $gdb_test_name=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-re -wrap "" {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fail $gdb_test_name=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+}
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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+extern int common_func (void);
+
+int
+common_func (void)
+{
+=C2=A0 return 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Breakpoint he= re.=C2=A0 */
+}
diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile-lib.c b/g= db/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+extern int common_func (void);
+extern int lib_func (void);
+
+int
+lib_func (void)
+{
+=C2=A0 return common_func ();
+}
diff --git a/gdb/testsuite/gdb.base/source-tracking-multi-objfile.c b/gdb/t= estsuite/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.
+
+=C2=A0 =C2=A0Copyright 2026 Free Software Foundation, Inc.
+
+=C2=A0 =C2=A0This program is free software; you can redistribute it and/or= modify
+=C2=A0 =C2=A0it under the terms of the GNU General Public License as publi= shed by
+=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the License= , or
+=C2=A0 =C2=A0(at your option) any later version.
+
+=C2=A0 =C2=A0This program is distributed in the hope that it will be usefu= l,
+=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warranty o= f
+=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 Se= e the
+=C2=A0 =C2=A0GNU General Public License for more details.
+
+=C2=A0 =C2=A0You should have received a copy of the GNU General Public Lic= ense
+=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.= gnu.org/licenses/>.=C2=A0 */
+
+extern int common_func (void);
+extern int lib_func (void);
+
+volatile int global_var;
+
+int
+main (void)
+{
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+=C2=A0 global_var =3D global_var + 1;
+
+=C2=A0 return lib_func () + common_func (); /* Breakpoint here.=C2=A0 */ +}
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.=C2=A0 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.=C2=A0 If not, see <http://www.gnu.org/lic= enses/>.
+
+# 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.=C2=A0 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 \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 [list $srcfile3 $srcfile2] {debug shlib}] =3D= =3D -1} {
+=C2=A0 =C2=A0 return
+}
+
+if {[prepare_for_testing "prepare" $testfile \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 [list $srcfile $srcfile2] [list debug shlib=3D= $objlib]] =3D=3D -1} {
+=C2=A0 =C2=A0 return
+}
+
+if {![runto_main]} {
+=C2=A0 =C2=A0 return
+}
+
+# Enable the source tracking feature.
+gdb_test_no_output "set breakpoint source-tracking enabled on" \=
+=C2=A0 =C2=A0 "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" {
+=C2=A0 =C2=A0 set lineno [gdb_get_line_number "/* Breakpoint here.=C2= =A0 */" $srcfile2]
+
+=C2=A0 =C2=A0 gdb_breakpoint $srcfile2:$lineno
+=C2=A0 =C2=A0 set bp_num [get_integer_valueof "\$bpnum" "*U= NKNOWN*"]
+
+=C2=A0 =C2=A0 gdb_test "info breakpoint $bp_num" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"\r\n$bp_num\\.1\\s+\[^\r\n\]+\r\n$bp_num\= \.2\\s+\[^\r\n\]+" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"check there are two locations for the bre= akpoint"
+
+=C2=A0 =C2=A0 gdb_test "maintenance info source-tracking-context $bp_= num" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"Breakpoint $bp_num does not have source t= racking enabled\\." \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"check breakpoint is not source tracked&qu= ot;
+}
+
+# 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" {
+=C2=A0 =C2=A0 set lineno [gdb_get_line_number "/* Breakpoint here.=C2= =A0 */" $srcfile]
+
+=C2=A0 =C2=A0 gdb_breakpoint $srcfile:$lineno
+=C2=A0 =C2=A0 set bp_num [get_integer_valueof "\$bpnum" "*U= NKNOWN*"]
+
+=C2=A0 =C2=A0 gdb_test "info breakpoint $bp_num" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0[multi_line \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "\r\n$bp_num\\s+\[^\r\n\]+&= quot; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "\\s+source-tracking enable= d\[^\r\n\]*"] \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"check there is just one location for the = breakpoint"
+
+=C2=A0 =C2=A0 gdb_test "maintenance info source-tracking-context $bp_= num" \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"/\\* Breakpoint here\\.=C2=A0 \\*/.*"= ; \
+=C2=A0 =C2=A0 =C2=A0 =C2=A0"check breakpoint is source tracked"<= br> +}

base-commit: abcacfa2875d31480637ac082ce4862d518992f2
--
2.25.4


This patch looks great.
Revi= ewed-by: Alexandra Hajkova <ahajk= ova@redhat.com>

--0000000000003da880065f9e27a8--