From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id NRj6DUK08mrEYj0AWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 01:05:54 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ayJWQAmu; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 22B641E06A; Tue, 10 Nov 2026 01:05:54 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7E0631E043 for ; Tue, 10 Nov 2026 01:05:52 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 59D734BA23D3 for ; Tue, 10 Nov 2026 06:05:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59D734BA23D3 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ayJWQAmu Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id B39B84BA2E15 for ; Tue, 10 Nov 2026 06:05:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B39B84BA2E15 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B39B84BA2E15 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794290716; cv=none; b=tfNZEsR00ZnN++APk+q5hk16Qzvzl0u2E0CitrRwtG3xs4D+o5QQPz0RrSAmXYxI7Z+o6ssMufUF65RZO2FRksMDD73m7HzvUvJLeuZTGvUrAD3+B+/4vVDRq1vG8O5LgfwDumpiBompciGzTKJfhsuNzwkAp1tyWVUVHP07JzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794290716; c=relaxed/simple; bh=COYxuiaTyrwkVAVmvXVzrHcgM5gvO/DYma01mkyrfio=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hkWHaO79m7AywXyC6i3OvC6GuG65TUaJXcOQDMSMoYo19fOuhMzr21kybO9eBOJaNAuTEE4D5p3BgjoVRdHxvrKBF6TSP+XFDqbYPxsVQ9CJi/T2syUyT6HmrIThsCfTJ5s+bayj0K+X/BBuzvvXHQQA+7/R9THV8mcB2DQbNBs= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ayJWQAmu DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B39B84BA2E15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794290716; x=1825826716; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=COYxuiaTyrwkVAVmvXVzrHcgM5gvO/DYma01mkyrfio=; b=ayJWQAmuUqPTjlwX3PRjGN/xCtXAOVlyBDO1pq71sHbig1SVvjJpviVo 84FkxBdvKAcbl7HED1dpM2Cg0y+nB76XdSDd8pXf8QF9Xt5+JVSGSabZ5 FHx+4J6xSA/s0p7LLw5yYoim/50MaSjY6sXilb4kC2Vra/QaNyy5Js72n uczuIfEMl9Q/uwYJXPPBHs53ZSWwYeut851wQNZhGvC4f7YIFeMcfzXV5 8FZLB0S+xJINC9OrwS9h7jhW+z+ngJ15w5DHOdVEMyrCtAC/zGDCP/tQS AwjeK399OgksPmwPOm5CLxuKAfV/Uh/rszfmkXesXNw7obda2+C7KFwld Q==; X-CSE-ConnectionGUID: 2cnquOhPQtK1pLRThR8GGQ== X-CSE-MsgGUID: GBpY0fVgSRqiQgUFJwqKqw== X-IronPort-AV: E=McAfee;i="6800,10657,11961"; a="3065758" X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="3065758" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:05:14 -0800 X-CSE-ConnectionGUID: 3ElqM5wxSaGVu0j32E8RPg== X-CSE-MsgGUID: YDJS+K9vTUaORtErqMhlhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="8207336" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:05:14 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Cc: aburgess@redhat.com, Guinevere Larsen Subject: [PATCH v3] gdb: fix breakpoints on inline functions qualified with source file name Date: Tue, 10 Nov 2026 07:05:11 +0100 Message-ID: <20261110060511.330163-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 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 '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 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. Also add iterate_over_local_blocks() as helper function similar to iterate_over_file_blocks(). Reviewed-By: Guinevere Larsen --- gdb/linespec.c | 53 +++++++++++++++++------- gdb/testsuite/gdb.base/break-inline2.c | 32 ++++++++++++++ gdb/testsuite/gdb.base/break-inline2.exp | 30 ++++++++++++++ gdb/testsuite/gdb.base/break-inline2.h | 28 +++++++++++++ 4 files changed, 127 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 95ad0b048d2..39167714a01 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); @@ -1143,23 +1148,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); } return iteration_status::keep_going; @@ -1199,6 +1195,24 @@ iterate_over_file_blocks current_language->for_each_symbol (block, name, domain, callback); } +/* 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. */ @@ -4249,6 +4263,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) { @@ -4271,6 +4290,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..59ed88002a9 --- /dev/null +++ b/gdb/testsuite/gdb.base/break-inline2.c @@ -0,0 +1,32 @@ +/* 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) +{ + 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..b57c83749cd --- /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 +gdb_breakpoint bar -message + +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 */ +} base-commit: 892d98146139de38662c1f5b7d48fc3a606ec3f6 -- 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.