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] New function displaced_step_in_progress_thread


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

commit c098766357b77f0553ec017b48abdd563de0281e
Author: Yao Qi <yao.qi@linaro.org>
Date:   Mon Nov 9 14:39:56 2015 +0000

    New function displaced_step_in_progress_thread
    
    This patch adds a new function displaced_step_in_progress_thread,
    which returns whether the thread is in progress of displaced
    stepping.
    
    gdb:
    
    2015-11-09  Yao Qi  <yao.qi@linaro.org>
    
    	* infrun.c (displaced_step_in_progress_thread): New function.
    	(handle_inferior_event_1): Call it.

Diff:
---
 gdb/ChangeLog |  5 +++++
 gdb/infrun.c  | 22 +++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 366ee4c..0e63ed2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-09  Yao Qi  <yao.qi@linaro.org>
+
+	* infrun.c (displaced_step_in_progress_thread): New function.
+	(handle_inferior_event_1): Call it.
+
 2015-11-05  Yao Qi  <yao.qi@linaro.org>
 
 	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Call
diff --git a/gdb/infrun.c b/gdb/infrun.c
index ef4ccb4..185b79b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1536,6 +1536,21 @@ displaced_step_in_progress_any_inferior (void)
   return 0;
 }
 
+/* Return true if thread represented by PTID is doing a displaced
+   step.  */
+
+static int
+displaced_step_in_progress_thread (ptid_t ptid)
+{
+  struct displaced_step_inferior_state *displaced;
+
+  gdb_assert (!ptid_equal (ptid, null_ptid));
+
+  displaced = get_displaced_stepping_state (ptid_get_pid (ptid));
+
+  return (displaced != NULL && ptid_equal (displaced->step_ptid, ptid));
+}
+
 /* Return true if process PID has a thread doing a displaced step.  */
 
 static int
@@ -4946,12 +4961,10 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
       {
 	struct regcache *regcache = get_thread_regcache (ecs->ptid);
 	struct gdbarch *gdbarch = get_regcache_arch (regcache);
-	struct displaced_step_inferior_state *displaced
-	  = get_displaced_stepping_state (ptid_get_pid (ecs->ptid));
 
 	/* If checking displaced stepping is supported, and thread
 	   ecs->ptid is displaced stepping.  */
-	if (displaced && ptid_equal (displaced->step_ptid, ecs->ptid))
+	if (displaced_step_in_progress_thread (ecs->ptid))
 	  {
 	    struct inferior *parent_inf
 	      = find_inferior_ptid (ecs->ptid);
@@ -4970,6 +4983,9 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
 
 	    if (ecs->ws.kind == TARGET_WAITKIND_FORKED)
 	      {
+		struct displaced_step_inferior_state *displaced
+		  = get_displaced_stepping_state (ptid_get_pid (ecs->ptid));
+
 		/* Restore scratch pad for child process.  */
 		displaced_step_restore (displaced, ecs->ws.value.related_pid);
 	      }


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