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]

[patch] hppa cleanup


Let's try some more cleaning up for hppa....

I realize this is mixing together several changes, but hopefully they 
are all obvious. Most of it is just moving things around. Let me know 
if you want me to break this apart into smaller bits.

Tested on palinux and hpux11.

thanks
randolph

 config/pa/tm-hppa.h |  128 ----------------------------------------------------
 hppa-tdep.c         |   33 +++++--------
 hppa-tdep.h         |  100 ++++++++++++++++++++++++++++++++++++++++
 hpread.c            |   39 ++++++++++-----
 pa64solib.c         |    1
 regcache.c          |   14 -----
 somsolib.c          |    1
 7 files changed, 142 insertions(+), 174 deletions(-)

2004-04-07  Randolph Chung  <tausq@debian.org>

	* tm-hppa.h (frame_info, frame_saved_regs, value, type, 
	inferior_status): Remove unneeded forward declarations.
	(DEPRECATED_CLEAN_UP_REGISTER_VALUE): Remove.
	(INSTRUCTION_SIZE): Move to hppa-tdep.c.
	(unwind_table_entry, unwind_stub_types, obj_unwind_info,
	obj_private_struct): Move to hppa-tdep.h.
	(HPREAD_ADJUST_STACK_ADDRESS): Remove.
	(hpread_adjust_stack_address): Remove.
	* hppa-tdep.c (INSTRUCTION_SIZE): Define.
	(hpread_adjust_stack_address): Move to hpread.c.
	(hppa_pseudo_register_read): Define.
	(hppa_gdbarch_init): Use hppa_pseudo_register_read.
	* hppa-tdep.h (unwind_table_entry, unwind_stub_types, obj_unwind_info,
	obj_private_struct): Moved from tm-hppa.h
	* hpread.c: Include hppa-tdep.h
	(hpread_adjust_stack_address): Define.
	(hpread_read_function_type): Remove HPREAD_ADJUST_STACK_ADDRESS and
	call hpread_adjust_stack_address directly.
	(hpread_read_doc_function_type): Likewise.
	(hpread_process_one_debug_symbol): Likewise.
	* pa64solib.c: Include hppa-tdep.h.
	* somsolib.c: Likewise.
	* regcache.c (supply_register): Remove 
	DEPRECATED_CLEAN_UP_REGISTER_VALUE.

diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/config/pa/tm-hppa.h gdb-work/gdb/config/pa/tm-hppa.h
--- gdb-cvs/gdb/config/pa/tm-hppa.h	2004-04-06 09:11:06.000000000 -0700
+++ gdb-work/gdb/config/pa/tm-hppa.h	2004-04-07 21:50:02.322326288 -0700
@@ -28,17 +28,6 @@
 
 #define GDB_MULTI_ARCH 1
 
-/* Hack, get around problem with including "arch-utils.h".  */
-struct frame_info;
-
-/* Forward declarations of some types we use in prototypes */
-
-struct frame_info;
-struct frame_saved_regs;
-struct value;
-struct type;
-struct inferior_status;
-
 extern int hppa_pc_requires_run_before_use (CORE_ADDR pc);
 #define PC_REQUIRES_RUN_BEFORE_USE(pc) hppa_pc_requires_run_before_use (pc)
 
@@ -77,129 +66,12 @@ extern int hppa_pc_requires_run_before_u
 #define ARG2_REGNUM 24		/* The third argument of a callee. */
 #define ARG3_REGNUM 23		/* The fourth argument of a callee. */
 
-/* When fetching register values from an inferior or a core file,
-   clean them up using this macro.  BUF is a char pointer to
-   the raw value of the register in the registers[] array.  */
-
-#define	DEPRECATED_CLEAN_UP_REGISTER_VALUE(regno, buf) \
-  do {	\
-    if ((regno) == PCOQ_HEAD_REGNUM || (regno) == PCOQ_TAIL_REGNUM) \
-      (buf)[sizeof(CORE_ADDR) -1] &= ~0x3; \
-  } while (0)
-
 /* PA specific macro to see if the current instruction is nullified. */
 #ifndef INSTRUCTION_NULLIFIED
 extern int hppa_instruction_nullified (void);
 #define INSTRUCTION_NULLIFIED hppa_instruction_nullified ()
 #endif
 
