From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hTl1NAUff2rlkCUAWB0awg (envelope-from ) for ; Fri, 14 Aug 2026 09:58:29 -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=aB4faGmm; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C38C51E033; Fri, 14 Aug 2026 09:58:29 -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 AD20A1E033 for ; Fri, 14 Aug 2026 09:58:28 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8096A4BA7988 for ; Fri, 14 Aug 2026 13:58:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8096A4BA7988 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=aB4faGmm 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 D64EC4BA2E07 for ; Fri, 14 Aug 2026 13:58:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D64EC4BA2E07 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 D64EC4BA2E07 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=1786715880; cv=none; b=B+/2u3h+uV6ZlmLiIQaZUXMvyNmEH73vRafypoEk6SkfhPNheOFxN+HksJRJ4t/jMqX1iJ4Ohs5yg82ksoPR5Qmr6jP4nc67RAyVD23ZQrDSctLgt8Q4Jj5Ugyz8Oa7rYzjLMNHWsWMzRw6JNsIw/t4zRa1icP2HftJnRi6jj6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786715880; c=relaxed/simple; bh=uaALU+knjMt1WK4A3BnnE2vvIiy7SHPHG+1RF9YSO7U=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=OPOZ0XQAROKWBxejqVExsLPn6uiX+AEzHkDu3GaeRWxcOBwCeC5JAqSvzps02iHztxxCwEq+UYYPy0NNyRNRtc59yt088XdK1Ksk4cAe3/Zo+YI0YsWNpQavxVeS7bXWvxiUi04WerbK/C3RSVvOSoglhdq4Kh75LtPC5hkE4CQ= 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=aB4faGmm DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D64EC4BA2E07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786715880; 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=D/mF6OB4tOKeR9Ws4mQQCAz9wJVKrECWcRLmpdxl5NE=; b=aB4faGmm66PbYmH1RA77rGY/uni3cSYx0cTKqeLQyS6SxQAiPnw84a7KafMneXuKUL5l3b kABzR3ZRoqnpjveZfuD5lgSRUg0UNEGaJIsD22J7mS6YHCkzy0iZ9Nnaacs34e8iRsAfVg iQmoYYjzGjbPVAvvHCo9eP5G+u8TRQc= 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-682-TN6M7nu1MRepQDAKrTHOmw-1; Fri, 14 Aug 2026 09:57:57 -0400 X-MC-Unique: TN6M7nu1MRepQDAKrTHOmw-1 X-Mimecast-MFC-AGG-ID: TN6M7nu1MRepQDAKrTHOmw_1786715877 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38e7ff7b375so1190593a91.1 for ; Fri, 14 Aug 2026 06:57:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786715877; x=1787320677; h=content-transfer-encoding:content-type:in-reply-to:content-language :from: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=D/mF6OB4tOKeR9Ws4mQQCAz9wJVKrECWcRLmpdxl5NE=; b=lIxjFoolBUhG9I22TP7SvL4IGMikgvu0ucnGerh+gxBCtTd0k0qAllgW6+iLkLRh6P 4KZkTXF88Ty+QrOx6mQvvFlM9vr/VI/WfyrxFDBrkxidrJGdSW8bPDmBGTrxAY1PCxjo NLCBODEuTVO5EmrM5KiNY+XC1B6icn6i+J7g4ZYZ4y6i6cFxxECSb8zQ/0XhWA17BXr7 V68oI50xAlhyfQjS50hMAk+pOsteJpsRJ8PeXBbli7L2TZCC46C++2zsCW+zOw0RfRwM IbWRtxuT9NZ0iwGmJa112p5Gfpqj/ium6FkWL4aU2OkXn1ks8eMXsv+0H18pLSKj5RfG gFaw== X-Forwarded-Encrypted: i=1; AHgh+Rq+3YQq3SJGck9gBAebO+cFPCQ3FQ91fqSoIqpgY7JWXbnLHN8MAhdPD2m4dmwZarUOrCnyr5B0a7Hn+g==@sourceware.org X-Gm-Message-State: AOJu0Yy5VyrSn46IwS1JSeV5OABvwRMpVRy687HoDMFBk3xGfyOJfC4/ w6x6C8FTn3mz8luT/eQb4d+MolKcD61hck0OBn/2nQo7zHe3wSIr9HEUWMTMJ54Pk7nJRgCQ1mr twuS2lzubeGC8g3sGKzx/COjYK0obVI+6PoKm2/fs5PUUR6Q6cjSN6Cx8nOBfWLym6fU7C4M= X-Gm-Gg: AR+sD13zngMXJmr9of4A75lT0HfWl+i//AzZMoJZ1MCJ6+igWSw4ELdfY5aQM59kUYN 1hvv8Fh6GhNWdPEp1WasX4CQ4cetznv1zz/98ALaEsvJhKFdF3ggTI+AJJfRNCtdmij8DMeYbaN cphm7nSZolDk4KriQA7gVm/YPMWLETd5fJwBkdO+tNdhtWrA1MwNSD2T7AXbI89QQNggVD8TlGC x0LPqXe/WB1QlTMliL5JVjjwZCtmXNc5N5908b8kqX3+jQfcepXb7MD3vkg+YLIVNUXq48YE/1L 683nH/LblfguRokhoCV/kx7pItS2xe8y0EtkvCA2kfsZVkqKFP1T0W7UNGnRHyXtg5KExgEFXJf jYk8ZAJIcJw== X-Received: by 2002:a17:90a:dfd0:b0:38f:23d6:b4ad with SMTP id 98e67ed59e1d1-3933b792985mr6801092a91.8.1786715876365; Fri, 14 Aug 2026 06:57:56 -0700 (PDT) X-Received: by 2002:a17:90a:dfd0:b0:38f:23d6:b4ad with SMTP id 98e67ed59e1d1-3933b792985mr6801037a91.8.1786715875704; Fri, 14 Aug 2026 06:57:55 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e::75d? ([2804:14d:8084:993e::75d]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1413887ee65sm9294069c88.10.2026.08.14.06.57.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Aug 2026 06:57:55 -0700 (PDT) Message-ID: <12dc314a-8ab4-4a26-871e-c7c62675f689@redhat.com> Date: Fri, 14 Aug 2026 10:57:51 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb: fix breakpoints on inline functions qualified with source file name To: Markus Metzger , gdb-patches@sourceware.org References: <20260813095614.3662164-1-markus.t.metzger@intel.com> From: Guinevere Larsen In-Reply-To: <20260813095614.3662164-1-markus.t.metzger@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 4ym9J8almQldy902XP57zqryQC743sLBoZej9t2bxIA_1786715877 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 8/13/26 6:56 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. > > Also add iterate_over_local_blocks() as helper function similar to > iterate_over_file_blocks(). > --- Hi Markus! I looked over this and all my questions have been solved. Reviewed-By: Guinevere Larsen -- Cheers, Guinevere Larsen it/its she/her (deprecated) > 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); > } > > 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. */ > + > +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. */ > + 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 */ > +}