This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] btrace: move breakpoint checking into stepping functions


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=011c71b6cbda4ecd856a08cf3124330d7f4342de

commit 011c71b6cbda4ecd856a08cf3124330d7f4342de
Author: Markus Metzger <markus.t.metzger@intel.com>
Date:   Mon Aug 24 15:55:02 2015 +0200

    btrace: move breakpoint checking into stepping functions
    
    Breakpoints are only checked for BTHR_CONT and BTHR_RCONT stepping requests.
    A BTHR_STEP and BTHR_RSTEP request will always report stopped without reason.
    Since breakpoints are reported correctly, I assume infrun is handling this.
    
    Move the breakpoint check into the btrace single stepping functions.  This
    will cause us to report breakpoint hits now also for single-step requests.
    
    One thing to notice is that
    
      - when executing forwards, the breakpoint is checked before 'executing'
        the instruction, i.e. before moving the PC to the next instruction.
    
      - when executing backwards,  the breakpoint is checked after 'executing'
        the instruction, i.e. after moving the PC to the preceding instruction
        in the recorded execution.
    
    There is code in infrun (see, for example proceed and adjust_pc_after_break)
    that handles this and also depends on this behaviour.
    
    gdb/
    	* record-btrace.c (record_btrace_step_thread): Move breakpoint check
    	to ...
    	(record_btrace_single_step_forward): ... here and
    	(record_btrace_single_step_backward): ... here.

Diff:
---
 gdb/ChangeLog       |  7 +++++++
 gdb/record-btrace.c | 22 ++++++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6b5de6c..e50557f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2015-09-18  Markus Metzger  <markus.t.metzger@intel.com>
 
+	* record-btrace.c (record_btrace_step_thread): Move breakpoint check
+	to ...
+	(record_btrace_single_step_forward): ... here and
+	(record_btrace_single_step_backward): ... here.
+
+2015-09-18  Markus Metzger  <markus.t.metzger@intel.com>
+
 	* record-btrace.c (btrace_step_spurious)
 	(record_btrace_single_step_forward)
 	(record_btrace_single_step_backward): New.
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index fdf7afb..5e8c1d4 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2038,6 +2038,10 @@ record_btrace_single_step_forward (struct thread_info *tp)
   if (replay == NULL)
     return btrace_step_no_history ();
 
+  /* Check if we're stepping a breakpoint.  */
+  if (record_btrace_replay_at_breakpoint (tp))
+    return btrace_step_stopped ();
+
   /* Skip gaps during replay.  */
   do
     {
@@ -2089,6 +2093,18 @@ record_btrace_single_step_backward (struct thread_info *tp)
     }
   while (btrace_insn_get (replay) == NULL);
 
+  /* Check if we're stepping a breakpoint.
+
+     For reverse-stepping, this check is after the step.  There is logic in
+     infrun.c that handles reverse-stepping separately.  See, for example,
+     proceed and adjust_pc_after_break.
+
+     This code assumes that for reverse-stepping, PC points to the last
+     de-executed instruction, whereas for forward-stepping PC points to the
+     next to-be-executed instruction.  */
+  if (record_btrace_replay_at_breakpoint (tp))
+    return btrace_step_stopped ();
+
   return btrace_step_spurious ();
 }
 
@@ -2154,9 +2170,6 @@ record_btrace_step_thread (struct thread_info *tp)
 		     target_pid_to_str (tp->ptid),
 		     core_addr_to_string_nz (insn->pc));
 	    }
-
-	  if (record_btrace_replay_at_breakpoint (tp))
-	    return btrace_step_stopped ();
 	}
 
     case BTHR_RCONT:
@@ -2176,9 +2189,6 @@ record_btrace_step_thread (struct thread_info *tp)
 	  DEBUG ("reverse-stepping %d (%s) ... %s", tp->num,
 		 target_pid_to_str (tp->ptid),
 		 core_addr_to_string_nz (insn->pc));
-
-	  if (record_btrace_replay_at_breakpoint (tp))
-	    return btrace_step_stopped ();
 	}
     }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]