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]

[PATCH 11/13] Add default_breakpoint_from_pc


This patch adds the default implementation of gdbarch breakpoint_from_pc,
which is,

const gdb_byte *
default_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
                           int *lenptr)
{
  int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr);

  return gdbarch_sw_breakpoint_from_kind (gdbarch, kind, lenptr);
}

so gdbarch can only defines sw_breakpoint_from_kind and
breakpoint_kind_from_pc.

gdb:

2016-08-30  Yao Qi  <yao.qi@linaro.org>

	* arch-utils.c (default_breakpoint_from_pc): New function.
	* arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): Remove.
	(GDBARCH_BREAKPOINT_MANIPULATION): Don't use
	GDBARCH_BREAKPOINT_FROM_PC.
	(SET_GDBARCH_BREAKPOINT_MANIPULATION): Don't call
	set_gdbarch_breakpoint_from_pc.
	(default_breakpoint_from_pc): Remove declaration.
	* gdbarch.sh (breakpoint_from_pc): Add its default implementation.
	* gdbarch.c, gdbarch.h: Regenerate.
	* arm-tdep.c: Don't use GDBARCH_BREAKPOINT_FROM_PC.
	* bfin-tdep.c, cris-tdep.c, iq2000-tdep.c: Likewise.
	* m32r-tdep.c, mips-tdep.c, mt-tdep.c: Likewise.
	* nios2-tdep.c, score-tdep.c, sh-tdep.c: Likewise.
	* sh64-tdep.c, tic6x-tdep.c, v850-tdep.c, xtensa-tdep.c: Likewise.
---
 gdb/arch-utils.c  |  9 +++++++++
 gdb/arch-utils.h  | 22 ++++++----------------
 gdb/arm-tdep.c    | 10 ----------
 gdb/bfin-tdep.c   |  8 --------
 gdb/cris-tdep.c   |  8 --------
 gdb/gdbarch.c     |  4 ++--
 gdb/gdbarch.sh    |  2 +-
 gdb/iq2000-tdep.c |  2 --
 gdb/m32r-tdep.c   |  2 --
 gdb/mips-tdep.c   |  9 ---------
 gdb/mt-tdep.c     |  2 --
 gdb/nios2-tdep.c  |  4 ----
 gdb/score-tdep.c  |  4 ----
 gdb/sh-tdep.c     |  2 --
 gdb/sh64-tdep.c   |  2 --
 gdb/tic6x-tdep.c  |  4 ----
 gdb/v850-tdep.c   |  2 --
 gdb/xtensa-tdep.c |  2 --
 18 files changed, 18 insertions(+), 80 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index b562716..e236877 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -812,6 +812,15 @@ default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
   return 1;
 }
 
+const gdb_byte *
+default_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
+			    int *lenptr)
+{
+  int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr);
+
+  return gdbarch_sw_breakpoint_from_kind (gdbarch, kind, lenptr);
+}
+
 void
 default_gen_return_address (struct gdbarch *gdbarch,
 			    struct agent_expr *ax, struct axs_value *value,
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 263f4d5..4af8b9f 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -26,17 +26,6 @@ struct minimal_symbol;
 struct type;
 struct gdbarch_info;
 
-#define GDBARCH_BREAKPOINT_FROM_PC(ARCH)			       \
-  static const gdb_byte *					       \
-  ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch,		       \
-			     CORE_ADDR *pcptr,				\
-			     int *lenptr)				\
-  {									\
-    int kind = ARCH##_breakpoint_kind_from_pc (gdbarch, pcptr);	\
-								     \
-    return ARCH##_sw_breakpoint_from_kind (gdbarch, kind, lenptr);   \
-  }
-
 #define GDBARCH_BREAKPOINT_MANIPULATION(ARCH,BREAK_INSN)	      \
   static int							      \
   ARCH##_breakpoint_kind_from_pc (struct gdbarch *gdbarch,	      \
