Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Randolph Chung <randolph@tausq.org>
To: Andrew Cagney <cagney@gnu.org>, gdb-patches@sources.redhat.com
Subject: Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess
Date: Wed, 26 May 2004 15:35:00 -0000	[thread overview]
Message-ID: <20040526153530.GZ7207@tausq.org> (raw)
In-Reply-To: <20040526132546.GB7594@nevyn.them.org>

> 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/


  reply	other threads:[~2004-05-26 15:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-19 20:40 Randolph Chung
2004-05-19 21:37 ` Joel Brobecker
2004-05-19 21:44   ` Randolph Chung
2004-05-19 22:06     ` Joel Brobecker
2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-21 19:02   ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung
     [not found]     ` <40AE6260.2090205@gnu.org>
2004-05-26  5:27       ` Randolph Chung
2004-05-26 13:25         ` Daniel Jacobowitz
2004-05-26 15:35           ` Randolph Chung [this message]
2004-05-26 16:48             ` Daniel Jacobowitz
2004-05-26 17:54             ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-28 23:43               ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz
2004-05-31 19:43                 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-31 20:43                   ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz
2004-06-01  1:31                     ` Andrew Cagney
2004-06-01  1:40                       ` Daniel Jacobowitz
2004-06-03 17:41                       ` Randolph Chung
2004-06-04 18:26                         ` Andrew Cagney
2004-05-24 15:45   ` Randolph Chung
2004-05-24 18:55     ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040526153530.GZ7207@tausq.org \
    --to=randolph@tausq.org \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox