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] [1/4] SPU overlay support: New gdbarch_overlay_update routine


Hello,

on spu-elf we have code overlays, but the structure of the overlay
table used by the overlay manager is different from the "simple" 
overlay manager implemented in GDB.

To enable SPU overlay support, this patch adds a new gdbarch function
that allows to install platform-specific "overlay_update" routines
to handle those details.

According to the overlays.exp test case, only the (obsolete) d10v
and m32r targets support overlays.  Thus I've installed the 
existing "simple" overlay manager for the m32r target only.
If this is incorrect, it could be added to other targets as
well.  Or should we have the gdbarch function default always
to simple_overlay_update?

Tested on spu-elf (together with the next patch).

Any comments?  I plan to commit this in a couple of days ...

Bye,
Ulrich


ChangeLog:

	* gdbarch.sh (overlay_update): New gdbarch function.
	(struct obj_section): Add forward declaration.
	* gdbarch.c, gdbarch.h: Regenerate.

	* symfile.c (simple_overlay_update): Make global.
	(target_overlay_update): Remove variable.
	(overlay_is_mapped): Call gdbarch_overlay_update instead of
	target_overlay_update.
	(overlay_load_command): Likewise.
	* symfile.h (struct obj_section): Add forward declaration.
	(simple_overlay_update): Add prototype.

	* m32r-tdep.c (m32r_gdbarch_init): Install simple_overlay_update.


diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c
--- gdb-orig/gdb/gdbarch.c	2007-05-07 22:32:46.148712110 +0200
+++ gdb-head/gdb/gdbarch.c	2007-05-07 22:27:45.389355926 +0200
@@ -238,6 +238,7 @@ struct gdbarch
   int vtable_function_descriptors;
   int vbit_in_delta;
   gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
+  gdbarch_overlay_update_ftype *overlay_update;
 };
 
 
@@ -366,6 +367,7 @@ struct gdbarch startup_gdbarch =
   0,  /* vtable_function_descriptors */
   0,  /* vbit_in_delta */
   0,  /* skip_permanent_breakpoint */
+  0,  /* overlay_update */
   /* startup_gdbarch() */
 };
 
@@ -621,6 +623,7 @@ verify_gdbarch (struct gdbarch *current_
   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
   /* Skip verify of vbit_in_delta, invalid_p == 0 */
   /* Skip verify of skip_permanent_breakpoint, has predicate */
+  /* Skip verify of overlay_update, has predicate */
   buf = ui_file_xstrdup (log, &dummy);
   make_cleanup (xfree, buf);
   if (strlen (buf) > 0)
@@ -1249,6 +1252,12 @@ gdbarch_dump (struct gdbarch *current_gd
   fprintf_unfiltered (file,
                       "gdbarch_dump: osabi = %s\n",
                       paddr_d (current_gdbarch->osabi));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_overlay_update_p() = %d\n",
+                      gdbarch_overlay_update_p (current_gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: overlay_update = <0x%lx>\n",
+                      (long) current_gdbarch->overlay_update);
 #ifdef PC_REGNUM
   fprintf_unfiltered (file,
                       "gdbarch_dump: PC_REGNUM # %s\n",
@@ -3674,6 +3683,30 @@ set_gdbarch_skip_permanent_breakpoint (s
   gdbarch->skip_permanent_breakpoint = skip_permanent_breakpoint;
 }
 
+int
+gdbarch_overlay_update_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->overlay_update != NULL;
+}
+
+void
+gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->overlay_update != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_overlay_update called\n");
+  gdbarch->overlay_update (osect);
+}
+
+void
+set_gdbarch_overlay_update (struct gdbarch *gdbarch,
+                            gdbarch_overlay_update_ftype overlay_update)
+{
+  gdbarch->overlay_update = overlay_update;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h
--- gdb-orig/gdb/gdbarch.h	2007-05-07 22:32:46.158710671 +0200
+++ gdb-head/gdb/gdbarch.h	2007-05-07 22:27:25.633138830 +0200
@@ -42,6 +42,7 @@ struct ui_file;
 struct frame_info;
 struct value;
 struct objfile;
+struct obj_section;
 struct minimal_symbol;
 struct regcache;
 struct reggroup;
@@ -1376,6 +1377,14 @@ typedef void (gdbarch_skip_permanent_bre
 extern void gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache);
 extern void set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint);
 
+/* Refresh overlay mapped state for section OSECT. */
+
+extern int gdbarch_overlay_update_p (struct gdbarch *gdbarch);
+
+typedef void (gdbarch_overlay_update_ftype) (struct obj_section *osect);
+extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect);
+extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update);
+
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh
--- gdb-orig/gdb/gdbarch.sh	2007-05-07 22:32:46.168709233 +0200
+++ gdb-head/gdb/gdbarch.sh	2007-05-07 22:27:15.888077084 +0200
@@ -685,6 +685,9 @@ v::int:vbit_in_delta:::0:0::0
 
 # Advance PC to next instruction in order to skip a permanent breakpoint.
 F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache
+
+# Refresh overlay mapped state for section OSECT.
+F::void:overlay_update:struct obj_section *osect:osect
 EOF
 }
 
@@ -787,6 +790,7 @@ struct ui_file;
 struct frame_info;
 struct value;
 struct objfile;
+struct obj_section;
 struct minimal_symbol;
 struct regcache;
 struct reggroup;
diff -urNp gdb-orig/gdb/m32r-tdep.c gdb-head/gdb/m32r-tdep.c
--- gdb-orig/gdb/m32r-tdep.c	2007-05-07 22:32:46.174708370 +0200
+++ gdb-head/gdb/m32r-tdep.c	2007-05-07 22:26:30.301718277 +0200
@@ -963,6 +963,9 @@ m32r_gdbarch_init (struct gdbarch_info i
   /* Hook in the default unwinders.  */
   frame_unwind_append_sniffer (gdbarch, m32r_frame_sniffer);
 
+  /* Support simple overlay manager.  */
+  set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
+
   return gdbarch;
 }
 
diff -urNp gdb-orig/gdb/symfile.c gdb-head/gdb/symfile.c
--- gdb-orig/gdb/symfile.c	2007-05-07 22:32:46.199704774 +0200
+++ gdb-head/gdb/symfile.c	2007-05-07 22:32:57.284839784 +0200
@@ -3042,10 +3042,6 @@ init_psymbol_list (struct objfile *objfi
 enum overlay_debugging_state overlay_debugging = ovly_off;
 int overlay_cache_invalid = 0;	/* True if need to refresh mapped state */
 
-/* Target vector for refreshing overlay mapped state */
-static void simple_overlay_update (struct obj_section *);
-void (*target_overlay_update) (struct obj_section *) = simple_overlay_update;
-
 /* Function: section_is_overlay (SECTION)
    Returns true if SECTION has VMA not equal to LMA, ie.
    SECTION is loaded at an address different from where it will "run".  */
@@ -3099,9 +3095,9 @@ overlay_is_mapped (struct obj_section *o
     case ovly_off:
       return 0;			/* overlay debugging off */
     case ovly_auto:		/* overlay debugging automatic */
-      /* Unles there is a target_overlay_update function,
+      /* Unles there is a gdbarch_overlay_update function,
          there's really nothing useful to do here (can't really go auto)  */
-      if (target_overlay_update)
+      if (gdbarch_overlay_update_p (current_gdbarch))
 	{
 	  if (overlay_cache_invalid)
 	    {
@@ -3109,7 +3105,7 @@ overlay_is_mapped (struct obj_section *o
 	      overlay_cache_invalid = 0;
 	    }
 	  if (osect->ovly_mapped == -1)
-	    (*target_overlay_update) (osect);
+	    gdbarch_overlay_update (current_gdbarch, osect);
 	}
       /* fall thru to manual case */
     case ovly_on:		/* overlay debugging manual */
@@ -3462,8 +3458,8 @@ overlay_off_command (char *args, int fro
 static void
 overlay_load_command (char *args, int from_tty)
 {
-  if (target_overlay_update)
-    (*target_overlay_update) (NULL);
+  if (gdbarch_overlay_update_p (current_gdbarch))
+    gdbarch_overlay_update (current_gdbarch, NULL);
   else
     error (_("This target does not know how to read its overlay state."));
 }
@@ -3487,7 +3483,7 @@ overlay_command (char *args, int from_tt
 
    This is GDB's default target overlay layer.  It works with the
    minimal overlay manager supplied as an example by Cygnus.  The
-   entry point is via a function pointer "target_overlay_update",
+   entry point is via a function pointer "gdbarch_overlay_update",
    so targets that use a different runtime overlay manager can
    substitute their own overlay_update function and take over the
    function pointer.
@@ -3690,7 +3686,7 @@ simple_overlay_update_1 (struct obj_sect
    If a cached entry can't be found or the cache isn't valid, then
    re-read the entire cache, and go ahead and update all sections.  */
 
-static void
+void
 simple_overlay_update (struct obj_section *osect)
 {
   struct objfile *objfile;
diff -urNp gdb-orig/gdb/symfile.h gdb-head/gdb/symfile.h
--- gdb-orig/gdb/symfile.h	2007-05-07 22:32:46.205703911 +0200
+++ gdb-head/gdb/symfile.h	2007-05-07 22:26:30.342712380 +0200
@@ -29,6 +29,7 @@
 /* Opaque declarations.  */
 struct section_table;
 struct objfile;
+struct obj_section;
 struct obstack;
 struct block;
 
@@ -306,6 +307,9 @@ extern void symbol_file_add_main (char *
 /* Clear GDB symbol tables.  */
 extern void symbol_file_clear (int from_tty);
 
+/* Default overlay update function.  */
+extern void simple_overlay_update (struct obj_section *);
+
 extern bfd_byte *symfile_relocate_debug_section (bfd *abfd, asection *sectp,
 						 bfd_byte * buf);
 
-- 
  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]