This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: Assume solib.h


   Date: Mon, 15 Nov 2004 14:32:17 -0700
   From: Kevin Buettner <kevinb@redhat.com>

   This is a multi-part message in MIME format.

   --Multipart=_Mon__15_Nov_2004_14_32_17_-0700_xcMRgDYW/T7vXH4.
   Content-Type: text/plain; charset=US-ASCII
   Content-Transfer-Encoding: 7bit

   On Fri, 12 Nov 2004 19:14:30 +0200
   "Eli Zaretskii" <eliz@gnu.org> wrote:

   > I'm with Mark on this one: a patch that potentially breaks a supported
   > platform doesn't get my vote.  If a platform is supported, it deserves
   > that we don't break it, and calling it ``marginal'' doesn't change
   > anything.

   Mark, Eli,

   Would the addition of the attached file (solib-null.c) to Andrew's patch
   address your concerns?  (Makefile.in has to change too; basically
   solib-null.o is unconditionally built and linked into gdb.  I can post
   a patch if desired...)

I think it would, although I've been working on a slightly more
complicated solution that's a bit more multi-arch.  I've attached an
initial patch, but this really needs a bit more work.

   I've not been able to test it as thoroughly as I'd like, but it does
   seem to get me past some solib related problems on remote targets which
   lack shared library support.

It looks good to me.  It can't really hurt things, and it'll serve as
a stopgap while I'm finishing up my multi-arch patch.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* solib.c: Update copyright year.  Include "gdbarch.h".
	(solib_data): New variable.
	(solib_init): New function.
	(solib_open, solib_map_sections, free_so, update_solib_list)
	(solib_add, clear_solib, solib_create_inferior_hook): Get shared
	library architecture operations from architecture; allow them to
	be unimplemented.
	* solist.h (TARGET_SO_RELOCATE_SECTION_ADDRESS)
	(TARGET_SO_FREE_SO, TARGET_SO_CLEAR_SOLIB)
	(TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK)
	(TARGET_SO_SPECIAL_SYMBOL_HANDLING, TARGET_SO_CURRENT_SOS)
	(TARGET_SO_OPEN_SYMBOL_FILE_OBJECT)
	(TARGET_SO_IN_DYNSYM_RESOLVE_CODE)
	(TARGET_SO_FIND_AND_OPEN_SOLIB): Remove.

Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.68
diff -u -p -r1.68 solib.c
--- solib.c 11 Sep 2004 10:24:50 -0000 1.68
+++ solib.c 15 Nov 2004 23:26:54 -0000
@@ -1,7 +1,7 @@
 /* Handle shared libraries for GDB, the GNU Debugger.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,6 +21,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "gdbarch.h"
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -68,6 +69,29 @@ static char *solib_absolute_prefix = NUL
    symbol files.  This takes precedence over the environment variables PATH
    and LD_LIBRARY_PATH.  */
 static char *solib_search_path = NULL;
+
+
+/* Architecture-specific operations.  */
+
+/* Per-architecture data key.  */
+static struct gdbarch_data *solib_data;
+
+/* Return a default for the architecture-specific operations.  */
+
+static void *
+solib_init (struct obstack *obstack)
+{
+  struct target_so_ops *ops;
+
+  ops = OBSTACK_ZALLOC (obstack, struct target_so_ops);
+
+  /* FIXME: kettenis/20041112: This should be removed.  */
+  if (current_target_so_ops)
+    memcpy (ops, current_target_so_ops, sizeof (struct target_so_ops));
+
+  return ops;
+}
+
 
 /*
 
@@ -109,6 +133,7 @@ static char *solib_search_path = NULL;
 int
 solib_open (char *in_pathname, char **found_pathname)
 {
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
   int found_file = -1;
   char *temp_pathname = NULL;
   char *p = in_pathname;
@@ -169,9 +194,9 @@ solib_open (char *in_pathname, char **fo
                         &temp_pathname);
 
   /* If not found, try to use target supplied solib search method */
-  if (found_file < 0 && TARGET_SO_FIND_AND_OPEN_SOLIB != NULL)
-    found_file = TARGET_SO_FIND_AND_OPEN_SOLIB
-                 (in_pathname, O_RDONLY, &temp_pathname);
+  if (found_file < 0 && ops->find_and_open_solib)
+    found_file = ops->find_and_open_solib (in_pathname, O_RDONLY,
+					   &temp_pathname);
 
   /* If not found, next search the inferior's $PATH environment variable. */
   if (found_file < 0 && solib_absolute_prefix == NULL)
