diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/arm-linux-tdep.c | 5 | ||||
-rw-r--r-- | gdb/breakpoint.c | 25 | ||||
-rw-r--r-- | gdb/breakpoint.h | 8 | ||||
-rw-r--r-- | gdb/gdbarch-gen.h | 12 | ||||
-rw-r--r-- | gdb/gdbarch_components.py | 12 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 29 | ||||
-rw-r--r-- | gdb/i386-tdep.h | 84 | ||||
-rw-r--r-- | gdb/infrun.c | 19 | ||||
-rw-r--r-- | gdb/record-full.c | 4 |
9 files changed, 97 insertions, 101 deletions
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 2f034af..08526d8 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -960,6 +960,11 @@ arm_linux_software_single_step (struct regcache *regcache) struct gdbarch *gdbarch = regcache->arch (); struct arm_get_next_pcs next_pcs_ctx; + /* If the target does have hardware single step, GDB doesn't have + to bother software single step. */ + if (target_can_do_single_step () == 1) + return {}; + arm_get_next_pcs_ctor (&next_pcs_ctx, &arm_linux_get_next_pcs_ops, gdbarch_byte_order (gdbarch), diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f795d7b..d704ad1 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -13998,26 +13998,11 @@ insert_single_step_breakpoint (struct gdbarch *gdbarch, update_global_location_list (UGLL_INSERT); } -/* Try to setup for software single stepping. Return true if - target_resume() should use hardware single step. +/* Insert single step breakpoints according to the current state. */ - GDBARCH is the current gdbarch. */ - -bool -maybe_software_singlestep (struct gdbarch *gdbarch) +int +insert_single_step_breakpoints (struct gdbarch *gdbarch) { - if (execution_direction != EXEC_FORWARD) - return true; - - if (target_can_do_single_step () == 1) - { - /* The target definitely has hardware single step. */ - return true; - } - - if (!gdbarch_software_single_step_p (gdbarch)) - return true; - regcache *regcache = get_thread_regcache (inferior_thread ()); std::vector<CORE_ADDR> next_pcs; @@ -14031,10 +14016,10 @@ maybe_software_singlestep (struct gdbarch *gdbarch) for (CORE_ADDR pc : next_pcs) insert_single_step_breakpoint (gdbarch, aspace, pc); - return false; + return 1; } else - return true; + return 0; } /* See breakpoint.h. */ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index e9201bc..9341112 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1884,10 +1884,10 @@ extern void insert_single_step_breakpoint (struct gdbarch *, const address_space *, CORE_ADDR); -/* Try to setup for software single stepping. Return true if - target_resume() should use hardware single step. GDBARCH is the - current gdbarch. */ -extern bool maybe_software_singlestep (struct gdbarch *); +/* Insert all software single step breakpoints for the current frame. + Return true if any software single step breakpoints are inserted, + otherwise, return false. */ +extern int insert_single_step_breakpoints (struct gdbarch *); /* Check whether any hardware watchpoints have triggered or not, according to the target, and record it in each watchpoint's diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 1e51081..281b97b 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -776,10 +776,16 @@ extern void set_gdbarch_get_memtag (struct gdbarch *gdbarch, gdbarch_get_memtag_ extern CORE_ADDR gdbarch_memtag_granule_size (struct gdbarch *gdbarch); extern void set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, CORE_ADDR memtag_granule_size); -/* Return a vector of addresses at which the software single step - breakpoints should be inserted. An empty vector means software single - step is not used. +/* FIXME/cagney/2001-01-18: This should be split in two. A target method that + indicates if the target needs software single step. An ISA method to + implement it. + FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the + target can single step. If not, then implement single step using breakpoints. + + Return a vector of addresses on which the software single step + breakpoints should be inserted. NULL means software single step is + not used. Multiple breakpoints may be inserted for some instructions such as conditional branch. However, each implementation must always evaluate the condition and only put the breakpoint at the branch destination if diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 55df102..91c867e 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -1378,10 +1378,16 @@ For a non-zero value, this represents the number of bytes of memory per tag. Function( comment=""" -Return a vector of addresses at which the software single step -breakpoints should be inserted. An empty vector means software single -step is not used. +FIXME/cagney/2001-01-18: This should be split in two. A target method that +indicates if the target needs software single step. An ISA method to +implement it. +FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the +target can single step. If not, then implement single step using breakpoints. + +Return a vector of addresses on which the software single step +breakpoints should be inserted. NULL means software single step is +not used. Multiple breakpoints may be inserted for some instructions such as conditional branch. However, each implementation must always evaluate the condition and only put the breakpoint at the branch destination if diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f97c98e..21a5a28 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8977,41 +8977,12 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->num_core_regs = I386_NUM_GREGS + I387_NUM_REGS; tdep->register_names = i386_register_names; - /* No upper YMM registers. */ - tdep->ymmh_register_names = NULL; - tdep->ymm0h_regnum = -1; - - /* No upper ZMM registers. */ - tdep->zmmh_register_names = NULL; - tdep->zmm0h_regnum = -1; - - /* No high XMM registers. */ - tdep->xmm_avx512_register_names = NULL; - tdep->xmm16_regnum = -1; - - /* No upper YMM16-31 registers. */ - tdep->ymm16h_register_names = NULL; - tdep->ymm16h_regnum = -1; - tdep->num_byte_regs = 8; tdep->num_word_regs = 8; tdep->num_dword_regs = 0; tdep->num_mmx_regs = 8; tdep->num_ymm_regs = 0; - /* No AVX512 registers. */ - tdep->k0_regnum = -1; - tdep->num_zmm_regs = 0; - tdep->num_ymm_avx512_regs = 0; - tdep->num_xmm_avx512_regs = 0; - - /* No PKEYS registers */ - tdep->pkru_regnum = -1; - tdep->num_pkeys_regs = 0; - - /* No segment base registers. */ - tdep->fsbase_regnum = -1; - tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction); diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index e849b33..e4895b1 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -69,56 +69,57 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base size_t sizeof_fpregset = 0; /* Register number for %st(0). The register numbers for the other - registers follow from this one. Set this to -1 to indicate the - absence of an FPU. */ - int st0_regnum = 0; + registers follow from this one. Set this to a value >= 0 if FPU is + present. */ + int st0_regnum = -1; /* Number of MMX registers. */ int num_mmx_regs = 0; - /* Register number for %mm0. Set this to -1 to indicate the absence - of MMX support. */ - int mm0_regnum = 0; + /* Register number for %mm0. Set this to a value >= 0 if MMX is + supported. */ + int mm0_regnum = -1; /* Number of pseudo YMM registers. */ int num_ymm_regs = 0; - /* Register number for %ymm0. Set this to -1 to indicate the absence - of pseudo YMM register support. */ - int ymm0_regnum = 0; + /* Register number for %ymm0. Set this to a value >= 0 if pseudo YMM + registers are supported. */ + int ymm0_regnum = -1; /* Number of AVX512 OpMask registers (K-registers) */ int num_k_regs = 0; - /* Register number for %k0. Set this to -1 to indicate the absence - of AVX512 OpMask register support. */ - int k0_regnum = 0; + /* Register number for %k0. Set this to a value >= 0 if AVX512 OpMask + is supported. */ + int k0_regnum = -1; /* Number of pseudo ZMM registers ($zmm0-$zmm31). */ int num_zmm_regs = 0; - /* Register number for %zmm0. Set this to -1 to indicate the absence - of pseudo ZMM register support. */ - int zmm0_regnum = 0; + /* Register number for %zmm0. Set this to a value >= 0 if pseudo ZMM + registers are supported. */ + int zmm0_regnum = -1; /* Number of byte registers. */ int num_byte_regs = 0; - /* Register pseudo number for %al. */ - int al_regnum = 0; + /* Register pseudo number for %al. If supported, set this to a + value >= 0. */ + int al_regnum = -1; /* Number of pseudo word registers. */ int num_word_regs = 0; - /* Register number for %ax. */ - int ax_regnum = 0; + /* Register number for %ax. If supported, set this to a value >= 0. */ + int ax_regnum = -1; /* Number of pseudo dword registers. */ int num_dword_regs = 0; - /* Register number for %eax. Set this to -1 to indicate the absence - of pseudo dword register support. */ - int eax_regnum = 0; + /* Register number for %eax. Set this to a value >= 0 if pseudo dword + registers are supported. */ + int eax_regnum = -1; /* Number of core registers. */ int num_core_regs = 0; @@ -129,14 +130,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Number of SSE registers added in AVX512. */ int num_xmm_avx512_regs = 0; - /* Register number of XMM16, the first XMM register added in AVX512. */ - int xmm16_regnum = 0; + /* Register number of XMM16, the first XMM register added in AVX512. + Set this to a value >= 0 if XMM registers are supported. */ + int xmm16_regnum = -1; /* Number of YMM registers added in AVX512. */ int num_ymm_avx512_regs = 0; - /* Register number of YMM16, the first YMM register added in AVX512. */ - int ymm16_regnum = 0; + /* Register number of YMM16, the first YMM register added in AVX512. + Set this to a value >= 0 if YMM registers are supported. */ + int ymm16_regnum = -1; /* Bits of the extended control register 0 (the XFEATURE_ENABLED_MASK register), excluding the x87 bit, which are supported by this GDB. */ @@ -152,23 +155,23 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Register names. */ const char * const *register_names = nullptr; - /* Register number for %ymm0h. Set this to -1 to indicate the absence - of upper YMM register support. */ - int ymm0h_regnum = 0; + /* Register number for %ymm0h. Set this to a value >= 0 if they are + supported. */ + int ymm0h_regnum = -1; /* Upper YMM register names. Only used for tdesc_numbered_register. */ const char * const *ymmh_register_names = nullptr; - /* Register number for %ymm16h. Set this to -1 to indicate the absence - of support for YMM16-31. */ - int ymm16h_regnum = 0; + /* Register number for %ymm16h. Set this to a value >= 0 if they are + supported. */ + int ymm16h_regnum = -1; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ const char * const *ymm16h_register_names = nullptr; - /* Register number for %zmm0h. Set this to -1 to indicate the absence - of ZMM_HI256 register support. */ - int zmm0h_regnum = 0; + /* Register number for %zmm0h. Set this to a value >= 0 if ZMM_HI256 + registers are supported. */ + int zmm0h_regnum = -1; /* OpMask register names. */ const char * const *k_register_names = nullptr; @@ -185,15 +188,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Number of PKEYS registers. */ int num_pkeys_regs = 0; - /* Register number for PKRU register. */ - int pkru_regnum = 0; + /* Register number for PKRU register. If supported, set this to a value + >= 0. */ + int pkru_regnum = -1; /* PKEYS register names. */ const char * const *pkeys_register_names = nullptr; - /* Register number for %fsbase. Set this to -1 to indicate the - absence of segment base registers. */ - int fsbase_regnum = 0; + /* Register number for %fsbase. If supported, set this to a value + >= 0. */ + int fsbase_regnum = -1; /* Target description. */ const struct target_desc *tdesc = nullptr; diff --git a/gdb/infrun.c b/gdb/infrun.c index e0e9ffa..9d3e1b7 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -93,6 +93,8 @@ static void insert_step_resume_breakpoint_at_caller (const frame_info_ptr &); static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR); +static bool maybe_software_singlestep (struct gdbarch *gdbarch); + static void resume (gdb_signal sig); static void wait_for_inferior (inferior *inf); @@ -2357,6 +2359,23 @@ set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c) process. */ bool sched_multi = false; +/* Try to setup for software single stepping. Return true if target_resume() + should use hardware single step. + + GDBARCH the current gdbarch. */ + +static bool +maybe_software_singlestep (struct gdbarch *gdbarch) +{ + bool hw_step = true; + + if (execution_direction == EXEC_FORWARD + && gdbarch_software_single_step_p (gdbarch)) + hw_step = !insert_single_step_breakpoints (gdbarch); + + return hw_step; +} + /* See infrun.h. */ ptid_t diff --git a/gdb/record-full.c b/gdb/record-full.c index 7d4ef87..7e3da27 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1105,7 +1105,7 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal) record_full_resume_step = 1; } else - step = maybe_software_singlestep (gdbarch); + step = !insert_single_step_breakpoints (gdbarch); } } @@ -1277,7 +1277,7 @@ record_full_wait_1 (struct target_ops *ops, }; reinit_frame_cache (); - step = maybe_software_singlestep (gdbarch); + step = !insert_single_step_breakpoints (gdbarch); } if (record_debug) |