From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: iterate_over_symbols should be a wrapper? (was: "Re: GDB 7.4 branching status? (2011-11-23)")
Date: Tue, 29 Nov 2011 02:49:00 -0000 [thread overview]
Message-ID: <20111129024833.GL24943@adacore.com> (raw)
In-Reply-To: <m31ussq6o2.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]
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
[-- Attachment #2: 0005-Call-current_language-la_iterate_over_symbols-for-FI.patch --]
[-- Type: text/x-diff, Size: 4304 bytes --]
From a86c5755b965bb1e060130319cb1e09ab2e2d92c Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
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 <http://www.gnu.org/licenses/>.
+
+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 <http://www.gnu.org/licenses/>.
+
+procedure Foo is
+begin
+ null;
+end Foo;
--
1.7.1
next prev parent reply other threads:[~2011-11-29 2:49 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-23 16:39 GDB 7.4 branching status? (2011-11-23) Joel Brobecker
2011-11-23 16:56 ` Tristan Gingold
2011-11-23 18:47 ` Tom Tromey
2011-11-23 23:24 ` Joel Brobecker
2011-11-24 10:56 ` Jerome Guitton
2011-11-24 16:33 ` Joel Brobecker
2011-11-28 16:17 ` Tom Tromey
2011-11-28 21:29 ` Tom Tromey
2011-11-29 2:28 ` Joel Brobecker
2011-11-29 2:49 ` Joel Brobecker [this message]
2011-11-29 15:27 ` iterate_over_symbols should be a wrapper? Tom Tromey
2011-11-29 3:07 ` partial-symtab symbol sorting (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 8:41 ` Pierre Muller
2011-11-29 14:51 ` partial-symtab symbol sorting Tom Tromey
[not found] ` <47228.5772244961$1322556128@news.gmane.org>
2011-11-29 14:55 ` Tom Tromey
2011-11-29 3:11 ` multiple-location breakpoint output (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 15:06 ` multiple-location breakpoint output Tom Tromey
2011-11-29 3:14 ` decode_digits_line_mode (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 14:56 ` decode_digits_line_mode Tom Tromey
2011-11-29 3:19 ` [RFA/commit/testcase] "info line" should not skip prologues (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 15:03 ` [RFA/commit/testcase] "info line" should not skip prologues Tom Tromey
2011-11-29 17:00 ` Joel Brobecker
2011-11-29 3:22 ` GDB 7.4 branching status? (2011-11-23) Joel Brobecker
2011-11-29 15:38 ` Tom Tromey
2011-11-29 3:29 ` set multiple-symbol ask/cancel not working (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 16:14 ` set multiple-symbol ask/cancel not working Tom Tromey
2011-11-29 16:57 ` Tom Tromey
2011-11-29 17:06 ` Joel Brobecker
2011-11-30 16:41 ` Tom Tromey
2011-11-29 3:33 ` one-too-many location in breakpoint (was: "Re: GDB 7.4 branching status? (2011-11-23)") Joel Brobecker
2011-11-29 16:15 ` one-too-many location in breakpoint Tom Tromey
2011-11-29 16:59 ` Tom Tromey
2011-11-30 5:59 ` Joel Brobecker
2011-11-30 16:41 ` Tom Tromey
2011-12-05 12:04 ` Pedro Alves
2011-12-05 12:17 ` Pedro Alves
2011-12-08 18:56 ` Maciej W. Rozycki
2011-12-09 8:47 ` Joel Brobecker
2011-11-24 0:58 ` GDB 7.4 branching status? (2011-11-23) Yao Qi
2011-11-24 17:17 ` Maciej W. Rozycki
2011-11-24 17:27 ` Joel Brobecker
2011-12-03 1:19 ` Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111129024833.GL24943@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sources.redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox