Add default_breakpoint_from_pc
authorYao Qi <yao.qi@linaro.org>
Thu, 3 Nov 2016 14:35:14 +0000 (14:35 +0000)
committerYao Qi <yao.qi@linaro.org>
Thu, 3 Nov 2016 14:35:14 +0000 (14:35 +0000)
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-11-03  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.
* arc-tdep.c, 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.

20 files changed:
gdb/ChangeLog
gdb/arc-tdep.c
gdb/arch-utils.c
gdb/arch-utils.h
gdb/arm-tdep.c
gdb/bfin-tdep.c
gdb/cris-tdep.c
gdb/gdbarch.c
gdb/gdbarch.sh
gdb/iq2000-tdep.c
gdb/m32r-tdep.c
gdb/mips-tdep.c
gdb/mt-tdep.c
gdb/nios2-tdep.c
gdb/score-tdep.c
gdb/sh-tdep.c
gdb/sh64-tdep.c
gdb/tic6x-tdep.c
gdb/v850-tdep.c
gdb/xtensa-tdep.c

index 3e742ac9bceb6ab26ae71c0e3655d641f35c3ce9..313e24c1f2f68796c8f69cd75fc50efac911e4ae 100644 (file)
@@ -1,3 +1,20 @@
+2016-11-03  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.
+       * arc-tdep.c, 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.
+
 2016-11-03  Yao Qi  <yao.qi@linaro.org>
 
        * arch-utils.c (default_remote_breakpoint_from_pc): Remove.
index fe8d38d082fe7a5a600a63b5e57cddc08a397b45..f310da9c866f80a0cab7ba54eef5ade850285dd7 100644 (file)
@@ -772,8 +772,6 @@ arc_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-GDBARCH_BREAKPOINT_FROM_PC (arc)
-
 /* Implement the "unwind_pc" gdbarch method.  */
 
 static CORE_ADDR
index 72156fd5ffe80914ead08c3c0034eff539339ff8..39e8eb53e4d05b5fc6458e5b3fcfd2a6ce3b97eb 100644 (file)
@@ -840,6 +840,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,
index ab558e2c805d009a269325a47c83bf3e7b275bdf..791725db977e1cf538943f0a783ff6c5f43cdd65 100644 (file)
@@ -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
@@ -228,6 +214,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,
index 3f21299bcb357a24cc732a9640ce3ff9fd54a72d..ac989447041734ed8d0072848e4b4d813f7862ed 100644 (file)
@@ -7901,16 +7901,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.  */
index c75858ba985595d26a02104bb67c7a0ccea9aa4e..989912e911c991723fb588b8abf7af9a4a3fc8ce 100644 (file)
@@ -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,
index b202730d97493f117e76dde56bd95a224a8e9c0e..3103f1c7e6a303f0389d148efd90c8af54a124f6 100644 (file)
@@ -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.  */
 
index a1e311ba1885c838061b965bef8114d86ab6fb5a..1a3acabd49a9501a44d4a183de30af1225e27cca 100644 (file)
@@ -404,6 +404,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;
@@ -582,8 +583,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 */
index e410e657bb202350d1f0570a9fe9419e4a573239..e3ead6b440cd12d31d46ad303fc473607b024767 100755 (executable)
@@ -559,7 +559,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:
index ecd90747846aae186ba99b351d2a675f0cf7e65a..874fc6a8bfd69fdd9bd355e82a1a7c695055ed91 100644 (file)
@@ -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
index f5aecbd05a57bee3eb38f801b5999c18efa93cfe..c493e2d53a8d649ae54ad6550608cc06cdd501f6 100644 (file)
@@ -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",
index 6a254f500ddfa43c6495f254d9ac8b32433dbd3c..9eb2de15d4e1d7aee0d1105c9230b7dc2eaff17b 100644 (file)
@@ -7122,15 +7122,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.  */
index ffc03fbab812d465782d3e06f87eecfcba90e4fd..a34023f0f47a22593183eb114fcd4ef1b02aab71 100644 (file)
@@ -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.  */
 
index 2c569c6356419758916f1423064309b595ff71b5..97b422a70550f1224ab9ea6a30b0066aa4946947 100644 (file)
@@ -1772,10 +1772,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
index 715a092eb4e33eca3d7b6160aa208b5e4a4d6cb7..1bba20b87d4e1f741253d4c7c7e47d71b2df22ee 100644 (file)
@@ -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)
 {
index 51a846b0d7df5f492df0d22d5841eeaed8c86e5b..27795ba013486c1c0f6fd62d60edac6f152f0563 100644 (file)
@@ -454,8 +454,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
index 97e5a587f1eadb533a30ffaf5ec124c040461244..80df8b9aafcdf94a5fe1a936e39ccecb278e1bd6 100644 (file)
@@ -306,8 +306,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]
index 6b166f13ac3ebd18129745e8fcf80ba5aa5ac96b..d278e80d806d6d958a103c4557e928570c6a9dc9 100644 (file)
@@ -346,10 +346,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
index 85392a24a51b28f9938261e8c02c87f1cf8c4c82..27e67a49cb1e74e8aeea130fd451c6d8c035934e 100644 (file)
@@ -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)
 {
index a995946052758e4d7905442aa20bfce4886aa849..8eef5cb9c43fc6b14dce587f92a9c6493c539707 100644 (file)
@@ -2009,8 +2009,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".  */