]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
authorYao Qi <yao.qi@linaro.org>
Thu, 3 Nov 2016 14:35:13 +0000 (14:35 +0000)
committerYao Qi <yao.qi@linaro.org>
Thu, 3 Nov 2016 14:35:13 +0000 (14:35 +0000)
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint.  This patch updates the usages of
target_info.placed_size.

The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint.  In this way, each target doesn't have
to set target_info.placed_size any more.

This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.

Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,

      CORE_ADDR addr = bl->target_info.reqstd_address;

      bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
      bl->target_info.placed_address = addr;

      return target_insert_breakpoint (bl->gdbarch, &bl->target_info);

target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint.  They should be determined by
gdbarch.

gdb:

2016-11-03  Yao Qi  <yao.qi@linaro.org>

* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.  Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc.  Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc.  Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.

22 files changed:
gdb/ChangeLog
gdb/arch-utils.h
gdb/arm-tdep.c
gdb/bfin-tdep.c
gdb/breakpoint.c
gdb/cris-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/ia64-tdep.c
gdb/m32r-tdep.c
gdb/mem-break.c
gdb/mips-tdep.c
gdb/mt-tdep.c
gdb/nios2-tdep.c
gdb/record-full.c
gdb/remote.c
gdb/score-tdep.c
gdb/sh-tdep.c
gdb/tic6x-tdep.c
gdb/v850-tdep.c
gdb/xtensa-tdep.c

index 22cbedbf551bff592a01dbc19c5253b4c50dfc05..a8a176e9523e9bc0d39dceebfb5bad075cae7c62 100644 (file)
@@ -1,3 +1,50 @@
+2016-11-03  Yao Qi  <yao.qi@linaro.org>
+
+       * arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
+       breakpoint_kind_from_pc and sw_breakpoint_from_kind.
+       (GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
+       (SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
+       set_gdbarch_breakpoint_kind_from_pc and
+       set_gdbarch_sw_breakpoint_from_kind.
+       * arm-tdep.c: Add comments.
+       * bfin-tdep.c: Likewise.
+       * breakpoint.c (breakpoint_kind): New function.
+       (insert_bp_location): Set target_info.placed_size and
+       target_info.placed_address.
+       (bkpt_insert_location): Likewise.
+       * cris-tdep.c: Add comments.
+       * gdbarch.sh (breakpoint_kind_from_pc): New.
+       (sw_breakpoint_from_kind): New.
+       * gdbarch.c, gdbarch.h: Regenerated.
+       * ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
+       bp_tgt->placed_size.
+       (ia64_memory_remove_breakpoint): Don't assert
+       bp_tgt->placed_size.
+       (ia64_breakpoint_kind_from_pc): New function.
+       (ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
+       * m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
+       bp_tgt->placed_size.
+       * mem-break.c (default_memory_insert_breakpoint): Don't set
+       bp_tgt->placed_size.  Call gdbarch_sw_breakpoint_from_kind.
+       (default_memory_remove_breakpoint): Call
+       gdbarch_sw_breakpoint_from_kind.
+       (memory_validate_breakpoint): Don't check bp_tgt->placed_size.
+       * mips-tdep.c: Add comments.
+       * mt-tdep.c: Likewise.
+       * nios2-tdep.c: Likewise.
+       * record-full.c (record_full_insert_breakpoint): Don't call
+       gdbarch_breakpoint_from_pc.  Don't set bp_tgt->placed_address
+       and bp_tgt->placed_size.
+       * remote.c (remote_insert_breakpoint): Don't call
+       gdbarch_remote_breakpoint_from_pc.  Use bp_tgt->placed_size.
+       Don't set bp_tgt->placed_address and bp_tgt->placed_size.
+       (remote_insert_hw_breakpoint): Likewise.
+       * score-tdep.c: Likewise.
+       * sh-tdep.c: Likewise.
+       * tic6x-tdep.c: Likewise.
+       * v850-tdep.c: Likewise.
+       * xtensa-tdep.c: Likewise.
+
 2016-11-03  Yao Qi  <yao.qi@linaro.org>
 
        * arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): New macro.
index 2ccf19180855f074809a6e9ad51387e55a3cf818..c9a74a7743758321ae8b35938583a0f017240fb9 100644 (file)
@@ -38,34 +38,50 @@ struct gdbarch_info;
   }
 
 #define GDBARCH_BREAKPOINT_MANIPULATION(ARCH,BREAK_INSN)             \
+  static int                                                         \
+  ARCH##_breakpoint_kind_from_pc (struct gdbarch *gdbarch,           \
+                                 CORE_ADDR *pcptr)                   \
+  {                                                                  \
+    return sizeof (BREAK_INSN);                                      \
+  }                                                                  \
   static const gdb_byte *                                            \
-  ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch,                \
-                            CORE_ADDR *pcptr,                        \
-                            int *lenptr)                             \
+  ARCH##_sw_breakpoint_from_kind (struct gdbarch *gdbarch,           \
+                                 int kind, int *size)                \
   {                                                                  \
-    *lenptr = sizeof (BREAK_INSN);                                   \
+    *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)
+#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,                        \
+                                      ARCH##_sw_breakpoint_from_kind)
 
 #define GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN(ARCH, \
                                               LITTLE_BREAK_INSN,       \
                                               BIG_BREAK_INSN)          \
-  static const gdb_byte *                                              \
-  ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch,                  \
-                            CORE_ADDR *pcptr,                          \
-                            int *lenptr)                               \
+  static int                                                           \
+  ARCH##_breakpoint_kind_from_pc (struct gdbarch *gdbarch,             \
+                                 CORE_ADDR *pcptr)                     \
   {                                                                    \
     gdb_static_assert (ARRAY_SIZE (LITTLE_BREAK_INSN)                  \
                       == ARRAY_SIZE (BIG_BREAK_INSN));         \
-    *lenptr = sizeof (LITTLE_BREAK_INSN);                              \
-    if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)                \
-      return BIG_BREAK_INSN;                                           \
-    else                                                               \
-      return LITTLE_BREAK_INSN;                                        \
-  }
+    return sizeof (BIG_BREAK_INSN);                                    \
+  }                                                                    \
+  static const gdb_byte *                                            \
+  ARCH##_sw_breakpoint_from_kind (struct gdbarch *gdbarch,           \
+                                 int kind, int *size)                \
+  {                                                                  \
+    *size = kind;                                                    \
+    if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)              \
+      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
index 183c36567d854f4829909be8e7cfe79bc90c6a48..05b65f1551d9889e6a2b87c1761b884ae7b947bd 100644 (file)
@@ -7843,6 +7843,8 @@ static const gdb_byte arm_default_arm_be_breakpoint[] = ARM_BE_BREAKPOINT;
 static const gdb_byte arm_default_thumb_le_breakpoint[] = THUMB_LE_BREAKPOINT;
 static const gdb_byte arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT;
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -7876,6 +7878,8 @@ arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 arm_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index d89599738e4ef0bd6114d23bcd85e67905087a51..c75858ba985595d26a02104bb67c7a0ccea9aa4e 100644 (file)
@@ -568,6 +568,8 @@ bfin_reg_to_regnum (struct gdbarch *gdbarch, int reg)
   return map_gcc_gdb[reg];
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 bfin_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -583,6 +585,8 @@ bfin_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
     return 2;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 bfin_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 25849daa2cfee83c786ac4d2ff871b013ddba2ff..fcf73a586622ff3b2b3caf29d25e7a694a017414 100644 (file)
@@ -2603,6 +2603,14 @@ build_target_command_list (struct bp_location *bl)
     bl->target_info.persist = 1;
 }
 
+/* Return the kind of breakpoint on address *ADDR.  */
+
+static int
+breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr)
+{
+  return gdbarch_breakpoint_kind_from_pc (bl->gdbarch, addr);
+}
+
 /* Insert a low-level "breakpoint" of some type.  BL is the breakpoint
    location.  Any error messages are printed to TMP_ERROR_STREAM; and
    DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems.
@@ -2762,6 +2770,9 @@ insert_bp_location (struct bp_location *bl,
                    {
                      int val;
 
+                     bl->overlay_target_info.placed_size
+                       = breakpoint_kind (bl, &addr);
+                     bl->overlay_target_info.placed_address = addr;
                      val = target_insert_breakpoint (bl->gdbarch,
                                                      &bl->overlay_target_info);
                      if (val)
@@ -13113,6 +13124,11 @@ bkpt_re_set (struct breakpoint *b)
 static int
 bkpt_insert_location (struct bp_location *bl)
 {
+  CORE_ADDR addr = bl->target_info.reqstd_address;
+
+  bl->target_info.placed_size = breakpoint_kind (bl, &addr);
+  bl->target_info.placed_address = addr;
+
   if (bl->loc_type == bp_loc_hardware_breakpoint)
     return target_insert_hw_breakpoint (bl->gdbarch, &bl->target_info);
   else
index bee95cfc702b3bff01a14adfb7c13ac9b940fa33..b202730d97493f117e76dde56bd95a224a8e9c0e 100644 (file)
@@ -1391,12 +1391,16 @@ cris_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
   return sp;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 cris_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   return 2;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 cris_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 4d8ef183cde220e51dd896b74c9f63b0c99a73bf..0377b4d906caec8e3cae800ccb09cd5d18e7e60b 100644 (file)
@@ -230,6 +230,8 @@ struct gdbarch
   gdbarch_skip_entrypoint_ftype *skip_entrypoint;
   gdbarch_inner_than_ftype *inner_than;
   gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc;
+  gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc;
+  gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind;
   gdbarch_remote_breakpoint_from_pc_ftype *remote_breakpoint_from_pc;
   gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address;
   gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint;
@@ -403,6 +405,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->sw_breakpoint_from_kind = NULL;
   gdbarch->remote_breakpoint_from_pc = default_remote_breakpoint_from_pc;
   gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
   gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
@@ -583,6 +586,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
     fprintf_unfiltered (log, "\n\tinner_than");
   if (gdbarch->breakpoint_from_pc == 0)
     fprintf_unfiltered (log, "\n\tbreakpoint_from_pc");
+  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 */
   /* Skip verify of remote_breakpoint_from_pc, invalid_p == 0 */
   /* Skip verify of adjust_breakpoint_address, has predicate.  */
   /* Skip verify of memory_insert_breakpoint, invalid_p == 0 */
@@ -792,6 +798,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <%s>\n",
                       host_address_to_string (gdbarch->breakpoint_from_pc));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: breakpoint_kind_from_pc = <%s>\n",
+                      host_address_to_string (gdbarch->breakpoint_kind_from_pc));
   fprintf_unfiltered (file,
                       "gdbarch_dump: byte_order = %s\n",
                       plongest (gdbarch->byte_order));
@@ -1398,6 +1407,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: static_transform_name = <%s>\n",
                       host_address_to_string (gdbarch->static_transform_name));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: sw_breakpoint_from_kind = <%s>\n",
+                      host_address_to_string (gdbarch->sw_breakpoint_from_kind));
   fprintf_unfiltered (file,
                       "gdbarch_dump: syscalls_info = %s\n",
                       host_address_to_string (gdbarch->syscalls_info));
@@ -2782,6 +2794,40 @@ set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch,
   gdbarch->breakpoint_from_pc = breakpoint_from_pc;
 }
 
+int
+gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->breakpoint_kind_from_pc != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_breakpoint_kind_from_pc called\n");
+  return gdbarch->breakpoint_kind_from_pc (gdbarch, pcptr);
+}
+
+void
+set_gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch,
+                                     gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
+{
+  gdbarch->breakpoint_kind_from_pc = breakpoint_kind_from_pc;
+}
+
+const gdb_byte *
+gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->sw_breakpoint_from_kind != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_sw_breakpoint_from_kind called\n");
+  return gdbarch->sw_breakpoint_from_kind (gdbarch, kind, size);
+}
+
+void
+set_gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch,
+                                     gdbarch_sw_breakpoint_from_kind_ftype sw_breakpoint_from_kind)
+{
+  gdbarch->sw_breakpoint_from_kind = sw_breakpoint_from_kind;
+}
+
 void
 gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr)
 {
index cd01718be2f312e855243d72c926736ad137715b..807f7909a86b8259dad02da1d700eea748bfdbf3 100644 (file)
@@ -550,6 +550,20 @@ typedef const gdb_byte * (gdbarch_breakpoint_from_pc_ftype) (struct gdbarch *gdb
 extern const gdb_byte * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
 extern void set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc);
 
+/* Return the breakpoint kind for this target based on *PCPTR. */
+
+typedef int (gdbarch_breakpoint_kind_from_pc_ftype) (struct gdbarch *gdbarch, CORE_ADDR *pcptr);
+extern int gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr);
+extern void set_gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc);
+
+/* Return the software breakpoint from KIND.  KIND can have target
+   specific meaning like the Z0 kind parameter.
+   SIZE is set to the software breakpoint's length in memory. */
+
+typedef const gdb_byte * (gdbarch_sw_breakpoint_from_kind_ftype) (struct gdbarch *gdbarch, int kind, int *size);
+extern const gdb_byte * gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size);
+extern void set_gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind);
+
 /* Return the adjusted address and kind to use for Z0/Z1 packets.
    KIND is usually the memory length of the breakpoint, but may have a
    different target-specific meaning. */
index 1663156057110ddd26c62cec235f61362a865de5..5e2726d08f62345d9713178ce9720cc2b09cc311 100755 (executable)
@@ -560,6 +560,15 @@ 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:
+
+# Return the breakpoint kind for this target based on *PCPTR.
+m:int:breakpoint_kind_from_pc:CORE_ADDR *pcptr:pcptr::0:
+
+# Return the software breakpoint from KIND.  KIND can have target
+# specific meaning like the Z0 kind parameter.
+# SIZE is set to the software breakpoint's length in memory.
+m:const gdb_byte *:sw_breakpoint_from_kind:int kind, int *size:kind, size::NULL::0
+
 # Return the adjusted address and kind to use for Z0/Z1 packets.
 # KIND is usually the memory length of the breakpoint, but may have a
 # different target-specific meaning.
index 5a144090548ecef9fc0a7119872d3373eec6f466..475decd013ce1f1780e655452ce271a78c19c0b4 100644 (file)
@@ -719,8 +719,6 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch,
                    paddress (gdbarch, bp_tgt->placed_address));
   replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
 
-  bp_tgt->placed_size = bp_tgt->shadow_len;
-
   val = target_write_memory (addr + shadow_slotnum, bundle + shadow_slotnum,
                             bp_tgt->shadow_len);
 
@@ -783,8 +781,7 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
       slotnum = 2;
     }
 
-  gdb_assert (bp_tgt->placed_size == BUNDLE_LEN - shadow_slotnum);
-  gdb_assert (bp_tgt->placed_size == bp_tgt->shadow_len);
+  gdb_assert (bp_tgt->shadow_len == BUNDLE_LEN - shadow_slotnum);
 
   instr_breakpoint = slotN_contents (bundle_mem, slotnum);
   if (instr_breakpoint != IA64_BREAKPOINT)
@@ -812,6 +809,15 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
   return val;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
+static int
+ia64_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+{
+  /* A place holder of gdbarch method breakpoint_kind_from_pc.   */
+  return 0;
+}
+
 /* As gdbarch_breakpoint_from_pc ranges have byte granularity and ia64
    instruction slots ranges are bit-granular (41 bits) we have to provide an
    extended range as described for ia64_memory_insert_breakpoint.  We also take
@@ -4009,6 +4015,7 @@ ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_memory_remove_breakpoint (gdbarch,
                                        ia64_memory_remove_breakpoint);
   set_gdbarch_breakpoint_from_pc (gdbarch, ia64_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch, ia64_breakpoint_kind_from_pc);
   set_gdbarch_read_pc (gdbarch, ia64_read_pc);
   set_gdbarch_write_pc (gdbarch, ia64_write_pc);
 
index 2ca89401a76e3e1186ad6fe207247929f3cd63d7..f5aecbd05a57bee3eb38f801b5999c18efa93cfe 100644 (file)
@@ -91,7 +91,7 @@ m32r_memory_insert_breakpoint (struct gdbarch *gdbarch,
     return val;                        /* return error */
 
   memcpy (bp_tgt->shadow_contents, contents_cache, 4);
-  bp_tgt->placed_size = bp_tgt->shadow_len = 4;
+  bp_tgt->shadow_len = 4;
 
   /* Determine appropriate breakpoint contents and size for this address.  */
   if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
@@ -165,6 +165,8 @@ m32r_memory_remove_breakpoint (struct gdbarch *gdbarch,
   return val;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 m32r_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -174,6 +176,8 @@ m32r_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
     return 2;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 m32r_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index cc8145c4c38bcbeabecaf07b0194065a3aff7cb0..dafe834876deb8ecce22f8ac668a9838dbff4996 100644 (file)
@@ -44,10 +44,7 @@ default_memory_insert_breakpoint (struct gdbarch *gdbarch,
   int val;
 
   /* Determine appropriate breakpoint contents and size for this address.  */
-  bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
-
-  bp_tgt->placed_address = addr;
-  bp_tgt->placed_size = bplen;
+  bp = gdbarch_sw_breakpoint_from_kind (gdbarch, bp_tgt->placed_size, &bplen);
 
   /* Save the memory contents in the shadow_contents buffer and then
      write the breakpoint instruction.  */
@@ -77,8 +74,12 @@ int
 default_memory_remove_breakpoint (struct gdbarch *gdbarch,
                                  struct bp_target_info *bp_tgt)
 {
+  int bplen;
+
+  gdbarch_sw_breakpoint_from_kind (gdbarch, bp_tgt->placed_size, &bplen);
+
   return target_write_raw_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
-                                 bp_tgt->placed_size);
+                                 bplen);
 }
 
 
@@ -113,7 +114,7 @@ memory_validate_breakpoint (struct gdbarch *gdbarch,
      address.  */
   bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
 
-  if (bp == NULL || bp_tgt->placed_size != bplen)
+  if (bp == NULL)
     return 0;
 
   /* Make sure we see the memory breakpoints.  */
index aaf7872d43de0724224cbdae176f82fac3a6b33f..424150a031bee31827b3c27213507057c5011f95 100644 (file)
@@ -7035,6 +7035,8 @@ gdb_print_insn_mips_n64 (bfd_vma memaddr, struct disassemble_info *info)
   return gdb_print_insn_mips (memaddr, info);
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 mips_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -7061,6 +7063,8 @@ mips_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
     return MIPS_BP_KIND_MIPS32;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 mips_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 0adf413c74b820a79a16d6979206ec74ce958c91..ffc03fbab812d465782d3e06f87eecfcba90e4fd 100644 (file)
@@ -449,12 +449,16 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   return pc;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 mt_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   return 4;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 mt_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 57fd331fc05a4ac73a8dfc8708b62c0d88c13dc1..2c569c6356419758916f1423064309b595ff71b5 100644 (file)
@@ -1694,6 +1694,8 @@ nios2_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
   return nios2_analyze_prologue (gdbarch, start_pc, start_pc, &cache, NULL);
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 nios2_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -1714,6 +1716,8 @@ nios2_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
     return NIOS2_OPCODE_SIZE;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 nios2_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 50f235d072a5184422f83c12abdf1f602c0dd079..cce922808c26363a1c1c6a62b417f0ba7ca89644 100644 (file)
@@ -1673,16 +1673,6 @@ record_full_insert_breakpoint (struct target_ops *ops,
 
       in_target_beneath = 1;
     }
-  else
-    {
-      CORE_ADDR addr = bp_tgt->reqstd_address;
-      int bplen;
-
-      gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
-
-      bp_tgt->placed_address = addr;
-      bp_tgt->placed_size = bplen;
-    }
 
   /* Use the existing entries if found in order to avoid duplication
      in record_full_breakpoints.  */
index 517e36ddfa8ca351562d90ee44114f68d63d41f1..c4f394722cbdada09629397f88227101f6055b5c 100644 (file)
@@ -9710,8 +9710,6 @@ remote_insert_breakpoint (struct target_ops *ops,
       if (!gdbarch_has_global_breakpoints (target_gdbarch ()))
        set_general_process ();
 
-      gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize);
-
       rs = get_remote_state ();
       p = rs->buf;
       endbuf = rs->buf + get_remote_packet_size ();
@@ -9721,7 +9719,7 @@ remote_insert_breakpoint (struct target_ops *ops,
       *(p++) = ',';
       addr = (ULONGEST) remote_address_masked (addr);
       p += hexnumstr (p, addr);
-      xsnprintf (p, endbuf - p, ",%d", bpsize);
+      xsnprintf (p, endbuf - p, ",%d", bp_tgt->placed_size);
 
       if (remote_supports_cond_breakpoints (ops))
        remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
@@ -9737,8 +9735,6 @@ remote_insert_breakpoint (struct target_ops *ops,
        case PACKET_ERROR:
          return -1;
        case PACKET_OK:
-         bp_tgt->placed_address = addr;
-         bp_tgt->placed_size = bpsize;
          return 0;
        case PACKET_UNKNOWN:
          break;
@@ -10015,12 +10011,6 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
   struct remote_state *rs;
   char *p, *endbuf;
   char *message;
-  int bpsize;
-
-  /* The length field should be set to the size of a breakpoint
-     instruction, even though we aren't inserting one ourselves.  */
-
-  gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize);
 
   if (packet_support (PACKET_Z1) == PACKET_DISABLE)
     return -1;
@@ -10040,7 +10030,7 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
 
   addr = remote_address_masked (addr);
   p += hexnumstr (p, (ULONGEST) addr);
-  xsnprintf (p, endbuf - p, ",%x", bpsize);
+  xsnprintf (p, endbuf - p, ",%x", bp_tgt->placed_size);
 
   if (remote_supports_cond_breakpoints (self))
     remote_add_target_side_condition (gdbarch, bp_tgt, p, endbuf);
@@ -10064,8 +10054,6 @@ remote_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
     case PACKET_UNKNOWN:
       return -1;
     case PACKET_OK:
-      bp_tgt->placed_address = addr;
-      bp_tgt->placed_size = bpsize;
       return 0;
     }
   internal_error (__FILE__, __LINE__,
index c325d48cd8ceb9e7c358e38dc27eb298f21f9ba9..715a092eb4e33eca3d7b6160aa208b5e4a4d6cb7 100644 (file)
@@ -306,6 +306,8 @@ score3_adjust_pc_and_fetch_inst (CORE_ADDR *pcptr, int *lenptr,
   return &inst;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 score7_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -335,6 +337,8 @@ score7_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
     }
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 score7_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
@@ -366,6 +370,8 @@ 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
 score3_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -377,6 +383,8 @@ score3_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
   return len;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 score3_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 6100d922f26a066425e58abbe1e1437b13e64c04..51a846b0d7df5f492df0d22d5841eeaed8c86e5b 100644 (file)
@@ -418,12 +418,16 @@ sh_sh4al_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
   return register_names[reg_nr];
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 sh_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   return 2;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 sh_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 995794730043de28be96d22c89cf30329b9bd144..6b166f13ac3ebd18129745e8fcf80ba5aa5ac96b 100644 (file)
@@ -318,12 +318,16 @@ tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
                                 NULL);
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 tic6x_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   return 4;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 9cc1b8b396a2eea9b43efbd36ef40d176489b46b..85392a24a51b28f9938261e8c02c87f1cf8c4c82 100644 (file)
@@ -1168,12 +1168,16 @@ v850_return_value (struct gdbarch *gdbarch, struct value *function,
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 v850_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   return 2;
 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 v850_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
index 90da611e9d3152c7e218d2f4231dfd0949d1708c..a995946052758e4d7905442aa20bfce4886aa849 100644 (file)
@@ -1959,6 +1959,8 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
   return sp + SP_ALIGNMENT;
 }
 
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
 static int
 xtensa_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
@@ -1977,6 +1979,8 @@ xtensa_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 #define DENSITY_BIG_BREAKPOINT { 0xd2, 0x0f }
 #define DENSITY_LITTLE_BREAKPOINT { 0x2d, 0xf0 }
 
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
 static const gdb_byte *
 xtensa_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {