Author: zbb
Date: Fri Nov 27 19:03:59 2015
New Revision: 291407
URL: https://svnweb.freebsd.org/changeset/base/291407

Log:
  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 <[email protected]>
  Obtained from: Semihalf
  Sponsored by:  Juniper Networks Inc.
  Differential Revision: https://reviews.freebsd.org/D4036

Modified:
  head/sys/ddb/db_run.c

Modified: head/sys/ddb/db_run.c
==============================================================================
--- head/sys/ddb/db_run.c       Fri Nov 27 18:58:26 2015        (r291406)
+++ head/sys/ddb/db_run.c       Fri Nov 27 19:03:59 2015        (r291407)
@@ -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();
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to