[commit/multiarch/hppa] A bit of code shuffling...

Joel Brobecker brobecker@gnat.com
Thu May 22 02:11:00 GMT 2003


I committed the attached patch. It removes some macros that I found to
be unused, and also moved some others from the tm- file into the -tdep
file. It's still all pretty mechanical changes, with the ultimate goal
of slimming these tm- files so much that they are no longer needed.
There are some other macros which I think I could have moved as well,
but it's less mechanical, so I am keeping these kind of changes for
a standalone patch.

Tested on hpux 11.00.

2003-05-21  J. Brobecker  <brobecker@gnat.com>

        * config/pa/tm-hppa.h: Delete some unused macros. Move some
        macro definitions from here...
        * hppa-tdep.c: ...to there.

Eventually, I think I'll have to create a hppa-tdep.h file...

-- 
Joel
-------------- next part --------------
Index: config/pa/tm-hppa.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/tm-hppa.h,v
retrieving revision 1.51
diff -u -3 -p -r1.51 tm-hppa.h
--- config/pa/tm-hppa.h	15 May 2003 22:58:39 -0000	1.51
+++ config/pa/tm-hppa.h	22 May 2003 01:55:28 -0000
@@ -45,19 +45,6 @@ struct value;
 struct type;
 struct inferior_status;
 
-/* Get at various relevent fields of an instruction word. */
-
-#define MASK_5 0x1f
-#define MASK_11 0x7ff
-#define MASK_14 0x3fff
-#define MASK_21 0x1fffff
-
-/* This macro gets bit fields using HP's numbering (MSB = 0) */
-#ifndef GET_FIELD
-#define GET_FIELD(X, FROM, TO) \
-  ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
-#endif
-
 /* Sequence of bytes for breakpoint instruction.  */
 
 const unsigned char *hppa_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr);
@@ -121,27 +108,6 @@ 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. */
 
-/*
- * Processor Status Word Masks
- */
-
-#define PSW_T   0x01000000	/* Taken Branch Trap Enable */
-#define PSW_H   0x00800000	/* Higher-Privilege Transfer Trap Enable */
-#define PSW_L   0x00400000	/* Lower-Privilege Transfer Trap Enable */
-#define PSW_N   0x00200000	/* PC Queue Front Instruction Nullified */
-#define PSW_X   0x00100000	/* Data Memory Break Disable */
-#define PSW_B   0x00080000	/* Taken Branch in Previous Cycle */
-#define PSW_C   0x00040000	/* Code Address Translation Enable */
-#define PSW_V   0x00020000	/* Divide Step Correction */
-#define PSW_M   0x00010000	/* High-Priority Machine Check Disable */
-#define PSW_CB  0x0000ff00	/* Carry/Borrow Bits */
-#define PSW_R   0x00000010	/* Recovery Counter Enable */
-#define PSW_Q   0x00000008	/* Interruption State Collection Enable */
-#define PSW_P   0x00000004	/* Protection ID Validation Enable */
-#define PSW_D   0x00000002	/* Data Address Translation Enable */
-#define PSW_I   0x00000001	/* External, Power Failure, Low-Priority */
-				/* Machine Check Interruption Enable */
-
 /* 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.  */
