From d4807ea231eea599a474a9ad75a0552ef7217e1f Mon Sep 17 00:00:00 2001 From: Tankut Baris Aktemur Date: Thu, 2 Apr 2020 15:11:26 +0200 Subject: [PATCH] gdbserver/linux-low: turn the 'decr_pc_after_break' field into a method gdbserver/ChangeLog: 2020-04-02 Tankut Baris Aktemur Turn the 'decr_pc_after_break' linux_target_ops field into a method of linux_process_target. * linux-low.h (struct linux_target_ops) : Remove. (class linux_process_target) : New method declaration. * linux-low.cc (linux_process_target::low_decr_pc_after_break): New method implementation. Update the users below. (linux_process_target::save_stop_reason) (linux_process_target::wait_1) * linux-x86-low.cc (class x86_target) : New declaration. (x86_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-bfin-low.cc (class bfin_target) : New declaration. (bfin_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-m68k-low.cc (class m68k_target) : New declaration. (m68k_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-s390-low.cc (class s390_target) : New declaration. (s390_target::low_decr_pc_after_break): New method implementation. (the_low_target): Remove the field. * linux-aarch64-low.cc (the_low_target): Remove the field. * linux-arm-low.cc (the_low_target): Remove the field. * linux-cris-low.cc (the_low_target): Remove the field. * linux-crisv32-low.cc (the_low_target): Remove the field. * linux-m32r-low.cc (the_low_target): Remove the field. * linux-mips-low.cc (the_low_target): Remove the field. * linux-nios2-low.cc (the_low_target): Remove the field. * linux-ppc-low.cc (the_low_target): Remove the field. * linux-riscv-low.cc (the_low_target): Remove the field. * linux-sh-low.cc (the_low_target): Remove the field. * linux-sparc-low.cc (the_low_target): Remove the field. * linux-tic6x-low.cc (the_low_target): Remove the field. * linux-tile-low.cc (the_low_target): Remove the field. * linux-xtensa-low.cc (the_low_target): Remove the field. --- gdbserver/ChangeLog | 47 ++++++++++++++++++++++++++++++++++ gdbserver/linux-aarch64-low.cc | 1 - gdbserver/linux-arm-low.cc | 1 - gdbserver/linux-bfin-low.cc | 9 ++++++- gdbserver/linux-cris-low.cc | 1 - gdbserver/linux-crisv32-low.cc | 1 - gdbserver/linux-low.cc | 10 ++++++-- gdbserver/linux-low.h | 4 ++- gdbserver/linux-m32r-low.cc | 1 - gdbserver/linux-m68k-low.cc | 9 ++++++- gdbserver/linux-mips-low.cc | 1 - gdbserver/linux-nios2-low.cc | 1 - gdbserver/linux-ppc-low.cc | 1 - gdbserver/linux-riscv-low.cc | 1 - gdbserver/linux-s390-low.cc | 9 ++++++- gdbserver/linux-sh-low.cc | 1 - gdbserver/linux-sparc-low.cc | 1 - gdbserver/linux-tic6x-low.cc | 1 - gdbserver/linux-tile-low.cc | 1 - gdbserver/linux-x86-low.cc | 10 +++++++- gdbserver/linux-xtensa-low.cc | 1 - 21 files changed, 91 insertions(+), 21 deletions(-) diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index f9a3df22d02..4fc0609e48a 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,50 @@ +2020-04-02 Tankut Baris Aktemur + + Turn the 'decr_pc_after_break' linux_target_ops field into + a method of linux_process_target. + + * linux-low.h (struct linux_target_ops) + : Remove. + (class linux_process_target) : New method + declaration. + * linux-low.cc (linux_process_target::low_decr_pc_after_break): + New method implementation. + + Update the users below. + + (linux_process_target::save_stop_reason) + (linux_process_target::wait_1) + * linux-x86-low.cc (class x86_target) : + New declaration. + (x86_target::low_decr_pc_after_break): New method implementation. + (the_low_target): Remove the field. + * linux-bfin-low.cc (class bfin_target) : + New declaration. + (bfin_target::low_decr_pc_after_break): New method implementation. + (the_low_target): Remove the field. + * linux-m68k-low.cc (class m68k_target) : + New declaration. + (m68k_target::low_decr_pc_after_break): New method implementation. + (the_low_target): Remove the field. + * linux-s390-low.cc (class s390_target) : + New declaration. + (s390_target::low_decr_pc_after_break): New method implementation. + (the_low_target): Remove the field. + * linux-aarch64-low.cc (the_low_target): Remove the field. + * linux-arm-low.cc (the_low_target): Remove the field. + * linux-cris-low.cc (the_low_target): Remove the field. + * linux-crisv32-low.cc (the_low_target): Remove the field. + * linux-m32r-low.cc (the_low_target): Remove the field. + * linux-mips-low.cc (the_low_target): Remove the field. + * linux-nios2-low.cc (the_low_target): Remove the field. + * linux-ppc-low.cc (the_low_target): Remove the field. + * linux-riscv-low.cc (the_low_target): Remove the field. + * linux-sh-low.cc (the_low_target): Remove the field. + * linux-sparc-low.cc (the_low_target): Remove the field. + * linux-tic6x-low.cc (the_low_target): Remove the field. + * linux-tile-low.cc (the_low_target): Remove the field. + * linux-xtensa-low.cc (the_low_target): Remove the field. + 2020-04-02 Tankut Baris Aktemur Remove the 'supports_software_single_step' linux target op and let diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 11c3296eb6b..988aa939145 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -3103,7 +3103,6 @@ aarch64_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - 0, /* decr_pc_after_break */ aarch64_breakpoint_at, aarch64_supports_z_point_type, aarch64_insert_point, diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc index bd42feba1c4..18f427245c1 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -1085,7 +1085,6 @@ arm_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, arm_breakpoint_at, arm_supports_z_point_type, arm_insert_point, diff --git a/gdbserver/linux-bfin-low.cc b/gdbserver/linux-bfin-low.cc index 17948ed16f0..23d0342c0db 100644 --- a/gdbserver/linux-bfin-low.cc +++ b/gdbserver/linux-bfin-low.cc @@ -46,6 +46,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + int low_decr_pc_after_break () override; }; /* The singleton target ops object. */ @@ -70,6 +72,12 @@ bfin_target::low_set_pc (regcache *regcache, CORE_ADDR pc) linux_set_pc_32bit (regcache, pc); } +int +bfin_target::low_decr_pc_after_break () +{ + return 2; +} + /* Defined in auto-generated file reg-bfin.c. */ void init_registers_bfin (void); extern const struct target_desc *tdesc_bfin; @@ -161,7 +169,6 @@ bfin_target::get_regs_info () } struct linux_target_ops the_low_target = { - 2, bfin_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc index 99060de1765..5fb40bf1c36 100644 --- a/gdbserver/linux-cris-low.cc +++ b/gdbserver/linux-cris-low.cc @@ -158,7 +158,6 @@ cris_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, cris_breakpoint_at, }; diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc index c75e428885e..b55a0176dde 100644 --- a/gdbserver/linux-crisv32-low.cc +++ b/gdbserver/linux-crisv32-low.cc @@ -455,7 +455,6 @@ crisv32_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, cris_breakpoint_at, cris_supports_z_point_type, cris_insert_point, diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 8eca077180e..fd225789347 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -317,6 +317,12 @@ linux_process_target::low_get_next_pcs (regcache *regcache) "implemented"); } +int +linux_process_target::low_decr_pc_after_break () +{ + return 0; +} + /* Returns true if this target can support fast tracepoints. This does not mean that the in-process agent has been loaded in the inferior. */ @@ -796,7 +802,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp) return false; pc = get_pc (lwp); - sw_breakpoint_pc = pc - the_low_target.decr_pc_after_break; + sw_breakpoint_pc = pc - low_decr_pc_after_break (); /* breakpoint_at reads from the current thread. */ saved_thread = current_thread; @@ -3694,7 +3700,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus, if (event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT && !cs.swbreak_feature) { - int decr_pc = the_low_target.decr_pc_after_break; + int decr_pc = low_decr_pc_after_break (); if (decr_pc != 0) { diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h index 2202a658225..5867960ae59 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -131,7 +131,6 @@ struct lwp_info; struct linux_target_ops { - int decr_pc_after_break; int (*breakpoint_at) (CORE_ADDR pc); /* Breakpoint and watchpoint related functions. See target.h for @@ -666,6 +665,9 @@ protected: Targets that override this method should also override 'supports_software_single_step' to return true. */ virtual std::vector low_get_next_pcs (regcache *regcache); + + /* How many bytes the PC should be decremented after a break. */ + virtual int low_decr_pc_after_break (); }; extern linux_process_target *the_linux_target; diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc index 78e002dfb24..1d23438687e 100644 --- a/gdbserver/linux-m32r-low.cc +++ b/gdbserver/linux-m32r-low.cc @@ -160,7 +160,6 @@ m32r_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, m32r_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc index 00851af5f02..33e0d7b1b86 100644 --- a/gdbserver/linux-m68k-low.cc +++ b/gdbserver/linux-m68k-low.cc @@ -42,6 +42,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + int low_decr_pc_after_break () override; }; /* The singleton target ops object. */ @@ -66,6 +68,12 @@ m68k_target::low_set_pc (regcache *regcache, CORE_ADDR pc) linux_set_pc_32bit (regcache, pc); } +int +m68k_target::low_decr_pc_after_break () +{ + return 2; +} + /* Defined in auto-generated file reg-m68k.c. */ void init_registers_m68k (void); extern const struct target_desc *tdesc_m68k; @@ -255,7 +263,6 @@ m68k_supports_hardware_single_step (void) } struct linux_target_ops the_low_target = { - 2, m68k_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc index 710245c1610..82e141f0250 100644 --- a/gdbserver/linux-mips-low.cc +++ b/gdbserver/linux-mips-low.cc @@ -966,7 +966,6 @@ mips_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, mips_breakpoint_at, mips_supports_z_point_type, mips_insert_point, diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc index 3cae8dac285..2544b495e0f 100644 --- a/gdbserver/linux-nios2-low.cc +++ b/gdbserver/linux-nios2-low.cc @@ -277,7 +277,6 @@ nios2_target::get_regs_info () struct linux_target_ops the_low_target = { - 0, nios2_breakpoint_at, }; diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc index af9dc0b2adf..e488b7d3fea 100644 --- a/gdbserver/linux-ppc-low.cc +++ b/gdbserver/linux-ppc-low.cc @@ -3406,7 +3406,6 @@ ppc_get_ipa_tdesc_idx (void) } struct linux_target_ops the_low_target = { - 0, ppc_breakpoint_at, ppc_supports_z_point_type, ppc_insert_point, diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc index 9e96504687e..9f3ea590fa7 100644 --- a/gdbserver/linux-riscv-low.cc +++ b/gdbserver/linux-riscv-low.cc @@ -309,7 +309,6 @@ riscv_breakpoint_at (CORE_ADDR pc) /* RISC-V/Linux target operations. */ struct linux_target_ops the_low_target = { - 0, /* decr_pc_after_break */ riscv_breakpoint_at, }; diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc index 4c4b877bb75..f9444312121 100644 --- a/gdbserver/linux-s390-low.cc +++ b/gdbserver/linux-s390-low.cc @@ -74,6 +74,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + int low_decr_pc_after_break () override; }; /* The singleton target ops object. */ @@ -502,6 +504,12 @@ s390_target::low_set_pc (regcache *regcache, CORE_ADDR newpc) } } +int +s390_target::low_decr_pc_after_break () +{ + return s390_breakpoint_len; +} + /* Determine the word size for the given PID, in bytes. */ #ifdef __s390x__ @@ -2826,7 +2834,6 @@ s390_emit_ops (void) } struct linux_target_ops the_low_target = { - s390_breakpoint_len, s390_breakpoint_at, s390_supports_z_point_type, NULL, diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc index 47242dafe94..77a4f105d1a 100644 --- a/gdbserver/linux-sh-low.cc +++ b/gdbserver/linux-sh-low.cc @@ -190,7 +190,6 @@ sh_target::low_arch_setup () } struct linux_target_ops the_low_target = { - 0, sh_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc index f724cb88b71..81eb36225e9 100644 --- a/gdbserver/linux-sparc-low.cc +++ b/gdbserver/linux-sparc-low.cc @@ -339,7 +339,6 @@ sparc_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, sparc_breakpoint_at, NULL, /* supports_z_point_type */ NULL, NULL, NULL, NULL, diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc index 347b79e6519..51453c6713c 100644 --- a/gdbserver/linux-tic6x-low.cc +++ b/gdbserver/linux-tic6x-low.cc @@ -421,7 +421,6 @@ tic6x_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, tic6x_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc index 86191b9bb1c..53d39c47f45 100644 --- a/gdbserver/linux-tile-low.cc +++ b/gdbserver/linux-tile-low.cc @@ -222,7 +222,6 @@ tile_supports_hardware_single_step (void) struct linux_target_ops the_low_target = { - 0, tile_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 59c6b386d11..eb36aced8b6 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -121,6 +121,8 @@ protected: CORE_ADDR low_get_pc (regcache *regcache) override; void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; + + int low_decr_pc_after_break () override; }; /* The singleton target ops object. */ @@ -547,6 +549,13 @@ x86_target::low_set_pc (regcache *regcache, CORE_ADDR pc) supply_register_by_name (regcache, "eip", &newpc); } } + +int +x86_target::low_decr_pc_after_break () +{ + return 1; +} + static const gdb_byte x86_breakpoint[] = { 0xCC }; #define x86_breakpoint_len 1 @@ -2899,7 +2908,6 @@ x86_get_ipa_tdesc_idx (void) struct linux_target_ops the_low_target = { - 1, x86_breakpoint_at, x86_supports_z_point_type, x86_insert_point, diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc index 320ac92968d..606204b45e4 100644 --- a/gdbserver/linux-xtensa-low.cc +++ b/gdbserver/linux-xtensa-low.cc @@ -328,7 +328,6 @@ xtensa_target::get_regs_info () } struct linux_target_ops the_low_target = { - 0, xtensa_breakpoint_at, NULL, /* supports_z_point_type */ NULL, /* insert_point */ -- 2.30.2