From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id JgxxOdRT8mqwMDwAWB0awg (envelope-from ) for ; Mon, 09 Nov 2026 18:14:28 -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=YOmxGQ3D; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CFEA61E043; Mon, 09 Nov 2026 18:14:28 -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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,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 938551E043 for ; Mon, 09 Nov 2026 18:14:27 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BE5CE4BBC0F4 for ; Mon, 9 Nov 2026 23:14:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE5CE4BBC0F4 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=YOmxGQ3D 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 0E2F24B920D3 for ; Mon, 9 Nov 2026 23:13:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E2F24B920D3 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 0E2F24B920D3 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=1794266039; cv=none; b=uOctKpeuiMHkDT+t2BDtnIfHeSQFd9jswxaNrIe2d++/sjA9Rxg7Tnc+kuWfB3LRofa3Bli3/wCjhOnxvPeKJH/+7XhDa4ce3xR2UdtJYI0Vk6bk89pTuCuBgJCBd8MEveIOhd5j44DoI8nSAm7wINcMyySfPj6HE3qLZJb7H6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794266039; c=relaxed/simple; bh=V71RPvwWls3CFiAFkNstqaObINzKk99IesFfFqO/vIs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cpocTMhk1OjbUF+jr/B14tkkJXP2yo3dgF4Yiiclg2g/x9cF9q9IoRRMqqWUKiWEiTR7726cLJY48F1Lr24c6f/gCt9qRCaSzfx/Cpszk8cSUjf1VgMwy5YtvK8GyFujFVw4aounfnFixj472qtGCCNEIkqKYxMCHAzROn6Tr+8= 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=YOmxGQ3D DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E2F24B920D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794266038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PwZEJ4U1itx2jw+TRTIUfqZRd3grGlmhD+WVxMEuGbU=; b=YOmxGQ3D6zfsmeKqsQfIWk0Sp/TtCNDl6TchVcUCWUeSRdDBbBBOdzN+fSntmQVrjNGP5Q a3fz/j4D9tZfKIv0eRMh6beCNyb2EuISpJ4bVIPctEHiXnn/JX3R7RCvkLt1lnQLE1X9B3 NViQ/LXAXEJeqUfCK8h1xuWdTqmNdro= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665--0plS8V8NvmJxDTR515prQ-1; Mon, 09 Nov 2026 18:13:56 -0500 X-MC-Unique: -0plS8V8NvmJxDTR515prQ-1 X-Mimecast-MFC-AGG-ID: -0plS8V8NvmJxDTR515prQ_1794266035 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4931c89d228so992445f8f.2 for ; Mon, 09 Nov 2026 15:13:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794266035; x=1794870835; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PwZEJ4U1itx2jw+TRTIUfqZRd3grGlmhD+WVxMEuGbU=; b=MeRqNcYW2BYI9CWxP0Jk+D2W+0+fjBFGuWsBgYJtjzXJs6dd8xKe9nAJKPSL+KM8O6 dk0QFwTX6iKg+p+Bpvggmm+T3Cy9yxjkyBQd0KcJVaUqlUXl/8wLZ52qhsnCqmarPznQ CYKYiXDiz2NtpnvbnCEQfh9gVhYXruIvgV04HzYYnJxwvHmJmCjXXmHt43KkHryLVDje 41n3yOcYeSCZN31qtE52CAJ4V2R+Jx5q2XHoianvBz8F1LR/U4Ow3ClFzoKgzb55YW09 T3llnCovHtRBEtCEqsCAERqEkC+uJjtZ7AalaT5aV4ozOeF9NpRXUlNJiagmxC/8Gyeq Lpzg== X-Forwarded-Encrypted: i=1; AL+hErECHkVPTyRA/1MuUaHfw16pvHgNMOECUTJUhnIRI3uXPue5gb1QoGZrLDLl09Bn/5+8U8+Xr4SxPNaZIA==@sourceware.org X-Gm-Message-State: APuU4Z9sGePMM092zsL3fPHuJ5LGGE2PbEsgfrhoiT0hjp61bQAZme5G snpBtmAttJVdPEPyg8mRvGchcOBP70SwlAgaZPxymMb1D84PxG6kIQ4PGUgh75GEsBk7JWEUG0W Cb+wCUUG4w1quMkjLggTJ9DYIjPUMV9+cgJqfaz+xIqfk6kw+kRveUPqmiy0ULdA= X-Gm-Gg: AYBFou33Q5YbRIYQeVMinoeHwaCkgcWPlaquWh+ZNKNW/MLsyE34BkZqhrmcfPfnDJe vh2cBu/JpobxBsNKbM3reRO1287TPUHncCEo+GONd8paRicG+wTT/coZ6r6UykSet8/XPl6QxrN 3QVEFFRNrm5tYfeH/BS7LEtj3W6qbsC4F/vmYVC19U/wC+PFLzXvh/eGdy7JmMri2viExCWs0Uz mGZdgmCe5hTN3LBiGgsZODpYL5Lnr1a6o9nOEQQgUQY6tsTdnAV0rEx2khRdmsRNLg+BYf7zzin IKPiKc7YQNrqRZ5e+2OTlx32cs/fDzAX0/mdxUjDWSorTAuASQFsnqv0++hs/bBRnm+qJdFsixR vKJi61rUu38gGc1TCtmLQ0tJXzUNoDCVVbOw7ge0wmYJE X-Received: by 2002:a05:6000:4102:b0:491:36b3:23d with SMTP id ffacd0b85a97d-4982f2b4b99mr1075577f8f.13.1794266035424; Mon, 09 Nov 2026 15:13:55 -0800 (PST) X-Received: by 2002:a05:6000:4102:b0:491:36b3:23d with SMTP id ffacd0b85a97d-4982f2b4b99mr1075555f8f.13.1794266034844; Mon, 09 Nov 2026 15:13:54 -0800 (PST) Received: from localhost ([83.216.138.189]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4983585c5b9sm1540581f8f.9.2026.11.09.15.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 15:13:54 -0800 (PST) From: Andrew Burgess To: Markus Metzger , gdb-patches@sourceware.org Subject: Re: [PATCH v2] gdb: fix breakpoints on inline functions qualified with source file name In-Reply-To: <20260813095614.3662164-1-markus.t.metzger@intel.com> References: <20260813095614.3662164-1-markus.t.metzger@intel.com> Date: Mon, 09 Nov 2026 23:13:53 +0000 Message-ID: <87tslp61ji.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: U7Wy_ucd_KACK_I0j_G78je0hoK6YN8ZZqxVpFPpPxM_1794266035 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Markus Metzger writes: > 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(). Not "called indirectly from" just "called from". > > Add that functionality to add_matching_symbols_to_info() in case it is > called with a list of file symtabs to search. > > Also add iterate_over_local_blocks() as helper function similar to > iterate_over_file_blocks(). > --- > gdb/linespec.c | 51 ++++++++++++++++-------- > 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, 126 insertions(+), 16 deletions(-) > 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..9959690b57b 100644 > --- a/gdb/linespec.c > +++ b/gdb/linespec.c > @@ -363,6 +363,11 @@ static void iterate_over_file_blocks > domain_search_flags domain, > for_each_symbol_callback_ftype callback); > > +static void iterate_over_local_blocks > + (const symtab *symtab, const language_defn *language, > + const lookup_name_info &name, domain_search_flags domain, > + for_each_symbol_callback_ftype callback); > + > static void initialize_defaults (struct symtab **default_symtab, > int *default_line); > > @@ -1147,23 +1152,14 @@ iterate_over_all_matching_symtabs > > if (include_inline) > { > - const struct block *block; > - int i; > - const blockvector *bv = symtab->compunit ().blockvector (); > - > - for (i = FIRST_LOCAL_BLOCK; i < bv->num_blocks (); i++) > + auto callback_inlined = [&] (block_symbol *bsym) > { > - block = bv->block (i); > - state->language->for_each_symbol > - (block, lookup_name, domain, > - [&] (block_symbol *bsym) > - { > - /* Restrict calls to CALLBACK to symbols > - representing inline symbols only. */ > - if (bsym->symbol->is_inlined ()) > - callback (bsym); > - }); > - } > + if (bsym->symbol->is_inlined ()) > + callback (bsym); > + }; > + iterate_over_local_blocks (symtab, state->language, > + lookup_name, domain, > + callback_inlined); The iterate_over_local_blocks call is over indented, it should start in the same column as the auto does. > } > > return iteration_status::keep_going; > @@ -1203,6 +1199,22 @@ iterate_over_file_blocks > current_language->for_each_symbol (block, name, domain, callback); > } > > +/* Iterate over local blocks. */ Function comments should ideally mention all the arguments: /* Iterate over the local block in the block vector of SYMTAB. Search for symbols matching NAME in DOMAIN for LANGUAGE and call CALLBACK for each matching symbol. */ > + > +static void > +iterate_over_local_blocks > + (const symtab *symtab, const language_defn *language, > + const lookup_name_info &name, domain_search_flags domain, > + for_each_symbol_callback_ftype callback) > +{ > + const blockvector *bv = symtab->compunit ().blockvector (); > + for (int i = FIRST_LOCAL_BLOCK; i < bv->num_blocks (); i++) > + { > + const struct block *block = bv->block (i); > + language->for_each_symbol (block, name, domain, callback); > + } > +} > + > /* A helper for find_method. This finds all methods in type T of > language T_LANG which match NAME. It adds matching symbol names to > RESULT_NAMES, and adds T's direct superclasses to SUPERCLASSES. */ > @@ -4253,6 +4265,11 @@ add_matching_symbols_to_info (const char *name, > { > info->add_symbol (bsym); > }; > + auto add_inlined_symbol = [&] (block_symbol *bsym) > + { > + if (bsym->symbol->is_inlined ()) > + info->add_symbol (bsym); > + }; > > for (const auto &elt : info->file_symtabs) > { > @@ -4275,6 +4292,8 @@ add_matching_symbols_to_info (const char *name, > gdb_assert (!elt_pspace->executing_startup); > set_current_program_space (elt_pspace); > iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, add_symbol); > + iterate_over_local_blocks (elt, info->state->language, lookup_name, > + SEARCH_VFT, add_inlined_symbol); > > /* If no new symbols were found in this iteration and this symtab > is in assembler, we might actually be looking for a label for > 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. */ This comment is missing a space at the beginning, and a space at the end after the period. But even then, at a first glance I don't understand what this comment is telling me. Can you rewrite it to better explain what's going on please. Thanks, Andrew > + 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 */ > +} > -- > 2.53.0 > > ________________________________________ > Intel Deutschland GmbH > > Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany > > Tel: +49 (89) 99143-0 > > www.intel.de > > Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman > > Chairperson of the Supervisory Board: Sonja Pierer > > Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies.