From d19280adb5b2d1470dc39756ccac8a8fa2af8321 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Thu, 3 Nov 2016 14:35:13 +0000 Subject: Split breakpoint_from_pc to breakpoint_kind_from_pc and sw_breakpoint_from_kind We convert each ARCH_breakpoint_from_pc to ARCH_breakpoint_kind_from_pc and ARCH_sw_breakpoint_from_kind. Note that gdbarch doesn't have methods breakpoint_kind_from_pc and sw_breakpoint_from_kind so far. gdb: 2016-11-03 Yao Qi * arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): New macro. (GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): New macro. * arm-tdep.c (arm_breakpoint_from_pc): Remove. (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. (arm_breakpoint_from_pc): Call arm_breakpoint_kind_from_pc and arm_sw_breakpoint_from_kind. Use GDBARCH_BREAKPOINT_FROM_PC. (arm_remote_breakpoint_from_pc): Call arm_breakpoint_kind_from_pc. (arm_gdbarch_init): Replace set_gdbarch_breakpoint_from_pc with SET_GDBARCH_BREAKPOINT_MANIPULATION. * arc-tdep.c: Likewise. * bfin-tdep.c: Likewise. * cris-tdep.c: Likewise. * iq2000-tdep.c: Likewise. * m32r-tdep.c: Likewise. * mips-tdep.c: Likewise. * mt-tdep.c: Likewise. * nios2-tdep.c: Likewise. * rs6000-tdep.c: Likewise. * score-tdep.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * tic6x-tdep.c: Likewise. * v850-tdep.c: Likewise. * xtensa-tdep.c: Likewise. --- gdb/m32r-tdep.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'gdb/m32r-tdep.c') diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 8e1d79e..2ca8940 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -165,9 +165,17 @@ m32r_memory_remove_breakpoint (struct gdbarch *gdbarch, return val; } +static int +m32r_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) +{ + if ((*pcptr & 3) == 0) + return 4; + else + return 2; +} + static const gdb_byte * -m32r_breakpoint_from_pc (struct gdbarch *gdbarch, - CORE_ADDR *pcptr, int *lenptr) +m32r_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) { static gdb_byte be_bp_entry[] = { 0x10, 0xf1, 0x70, 0x00 @@ -175,39 +183,22 @@ m32r_breakpoint_from_pc (struct gdbarch *gdbarch, static gdb_byte le_bp_entry[] = { 0x00, 0x70, 0xf1, 0x10 }; /* dpt -> nop */ - gdb_byte *bp; + + *size = kind; /* Determine appropriate breakpoint. */ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - { - if ((*pcptr & 3) == 0) - { - bp = be_bp_entry; - *lenptr = 4; - } - else - { - bp = be_bp_entry; - *lenptr = 2; - } - } + return be_bp_entry; else { - if ((*pcptr & 3) == 0) - { - bp = le_bp_entry; - *lenptr = 4; - } + if (kind == 4) + return le_bp_entry; else - { - bp = le_bp_entry + 2; - *lenptr = 2; - } + return le_bp_entry + 2; } - - return bp; } +GDBARCH_BREAKPOINT_FROM_PC (m32r) char *m32r_register_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", @@ -929,7 +920,7 @@ m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_skip_prologue (gdbarch, m32r_skip_prologue); set_gdbarch_inner_than (gdbarch, core_addr_lessthan); - set_gdbarch_breakpoint_from_pc (gdbarch, m32r_breakpoint_from_pc); + SET_GDBARCH_BREAKPOINT_MANIPULATION (m32r); set_gdbarch_memory_insert_breakpoint (gdbarch, m32r_memory_insert_breakpoint); set_gdbarch_memory_remove_breakpoint (gdbarch, -- cgit v1.1