@@ -224,6 +249,7 @@ solib_open (char *in_pathname, char **fo
 static int
 solib_map_sections (void *arg)
 {
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
   struct so_list *so = (struct so_list *) arg;	/* catch_errors bogon */
   char *filename;
   char *scratch_pathname;
@@ -274,14 +300,13 @@ solib_map_sections (void *arg)
 
   for (p = so->sections; p < so->sections_end; p++)
     {
-      /* Relocate the section binding addresses as recorded in the shared
-         object's file by the base address to which the object was actually
-         mapped. */
-      TARGET_SO_RELOCATE_SECTION_ADDRESSES (so, p);
+      /* Relocate the section binding addresses as recorded in the
+         shared object's file by the base address to which the object
+         was actually mapped.  */
+      if (ops->relocate_section_addresses)
+	ops->relocate_section_addresses (so, p);
       if (strcmp (p->the_bfd_section->name, ".text") == 0)
-	{
-	  so->textsection = p;
-	}
+	so->textsection = p;
     }
 
   /* Free the file names, close the file now.  */
@@ -314,6 +339,7 @@ solib_map_sections (void *arg)
 void
 free_so (struct so_list *so)
 {
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
   char *bfd_filename = 0;
 
   if (so->sections)
@@ -330,7 +356,8 @@ free_so (struct so_list *so)
   if (bfd_filename)
     xfree (bfd_filename);
 
-  TARGET_SO_FREE_SO (so);
+  if (ops->free_so)
+    ops->free_so (so);
 
   xfree (so);
 }
@@ -402,15 +429,18 @@ symbol_add_stub (void *arg)
 static void
 update_solib_list (int from_tty, struct target_ops *target)
 {
-  struct so_list *inferior = TARGET_SO_CURRENT_SOS ();
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
+  struct so_list *inferior = NULL;
   struct so_list *gdb, **gdb_link;
 
+  if (ops->current_sos)
+    inferior = ops->current_sos ();
+
   /* If we are attaching to a running process for which we 
      have not opened a symbol file, we may be able to get its 
      symbols now!  */
-  if (attach_flag &&
-      symfile_objfile == NULL)
-    catch_errors (TARGET_SO_OPEN_SYMBOL_FILE_OBJECT, &from_tty, 
+  if (attach_flag && symfile_objfile == NULL && ops->open_symbol_file_object)
+    catch_errors (ops->open_symbol_file_object, &from_tty, 
 		  "Error reading attached process's symbol file.\n",
 		  RETURN_MASK_ALL);
 
@@ -561,6 +591,7 @@ update_solib_list (int from_tty, struct 
 void
 solib_add (char *pattern, int from_tty, struct target_ops *target, int readsyms)
 {
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
   struct so_list *gdb;
 
   if (pattern)
@@ -617,7 +648,8 @@ solib_add (char *pattern, int from_tty, 
 	   frameless.  */
 	reinit_frame_cache ();
 
-	TARGET_SO_SPECIAL_SYMBOL_HANDLING ();
+	if (ops->special_symbol_handling)
+	  ops->special_symbol_handling ();
       }
   }
 }
@@ -738,6 +770,8 @@ solib_address (CORE_ADDR address)
 void
 clear_solib (void)
 {
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
+
   /* This function is expected to handle ELF shared libraries.  It is
      also used on Solaris, which can run either ELF or a.out binaries
      (for compatibility with SunOS 4), both of which can use shared
@@ -771,7 +805,8 @@ clear_solib (void)
       free_so (so);
     }
 
-  TARGET_SO_CLEAR_SOLIB ();
+  if (ops->clear_solib)
+    ops->clear_solib ();
 }
 
 static void
@@ -799,7 +834,10 @@ do_clear_solib (void *dummy)
 void
 solib_create_inferior_hook (void)
 {
-  TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK ();
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
+
+  if (ops->solib_create_inferior_hook)
+    ops->solib_create_inferior_hook ();
 }
 
 /* GLOBAL FUNCTION
@@ -821,7 +859,12 @@ solib_create_inferior_hook (void)
 int
 in_solib_dynsym_resolve_code (CORE_ADDR pc)
 {
-  return TARGET_SO_IN_DYNSYM_RESOLVE_CODE (pc);
+  struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data);
+
+  if (ops->in_dynsym_resolve_code)
+    return ops->in_dynsym_resolve_code (pc);
+
+  return 0;
 }
 
 /*
@@ -878,6 +921,8 @@ _initialize_solib (void)
 {
   struct cmd_list_element *c;
 
+  solib_data = gdbarch_data_register_pre_init (solib_init);
+
   add_com ("sharedlibrary", class_files, sharedlibrary_command,
 	   "Load shared object library symbols for files matching REGEXP.");
   add_info ("sharedlibrary", info_sharedlibrary_command,
Index: solist.h
===================================================================
RCS file: /cvs/src/src/gdb/solist.h,v
retrieving revision 1.9
diff -u -p -r1.9 solist.h
--- solist.h 11 Mar 2004 17:04:40 -0000 1.9
+++ solist.h 15 Nov 2004 23:26:54 -0000
@@ -119,20 +119,4 @@ extern int solib_open (char *in_pathname
 /* FIXME: gdbarch needs to control this variable */
 extern struct target_so_ops *current_target_so_ops;
 
-#define TARGET_SO_RELOCATE_SECTION_ADDRESSES \
-  (current_target_so_ops->relocate_section_addresses)
-#define TARGET_SO_FREE_SO (current_target_so_ops->free_so)
-#define TARGET_SO_CLEAR_SOLIB (current_target_so_ops->clear_solib)
-#define TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK \
-  (current_target_so_ops->solib_create_inferior_hook)
-#define TARGET_SO_SPECIAL_SYMBOL_HANDLING \
-  (current_target_so_ops->special_symbol_handling)
-#define TARGET_SO_CURRENT_SOS (current_target_so_ops->current_sos)
-#define TARGET_SO_OPEN_SYMBOL_FILE_OBJECT \
-  (current_target_so_ops->open_symbol_file_object)
-#define TARGET_SO_IN_DYNSYM_RESOLVE_CODE \
-  (current_target_so_ops->in_dynsym_resolve_code)
-#define TARGET_SO_FIND_AND_OPEN_SOLIB \
-  (current_target_so_ops->find_and_open_solib)
-
 #endif


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