[PATCH 04/13] GDBARCH_BREAKPOINT_MANIPULATION and SET_GDBARCH_BREAKPOINT_MANIPULATION

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

Many archs have only one kind of breakpoint, so their breakpoint_from_pc
implementations are quite similar. This patch uses macro
GDBARCH_BREAKPOINT_MANIPULATION and SET_GDBARCH_BREAKPOINT_MANIPULATION
for breakpoint_from_pc, so that we can easily switch from
breakpoint_from_pc to breakpoint_kind_from_pc and sw_breakpoint_from_kind
later.

gdb:

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

* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): New macro.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): New macro.
aarch64-tdep.c (aarch64_breakpoint_from_pc): Remove. Use
GDBARCH_BREAKPOINT_MANIPULATION.
(aarch64_gdbarch_init): Replace set_gdbarch_breakpoint_from_pc
with SET_GDBARCH_BREAKPOINT_MANIPULATION.
* alpha-tdep.c: Likewise.
* avr-tdep.c: Likewise.
* frv-tdep.c: Likewise.
* ft32-tdep.c: Likewise.
* h8300-tdep.c: Likewise.
* hppa-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* lm32-tdep.c: Likewise.
* m32c-tdep.c: Likewise.
* m68hc11-tdep.c: Likewise.
* m68k-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* mep-tdep.c: Likewise.
* microblaze-tdep.c: Likewise.
* mn10300-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* msp430-tdep.c: Likewise.
* rl78-tdep.c: Likewise.
* rx-tdep.c: Likewise.
* s390-linux-tdep.c: Likewise.
* sparc-tdep.c: Likewise.
* spu-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* vax-tdep.c: Likewise.
* xstormy16-tdep.c: Likewise.
---
gdb/aarch64-tdep.c | 12 ++----------
gdb/alpha-tdep.c | 12 ++++--------
gdb/arch-utils.h | 13 +++++++++++++
gdb/avr-tdep.c | 13 ++++---------
gdb/frv-tdep.c | 12 ++++--------
gdb/ft32-tdep.c | 13 +++----------
gdb/h8300-tdep.c | 14 ++++----------
gdb/hppa-tdep.c | 12 ++++--------
gdb/i386-tdep.c | 11 +++--------
gdb/lm32-tdep.c | 12 +++---------
gdb/m32c-tdep.c | 13 +++----------
gdb/m68hc11-tdep.c | 13 +++----------
gdb/m68k-tdep.c | 13 ++++---------
gdb/m88k-tdep.c | 15 +++++----------
gdb/mep-tdep.c | 12 +++---------
gdb/microblaze-tdep.c | 13 ++++---------
gdb/mn10300-tdep.c | 12 +++---------
gdb/moxie-tdep.c | 14 +++-----------
gdb/msp430-tdep.c | 14 +++-----------
gdb/rl78-tdep.c | 22 +++++++---------------
gdb/rx-tdep.c | 13 ++++---------
gdb/s390-linux-tdep.c | 14 +++-----------
gdb/sparc-tdep.c | 12 +++---------
gdb/spu-tdep.c | 13 +++----------
gdb/tilegx-tdep.c | 18 +++++-------------
gdb/vax-tdep.c | 13 ++++---------
gdb/xstormy16-tdep.c | 13 ++++---------
27 files changed, 108 insertions(+), 253 deletions(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 3b7e954..b998867 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1567,15 +1567,7 @@ aarch64_gdb_print_insn (bfd_vma memaddr, disassemble_info *info)
1101.0100.0010.0000.0000.0000.0000.0000 = 0xd4200000. */
static const gdb_byte aarch64_default_breakpoint[] = {0x00, 0x00, 0x20, 0xd4};

-/* Implement the "breakpoint_from_pc" gdbarch method. */
-
-static const gdb_byte *
-aarch64_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- *lenptr = sizeof (aarch64_default_breakpoint);
- return aarch64_default_breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (aarch64, aarch64_default_breakpoint)

/* Extract from an array REGS containing the (raw) register state a
function return value of type TYPE, and copy that, in virtual
@@ -2737,7 +2729,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

/* Breakpoint manipulation. */
- set_gdbarch_breakpoint_from_pc (gdbarch, aarch64_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (aarch64);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
set_gdbarch_software_single_step (gdbarch, aarch64_software_single_step);

diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index b89ea13..c6378c2 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -644,14 +644,10 @@ alpha_return_in_memory_always (struct type *type)
return 1;
}
\f
-static const gdb_byte *
-alpha_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static const gdb_byte break_insn[] = { 0x80, 0, 0, 0 }; /* call_pal bpt */

- *len = sizeof(break_insn);
- return break_insn;
-}
+static const gdb_byte break_insn[] = { 0x80, 0, 0, 0 }; /* call_pal bpt */
+
+GDBARCH_BREAKPOINT_MANIPULATION (alpha, break_insn)

\f
/* This returns the PC of the first insn after the prologue.
@@ -1821,7 +1817,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);

- set_gdbarch_breakpoint_from_pc (gdbarch, alpha_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (alpha);
set_gdbarch_decr_pc_after_break (gdbarch, ALPHA_INSN_SIZE);
set_gdbarch_cannot_step_breakpoint (gdbarch, 1);

diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index ad3f126..77d4fb5 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -26,6 +26,19 @@ struct minimal_symbol;
struct type;
struct gdbarch_info;

+#define GDBARCH_BREAKPOINT_MANIPULATION(ARCH,BREAK_INSN) \
+ static const gdb_byte * \
+ ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
+ CORE_ADDR *pcptr, \
+ int *lenptr) \
+ { \
+ *lenptr = sizeof (BREAK_INSN); \
+ return BREAK_INSN; \
+ }
+
+#define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH) \
+ set_gdbarch_breakpoint_from_pc (gdbarch, ARCH##_breakpoint_from_pc)
+
/* An implementation of gdbarch_displaced_step_copy_insn for
processors that don't need to modify the instruction before
single-stepping the displaced copy.
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index f6f43a0..d8e9a36 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -912,14 +912,9 @@ avr_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
it as a NOP. Thus, it should be ok. Since the avr is currently a remote
only target, this shouldn't be a problem (I hope). TRoth/2003-05-14 */

-static const unsigned char *
-avr_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- static const unsigned char avr_break_insn [] = { 0x98, 0x95 };
- *lenptr = sizeof (avr_break_insn);
- return avr_break_insn;
-}
+static const unsigned char avr_break_insn [] = { 0x98, 0x95 };
+
+GDBARCH_BREAKPOINT_MANIPULATION (avr, avr_break_insn)

/* Determine, for architecture GDBARCH, how a return value of TYPE
should be returned. If it is supposed to be returned in registers,
@@ -1514,7 +1509,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_skip_prologue (gdbarch, avr_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

- set_gdbarch_breakpoint_from_pc (gdbarch, avr_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (avr);

frame_unwind_append_unwinder (gdbarch, &avr_frame_unwind);
frame_base_set_default (gdbarch, &avr_frame_base);
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 7ce08c0..89d26d0 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -424,13 +424,9 @@ frv_register_sim_regno (struct gdbarch *gdbarch, int reg)
internal_error (__FILE__, __LINE__, _("Bad register number %d"), reg);
}

-static const unsigned char *
-frv_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenp)
-{
- static unsigned char breakpoint[] = {0xc0, 0x70, 0x00, 0x01};
- *lenp = sizeof (breakpoint);
- return breakpoint;
-}
+static const unsigned char breakpoint[] = {0xc0, 0x70, 0x00, 0x01};
+
+GDBARCH_BREAKPOINT_MANIPULATION (frv, breakpoint)

/* Define the maximum number of instructions which may be packed into a
bundle (VLIW instruction). */
@@ -1537,7 +1533,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

set_gdbarch_skip_prologue (gdbarch, frv_skip_prologue);
set_gdbarch_skip_main_prologue (gdbarch, frv_skip_main_prologue);
- set_gdbarch_breakpoint_from_pc (gdbarch, frv_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (frv);
set_gdbarch_adjust_breakpoint_address
(gdbarch, frv_adjust_breakpoint_address);

diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 5eaa682..95b84fc 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -77,17 +77,10 @@ ft32_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
return sp & ~1;
}

-/* Implement the "breakpoint_from_pc" gdbarch method. */

-static const unsigned char *
-ft32_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- static const gdb_byte breakpoint[] = { 0x02, 0x00, 0x34, 0x00 };
+static const gdb_byte breakpoint[] = { 0x02, 0x00, 0x34, 0x00 };

- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (ft32, breakpoint)

/* FT32 register names. */

@@ -631,7 +624,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

set_gdbarch_skip_prologue (gdbarch, ft32_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_breakpoint_from_pc (gdbarch, ft32_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (ft32);
set_gdbarch_frame_align (gdbarch, ft32_frame_align);

frame_base_set_default (gdbarch, &ft32_frame_base);
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index 951f005..5e757a9 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -1242,16 +1242,10 @@ h8300s_dbg_reg_to_regnum (struct gdbarch *gdbarch, int regno)
return regno;
}

-static const unsigned char *
-h8300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- /*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
- static unsigned char breakpoint[] = { 0x01, 0x80 }; /* Sleep */
+/*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
+static const unsigned char breakpoint[] = { 0x01, 0x80 }; /* Sleep */

- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (h8300, breakpoint)

static struct gdbarch *
h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -1377,7 +1371,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Stack grows up. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

- set_gdbarch_breakpoint_from_pc (gdbarch, h8300_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (h8300);
set_gdbarch_push_dummy_call (gdbarch, h8300_push_dummy_call);

set_gdbarch_char_signed (gdbarch, 0);
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index f879a25..be91bdc 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -603,13 +603,9 @@ hppa_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
return 0;
}

-static const unsigned char *
-hppa_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static const unsigned char breakpoint[] = {0x00, 0x01, 0x00, 0x04};
- (*len) = sizeof (breakpoint);
- return breakpoint;
-}
+static const unsigned char breakpoint[] = {0x00, 0x01, 0x00, 0x04};
+
+GDBARCH_BREAKPOINT_MANIPULATION (hppa, breakpoint)

/* Return the name of a register. */

@@ -3185,7 +3181,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
internal_error (__FILE__, __LINE__, _("bad switch"));
}

- set_gdbarch_breakpoint_from_pc (gdbarch, hppa_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (hppa);
set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);

/* Frame unwind methods. */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 92987af..6c2c261 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -587,14 +587,9 @@ static const char *disassembly_flavor = att_flavor;

This function is 64-bit safe. */

-static const gdb_byte *
-i386_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static gdb_byte break_insn[] = { 0xcc }; /* int 3 */
+static const gdb_byte break_insn[] = { 0xcc }; /* int 3 */

- *len = sizeof (break_insn);
- return break_insn;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (i386, break_insn)
\f
/* Displaced instruction handling. */

@@ -8437,7 +8432,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

- set_gdbarch_breakpoint_from_pc (gdbarch, i386_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (i386);
set_gdbarch_decr_pc_after_break (gdbarch, 1);
set_gdbarch_max_insn_length (gdbarch, I386_MAX_INSN_LEN);

diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index ea83892..f9f3b0b 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -215,16 +215,10 @@ lm32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
}

/* Create a breakpoint instruction. */
+static const gdb_byte breakpoint[4] = { OP_RAISE << 2, 0, 0, 2 };

-static const gdb_byte *
-lm32_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- static const gdb_byte breakpoint[4] = { OP_RAISE << 2, 0, 0, 2 };
+GDBARCH_BREAKPOINT_MANIPULATION (lm32, breakpoint)

- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}

/* Setup registers and stack for faking a call to a function in the
inferior. */
@@ -562,7 +556,7 @@ lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
frame_unwind_append_unwinder (gdbarch, &lm32_frame_unwind);

/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, lm32_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (lm32);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);

/* Calling functions in the inferior. */
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 8737880..470406e 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -999,16 +999,9 @@ make_regs (struct gdbarch *arch)

\f
/* Breakpoints. */
+static const unsigned char break_insn[] = { 0x00 }; /* brk */

-static const unsigned char *
-m32c_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static unsigned char break_insn[] = { 0x00 }; /* brk */
-
- *len = sizeof (break_insn);
- return break_insn;
-}
-
+GDBARCH_BREAKPOINT_MANIPULATION (m32c, break_insn)

\f
/* Prologue analysis. */
@@ -2661,7 +2654,7 @@ m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_print_insn (gdbarch, print_insn_m32c);

/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, m32c_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (m32c);

/* Prologue analysis and unwinding. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index c30e682..620d1fb 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -390,16 +390,9 @@ m68hc11_register_name (struct gdbarch *gdbarch, int reg_nr)
return m68hc11_register_names[reg_nr];
}

-static const unsigned char *
-m68hc11_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- static unsigned char breakpoint[] = {0x0};
-
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+static unsigned char breakpoint[] = {0x0};

+GDBARCH_BREAKPOINT_MANIPULATION (m68hc11, breakpoint)
\f
/* 68HC11 & 68HC12 prologue analysis. */

@@ -1528,7 +1521,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
set_gdbarch_return_value (gdbarch, m68hc11_return_value);
set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (m68hc11);
set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11);

m68hc11_add_reggroups (gdbarch);
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 5d7b65d..cea2f01 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -57,14 +57,9 @@
#define BPT_VECTOR 0xf
#endif

-static const gdb_byte *
-m68k_local_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- static gdb_byte break_insn[] = {0x4e, (0x40 | BPT_VECTOR)};
- *lenptr = sizeof (break_insn);
- return break_insn;
-}
+static gdb_byte break_insn[] = {0x4e, (0x40 | BPT_VECTOR)};
+
+GDBARCH_BREAKPOINT_MANIPULATION (m68k, break_insn)
\f

/* Construct types for ISA-specific registers. */
@@ -1196,7 +1191,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_long_double_bit (gdbarch, long_double_format[0]->totalsize);

set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
- set_gdbarch_breakpoint_from_pc (gdbarch, m68k_local_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (m68k);

/* Stack grows down. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c
index 1a3c2cd..65f755c 100644
--- a/gdb/m88k-tdep.c
+++ b/gdb/m88k-tdep.c
@@ -96,16 +96,11 @@ m88k_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
encode a breakpoint instruction, store the length of the string in
*LEN and optionally adjust *PC to point to the correct memory
location for inserting the breakpoint. */
-
-static const gdb_byte *
-m88k_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- /* tb 0,r0,511 */
- static gdb_byte break_insn[] = { 0xf0, 0x00, 0xd1, 0xff };

- *len = sizeof (break_insn);
- return break_insn;
-}
+/* tb 0,r0,511 */
+static gdb_byte break_insn[] = { 0xf0, 0x00, 0xd1, 0xff };
+
+GDBARCH_BREAKPOINT_MANIPULATION (m88k, break_insn)

static CORE_ADDR
m88k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
@@ -856,7 +851,7 @@ m88k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_return_value (gdbarch, m88k_return_value);

set_gdbarch_addr_bits_remove (gdbarch, m88k_addr_bits_remove);
- set_gdbarch_breakpoint_from_pc (gdbarch, m88k_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (m88k);
set_gdbarch_unwind_pc (gdbarch, m88k_unwind_pc);
set_gdbarch_write_pc (gdbarch, m88k_write_pc);

diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index a110b04..a8900f1 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -1918,15 +1918,9 @@ mep_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)

\f
/* Breakpoints. */
+static unsigned char breakpoint[] = { 0x70, 0x32 };

-static const unsigned char *
-mep_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR * pcptr, int *lenptr)
-{
- static unsigned char breakpoint[] = { 0x70, 0x32 };
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
-
+GDBARCH_BREAKPOINT_MANIPULATION (mep, breakpoint)

\f
/* Frames and frame unwinding. */
@@ -2490,7 +2484,7 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_print_insn (gdbarch, mep_gdb_print_insn);

/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, mep_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (mep);
set_gdbarch_decr_pc_after_break (gdbarch, 0);
set_gdbarch_skip_prologue (gdbarch, mep_skip_prologue);

diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 665ec0c..ea33ae7 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -134,15 +134,10 @@ microblaze_fetch_instruction (CORE_ADDR pc)
return extract_unsigned_integer (buf, 4, byte_order);
}
\f
-static const gdb_byte *
-microblaze_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc,
- int *len)
-{
- static gdb_byte break_insn[] = MICROBLAZE_BREAKPOINT;
+static gdb_byte break_insn[] = MICROBLAZE_BREAKPOINT;
+
+GDBARCH_BREAKPOINT_MANIPULATION (microblaze, break_insn)

- *len = sizeof (break_insn);
- return break_insn;
-}
\f
/* Allocate and initialize a frame cache. */

@@ -736,7 +731,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

- set_gdbarch_breakpoint_from_pc (gdbarch, microblaze_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (microblaze);

set_gdbarch_frame_args_skip (gdbarch, 8);

diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 9ef88a8..16c0b39 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -322,15 +322,9 @@ mn10300_write_pc (struct regcache *regcache, CORE_ADDR val)
The Matsushita mn10x00 processors have single byte instructions
so we need a single byte breakpoint. Matsushita hasn't defined
one, so we defined it ourselves. */
+static gdb_byte breakpoint[] = {0xff};

-static const unsigned char *
-mn10300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
- int *bp_size)
-{
- static gdb_byte breakpoint[] = {0xff};
- *bp_size = 1;
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (mn10300, breakpoint)

/* Model the semantics of pushing a register onto the stack. This
is a helper function for mn10300_analyze_prologue, below. */
@@ -1444,7 +1438,7 @@ mn10300_gdbarch_init (struct gdbarch_info info,
/* Stack unwinding. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, mn10300_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (mn10300);
/* decr_pc_after_break? */
/* Disassembly. */
set_gdbarch_print_insn (gdbarch, print_insn_mn10300);
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 714734d..56989fd 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -67,17 +67,9 @@ moxie_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
return sp & ~1;
}

-/* Implement the "breakpoint_from_pc" gdbarch method. */
+static unsigned char breakpoint[] = { 0x35, 0x00 };

-static const unsigned char *
-moxie_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- static unsigned char breakpoint[] = { 0x35, 0x00 };
-
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (moxie, breakpoint)

/* Moxie register names. */

@@ -1138,7 +1130,7 @@ moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

set_gdbarch_skip_prologue (gdbarch, moxie_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_breakpoint_from_pc (gdbarch, moxie_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (moxie);
set_gdbarch_frame_align (gdbarch, moxie_frame_align);

frame_base_set_default (gdbarch, &moxie_frame_base);
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index 84189dc..8043155 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -277,17 +277,9 @@ msp430_register_sim_regno (struct gdbarch *gdbarch, int regnum)
return regnum;
}

-/* Implement the "breakpoint_from_pc" gdbarch method. */
+static gdb_byte breakpoint[] = { 0x43, 0x43 };

-static const gdb_byte *
-msp430_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- static gdb_byte breakpoint[] = { 0x43, 0x43 };
-
- *lenptr = sizeof breakpoint;
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (msp430, breakpoint)

/* Define a "handle" struct for fetching the next opcode. */

@@ -1001,7 +993,7 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);

/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, msp430_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (msp430);
set_gdbarch_decr_pc_after_break (gdbarch, 1);

/* Disassembly. */
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 420ee86..58e6642 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -768,21 +768,13 @@ rl78_pseudo_register_write (struct gdbarch *gdbarch,
gdb_assert_not_reached ("invalid pseudo register number");
}

-/* Implement the "breakpoint_from_pc" gdbarch method. */
+/* The documented BRK instruction is actually a two byte sequence,
+ {0x61, 0xcc}, but instructions may be as short as one byte.
+ Correspondence with Renesas revealed that the one byte sequence
+ 0xff is used when a one byte breakpoint instruction is required. */
+static gdb_byte breakpoint[] = { 0xff };

-static const gdb_byte *
-rl78_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- /* The documented BRK instruction is actually a two byte sequence,
- {0x61, 0xcc}, but instructions may be as short as one byte.
- Correspondence with Renesas revealed that the one byte sequence
- 0xff is used when a one byte breakpoint instruction is required. */
- static gdb_byte breakpoint[] = { 0xff };
-
- *lenptr = sizeof breakpoint;
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (rl78, breakpoint)

/* Define a "handle" struct for fetching the next opcode. */

@@ -1467,7 +1459,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_addr_bits_remove (gdbarch, rl78_addr_bits_remove);

/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, rl78_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (rl78);
set_gdbarch_decr_pc_after_break (gdbarch, 1);

/* Disassembly. */
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 904aebd..ddd340d 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -991,14 +991,9 @@ rx_return_value (struct gdbarch *gdbarch,
return RETURN_VALUE_REGISTER_CONVENTION;
}

-/* Implement the "breakpoint_from_pc" gdbarch method. */
-static const gdb_byte *
-rx_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
-{
- static gdb_byte breakpoint[] = { 0x00 };
- *lenptr = sizeof breakpoint;
- return breakpoint;
-}
+static gdb_byte breakpoint[] = { 0x00 };
+
+GDBARCH_BREAKPOINT_MANIPULATION (rx, breakpoint)

/* Implement the dwarf_reg_to_regnum" gdbarch method. */

@@ -1096,7 +1091,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sp_regnum (gdbarch, RX_SP_REGNUM);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_decr_pc_after_break (gdbarch, 1);
- set_gdbarch_breakpoint_from_pc (gdbarch, rx_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (rx);
set_gdbarch_skip_prologue (gdbarch, rx_skip_prologue);

set_gdbarch_print_insn (gdbarch, print_insn_rx);
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 70364b4..7ae1716 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -3549,17 +3549,9 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function,

/* Breakpoints. */
+static const gdb_byte breakpoint[] = { 0x0, 0x1 };

-static const gdb_byte *
-s390_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- static const gdb_byte breakpoint[] = { 0x0, 0x1 };
-
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
-
+GDBARCH_BREAKPOINT_MANIPULATION (s390, breakpoint)

/* Address handling. */

@@ -7982,7 +7974,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_decr_pc_after_break (gdbarch, 2);
/* Stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_breakpoint_from_pc (gdbarch, s390_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (s390);
set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 5a8acce..ac1504f 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -640,15 +640,9 @@ sparc32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
encode a breakpoint instruction, store the length of the string in
*LEN and optionally adjust *PC to point to the correct memory
location for inserting the breakpoint. */
-
-static const gdb_byte *
-sparc_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static const gdb_byte break_insn[] = { 0x91, 0xd0, 0x20, 0x01 };
+static const gdb_byte break_insn[] = { 0x91, 0xd0, 0x20, 0x01 };

- *len = sizeof (break_insn);
- return break_insn;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (sparc, break_insn)
\f

/* Allocate and initialize a frame cache. */
@@ -1708,7 +1702,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Stack grows downward. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);

- set_gdbarch_breakpoint_from_pc (gdbarch, sparc_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (sparc);

set_gdbarch_frame_args_skip (gdbarch, 8);

diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index f62e8e7..1863da1 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1570,16 +1570,9 @@ spu_return_value (struct gdbarch *gdbarch, struct value *function,

/* Breakpoints. */
+static const gdb_byte breakpoint[] = { 0x00, 0x00, 0x3f, 0xff };

-static const gdb_byte *
-spu_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR * pcptr, int *lenptr)
-{
- static const gdb_byte breakpoint[] = { 0x00, 0x00, 0x3f, 0xff };
-
- *lenptr = sizeof breakpoint;
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (spu, breakpoint)

static int
spu_memory_remove_breakpoint (struct gdbarch *gdbarch,
@@ -2797,7 +2790,7 @@ spu_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

/* Breakpoints. */
set_gdbarch_decr_pc_after_break (gdbarch, 4);
- set_gdbarch_breakpoint_from_pc (gdbarch, spu_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (spu);
set_gdbarch_memory_remove_breakpoint (gdbarch, spu_memory_remove_breakpoint);
set_gdbarch_software_single_step (gdbarch, spu_software_single_step);
set_gdbarch_get_longjmp_target (gdbarch, spu_get_longjmp_target);
diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index 550be4c..a8113cb 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -840,19 +840,11 @@ tilegx_write_pc (struct regcache *regcache, CORE_ADDR pc)
INT_SWINT_1_SIGRETURN);
}

-/* This is the implementation of gdbarch method breakpoint_from_pc. */
+/* 64-bit pattern for a { bpt ; nop } bundle. */
+static const unsigned char breakpoint[] =
+ { 0x00, 0x50, 0x48, 0x51, 0xae, 0x44, 0x6a, 0x28 };

-static const unsigned char *
-tilegx_breakpoint_from_pc (struct gdbarch *gdbarch,
- CORE_ADDR *pcptr, int *lenptr)
-{
- /* 64-bit pattern for a { bpt ; nop } bundle. */
- static const unsigned char breakpoint[] =
- { 0x00, 0x50, 0x48, 0x51, 0xae, 0x44, 0x6a, 0x28 };
-
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+GDBARCH_BREAKPOINT_MANIPULATION (tilegx, breakpoint)

/* Normal frames. */

@@ -1055,7 +1047,7 @@ tilegx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_push_dummy_call (gdbarch, tilegx_push_dummy_call);
set_gdbarch_get_longjmp_target (gdbarch, tilegx_get_longjmp_target);
set_gdbarch_write_pc (gdbarch, tilegx_write_pc);
- set_gdbarch_breakpoint_from_pc (gdbarch, tilegx_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (tilegx);
set_gdbarch_return_value (gdbarch, tilegx_return_value);

set_gdbarch_print_insn (gdbarch, print_insn_tilegx);
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index b7f4185..861f807 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -251,15 +251,10 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
encode a breakpoint instruction, store the length of the string in
*LEN and optionally adjust *PC to point to the correct memory
location for inserting the breakpoint. */
-
-static const gdb_byte *
-vax_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
- static gdb_byte break_insn[] = { 3 };

- *len = sizeof (break_insn);
- return break_insn;
-}
+static gdb_byte break_insn[] = { 3 };
+
+GDBARCH_BREAKPOINT_MANIPULATION (vax, break_insn)
\f
/* Advance PC across any function entry prologue instructions
to reach some "real" code. */
@@ -500,7 +495,7 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_dummy_id (gdbarch, vax_dummy_id);

/* Breakpoint info */
- set_gdbarch_breakpoint_from_pc (gdbarch, vax_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (vax);

/* Misc info */
set_gdbarch_deprecated_function_start_offset (gdbarch, 2);
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index af1551f..b2f0c5e 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -506,14 +506,9 @@ xstormy16_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
return 0;
}

-static const unsigned char *
-xstormy16_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
- int *lenptr)
-{
- static unsigned char breakpoint[] = { 0x06, 0x0 };
- *lenptr = sizeof (breakpoint);
- return breakpoint;
-}
+static unsigned char breakpoint[] = { 0x06, 0x0 };
+
+GDBARCH_BREAKPOINT_MANIPULATION (xstormy16, breakpoint)

/* Given a pointer to a jump table entry, return the address
of the function it jumps to. Return 0 if not found. */
@@ -843,7 +838,7 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)

/* These values and methods are used when gdb calls a target function. */
set_gdbarch_push_dummy_call (gdbarch, xstormy16_push_dummy_call);
- set_gdbarch_breakpoint_from_pc (gdbarch, xstormy16_breakpoint_from_pc);
+ SET_GDBARCH_BREAKPOINT_MANIPULATION (xstormy16);
set_gdbarch_return_value (gdbarch, xstormy16_return_value);

set_gdbarch_skip_trampoline_code (gdbarch, xstormy16_skip_trampoline_code);
--
1.9.1