-#define INSTRUCTION_SIZE 4
-
-/*
- * Unwind table and descriptor.
- */
-
-struct unwind_table_entry
-  {
-    CORE_ADDR region_start;
-    CORE_ADDR region_end;
-
-    unsigned int Cannot_unwind:1;	/* 0 */
-    unsigned int Millicode:1;	/* 1 */
-    unsigned int Millicode_save_sr0:1;	/* 2 */
-    unsigned int Region_description:2;	/* 3..4 */
-    unsigned int reserved1:1;	/* 5 */
-    unsigned int Entry_SR:1;	/* 6 */
-    unsigned int Entry_FR:4;	/* number saved *//* 7..10 */
-    unsigned int Entry_GR:5;	/* number saved *//* 11..15 */
-    unsigned int Args_stored:1;	/* 16 */
-    unsigned int Variable_Frame:1;	/* 17 */
-    unsigned int Separate_Package_Body:1;	/* 18 */
-    unsigned int Frame_Extension_Millicode:1;	/* 19 */
-    unsigned int Stack_Overflow_Check:1;	/* 20 */
-    unsigned int Two_Instruction_SP_Increment:1;	/* 21 */
-    unsigned int Ada_Region:1;	/* 22 */
-    unsigned int cxx_info:1;	/* 23 */
-    unsigned int cxx_try_catch:1;	/* 24 */
-    unsigned int sched_entry_seq:1;	/* 25 */
-    unsigned int reserved2:1;	/* 26 */
-    unsigned int Save_SP:1;	/* 27 */
-    unsigned int Save_RP:1;	/* 28 */
-    unsigned int Save_MRP_in_frame:1;	/* 29 */
-    unsigned int extn_ptr_defined:1;	/* 30 */
-    unsigned int Cleanup_defined:1;	/* 31 */
-
-    unsigned int MPE_XL_interrupt_marker:1;	/* 0 */
-    unsigned int HP_UX_interrupt_marker:1;	/* 1 */
-    unsigned int Large_frame:1;	/* 2 */
-    unsigned int Pseudo_SP_Set:1;	/* 3 */
-    unsigned int reserved4:1;	/* 4 */
-    unsigned int Total_frame_size:27;	/* 5..31 */
-
-    /* This is *NOT* part of an actual unwind_descriptor in an object
-       file.  It is *ONLY* part of the "internalized" descriptors that
-       we create from those in a file.
-     */
-    struct
-      {
-	unsigned int stub_type:4;	/* 0..3 */
-	unsigned int padding:28;	/* 4..31 */
-      }
-    stub_unwind;
-  };
-
-/* HP linkers also generate unwinds for various linker-generated stubs.
-   GDB reads in the stubs from the $UNWIND_END$ subspace, then 
-   "converts" them into normal unwind entries using some of the reserved
-   fields to store the stub type.  */
-
-/* The gaps represent linker stubs used in MPE and space for future
-   expansion.  */
-enum unwind_stub_types
-  {
-    LONG_BRANCH = 1,
-    PARAMETER_RELOCATION = 2,
-    EXPORT = 10,
-    IMPORT = 11,
-    IMPORT_SHLIB = 12,
-  };
-
-/* We use the objfile->obj_private pointer for two things:
-
- * 1.  An unwind table;
- *
- * 2.  A pointer to any associated shared library object.
- *
- * #defines are used to help refer to these objects.
- */
-
-/* Info about the unwind table associated with an object file.
-
- * This is hung off of the "objfile->obj_private" pointer, and
- * is allocated in the objfile's psymbol obstack.  This allows
- * us to have unique unwind info for each executable and shared
- * library that we are debugging.
- */
-struct obj_unwind_info
-  {
-    struct unwind_table_entry *table;	/* Pointer to unwind info */
-    struct unwind_table_entry *cache;	/* Pointer to last entry we found */
-    int last;			/* Index of last entry */
-  };
-
-typedef struct obj_private_struct
-  {
-    struct obj_unwind_info *unwind_info;	/* a pointer */
-    struct so_list *so_info;	/* a pointer  */
-    CORE_ADDR dp;
-  }
-obj_private_data_t;
-
-/* For a number of horrible reasons we may have to adjust the location
-   of variables on the stack.  Ugh.  */
-#define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR)
-extern int hpread_adjust_stack_address (CORE_ADDR);
-
 /* Here's how to step off a permanent breakpoint.  */
 #define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint)
 extern void hppa_skip_permanent_breakpoint (void);
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/hppa-tdep.c gdb-work/gdb/hppa-tdep.c
--- gdb-cvs/gdb/hppa-tdep.c	2004-04-06 09:11:02.000000000 -0700
+++ gdb-work/gdb/hppa-tdep.c	2004-04-07 21:59:59.848488504 -0700
@@ -64,6 +74,8 @@ static const int hppa64_num_regs = 96;
 #define MASK_14 0x3fff
 #define MASK_21 0x1fffff
 
+#define INSTRUCTION_SIZE 4
+
 /* Define offsets into the call dummy for the _sr4export address.
    See comments related to CALL_DUMMY for more info.  */
 #define SR4EXPORT_LDIL_OFFSET (INSTRUCTION_SIZE * 12)
@@ -746,26 +758,6 @@ hppa64_register_name (int i)
     return names[i];
 }
 
-
-
-/* Return the adjustment necessary to make for addresses on the stack
-   as presented by hpread.c.
-
-   This is necessary because of the stack direction on the PA and the
-   bizarre way in which someone (?) decided they wanted to handle
-   frame pointerless code in GDB.  */
-int
-hpread_adjust_stack_address (CORE_ADDR func_addr)
-{
-  struct unwind_table_entry *u;
-
-  u = find_unwind_entry (func_addr);
-  if (!u)
-    return 0;
-  else
-    return u->Total_frame_size << 3;
-}
-
 /* This function pushes a stack frame with arguments as part of the
    inferior function calling mechanism.
 
@@ -2576,6 +2568,15 @@ hppa_fetch_pointer_argument (struct fram
   return addr;
 }
 
+static void
+hppa_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+			   int regnum, void *buf)
+{
+    regcache_raw_read (regcache, regnum, buf);
+    if (regnum == PCOQ_HEAD_REGNUM || regnum == PCOQ_TAIL_REGNUM)
+      ((char *)buf)[sizeof(CORE_ADDR) -1 ] &= ~0x3;
+}
+
 /* 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:
@@ -2735,6 +2736,8 @@ hppa_gdbarch_init (struct gdbarch_info i
   frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
   frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
 
+  set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
+
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/hppa-tdep.h gdb-work/gdb/hppa-tdep.h
--- gdb-cvs/gdb/hppa-tdep.h	2003-08-15 16:02:03.000000000 -0700
+++ gdb-work/gdb/hppa-tdep.h	2004-04-07 21:16:54.467526152 -0700
@@ -29,4 +29,104 @@ struct gdbarch_tdep
   int bytes_per_address;
 };
 
+/*
+ * Unwind table and descriptor.
+ */
+
+struct unwind_table_entry
+  {
+    CORE_ADDR region_start;
+    CORE_ADDR region_end;
+
+    unsigned int Cannot_unwind:1;	/* 0 */
+    unsigned int Millicode:1;	/* 1 */
+    unsigned int Millicode_save_sr0:1;	/* 2 */
+    unsigned int Region_description:2;	/* 3..4 */
+    unsigned int reserved1:1;	/* 5 */
+    unsigned int Entry_SR:1;	/* 6 */
+    unsigned int Entry_FR:4;	/* number saved *//* 7..10 */
+    unsigned int Entry_GR:5;	/* number saved *//* 11..15 */
+    unsigned int Args_stored:1;	/* 16 */
+    unsigned int Variable_Frame:1;	/* 17 */
+    unsigned int Separate_Package_Body:1;	/* 18 */
+    unsigned int Frame_Extension_Millicode:1;	/* 19 */
+    unsigned int Stack_Overflow_Check:1;	/* 20 */
+    unsigned int Two_Instruction_SP_Increment:1;	/* 21 */
+    unsigned int Ada_Region:1;	/* 22 */
+    unsigned int cxx_info:1;	/* 23 */
+    unsigned int cxx_try_catch:1;	/* 24 */
+    unsigned int sched_entry_seq:1;	/* 25 */
+    unsigned int reserved2:1;	/* 26 */
+    unsigned int Save_SP:1;	/* 27 */
+    unsigned int Save_RP:1;	/* 28 */
+    unsigned int Save_MRP_in_frame:1;	/* 29 */
+    unsigned int extn_ptr_defined:1;	/* 30 */
+    unsigned int Cleanup_defined:1;	/* 31 */
+
+    unsigned int MPE_XL_interrupt_marker:1;	/* 0 */
+    unsigned int HP_UX_interrupt_marker:1;	/* 1 */
+    unsigned int Large_frame:1;	/* 2 */
+    unsigned int Pseudo_SP_Set:1;	/* 3 */
+    unsigned int reserved4:1;	/* 4 */
+    unsigned int Total_frame_size:27;	/* 5..31 */
+
+    /* This is *NOT* part of an actual unwind_descriptor in an object
+       file.  It is *ONLY* part of the "internalized" descriptors that
+       we create from those in a file.
+     */
+    struct
+      {
+	unsigned int stub_type:4;	/* 0..3 */
+	unsigned int padding:28;	/* 4..31 */
+      }
+    stub_unwind;
+  };
+
+/* HP linkers also generate unwinds for various linker-generated stubs.
+   GDB reads in the stubs from the $UNWIND_END$ subspace, then 
+   "converts" them into normal unwind entries using some of the reserved
+   fields to store the stub type.  */
+
+/* The gaps represent linker stubs used in MPE and space for future
+   expansion.  */
+enum unwind_stub_types
+  {
+    LONG_BRANCH = 1,
+    PARAMETER_RELOCATION = 2,
+    EXPORT = 10,
+    IMPORT = 11,
+    IMPORT_SHLIB = 12,
+  };
+
+/* We use the objfile->obj_private pointer for two things:
+
+ * 1.  An unwind table;
+ *
+ * 2.  A pointer to any associated shared library object.
+ *
+ * #defines are used to help refer to these objects.
+ */
+
+/* Info about the unwind table associated with an object file.
+
+ * This is hung off of the "objfile->obj_private" pointer, and
+ * is allocated in the objfile's psymbol obstack.  This allows
+ * us to have unique unwind info for each executable and shared
+ * library that we are debugging.
+ */
+struct obj_unwind_info
+  {
+    struct unwind_table_entry *table;	/* Pointer to unwind info */
+    struct unwind_table_entry *cache;	/* Pointer to last entry we found */
+    int last;			/* Index of last entry */
+  };
+
+typedef struct obj_private_struct
+  {
+    struct obj_unwind_info *unwind_info;	/* a pointer */
+    struct so_list *so_info;	/* a pointer  */
+    CORE_ADDR dp;
+  }
+obj_private_data_t;
+
 #endif  /* HPPA_TDEP_H */
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/hpread.c gdb-work/gdb/hpread.c
--- gdb-cvs/gdb/hpread.c	2004-02-07 15:13:47.000000000 -0800
+++ gdb-work/gdb/hpread.c	2004-04-07 21:49:57.448067288 -0700
@@ -37,6 +37,7 @@
 #include "demangle.h"
 #include "somsolib.h"
 #include "gdb_assert.h"
