Add helper to catch single step debug event and distinguish it from bkpt

Some architectures (including ARMv6/v7) do not have separate single step
events and cannot see difference between breakpoint and single step.
Add db_pc_is_singlestep() to avoid skipping instruction we stepped on
to trigger debug event.
This commit does not change the existing functionality but adds possibility
to implement custom db_pc_is_singlestep().

Reviewed by:   imp
Submitted by:  Zbigniew Bodek <zbb@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4036
This commit is contained in:
Zbigniew Bodek 2015-11-27 19:03:59 +00:00
parent 7f911abe54
commit cdf23c193a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291407

View File

@ -65,16 +65,28 @@ int db_inst_count;
int db_load_count;
int db_store_count;
#ifdef SOFTWARE_SSTEP
db_breakpoint_t db_not_taken_bkpt = 0;
db_breakpoint_t db_taken_bkpt = 0;
#endif
#ifndef db_set_single_step
void db_set_single_step(void);
#endif
#ifndef db_clear_single_step
void db_clear_single_step(void);
#endif
#ifndef db_pc_is_singlestep
static bool
db_pc_is_singlestep(db_addr_t pc)
{
#ifdef SOFTWARE_SSTEP
db_breakpoint_t db_not_taken_bkpt = 0;
db_breakpoint_t db_taken_bkpt = 0;
if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
|| (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
return (true);
#endif
return (false);
}
#endif
bool
@ -84,11 +96,9 @@ db_stop_at_pc(bool *is_breakpoint)
db_breakpoint_t bkpt;
pc = PC_REGS();
#ifdef SOFTWARE_SSTEP
if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
|| (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
if (db_pc_is_singlestep(pc))
*is_breakpoint = false;
#endif
db_clear_single_step();
db_clear_breakpoints();