@@ -50,11 +39,9 @@ struct gdbarch_info;
   {								      \
     *size = kind;						      \
     return BREAK_INSN;						      \
-  }								      \
-  GDBARCH_BREAKPOINT_FROM_PC (ARCH)
+  }
 
 #define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH)			\
-  set_gdbarch_breakpoint_from_pc (gdbarch, ARCH##_breakpoint_from_pc);	\
   set_gdbarch_breakpoint_kind_from_pc (gdbarch,			\
 				       ARCH##_breakpoint_kind_from_pc); \
   set_gdbarch_sw_breakpoint_from_kind (gdbarch,			\
@@ -80,8 +67,7 @@ struct gdbarch_info;
       return BIG_BREAK_INSN;					      \
     else							      \
       return LITTLE_BREAK_INSN;				      \
-  }								      \
-  GDBARCH_BREAKPOINT_FROM_PC (ARCH)
+  }
 
 /* An implementation of gdbarch_displaced_step_copy_insn for
    processors that don't need to modify the instruction before
@@ -223,6 +209,10 @@ extern int default_has_shared_address_space (struct gdbarch *);
 extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
 					     CORE_ADDR addr, char **msg);
 
+extern const gdb_byte *default_breakpoint_from_pc (struct gdbarch *gdbarch,
+						   CORE_ADDR *pcptr,
+						   int *lenptr);
+
 extern void default_gen_return_address (struct gdbarch *gdbarch,
 					struct agent_expr *ax,
 					struct axs_value *value,
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index eba59a5..f03897c 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7853,16 +7853,6 @@ arm_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-/* Determine the type and size of breakpoint to insert at PCPTR.  Uses
-   the program counter value to determine whether a 16-bit or 32-bit
-   breakpoint should be used.  It returns a pointer to a string of
-   bytes that encode a breakpoint instruction, stores the length of
-   the string to *lenptr, and adjusts the program counter (if
-   necessary) to point to the actual memory location where the
-   breakpoint should be inserted.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (arm)
-
 /* Extract from an array REGBUF containing the (raw) register state a
    function return value of type TYPE, and copy that, in virtual
    format, into VALBUF.  */
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index c75858b..989912e 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -601,14 +601,6 @@ bfin_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     return bfin_breakpoint;
 }
 
-/* This function implements the 'breakpoint_from_pc' gdbarch method.
-   It returns a pointer to a string of bytes that encode a breakpoint
-   instruction, stores the length of the string to *lenptr, and
-   adjusts the program counter (if necessary) to point to the actual
-   memory location where the breakpoint should be inserted.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (bfin)
-
 static void
 bfin_extract_return_value (struct type *type,
 			   struct regcache *regs,
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index b202730..3103f1c 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -1416,14 +1416,6 @@ cris_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     return break8_insn;
 }
 
-/* Use the program counter to determine the contents and size of a breakpoint
-   instruction.  It returns a pointer to a string of bytes that encode a
-   breakpoint instruction, stores the length of the string to *lenptr, and
-   adjusts pcptr (if necessary) to point to the actual memory location where
-   the breakpoint should be inserted.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (cris)
-
 /* Returns 1 if spec_reg is applicable to the current gdbarch's CRIS version,
    0 otherwise.  */
 
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index c85dc9a..ca430a9 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -402,6 +402,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->pointer_to_address = unsigned_pointer_to_address;
   gdbarch->address_to_pointer = unsigned_address_to_pointer;
   gdbarch->return_in_first_hidden_param_p = default_return_in_first_hidden_param_p;
+  gdbarch->breakpoint_from_pc = default_breakpoint_from_pc;
   gdbarch->sw_breakpoint_from_kind = NULL;
   gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
   gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
@@ -579,8 +580,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of skip_entrypoint, has predicate.  */
   if (gdbarch->inner_than == 0)
     fprintf_unfiltered (log, "\n\tinner_than");
-  if (gdbarch->breakpoint_from_pc == 0)
-    fprintf_unfiltered (log, "\n\tbreakpoint_from_pc");
+  /* Skip verify of breakpoint_from_pc, invalid_p == 0 */
   if (gdbarch->breakpoint_kind_from_pc == 0)
     fprintf_unfiltered (log, "\n\tbreakpoint_kind_from_pc");
   /* Skip verify of sw_breakpoint_from_kind, invalid_p == 0 */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index d7e4d87..c999f30 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -554,7 +554,7 @@ M:CORE_ADDR:skip_main_prologue:CORE_ADDR ip:ip
 M:CORE_ADDR:skip_entrypoint:CORE_ADDR ip:ip
 
 f:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
-m:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
+m:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr:0:default_breakpoint_from_pc::0
 
 # Return the breakpoint kind for this target based on *PCPTR.
 m:int:breakpoint_kind_from_pc:CORE_ADDR *pcptr:pcptr::0:
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index ecd9074..874fc6a 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -490,8 +490,6 @@ iq2000_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 	  == BFD_ENDIAN_BIG) ? big_breakpoint : little_breakpoint;
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (iq2000)
-
 /* Target function return value methods: */
 
 /* Function: store_return_value
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 86ba44a..00e7767 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -202,8 +202,6 @@ m32r_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (m32r)
-
 char *m32r_register_names[] = {
   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12", "fp", "lr", "sp",
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 10a1b08..8ffa8f6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -7180,15 +7180,6 @@ mips_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     };
 }
 
-/* This function implements gdbarch_breakpoint_from_pc.  It uses the
-   program counter value to determine whether a 16- or 32-bit breakpoint
-   should be used.  It returns a pointer to a string of bytes that encode a
-   breakpoint instruction, stores the length of the string to *lenptr, and
-   adjusts pc (if necessary) to point to the actual memory location where
-   the breakpoint should be inserted.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (mips)
-
 /* Return non-zero if the standard MIPS instruction INST has a branch
    delay slot (i.e. it is a jump or branch instruction).  This function
    is based on mips32_next_pc.  */
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index ffc03fb..a34023f 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -478,8 +478,6 @@ mt_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
   return ms1_breakpoint;
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (mt)
-
 /* Select the correct coprocessor register bank.  Return the pseudo
    regnum we really want to read.  */
 
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index 8d879d7..81b8dad 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -1771,10 +1771,6 @@ nios2_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-/* Implement the breakpoint_from_pc gdbarch hook.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (nios2)
-
 /* Implement the print_insn gdbarch method.  */
 
 static int
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 715a092..1bba20b 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -368,8 +368,6 @@ score7_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (score7)
-
 /* Implement the breakpoint_kind_from_pc gdbarch method.  */
 
 static int
@@ -406,8 +404,6 @@ score3_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
   return score_break_insns[index];
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (score3)
-
 static CORE_ADDR
 score_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
 {
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 4ab29f0..4dac56b 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -453,8 +453,6 @@ sh_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (sh)
-
 /* Prologue looks like
    mov.l	r14,@-r15
    sts.l	pr,@-r15
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 4f97223..b6c2cce 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -305,8 +305,6 @@ sh64_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (sh64)
-
 /* Prologue looks like
    [mov.l       <regs>,@-r15]...
    [sts.l       pr,@-r15]
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index b4ca757..e4d4749 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -345,10 +345,6 @@ tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     return tdep->breakpoint;
 }
 
-/* This is the implementation of gdbarch method breakpiont_from_pc.  */
-
-GDBARCH_BREAKPOINT_FROM_PC (tic6x)
-
 /* This is the implementation of gdbarch method print_insn.  */
 
 static int
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 85392a2..27e67a4 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -1208,8 +1208,6 @@ v850_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (v850)
-
 static struct v850_frame_cache *
 v850_alloc_frame_cache (struct frame_info *this_frame)
 {
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index ed0664b..3652bef 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -2008,8 +2008,6 @@ xtensa_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (xtensa)
-
 /* Call0 ABI support routines.  */
 
 /* Return true, if PC points to "ret" or "ret.n".  */ 
-- 
1.9.1


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