From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9137 invoked by alias); 10 Jan 2011 20:13:52 -0000 Received: (qmail 9085 invoked by uid 22791); 10 Jan 2011 20:13:45 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Jan 2011 20:13:39 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0AKDbuM026585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Jan 2011 15:13:37 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0AKDaXr016209; Mon, 10 Jan 2011 15:13:37 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0AKDaC1025499; Mon, 10 Jan 2011 15:13:36 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id A78773784A7; Mon, 10 Jan 2011 13:13:35 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: fix PR mi/10693 Date: Mon, 10 Jan 2011 20:13:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-01/txt/msg00201.txt.bz2 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 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 * 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 . + +# 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 . */ + + +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 . */ + + +int +libfunction (int x) +{ + return x + 1; +} -- 1.7.2.3