This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Call target_pre_inferior *after* clear_solib


Hello,

run_command_1 and attach_command currently call target_pre_inferior
and then clear_solib.  However, target_pre_inferior may reset
current_gdbarch (due to clearing the target description).

On the other hand, clear_solib will use current_gdbarch to detect
the free_so callback it needs to call to free solib-specific
information.

If the gdbarch installed by target_pre_inferior has a different
set of solib callbacks installed as the one that was running
before, we might call the incorrect free_so handler.

I have a test case where this happens, although only with the
multi-arch Cell debugger patches.  I believe the problem could
in principle occur with vanilla GDB too ...

To fix this, I think we simply need to call clear_solib *before*
target_pre_inferior.  Any comments on that approach?

Tested on powerpc-linux and powerpc64-linux.

Bye,
Ulrich


ChangeLog:

	* infcmd.c (run_command_1): Call target_pre_inferior after
	clear_solib, not before.
	(attach_command): Likewise.

diff -urNp src-orig/gdb/infcmd.c src/gdb/infcmd.c
--- src-orig/gdb/infcmd.c	2008-05-21 19:54:23.000000000 +0200
+++ src/gdb/infcmd.c	2008-05-30 19:24:44.000000000 +0200
@@ -482,15 +482,15 @@ run_command_1 (char *args, int from_tty,
   kill_if_already_running (from_tty);
   clear_breakpoint_hit_counts ();
 
-  /* 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);
+
   /* 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
@@ -1960,10 +1960,6 @@ attach_command (char *args, int from_tty
 	error (_("Not killed."));
     }
 
-  /* 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);
-
   /* 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
@@ -1982,6 +1978,10 @@ attach_command (char *args, int from_tty
   */
   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 (args)
     {
       async_exec = strip_bg_char (&args);
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]