From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFC: fix PR mi/10693
Date: Mon, 10 Jan 2011 20:13:00 -0000 [thread overview]
Message-ID: <m3oc7oldow.fsf@fleche.redhat.com> (raw)
I would appreciate comments on this.
In the absence of comments I will commit this in a few days.
This fixes PR mi/10693. The bug is that the MI =library-loaded
notification always claims that symbols have not been read.
The problem is that update_solib_list invokes the observer, but
debuginfo is not read until later. This patch fixes the problem by
moving the observer notification a bit later.
Built and regtested on x86-64 (compile farm).
New test case included.
Tom
2011-01-10 Tom Tromey <tromey@redhat.com>
PR mi/10693:
* solib.c (update_solib_list): Change return type. Do not call
observer_notify_solib_loaded.
(solib_add): Call observer_notify_solib_loaded.
2011-01-10 Tom Tromey <tromey@redhat.com>
* gdb.mi/miso2.c: New file.
* gdb.mi/miso1.c: New file.
* gdb.mi/mi-solib.exp: New file.
diff --git a/gdb/solib.c b/gdb/solib.c
index 21b554e..8fe35e5 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -694,14 +694,17 @@ solib_read_symbols (struct so_list *so, int flags)
sections for shared objects that have been unloaded, and it
doesn't check to see if the new shared objects are already present in
the section table. But we only use this for core files and
- processes we've just attached to, so that's okay. */
+ processes we've just attached to, so that's okay.
+
+ Returns a list of new solibs that were added. */
-static void
+static struct so_list *
update_solib_list (int from_tty, struct target_ops *target)
{
struct target_so_ops *ops = solib_ops (target_gdbarch);
struct so_list *inferior = ops->current_sos();
struct so_list *gdb, **gdb_link;
+ struct so_list *result_list = NULL;
/* We can reach here due to changing solib-search-path or the
sysroot, before having any inferior. */
@@ -813,6 +816,7 @@ update_solib_list (int from_tty, struct target_ops *target)
/* Add the new shared objects to GDB's list. */
*gdb_link = inferior;
+ result_list = inferior;
/* Fill in the rest of each of the `struct so_list' nodes. */
for (i = inferior; i; i = i->next)
@@ -836,10 +840,6 @@ update_solib_list (int from_tty, struct target_ops *target)
exception_fprintf (gdb_stderr, e,
_("Error while mapping shared "
"library sections:\n"));
-
- /* Notify any observer that the shared object has been
- loaded now that we've added it to GDB's tables. */
- observer_notify_solib_loaded (i);
}
/* If a library was not found, issue an appropriate warning
@@ -861,6 +861,8 @@ Use the \"info sharedlibrary\" command to see the complete listing.\n\
Do you need \"set solib-search-path\" or \"set sysroot\"?"),
not_found, not_found_filename);
}
+
+ return result_list;
}
@@ -908,7 +910,7 @@ void
solib_add (char *pattern, int from_tty,
struct target_ops *target, int readsyms)
{
- struct so_list *gdb;
+ struct so_list *gdb, *new_sos;
if (pattern)
{
@@ -918,7 +920,7 @@ solib_add (char *pattern, int from_tty,
error (_("Invalid regexp: %s"), re_err);
}
- update_solib_list (from_tty, target);
+ new_sos = update_solib_list (from_tty, target);
/* Walk the list of currently loaded shared libraries, and read
symbols for any that match the pattern --- or any whose symbols
@@ -956,6 +958,12 @@ solib_add (char *pattern, int from_tty,
}
}
+ /* Notify any observer that the new shared objects have been
+ loaded now that we've added them to GDB's tables and possibly
+ read their symbols. */
+ for (; new_sos; new_sos = new_sos->next)
+ observer_notify_solib_loaded (new_sos);
+
if (loaded_any_symbols)
breakpoint_re_set ();
diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp
new file mode 100644
index 0000000..ec2623e
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-solib.exp
@@ -0,0 +1,80 @@
+# 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/>.
+
+# Tests for MI and solibs.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi2"
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+# Library file.
+set libname "miso2"
+set srcfile_lib ${srcdir}/${subdir}/${libname}.c
+set binfile_lib ${objdir}/${subdir}/${libname}.so
+set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
+# Binary file.
+set testfile "miso1"
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+set bin_flags [list debug shlib=${binfile_lib}]
+
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
+ || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+ untested "Could not compile $binfile_lib or $binfile."
+ return -1
+}
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+mi_gdb_load ${binfile}
+
+mi_run_cmd
+
+set libtest "*${libname}*"
+set lib_found 0
+global expect_out
+gdb_expect {
+ -re "=library-loaded,id=.(\[^\"\]+).*,symbols-loaded=.(.)\[^\r\n]*\r\n" {
+ set libname $expect_out(1,string)
+ set loaded $expect_out(2,string)
+ verbose "comparing found library $libname"
+ if {[string match $libtest $libname] && $loaded == "1"} {
+ set lib_found 1
+ }
+ exp_continue
+ }
+ -re "(${thread_selected_re})?${mi_gdb_prompt}" {
+ }
+ timeout {
+ perror "Unable to start target"
+ return -1
+ }
+}
+
+if {$lib_found} {
+ pass "checking library load $libname"
+} else {
+ fail "checking library load $libname"
+}
diff --git a/gdb/testsuite/gdb.mi/miso1.c b/gdb/testsuite/gdb.mi/miso1.c
new file mode 100644
index 0000000..c7b8228
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/miso1.c
@@ -0,0 +1,27 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+
+extern int libfunction(int);
+
+int
+main ()
+{
+ int x = libfunction (23);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.mi/miso2.c b/gdb/testsuite/gdb.mi/miso2.c
new file mode 100644
index 0000000..fff3403
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/miso2.c
@@ -0,0 +1,23 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+
+int
+libfunction (int x)
+{
+ return x + 1;
+}
--
1.7.2.3
next reply other threads:[~2011-01-10 20:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-10 20:13 Tom Tromey [this message]
2011-01-10 23:48 ` Pedro Alves
2011-02-04 16:15 ` Tom Tromey
2011-02-04 17:03 ` Tom Tromey
2011-02-04 18:19 ` Eli Zaretskii
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=m3oc7oldow.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/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