From cdf23c193a94922f7334e944b6357b89a3b66757 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 27 Nov 2015 19:03:59 +0000 Subject: [PATCH] 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 Obtained from: Semihalf Sponsored by: Juniper Networks Inc. Differential Revision: https://reviews.freebsd.org/D4036 --- sys/ddb/db_run.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c index 026a9b683fa3..5250651efc52 100644 --- a/sys/ddb/db_run.c +++ b/sys/ddb/db_run.c @@ -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();