+#include "hppa-tdep.h"
 
 /* Private information attached to an objfile which we use to find
    and internalize the HP C debug symbols within that objfile.  */
@@ -234,6 +235,8 @@ static void fixup_class_method_type
 
 static void hpread_adjust_bitoffsets (struct type *, int);
 
+static int hpread_adjust_stack_address (CORE_ADDR func_addr);
+
 static dnttpointer hpread_get_next_skip_over_anon_unions
   (int, dnttpointer, union dnttentry **, struct objfile *);
 
@@ -3252,10 +3255,9 @@ hpread_read_function_type (dnttpointer h
       if (paramp->dfparam.copyparam)
 	{
 	  SYMBOL_VALUE (sym) = paramp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
 	  SYMBOL_VALUE (sym)
-	    += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+	    += hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
+
 	  /* This is likely a pass-by-invisible reference parameter,
 	     Hack on the symbol class to make GDB happy.  */
 	  /* ??rehrauer: This appears to be broken w/r/t to passing
@@ -3431,10 +3433,9 @@ hpread_read_doc_function_type (dnttpoint
       if (paramp->dfparam.copyparam)
 	{
 	  SYMBOL_VALUE (sym) = paramp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
 	  SYMBOL_VALUE (sym)
-	    += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+	    += hpread_adjust_stack_address(CURRENT_FUNCTION_VALUE (objfile));
+
 	  /* This is likely a pass-by-invisible reference parameter,
 	     Hack on the symbol class to make GDB happy.  */
 	  /* ??rehrauer: This appears to be broken w/r/t to passing
@@ -5702,10 +5703,8 @@ hpread_process_one_debug_symbol (union d
       if (dn_bufp->dfparam.copyparam)
 	{
 	  SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
 	  SYMBOL_VALUE (sym)
-	    += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+	    += hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
 	}
       else
 	SYMBOL_VALUE (sym) = dn_bufp->dfparam.location;
@@ -5786,10 +5785,8 @@ hpread_process_one_debug_symbol (union d
 	SYMBOL_CLASS (sym) = LOC_LOCAL;
 
       SYMBOL_VALUE (sym) = dn_bufp->ddvar.location;
-#ifdef HPREAD_ADJUST_STACK_ADDRESS
       SYMBOL_VALUE (sym)
-	+= HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile));
-#endif
+	+= hpread_adjust_stack_address (CURRENT_FUNCTION_VALUE (objfile));
       SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->ddvar.type, objfile);
       if (dn_bufp->ddvar.global)
 	add_symbol_to_list (sym, &global_symbols);
@@ -6269,6 +6266,24 @@ hpread_adjust_bitoffsets (struct type *t
     TYPE_FIELD_BITPOS (type, i) -= bits;
 }
 
+/* Return the adjustment necessary to make for addresses on the stack
+   as presented by hpread.c.
+
+   This is necessary because of the stack direction on the PA and the
+   bizarre way in which someone (?) decided they wanted to handle
+   frame pointerless code in GDB.  */
+int
+hpread_adjust_stack_address (CORE_ADDR func_addr)
+{
+  struct unwind_table_entry *u;
+
+  u = find_unwind_entry (func_addr);
+  if (!u)
+    return 0;
+  else
+    return u->Total_frame_size << 3;
+}
+
 /* Because of quirks in HP compilers' treatment of anonymous unions inside
    classes, we have to chase through a chain of threaded FIELD entries.
    If we encounter an anonymous union in the chain, we must recursively skip over
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/pa64solib.c gdb-work/gdb/pa64solib.c
--- gdb-cvs/gdb/pa64solib.c	2004-02-07 15:13:47.000000000 -0800
+++ gdb-work/gdb/pa64solib.c	2004-04-07 21:19:03.143964360 -0700
@@ -52,6 +52,7 @@
 #include "language.h"
 #include "regcache.h"
 #include "exec.h"
+#include "hppa-tdep.h"
 
 #include <fcntl.h>
 
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/regcache.c gdb-work/gdb/regcache.c
--- gdb-cvs/gdb/regcache.c	2004-03-15 12:38:08.000000000 -0800
+++ gdb-work/gdb/regcache.c	2004-04-07 21:39:51.802139464 -0700
@@ -1230,20 +1230,6 @@ void
 supply_register (int regnum, const void *val)
 {
   regcache_raw_supply (current_regcache, regnum, val);
-
-  /* On some architectures, e.g. HPPA, there are a few stray bits in
-     some registers, that the rest of the code would like to ignore.  */
-
-  /* NOTE: cagney/2001-03-16: The macro CLEAN_UP_REGISTER_VALUE is
-     going to be deprecated.  Instead architectures will leave the raw
-     register value as is and instead clean things up as they pass
-     through the method gdbarch_pseudo_register_read() clean up the
-     values. */
-
-#ifdef DEPRECATED_CLEAN_UP_REGISTER_VALUE
-  DEPRECATED_CLEAN_UP_REGISTER_VALUE \
-    (regnum, register_buffer (current_regcache, regnum));
-#endif
 }
 
 void
diff -uNrp -x CVS -x gdbtk -x testsuite gdb-cvs/gdb/somsolib.c gdb-work/gdb/somsolib.c
--- gdb-cvs/gdb/somsolib.c	2004-02-07 15:13:47.000000000 -0800
+++ gdb-work/gdb/somsolib.c	2004-04-07 21:19:09.025070296 -0700
@@ -43,6 +43,7 @@
 #include "regcache.h"
 #include "gdb_assert.h"
 #include "exec.h"
+#include "hppa-tdep.h"
 
 #include <fcntl.h>
 
-- 
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]