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: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess


> If this comment is right, why not move these to the hppa-hpux specific
> observer?  If the comment is wrong, just remove it, but it looks right.

ok. like this?

randolph

2004-05-26  Randolph Chung  <tausq@debian.org>

	* Makefile.in (hppa-hpux-tdep.o, hppa-tdep.o): Update dependency.
	* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Use dyncall
	and sr4export addresses from tdep structure.
	(hppa_hpux_skip_trampoline_code): Likewise.
	(hp_cxx_exception_support_initialized): Make static.
	(hppa_hpux_observer_inferior_created): New function; reset hp compiler
	flags and cached symbols when new inferior is created.
	(_initialize_hppa_hpux_tdep): Register for inferior created 
	notification.
	* hppa-linux-tdep.c (hppa_linux_in_dyncall): Use dyncall address from
	tdep structure.
	* hppa-tdep.c: Include observer.h
	(hppa_observer_inferior_created): New function; listen to inferior
	created notification and update addresses in tdep structure.
	(_initialize_hppa_tdep): Register for program change notification.
	* hppa-tdep.h (struct gdbarch_tdep): Add dyncall, dyncall_external
	and sr4export variables.
	* symfile.c: (RESET_HP_UX_GLOBALS) Remove HPUXHPPA-specific code.
	(symbol_file_add_main_1, symbol_file_clear, reread_symbols): Remove 
	HPUXHPPA-specific code.


Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.581
diff -u -p -r1.581 Makefile.in
--- Makefile.in	26 May 2004 05:31:39 -0000	1.581
+++ Makefile.in	26 May 2004 15:24:08 -0000
@@ -1835,12 +1835,12 @@ hppah-nat.o: hppah-nat.c $(defs_h) $(inf
 hppa-hpux-tdep.o: hppa-hpux-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \
 	$(osabi_h) $(gdb_string_h) $(frame_h) $(frame_unwind_h) \
 	$(trad_frame_h) $(symtab_h) $(objfiles_h) $(inferior_h) $(infcall_h) \
-	$(hppa_tdep_h)
+	$(hppa_tdep_h) $(observer_h)
 hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \
 	$(regcache_h) $(completer_h) $(osabi_h) $(gdb_assert_h) \
 	$(arch_utils_h) $(symtab_h) $(dis_asm_h) $(trad_frame_h) \
 	$(frame_unwind_h) $(frame_base_h) $(gdbcore_h) $(gdbcmd_h) \
-	$(symfile_h) $(objfiles_h) $(hppa_tdep_h)
+	$(symfile_h) $(objfiles_h) $(hppa_tdep_h) $(observer_h)
 hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
 	$(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \
 	$(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \
Index: hppa-hpux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v
retrieving revision 1.19
diff -u -p -r1.19 hppa-hpux-tdep.c
--- hppa-hpux-tdep.c	26 May 2004 05:31:39 -0000	1.19
+++ hppa-hpux-tdep.c	26 May 2004 15:24:10 -0000
@@ -61,32 +61,12 @@ hppa32_hpux_in_solib_call_trampoline (CO
 {
   struct minimal_symbol *minsym;
   struct unwind_table_entry *u;
-  static CORE_ADDR dyncall = 0;
-  static CORE_ADDR sr4export = 0;
+  struct gdbarch_tdep *tdep;
 
-  /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
-     new exec file */
+  tdep = gdbarch_tdep (current_gdbarch);
 
   /* First see if PC is in one of the two C-library trampolines.  */
-  if (!dyncall)
-    {
-      minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
-      if (minsym)
-	dyncall = SYMBOL_VALUE_ADDRESS (minsym);
-      else
-	dyncall = -1;
-    }
-
-  if (!sr4export)
-    {
-      minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
-      if (minsym)
-	sr4export = SYMBOL_VALUE_ADDRESS (minsym);
-      else
-	sr4export = -1;
-    }
-
-  if (pc == dyncall || pc == sr4export)
+  if (pc == tdep->dyncall || pc == tdep->sr4export)
     return 1;
 
   minsym = lookup_minimal_symbol_by_pc (pc);
@@ -295,45 +275,15 @@ hppa_hpux_skip_trampoline_code (CORE_ADD
 {
   long orig_pc = pc;
   long prev_inst, curr_inst, loc;
-  static CORE_ADDR dyncall = 0;
-  static CORE_ADDR dyncall_external = 0;
-  static CORE_ADDR sr4export = 0;
   struct minimal_symbol *msym;
   struct unwind_table_entry *u;
+  struct gdbarch_tdep *tdep;
 
-  /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
-     new exec file */
-
-  if (!dyncall)
-    {
-      msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
-      if (msym)
-	dyncall = SYMBOL_VALUE_ADDRESS (msym);
-      else
-	dyncall = -1;
-    }
-
-  if (!dyncall_external)
-    {
-      msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL);
-      if (msym)
-	dyncall_external = SYMBOL_VALUE_ADDRESS (msym);
-      else
-	dyncall_external = -1;
-    }
-
-  if (!sr4export)
-    {
-      msym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
-      if (msym)
-	sr4export = SYMBOL_VALUE_ADDRESS (msym);
-      else
-	sr4export = -1;
-    }
+  tdep = gdbarch_tdep (current_gdbarch);
 
   /* Addresses passed to dyncall may *NOT* be the actual address
      of the function.  So we may have to do something special.  */
-  if (pc == dyncall)
+  if (pc == tdep->dyncall)
     {
       pc = (CORE_ADDR) read_register (22);
 
@@ -343,12 +293,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD
       if (pc & 0x2)
 	pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
     }
-  if (pc == dyncall_external)
+  if (pc == tdep->dyncall_external)
     {
       pc = (CORE_ADDR) read_register (22);
       pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
     }
-  else if (pc == sr4export)
+  else if (pc == tdep->sr4export)
     pc = (CORE_ADDR) (read_register (22));
 
   /* Get the unwind descriptor corresponding to PC, return zero
@@ -1295,6 +1245,35 @@ hppa_hpux_elf_init_abi (struct gdbarch_i
   hppa_hpux_init_abi (info, gdbarch);
 }
 
+static void
+hppa_hpux_observer_inferior_created (struct target_ops *objfile, int from_tty)
+{
+  struct gdbarch_tdep *tdep;
+  struct minimal_symbol *minsym;
+
+  tdep = gdbarch_tdep (current_gdbarch);
+
+  /* Some HP-UX related globals to clear when a new "main"
+     symbol file is loaded. HP-specific.  */
+
+  /* Indicates HP-compiled code.  */
+  deprecated_hp_som_som_object_present = 0;
+  /* Must reinitialize exception stuff.  */
+  hp_cxx_exception_support_initialized = 0;
+
+  minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL);
+  if (minsym)
+    tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym);
+  else
+    tdep->dyncall_external = -1;
+
+  minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
+  if (minsym)
+    tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym);
+  else
+    tdep->sr4export = -1;
+}
+
 void
 _initialize_hppa_hpux_tdep (void)
 {
@@ -1302,4 +1281,5 @@ _initialize_hppa_hpux_tdep (void)
                           hppa_hpux_som_init_abi);
   gdbarch_register_osabi (bfd_arch_hppa, bfd_mach_hppa20w, GDB_OSABI_HPUX_ELF,
                           hppa_hpux_elf_init_abi);
+  observer_attach_inferior_created (hppa_hpux_observer_inferior_created);
 }
Index: hppa-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 hppa-linux-tdep.c
--- hppa-linux-tdep.c	8 May 2004 03:59:34 -0000	1.5
+++ hppa-linux-tdep.c	26 May 2004 15:24:10 -0000
@@ -161,21 +164,10 @@ insns_match_pattern (CORE_ADDR pc,
 static int
 hppa_linux_in_dyncall (CORE_ADDR pc)
 {
-  static CORE_ADDR dyncall = 0;
-
-  /* FIXME: if we switch exec files, dyncall should be reinitialized */
-  if (!dyncall)
-    {
-      struct minimal_symbol *minsym;
+  struct gdbarch_tdep *tdep;
+  tdep = gdbarch_tdep (current_gdbarch);
 
-      minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
-      if (minsym)
-	dyncall = SYMBOL_VALUE_ADDRESS (minsym);
-      else
-	dyncall = -1;
-    }
-
-  return pc == dyncall;
+  return pc == tdep->dyncall;
 }
 
 /* There are several kinds of "trampolines" that we need to deal with:
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.165
diff -u -p -r1.165 hppa-tdep.c
--- hppa-tdep.c	26 May 2004 04:02:24 -0000	1.165
+++ hppa-tdep.c	26 May 2004 15:24:12 -0000
@@ -42,6 +42,7 @@
 #include "gdbcore.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
+#include "observer.h"
 #include "hppa-tdep.h"
 
 static int hppa_debug = 0;
@@ -2331,6 +2371,21 @@ hppa_frame_prev_register_helper (struct 
 		      	    extract_unsigned_integer (valuep, regsize) + 4);
 }
 
+static void
+hppa_observer_inferior_created (struct target_ops *objfile, int from_tty)
+{
+  struct gdbarch_tdep *tdep;
+  struct minimal_symbol *minsym;
+
+  tdep = gdbarch_tdep (current_gdbarch);
+
+  minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
+  if (minsym)
+    tdep->dyncall = SYMBOL_VALUE_ADDRESS (minsym);
+  else
+    tdep->dyncall = -1;
+}
+
 /* Here is a table of C type sizes on hppa with various compiles
    and options.  I measured this on PA 9000/800 with HP-UX 11.11
    and these compilers:
@@ -2520,6 +2579,8 @@ _initialize_hppa_tdep (void)
 
   hppa_objfile_priv_data = register_objfile_data ();
 
+  observer_attach_inferior_created (hppa_observer_inferior_created);
+
   add_cmd ("unwind", class_maintenance, unwind_command,
 	   "Print unwind table entry at given address.",
 	   &maintenanceprintlist);
Index: hppa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.h,v
retrieving revision 1.10
diff -u -p -r1.10 hppa-tdep.h
--- hppa-tdep.h	25 May 2004 03:55:23 -0000	1.10
+++ hppa-tdep.h	26 May 2004 15:24:12 -0000
@@ -77,6 +78,12 @@ struct gdbarch_tdep
   /* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux
      system.  */
   int is_elf;
+
+  /* Internal symbols that are needed for handling this target; the values
+     are reinitialized if the program being debug changes.  */
+  CORE_ADDR dyncall;
+  CORE_ADDR dyncall_external;
+  CORE_ADDR sr4export;
 };
 
 /*
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.130
diff -u -p -r1.130 symfile.c
--- symfile.c	20 May 2004 09:51:33 -0000	1.130
+++ symfile.c	26 May 2004 15:24:13 -0000
@@ -60,18 +60,6 @@
 #define O_BINARY 0
 #endif
 
-#ifdef HPUXHPPA
-
-/* Some HP-UX related globals to clear when a new "main"
-   symbol file is loaded. HP-specific.  */
-
-extern int hp_cxx_exception_support_initialized;
-#define RESET_HP_UX_GLOBALS() do {\
-                                    deprecated_hp_som_som_object_present = 0;             /* indicates HP-compiled code */        \
-                                    hp_cxx_exception_support_initialized = 0;  /* must reinitialize exception stuff */ \
-                              } while (0)
-#endif
-
 int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num);
 void (*deprecated_show_load_progress) (const char *section,
 			    unsigned long section_sent,
@@ -957,10 +945,6 @@ symbol_file_add_main_1 (char *args, int 
 {
   symbol_file_add (args, from_tty, NULL, 1, flags);
 
-#ifdef HPUXHPPA
-  RESET_HP_UX_GLOBALS ();
-#endif
-
   /* Getting new symbols may change our opinion about
      what is frameless.  */
   reinit_frame_cache ();
@@ -989,9 +973,6 @@ symbol_file_clear (int from_tty)
     symfile_objfile = NULL;
     if (from_tty)
       printf_unfiltered ("No symbol file now.\n");
-#ifdef HPUXHPPA
-    RESET_HP_UX_GLOBALS ();
-#endif
 }
 
 static char *
@@ -1944,9 +1925,6 @@ reread_symbols (void)
 	      if (objfile == symfile_objfile)
 		{
 		  (*objfile->sf->sym_new_init) (objfile);
-#ifdef HPUXHPPA
-		  RESET_HP_UX_GLOBALS ();
-#endif
 		}
 
 	      (*objfile->sf->sym_init) (objfile);


-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/


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