@@ -185,9 +151,6 @@ extern void hppa_frame_init_saved_regs (
 
 #define INSTRUCTION_SIZE 4
 
-/* Non-level zero PA's have space registers (but they don't always have
-   floating-point, do they????  */
-
 /* This sequence of words is the instructions
 
    ; Call stack frame has already been built by gdb. Since we could be calling 
@@ -250,14 +213,6 @@ extern void hppa_frame_init_saved_regs (
    avoid the kernel bug.  The second NOP is needed to keep the call
    dummy 8 byte aligned.  */
 
-/* Define offsets into the call dummy for the target function address */
-#define FUNC_LDIL_OFFSET (INSTRUCTION_SIZE * 9)
-#define FUNC_LDO_OFFSET (INSTRUCTION_SIZE * 10)
-
-/* Define offsets into the call dummy for the _sr4export address */
-#define SR4EXPORT_LDIL_OFFSET (INSTRUCTION_SIZE * 12)
-#define SR4EXPORT_LDO_OFFSET (INSTRUCTION_SIZE * 13)
-
 #define CALL_DUMMY {0x4BDA3FB9, 0x4BD93FB1, 0x4BD83FA9, 0x4BD73FA1,\
                     0x37C13FB9, 0x24201004, 0x2C391005, 0x24311006,\
                     0x2C291007, 0x22C00000, 0x36D60000, 0x02C010A4,\
@@ -351,25 +306,6 @@ struct unwind_table_entry
    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.  */
-
-struct stub_unwind_entry
-  {
-    /* The offset within the executable for the associated stub.  */
-    unsigned stub_offset;
-
-    /* The type of stub this unwind entry describes.  */
-    char type;
-
-    /* Unknown.  Not needed by GDB at this time.  */
-    char prs_info;
-
-    /* Length (in instructions) of the associated stub.  */
-    short stub_length;
-  };
-
-/* Sizes (in bytes) of the native unwind entries.  */
-#define UNWIND_ENTRY_SIZE 16
-#define STUB_UNWIND_ENTRY_SIZE 8
 
 /* The gaps represent linker stubs used in MPE and space for future
    expansion.  */
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.78
diff -u -3 -p -r1.78 hppa-tdep.c
--- hppa-tdep.c	17 May 2003 05:59:58 -0000	1.78
+++ hppa-tdep.c	22 May 2003 01:55:30 -0000
@@ -68,11 +68,33 @@
 /* Some local constants.  */
 static const int hppa_num_regs = 128;
 
+/* Get at various relevent fields of an instruction word. */
+#define MASK_5 0x1f
+#define MASK_11 0x7ff
+#define MASK_14 0x3fff
+#define MASK_21 0x1fffff
+
+/* Define offsets into the call dummy for the target function address.
+   See comments related to CALL_DUMMY for more info.  */
+#define FUNC_LDIL_OFFSET (INSTRUCTION_SIZE * 9)
+#define FUNC_LDO_OFFSET (INSTRUCTION_SIZE * 10)
+
+/* 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)
+#define SR4EXPORT_LDO_OFFSET (INSTRUCTION_SIZE * 13)
+
 /* To support detection of the pseudo-initial frame
    that threads have. */
 #define THREAD_INITIAL_FRAME_SYMBOL  "__pthread_exit"
 #define THREAD_INITIAL_FRAME_SYM_LEN  sizeof(THREAD_INITIAL_FRAME_SYMBOL)
 
+/* Sizes (in bytes) of the native unwind entries.  */
+#define UNWIND_ENTRY_SIZE 16
+#define STUB_UNWIND_ENTRY_SIZE 8
+
+static int get_field (unsigned word, int from, int to);
+
 static int extract_5_load (unsigned int);
 
 static unsigned extract_5R_store (unsigned int);
@@ -224,6 +246,15 @@ low_sign_extend (unsigned val, unsigned 
   return (int) ((val & 0x1 ? (-1 << (bits - 1)) : 0) | val >> 1);
 }
 
+/* Extract the bits at positions between FROM and TO, using HP's numbering
+   (MSB = 0). */
+
+static int
+get_field (unsigned word, int from, int to)
+{
+  return ((word) >> (31 - (to)) & ((1 << ((to) - (from) + 1)) - 1));
+}
+
 /* extract the immediate field from a ld{bhw}s instruction */
 
 static int
@@ -275,15 +306,15 @@ extract_21 (unsigned word)
 
   word &= MASK_21;
   word <<= 11;
-  val = GET_FIELD (word, 20, 20);
+  val = get_field (word, 20, 20);
   val <<= 11;
-  val |= GET_FIELD (word, 9, 19);
+  val |= get_field (word, 9, 19);
   val <<= 2;
-  val |= GET_FIELD (word, 5, 6);
+  val |= get_field (word, 5, 6);
   val <<= 5;
-  val |= GET_FIELD (word, 0, 4);
+  val |= get_field (word, 0, 4);
   val <<= 2;
-  val |= GET_FIELD (word, 7, 8);
+  val |= get_field (word, 7, 8);
   return sign_extend (val, 21) << 11;
 }
 
@@ -296,15 +327,15 @@ deposit_21 (unsigned opnd, unsigned word
 {
   unsigned val = 0;
 
-  val |= GET_FIELD (opnd, 11 + 14, 11 + 18);
+  val |= get_field (opnd, 11 + 14, 11 + 18);
   val <<= 2;
-  val |= GET_FIELD (opnd, 11 + 12, 11 + 13);
+  val |= get_field (opnd, 11 + 12, 11 + 13);
   val <<= 2;
-  val |= GET_FIELD (opnd, 11 + 19, 11 + 20);
+  val |= get_field (opnd, 11 + 19, 11 + 20);
   val <<= 11;
-  val |= GET_FIELD (opnd, 11 + 1, 11 + 11);
+  val |= get_field (opnd, 11 + 1, 11 + 11);
   val <<= 1;
-  val |= GET_FIELD (opnd, 11 + 0, 11 + 0);
+  val |= get_field (opnd, 11 + 0, 11 + 0);
   return word | val;
 }
 
@@ -314,9 +345,9 @@ deposit_21 (unsigned opnd, unsigned word
 static int
 extract_17 (unsigned word)
 {
-  return sign_extend (GET_FIELD (word, 19, 28) |
-		      GET_FIELD (word, 29, 29) << 10 |
-		      GET_FIELD (word, 11, 15) << 11 |
+  return sign_extend (get_field (word, 19, 28) |
+		      get_field (word, 29, 29) << 10 |
+		      get_field (word, 11, 15) << 11 |
 		      (word & 0x1) << 16, 17) << 2;
 }
 


More information about the Gdb-patches mailing list