From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +Q37EnyjdGpDcQ0AWB0awg (envelope-from ) for ; Thu, 06 Aug 2026 11:08:44 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=go6CMD67; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 472121E166; Thu, 06 Aug 2026 11:08:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [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 11C8B1E09B for ; Thu, 06 Aug 2026 11:08:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A62ED4BB3BE5 for ; Thu, 6 Aug 2026 15:08:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A62ED4BB3BE5 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=go6CMD67 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B9CCB4BA798A for ; Thu, 6 Aug 2026 15:08:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9CCB4BA798A 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 B9CCB4BA798A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786028896; cv=none; b=GyjXVJBhIG27HmN0SjsM1fcCq74o4g24S+2Wf6x8t+fwVPGWtyLgalcpdnMRiBED+JMu0WafIJMBNDejlxHY6Y3S8duwGvTY7s8cd+wj4ku8DrU6vGVSTjoCkWRqLEYFgOuw874FcTZjrbv42PxmXdVUknGzRut+GdELVr/zy6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786028896; c=relaxed/simple; bh=S2adVJwxwfEQ+aiHU6J/nwfCL8CxBad+rlDxdygdwrI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ou7EQQz4QT59k0Gzv6m2EOylSzM2g5VLiiGi7LYCnorSf2bR51To1FR58uo+IbtwJNL8YQacCGAS0Xqqmsc9wfv3i0AiQ2NQrVq1frZ+viGHegej1oZk3WBwPZBMNQZZFovskM2rPs9ahbDyPsi/GSg0G0DMXhpHMJm1Sh/2HnU= 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=go6CMD67 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9CCB4BA798A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786028896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zHDONnvUvnGNN50eGWoGXmzAMDS/Ce0kZAGWKCVyT6Q=; b=go6CMD673M2IKVk1cP8O2L+5efCtvNS6SvCiNU99R6CsxxVFeb2Ek5sggsRKNlYkztjUJJ G2ETIdBBTmyyzz5tzY4VkiwS0aB/D8UDStmdp/sJId/gM7z007F0OxG7iwWB2wr2+YCmmi SCZfnQ/kdSC+BMJNFz7Sbmfrd79W160= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-4LKRAaFONue0toR_2hHsNw-1; Thu, 06 Aug 2026 11:08:14 -0400 X-MC-Unique: 4LKRAaFONue0toR_2hHsNw-1 X-Mimecast-MFC-AGG-ID: 4LKRAaFONue0toR_2hHsNw_1786028894 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38e22137fb3so3118504a91.0 for ; Thu, 06 Aug 2026 08:08:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786028893; x=1786633693; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zHDONnvUvnGNN50eGWoGXmzAMDS/Ce0kZAGWKCVyT6Q=; b=bktBGx/6oNkNO+58nN1t8IuqfkXgvjbvo9r7cgz19DAWqI/O+69/8E+Z8CRKL6V5+2 uz05dl+KemeeFXEE0UOoRjHTvpQlgfO8y4/D2jlaaQ7O3X7o1xVNnIJAYfOZaAIM3rxY 52gBd232nflrMeTA8hJUHwSW3bt08m0CY6ZgaPSgElEZkOLfIuY97VokJ9qMPQMSCqb/ rHZb0CrKJY/2lfc21LQcMB1zyWZ2YHN/9piDhvRJ/yyYuBft4sq4wnu/bo8JacrHx82I 2k+3E5opT32RkOIIdejPM6/Qe11CBIqa5QIqxbnFX18t8V9ihpaZGTAyjhYj1j6vSeMY rW/Q== X-Forwarded-Encrypted: i=1; AHgh+RriWo9ty+XfNF6pqYEq2IZivNuoEinbtYH406fcvr3n8Lg9++s45BwLSFSqyaUevl5sFvJiChRv5019RQ==@sourceware.org X-Gm-Message-State: AOJu0YyIibFewOwU3dWRUQ8XnB2DWq6Fyii9jAbjp9Bzqo0VokwwzFaw zMwAEvmtu1rxuWV8sfSrwun+uhn4Vr+MVrK+fW0cIRV/fvrndJKwXl51/AGVmLI0dMPtjz7R1QT Zx5Sbm8iRbhgJ+NOajsRKp+x8uoaqvJf0K4+wgvLfovbXvqry+CWmz5T+gjB0opNd9ol4NQM= X-Gm-Gg: AR+sD13XtNIQQBaJifvDIQYXEPpBe7Bu1ofxBdi5Okql0PgWQ4K0xwgB6kZU6o/AZa+ rcBt25dhxVjMTHlBT8JJlhr1RhBq1nu3GTVOp8StcMpVGp4WuqNPaC4vBW/iO1a5GC0AMXRYL4r 7Hmu/12OJZT3WkZEyCWVbM3gosEfDkuWozjNV8FBmeRyPbzVLPZPRMdsUBl5YrYz2+0p1CvYzUN N9PZOLKH2O89Klwr0UxmUy0miUNk5epUuETntH4cth4xnbsz7kAh1TPWeCDVmDoVjRoC7QYvutW 6wN2nlocJKp8y9wOvesk2rbofJE9S6Q+BBJ5WymoufLQ5PWfIe0oRY5c51TmcHH+r0ovWgZY1mN WWtRydlepbw== X-Received: by 2002:a17:90b:41:b0:37f:ed7e:7e42 with SMTP id 98e67ed59e1d1-3903c5bd850mr16328992a91.14.1786028893433; Thu, 06 Aug 2026 08:08:13 -0700 (PDT) X-Received: by 2002:a17:90b:41:b0:37f:ed7e:7e42 with SMTP id 98e67ed59e1d1-3903c5bd850mr16328879a91.14.1786028892773; Thu, 06 Aug 2026 08:08:12 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e::75d? ([2804:14d:8084:993e::75d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31586401627sm34682877eec.10.2026.08.06.08.08.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Aug 2026 08:08:11 -0700 (PDT) Message-ID: Date: Thu, 6 Aug 2026 12:08:07 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: fix breakpoints on inline functions qualified with source file name To: Markus Metzger , gdb-patches@sourceware.org References: <20260730061529.1248775-1-markus.t.metzger@intel.com> From: Guinevere Larsen In-Reply-To: <20260730061529.1248775-1-markus.t.metzger@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1sHDqSe92GD0di4nvka4YtAFMYvBIboXgyDV0O28eDI_1786028894 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 7/30/26 3:15 AM, Markus Metzger wrote: > On 'break foo.[hc]:foo', GDB only searches the symbols of foo.[hc] on file > scope. If foo has been inlined, GDB would not find it. > > On 'break foo', however, GDB also searches local blocks for inline > function symbols in iterate_over_all_matching_symtabs(), which is called > indirectly from add_matching_symbols_to_info(). > > Add that functionality to add_matching_symbols_to_info() in case it is > called with a list of file symtabs to search. > --- Hi Markus! I looked through and confirmed it fixes the test case you added, so all looks good! I wonder, though, does it make sense to add this code to some common place, so that future code isn't going to forget to add this handling a well. Have you tried adding it to the iterate_over_file_blocks code? -- Cheers, Guinevere Larsen it/its she/her (deprecated) > gdb/linespec.c | 14 ++++++++++ > gdb/testsuite/gdb.base/break-inline2.c | 33 ++++++++++++++++++++++++ > gdb/testsuite/gdb.base/break-inline2.exp | 30 +++++++++++++++++++++ > gdb/testsuite/gdb.base/break-inline2.h | 28 ++++++++++++++++++++ > 4 files changed, 105 insertions(+) > create mode 100644 gdb/testsuite/gdb.base/break-inline2.c > create mode 100644 gdb/testsuite/gdb.base/break-inline2.exp > create mode 100644 gdb/testsuite/gdb.base/break-inline2.h > > diff --git a/gdb/linespec.c b/gdb/linespec.c > index b6505ba283d..384c989ef2f 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -4276,6 +4276,20 @@ add_matching_symbols_to_info (const char *name, > set_current_program_space (elt_pspace); > iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, add_symbol); > > + /* Search local blocks for inline functions, too. */ > + const blockvector *bv = elt->compunit ().blockvector (); > + for (int i = FIRST_LOCAL_BLOCK; i < bv->num_blocks (); i++) > + { > + const struct block *block = bv->block (i); > + info->state->language->for_each_symbol > + (block, lookup_name, SEARCH_VFT, > + [&] (block_symbol *bsym) > + { > + if (bsym->symbol->is_inlined ()) > + add_symbol (bsym); > + }); > + } > + > /* If no new symbols were found in this iteration and this symtab > is in assembler, we might actually be looking for a label for > which we don't have debug info. Check for a minimal symbol in > diff --git a/gdb/testsuite/gdb.base/break-inline2.c b/gdb/testsuite/gdb.base/break-inline2.c > new file mode 100644 > index 00000000000..797ab07da31 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/break-inline2.c > @@ -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 . */ > + > +#include "break-inline2.h" > + > +static int > +test (void) > +{ > + int f = foo (); > + int b = bar (); > + return f + b; > +} > + > +int > +main (void) > +{ > + /* Don't make breakpoints on foo and main bind to the same address. */ > + return test (); > +} > diff --git a/gdb/testsuite/gdb.base/break-inline2.exp b/gdb/testsuite/gdb.base/break-inline2.exp > new file mode 100644 > index 00000000000..b10cdece118 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/break-inline2.exp > @@ -0,0 +1,30 @@ > +# Copyright (C) 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 . > + > +standard_testfile > + > +if {[prepare_for_testing "failed to prepare" "$testfile" "$srcfile"]} { > + return > +} > + > +if {![runto_main]} { > + return > +} > + > +gdb_breakpoint "$testfile.h:foo" -message -allow-pending > +gdb_breakpoint bar -message -allow-pending > + > +gdb_continue_to_breakpoint "foo" ".*foo.entry.*" > +gdb_continue_to_breakpoint "bar" ".*bar.entry.*" > diff --git a/gdb/testsuite/gdb.base/break-inline2.h b/gdb/testsuite/gdb.base/break-inline2.h > new file mode 100644 > index 00000000000..e60d054e85b > --- /dev/null > +++ b/gdb/testsuite/gdb.base/break-inline2.h > @@ -0,0 +1,28 @@ > +/* 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 . */ > + > +static inline int __attribute__((always_inline)) > +foo (void) /* foo.entry */ > +{ /* foo.entry */ > + return 42; /* foo.entry */ > +} > + > +static inline int __attribute__((always_inline)) > +bar (void) /* bar.entry */ > +{ /* bar.entry */ > + return 42; /* bar.entry */ > +}