struct type;
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##_sw_breakpoint_from_kind (struct gdbarch *gdbarch, \
- int kind, int *size) \
- { \
- *size = kind; \
- return BREAK_INSN; \
+template <size_t bp_size, const gdb_byte *break_insn>
+struct bp_manipulation
+{
+ static int
+ kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+ {
+ return bp_size;
}
-#define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH) \
- 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 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)); \
- 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; \
+ static const gdb_byte *
+ bp_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+ {
+ *size = kind;
+ return break_insn;
}
+};
+
+template <size_t bp_size,
+ const gdb_byte *break_insn_little,
+ const gdb_byte *break_insn_big>
+struct bp_manipulation_endian
+{
+ static int
+ kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
+ {
+ return bp_size;
+ }
+
+ static const gdb_byte *
+ bp_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+ {
+ *size = kind;
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ return break_insn_big;
+ else
+ return break_insn_little;
+ }
+};
+
+#define BP_MANIPULATION(BREAK_INSN) \
+ bp_manipulation<sizeof (BREAK_INSN), BREAK_INSN>
+
+#define BP_MANIPULATION_ENDIAN(BREAK_INSN_LITTLE, BREAK_INSN_BIG) \
+ bp_manipulation_endian<sizeof (BREAK_INSN_LITTLE), \
+ BREAK_INSN_LITTLE, BREAK_INSN_BIG>
/* An implementation of gdbarch_displaced_step_copy_insn for
processors that don't need to modify the instruction before