[PATCH 08/13] New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind

Yao Qi
2016-08-31T15:06:36Z

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-08-30 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.
---
gdb/arch-utils.h | 50 +++++++++++++++++++++++++++++++++-----------------
gdb/arm-tdep.c | 4 ++++
gdb/bfin-tdep.c | 4 ++++
gdb/breakpoint.c | 16 ++++++++++++++++
gdb/cris-tdep.c | 4 ++++
gdb/gdbarch.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
gdb/gdbarch.h | 14 ++++++++++++++
gdb/gdbarch.sh | 9 +++++++++
gdb/ia64-tdep.c | 15 +++++++++++----
gdb/m32r-tdep.c | 6 +++++-
gdb/mem-break.c | 13 +++++++------
gdb/mips-tdep.c | 4 ++++
gdb/mt-tdep.c | 4 ++++
gdb/nios2-tdep.c | 4 ++++
gdb/record-full.c | 10 ----------
gdb/remote.c | 16 ++--------------
gdb/score-tdep.c | 8 ++++++++
gdb/sh-tdep.c | 4 ++++
gdb/tic6x-tdep.c | 4 ++++
gdb/v850-tdep.c | 4 ++++
gdb/xtensa-tdep.c | 4 ++++
21 files changed, 191 insertions(+), 52 deletions(-)

diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 8efc4a8..0386d3d 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -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
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 2513707..065d177 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7795,6 +7795,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)
{
@@ -7828,6 +7830,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)
{
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index d895997..c75858b 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -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)
{
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 6bb6bbf..f00c6c3 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2602,6 +2602,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.
@@ -2761,6 +2769,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)
@@ -13116,6 +13127,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
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index bee95cf..b202730 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -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)
{
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index af7359e..a1cf602 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -229,6 +229,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;
@@ -401,6 +403,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;
@@ -580,6 +583,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 */
@@ -790,6 +796,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *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));
fprintf_unfiltered (file,
@@ -1393,6 +1402,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *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));
fprintf_unfiltered (file,
@@ -2759,6 +2771,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)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index bc0f692..29abf65 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -542,6 +542,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. */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index d8e0eeb..b73c6fa 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -555,6 +555,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.
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 5a14409..475decd 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -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);

diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 105fb9e..86ba44a 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -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)
{
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index cc8145c..dafe834 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -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. */
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 1a9cfa5..e73b6e1 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -7050,6 +7050,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)
{
@@ -7076,6 +7078,8 @@ mips_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
return MIPS_BP_KIND_32BIT;
}

+/* Implement the sw_breakpoint_from_kind gdbarch method. */
+
static const gdb_byte *
mips_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
{
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index 0adf413..ffc03fb 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -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)
{
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index d48e156..8d879d7 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -1693,6 +1693,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)
{
@@ -1713,6 +1715,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)
{
diff --git a/gdb/record-full.c b/gdb/record-full.c
index e4dd55b..d5e1f8d 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1663,16 +1663,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. */
diff --git a/gdb/remote.c b/gdb/remote.c
index 910ac81..9eb1d4b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9288,8 +9288,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 ();
@@ -9299,7 +9297,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);
@@ -9315,8 +9313,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;
@@ -9593,12 +9589,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;
@@ -9618,7 +9608,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);
@@ -9642,8 +9632,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__,
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index c325d48..715a092 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -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)
{
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 0ea5716..4ab29f0 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -417,12 +417,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)
{
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index cf8a30f..b4ca757 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -317,12 +317,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)
{
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 9cc1b8b..85392a2 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -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)
{
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 213f343..ed0664b 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1958,6 +1958,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)
{
@@ -1976,6 +1978,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)
{
--
1.9.1