From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1877 invoked by alias); 29 Nov 2011 02:49:03 -0000 Received: (qmail 1860 invoked by uid 22791); 29 Nov 2011 02:49:01 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 02:48:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B68D92BB2C4; Mon, 28 Nov 2011 21:48:46 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7rFf9j1PwTNL; Mon, 28 Nov 2011 21:48:46 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 5246A2BB2C3; Mon, 28 Nov 2011 21:48:46 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 8150F145615; Mon, 28 Nov 2011 21:48:33 -0500 (EST) Date: Tue, 29 Nov 2011 02:49:00 -0000 From: Joel Brobecker To: Tom Tromey Cc: gdb-patches@sources.redhat.com Subject: iterate_over_symbols should be a wrapper? (was: "Re: GDB 7.4 branching status? (2011-11-23)") Message-ID: <20111129024833.GL24943@adacore.com> References: <20111123163917.GA13809@adacore.com> <20111123232406.GQ13809@adacore.com> <20111124105603.GA91879@adacore.com> <20111124163304.GR13809@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZwgA9U+XZDXt4+m+" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00795.txt.bz2 --ZwgA9U+XZDXt4+m+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1730 I noticed that the following linespec does not work for Ada anymore: (gdb) break FILE:FUNCTION And that got me into looking how we do symbol matching. When no filename is provided in the linespec, we call iterate_over_all_matching_symtabs, which calls iterate_over_symbols over all symtabs, immediately followed by: if (current_language->la_iterate_over_symbols) (*current_language->la_iterate_over_symbols) (name, domain, So, basically, we do a first pass collecting symbols that follow a certain matching algorithm, and then we do a second pass for language that might require a different matching algorithm... It seems to me that there should be only one, language-specific matching routine, and iterate_over_symbols should call it. So, my proposal is to change the profile of la_iterate_over_symbols to match the iterate_over_symbols routine, and then then set the la_iterate_over_symbols field to iterate_over_symbols for all languages except Ada. The changes in ada_iterate_over_symbols should be straightforward, since ada_lookup_symbol_list accepts a block as well. That would solve the problem above as well: When the linespec contains a filename in it, add_matching_symbols_to_info only calls iterate_over_symbols: else if (pspace == NULL || pspace == SYMTAB_PSPACE (elt)) { [...] iterate_over_symbols (get_search_block (elt), name, VAR_DOMAIN, collect_symbols, info); } In the meantime, I applied a different type of patch which just follows the current approach of doing the generic matching first, followed by the language-specific one next. Attached is the corresponding patch. -- Joel --ZwgA9U+XZDXt4+m+ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0005-Call-current_language-la_iterate_over_symbols-for-FI.patch" Content-length: 4305 >From a86c5755b965bb1e060130319cb1e09ab2e2d92c Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Fri, 25 Nov 2011 15:21:19 -0800 Subject: [PATCH 5/5] Call current_language->la_iterate_over_symbols for FILE:FUNCTION linespecs Without this, breakpoints using FILE:FUNCTION linespecs fail for Ada units. For instance, consider for the following trivial program: procedure Foo is begin null; end Foo; Trying to insert a breakpoint on foo.adb:foo fails: (gdb) b foo.adb:foo Function "foo" not defined in "foo.adb". Make breakpoint pending on future shared library load? (y or [n]) This is because the default method of matching symbols does not work in this case, because the linkage name for procedure "Foo" here is _ada_foo. We need to apply Ada-specific symbol-name matching. gdb/ChangeLog: * linespec.c (add_matching_symbols_to_info): Add call current_language->la_iterate_over_symbols after call to iterate_over_symbols. gdb/testsuite/ChangeLog: * gdb.ada/file_fun_bp: New testcase. --- gdb/linespec.c | 4 +++ gdb/testsuite/gdb.ada/file_fun_bp.exp | 32 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.ada/file_fun_bp/foo.adb | 19 +++++++++++++++++ 3 files changed, 55 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.ada/file_fun_bp.exp create mode 100644 gdb/testsuite/gdb.ada/file_fun_bp/foo.adb diff --git a/gdb/linespec.c b/gdb/linespec.c index 146163a..1e713ee 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2806,6 +2806,10 @@ add_matching_symbols_to_info (const char *name, iterate_over_symbols (get_search_block (elt), name, VAR_DOMAIN, collect_symbols, info); + if (current_language->la_iterate_over_symbols) + (*current_language->la_iterate_over_symbols) (name, VAR_DOMAIN, + collect_symbols, + info); } } } diff --git a/gdb/testsuite/gdb.ada/file_fun_bp.exp b/gdb/testsuite/gdb.ada/file_fun_bp.exp new file mode 100644 index 0000000..06b757a --- /dev/null +++ b/gdb/testsuite/gdb.ada/file_fun_bp.exp @@ -0,0 +1,32 @@ +# Copyright 2011 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 . + +load_lib "ada.exp" + +set testdir "file_fun_bp" +set testfile "${testdir}/foo" +set srcfile ${srcdir}/${subdir}/${testfile}.adb +set binfile ${objdir}/${subdir}/${testfile} + +file mkdir ${objdir}/${subdir}/${testdir} +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { + return -1 +} + +clean_restart ${testfile} + +gdb_test "break foo.adb:foo" \ + "Breakpoint \[0-9\]+ at 0x\[0-9a-f]+: file .*foo.adb, line \[0-9\]+." + diff --git a/gdb/testsuite/gdb.ada/file_fun_bp/foo.adb b/gdb/testsuite/gdb.ada/file_fun_bp/foo.adb new file mode 100644 index 0000000..6d251fc --- /dev/null +++ b/gdb/testsuite/gdb.ada/file_fun_bp/foo.adb @@ -0,0 +1,19 @@ +-- Copyright 2011 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 . + +procedure Foo is +begin + null; +end Foo; -- 1.7.1 --ZwgA9U+XZDXt4+m+--