From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16764 invoked by alias); 8 Aug 2008 18:15:58 -0000 Received: (qmail 16753 invoked by uid 22791); 8 Aug 2008 18:15:56 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.29.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Aug 2008 18:14:46 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.8/8.13.8) with ESMTP id m78IEe3k311242 for ; Fri, 8 Aug 2008 18:14:40 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m78IEek02744486 for ; Fri, 8 Aug 2008 20:14:40 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m78IEdZT025991 for ; Fri, 8 Aug 2008 20:14:40 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id m78IEdm1025988; Fri, 8 Aug 2008 20:14:39 +0200 Message-Id: <200808081814.m78IEdm1025988@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 8 Aug 2008 20:14:39 +0200 Subject: Re: [rfc] Call target_pre_inferior *after* clear_solib To: drow@false.org (Daniel Jacobowitz) Date: Fri, 08 Aug 2008 18:15:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <20080530202239.GA2715@caradoc.them.org> from "Daniel Jacobowitz" at May 30, 2008 04:22:39 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2008-08/txt/msg00215.txt.bz2 Daniel Jacobowitz wrote: > On Fri, May 30, 2008 at 08:17:50PM +0200, Ulrich Weigand wrote: > > - /* Clean up any leftovers from other runs. Some other things from > > - this function should probably be moved into target_pre_inferior. */ > > - target_pre_inferior (from_tty); > > - > > /* Purge old solib objfiles. */ > > objfile_purge_solibs (); > > > > clear_solib (); > > > > + /* Clean up any leftovers from other runs. Some other things from > > + this function should probably be moved into target_pre_inferior. */ > > + target_pre_inferior (from_tty); > > + > > If the order is important, perhaps those two should move into > target_pre_inferior? > > The other option could be to clean up the handling of solibs so that > each solib_ops gets a chance to discard. I've long suspected we > should allow more than a 1:1 relationship. I'm finally getting back to this old patch, sorry for the delay ... For now, I think the best way is to go with your first suggestion. (This makes sense on its own in any case to reduce code duplication, even if at some later point we decide to implement multiple solib_ops as well.) The following patch implements this. Tested on spu-elf, powerpc-linux and powerpc64-linux with no regressions. What do you think? Bye, Ulrich ChangeLog: * target.c: Include "solib.h". (target_pre_inferior): Call no_shared_libraries. * infcmd.c (run_command_1): Do not call objfile_purge_solibs or clear_solib. (attach_command): Do not call clear_solib. Index: gdb/infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.196 diff -c -p -r1.196 infcmd.c *** gdb/infcmd.c 26 Jul 2008 10:23:56 -0000 1.196 --- gdb/infcmd.c 8 Aug 2008 17:19:20 -0000 *************** run_command_1 (char *args, int from_tty, *** 487,497 **** this function should probably be moved into target_pre_inferior. */ target_pre_inferior (from_tty); - /* Purge old solib objfiles. */ - objfile_purge_solibs (); - - clear_solib (); - /* The comment here used to read, "The exec file is re-read every time we do a generic_mourn_inferior, so we just have to worry about the symbol file." The `generic_mourn_inferior' function --- 487,492 ---- *************** attach_command (char *args, int from_tty *** 2023,2046 **** this function should probably be moved into target_pre_inferior. */ target_pre_inferior (from_tty); - /* Clear out solib state. Otherwise the solib state of the previous - inferior might have survived and is entirely wrong for the new - target. This has been observed on GNU/Linux using glibc 2.3. How - to reproduce: - - bash$ ./foo& - [1] 4711 - bash$ ./foo& - [1] 4712 - bash$ gdb ./foo - [...] - (gdb) attach 4711 - (gdb) detach - (gdb) attach 4712 - Cannot access memory at address 0xdeadbeef - */ - clear_solib (); - if (args) { async_exec = strip_bg_char (&args); --- 2018,2023 ---- Index: gdb/target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.169 diff -c -p -r1.169 target.c *** gdb/target.c 9 Jul 2008 22:42:42 -0000 1.169 --- gdb/target.c 8 Aug 2008 17:19:21 -0000 *************** *** 40,45 **** --- 40,46 ---- #include "exceptions.h" #include "target-descriptions.h" #include "gdbthread.h" + #include "solib.h" static void target_info (char *, int); *************** target_info (char *args, int from_tty) *** 1717,1722 **** --- 1718,1741 ---- void target_pre_inferior (int from_tty) { + /* Clear out solib state. Otherwise the solib state of the previous + inferior might have survived and is entirely wrong for the new + target. This has been observed on GNU/Linux using glibc 2.3. How + to reproduce: + + bash$ ./foo& + [1] 4711 + bash$ ./foo& + [1] 4712 + bash$ gdb ./foo + [...] + (gdb) attach 4711 + (gdb) detach + (gdb) attach 4712 + Cannot access memory at address 0xdeadbeef + */ + no_shared_libraries (NULL, from_tty); + invalidate_target_mem_regions (); target_clear_description (); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com