From dd373349578df87396bc43e7ab00a1a5ceb16c8b Mon Sep 17 00:00:00 2001 From: Antoine Tremblay Date: Wed, 21 Oct 2015 11:17:26 -0400 Subject: Add the target_ops needed for software breakpoints in GDBServer. This patch is in preparation for software breakpoints on ARM linux. It refactors breakpoint and breakpoint_len into breakpoint_kind_from_pc and sw_breakpoint_from kind to prepare the case where we have multiple types of breakpoints. Kind is the type of breakpoint (hardware or software) to be inserted, usually it is the lenght of the software breakpoint but can be something else depending on the target. This patch introduces the linux_target_ops breakpoint_kind_from_pc and sw_breakpoint_from_kind. breakpoint_kind_from_pc returns the breakpoint kind and adjusts the PC to the real memory location in case a flag was present in the PC. E.g the instruction mode on ARM. sw_breakpoint_from_kind returns the software breakpoint for this kind as a string of bytes, the length of the breakpoint is adjusted for the breakpoint's size in memory. For targets that have only one kind of breakpoint, the default value 0 is returned by linux_breakpoint_kind_from_pc so that not all targets need to implement the breakpoint_kind_from_pc operation. No regressions, tested on Ubuntu 14.04 on ARMv7 and x86 With gdbserver-{native,extended} / { -marm -mthumb } Also since the target_ops have been changed compilation was tested on affected archs namely : aarch64, arm, bfin, cris, crisv32, m32r, m68k, mips, nios2, ppc, s390, sparc, tic6x, tile, x86, steins. Not tested : sh gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (aarch64_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-arm-low.c (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. * linux-bfin-low.c (bfin_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-cris-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-crisv32-low.c (cris_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-low.c (linux_wait_1): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to increment the pc. (linux_breakpoint_kind_from_pc): New function. (linux_sw_breakpoint_from_kind): New function. (struct target_ops) : Initialize field. (initialize_low): Call breakpoint_kind_from_pc and sw_breakpoint_from_kind to replace breakpoint_data/len. * linux-low.h (struct linux_target_ops) : New field. (struct linux_target_ops) : Likewise. * linux-m32r-low.c (m32r_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-m68k-low.c (m68k_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-mips-low.c (mips_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-nios2-low.c (nios2_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-ppc-low.c (ppc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-s390-low.c (s390_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-sh-low.c (sh_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-sparc-low.c (sparc_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-tic6x-low.c (tic6x_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-tile-low.c (tile_sw_breakpoint_from_kind): New function. * linux-x86-low.c (x86_sw_breakpoint_from_kind): New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. * linux-xtensa-low.c (xtensa_sw_breakpoint_from_kind) New function. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Remove. (struct linux_target_ops) : Initialize field. (struct linux_target_ops) : Initialize field. --- gdb/gdbserver/linux-low.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gdb/gdbserver/linux-low.h') diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index f8f6e78..28dd4db 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -141,8 +141,13 @@ struct linux_target_ops CORE_ADDR (*get_pc) (struct regcache *regcache); void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); - const unsigned char *breakpoint; - int breakpoint_len; + + /* See target.h for details. */ + int (*breakpoint_kind_from_pc) (CORE_ADDR *pcptr); + + /* See target.h for details. */ + const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size); + CORE_ADDR (*breakpoint_reinsert_addr) (void); int decr_pc_after_break; -- cgit v1.1