* RFC: fix PR mi/10693
@ 2011-01-10 20:13 Tom Tromey
2011-01-10 23:48 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2011-01-10 20:13 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: RFC: fix PR mi/10693
2011-01-10 20:13 RFC: fix PR mi/10693 Tom Tromey
@ 2011-01-10 23:48 ` Pedro Alves
2011-02-04 16:15 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2011-01-10 23:48 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
On Monday 10 January 2011 20:13:35, Tom Tromey wrote:
> I would appreciate comments on this.
- What about info_sharedlibrary_command's update_solib_list call?
- I haven't really checked, but do we now need to care about
exceptions between reading the shared library, and
calling the observer leaving the frontend out of sync?
(e.g., quits, or some other error thrown while reading debug
info or printing something).
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFC: fix PR mi/10693
2011-01-10 23:48 ` Pedro Alves
@ 2011-02-04 16:15 ` Tom Tromey
2011-02-04 17:03 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2011-02-04 16:15 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
Tom> I would appreciate comments on this.
[ symbols-loaded = 0 always ]
Pedro> - What about info_sharedlibrary_command's update_solib_list call?
Pedro> - I haven't really checked, but do we now need to care about
Pedro> exceptions between reading the shared library, and
Pedro> calling the observer leaving the frontend out of sync?
Pedro> (e.g., quits, or some other error thrown while reading debug
Pedro> info or printing something).
I think I am going to drop this. I have been considering changing
symbol-loading for some multi-inferior cases, and it seems to me that if
a front end really needs to know about whether symbols are loaded, then
we should be emitting new notifications for changes in this area.
So I think we should instead just document that symbols-loaded is
emitted for compatibility but is not actually useful.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFC: fix PR mi/10693
2011-02-04 16:15 ` Tom Tromey
@ 2011-02-04 17:03 ` Tom Tromey
2011-02-04 18:19 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2011-02-04 17:03 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Tom> So I think we should instead just document that symbols-loaded is
Tom> emitted for compatibility but is not actually useful.
Like this.
Ok?
Tom
2011-02-04 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (GDB/MI Async Records): Document that symbols-loaded
is not useful.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5dc0af0..5ec7c1a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -24771,11 +24771,12 @@ opaque identifier of the library. For remote debugging case,
@var{target-name} and @var{host-name} fields give the name of the
library file on the target, and on the host respectively. For native
debugging, both those fields have the same value. The
-@var{symbols-loaded} field reports if the debug symbols for this
-library are loaded. The @var{thread-group} field, if present,
-specifies the id of the thread group in whose context the library was loaded.
-If the field is absent, it means the library was loaded in the context
-of all present thread groups.
+@var{symbols-loaded} field is emitted only for backward compatibility
+and should not be relied on to convey any useful information. The
+@var{thread-group} field, if present, specifies the id of the thread
+group in whose context the library was loaded. If the field is
+absent, it means the library was loaded in the context of all present
+thread groups.
@item =library-unloaded,...
Reports that a library was unloaded by the program. This notification
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-04 18:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-10 20:13 RFC: fix PR mi/10693 Tom Tromey
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox