From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MXMVLiLsamqeSDQAWB0awg (envelope-from ) for ; Thu, 30 Jul 2026 02:16:02 -0400 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=e3Xkj178; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AAEFC1E09E; Thu, 30 Jul 2026 02:16:02 -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 [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 BE8881E033 for ; Thu, 30 Jul 2026 02:16:00 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 754D34B920DB for ; Thu, 30 Jul 2026 06:15:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 754D34B920DB 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=e3Xkj178 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by sourceware.org (Postfix) with ESMTPS id 969994BB5911 for ; Thu, 30 Jul 2026 06:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 969994BB5911 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 969994BB5911 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785392133; cv=none; b=XIdOduDhrSGxwiG1u4yct6FcpzXsrW9mQuJO+gMIqs+lZCALKZvFKb3SwFMpOmbTmsdepdQDaOqcrJlsnCdiQjI+5h/2Vcxdf5ON81EFZWgBXcAbxIJIs1eYjnc2jw7fiB3aQEuWqzZjf5/SqhJgi7Ev6vHa+SnI1fHWUhvAdfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785392133; c=relaxed/simple; bh=qp80+IhczVGhVgXpzmJgt8FBczh8eXCMrZ+eBAenXIU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=e28p+SCUPdWauV2IIGLePiW1xl2tN2Kh9A6nbapwn+SGf8YgLrhclVxNBX5zXgROQgIf0tL0AKFrfBDe3m/cobTjkZ+5TfhtCyivhxNEM8AlUSfBK3xjMnPEF6MXupAxMR1xVs4FUgM9AneHoEFd8gMfkjviQYjHNVhNtqek/YQ= 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=e3Xkj178 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 969994BB5911 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1785392133; x=1816928133; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=qp80+IhczVGhVgXpzmJgt8FBczh8eXCMrZ+eBAenXIU=; b=e3Xkj178HHE14TYQaNDULjU9PcuWpMBMPeXy/6nFwKB/FkiTTpIrejKO MkysSsf82lBMaszuOfVyW0uuvPTPasxpUkdH94DI7jBF6AaeB7a7m4/Rr MYIV2BT2RyIp4dCEUQ4yRsyqjT6kDhQyQuDs+8l3VN/9Gb1/gSUIXtYQR /mUQXHUVxeFOVKSHA/2bPbH3z8210Ex/KAP3pVZ8gbfMlRoPdJJawiVoz CNtbi0E7B6hawV9U2hmRDdlepX1JPue2WwDprtIKZRx9e8LLlB6b1NBfo WvMcGgj+puTANkW3c6VRF9hNG1u6oiZDCR92WaMZFGVfkyrBIvZf/lTWB A==; X-CSE-ConnectionGUID: dW/Mt8jcT1KZ1FgjyfqkDA== X-CSE-MsgGUID: eibCdf/tTTO11cKSo7AQuw== X-IronPort-AV: E=McAfee;i="6800,10657,11859"; a="88542527" X-IronPort-AV: E=Sophos;i="6.25,194,1779174000"; d="scan'208";a="88542527" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2026 23:15:32 -0700 X-CSE-ConnectionGUID: JReCR3FVRsaQR42h9Q+J4w== X-CSE-MsgGUID: lHGX1jjoQkqja/fyNkxHNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,194,1779174000"; d="scan'208";a="298426044" 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; 29 Jul 2026 23:15:32 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH] gdb: fix breakpoints on inline functions qualified with source file name Date: Thu, 30 Jul 2026 06:15:29 +0000 Message-Id: <20260730061529.1248775-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 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 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. --- 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 */ +} -- 2.34.1 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928