Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 02/14] Move displaced_step_fixup bits out to displaced_step_next.
Date: Thu, 03 May 2012 13:13:00 -0000	[thread overview]
Message-ID: <1336050869-29605-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1336050869-29605-1-git-send-email-yao@codesourcery.com>

It is a refactor patch.  No functionality is changed.

gdb:

2012-04-12  Pedro Alves  <pedro@codesourcery.com>

	* infrun.c (displaced_step_fixup): Change return type to int.  Factor out
	bits into ...
	(displaced_step_next): ... this.
	(handle_inferior_event): Call displaced_step_next if displaced_step_fixup
	returns non-zero.
---
 gdb/infrun.c |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index c3074d5..c58688c 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1432,21 +1432,26 @@ displaced_step_restore (struct displaced_step_inferior_state *displaced,
 				  displaced->step_copy));
 }
 
-static void
+/* Fix up the resulting state after displaced stepping.  Return 0 if
+   no event to process.  Return 1 if instruction completes, otherwise
+   return -1.  */
+
+static int
 displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
 {
   struct cleanup *old_cleanups;
   struct displaced_step_inferior_state *displaced
     = get_displaced_stepping_state (ptid_get_pid (event_ptid));
+  int ret;
 
   /* Was any thread of this process doing a displaced step?  */
   if (displaced == NULL)
-    return;
+    return 0;
 
   /* Was this event for the pid we displaced?  */
   if (ptid_equal (displaced->step_ptid, null_ptid)
       || ! ptid_equal (displaced->step_ptid, event_ptid))
-    return;
+    return 0;
 
   old_cleanups = make_cleanup (displaced_step_clear_cleanup, displaced);
 
@@ -1461,6 +1466,7 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
                                     displaced->step_original,
                                     displaced->step_copy,
                                     get_thread_regcache (displaced->step_ptid));
+      ret = 1;
     }
   else
     {
@@ -1471,12 +1477,27 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
 
       pc = displaced->step_original + (pc - displaced->step_copy);
       regcache_write_pc (regcache, pc);
+      ret = -1;
     }
 
   do_cleanups (old_cleanups);
 
   displaced->step_ptid = null_ptid;
 
+  return ret;
+}
+
+/* Process pending displaced stepping requests.  */
+
+static void
+displaced_step_next (ptid_t event_ptid)
+{
+  struct displaced_step_inferior_state *displaced
+    = get_displaced_stepping_state (ptid_get_pid (event_ptid));
+
+  if (displaced == NULL)
+    return;
+
   /* Are there any pending displaced stepping requests?  If so, run
      one now.  Leave the state object around, since we're likely to
      need it again soon.  */
@@ -3481,7 +3502,8 @@ handle_inferior_event (struct execution_control_state *ecs)
 	       has been done.  Perform cleanup for parent process here.  Note
 	       that this operation also cleans up the child process for vfork,
 	       because their pages are shared.  */
-	    displaced_step_fixup (ecs->ptid, TARGET_SIGNAL_TRAP);
+	    if (displaced_step_fixup (ecs->ptid, TARGET_SIGNAL_TRAP))
+	      displaced_step_next (ecs->ptid);
 
 	    if (ecs->ws.kind == TARGET_WAITKIND_FORKED)
 	      {
@@ -3743,8 +3765,9 @@ handle_inferior_event (struct execution_control_state *ecs)
       /* Do we need to clean up the state of a thread that has
 	 completed a displaced single-step?  (Doing so usually affects
 	 the PC, so do it here, before we set stop_pc.)  */
-      displaced_step_fixup (ecs->ptid,
-			    ecs->event_thread->suspend.stop_signal);
+      if (displaced_step_fixup (ecs->ptid,
+				ecs->event_thread->suspend.stop_signal))
+	displaced_step_next (ecs->ptid);
 
       /* If we either finished a single-step or hit a breakpoint, but
 	 the user wanted this thread to be stopped, pretend we got a
-- 
1.7.0.4


  parent reply	other threads:[~2012-05-03 13:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 13:12 [PATCH v4 0/14] Run all-stop on non-stop target Yao Qi
2012-05-03 13:12 ` [PATCH 01/14] Fix displaced stepping debug log Yao Qi
2012-05-03 15:01   ` Pedro Alves
2012-05-03 13:12 ` [PATCH 03/14] Change parameters of adjust_pc_after_break Yao Qi
2012-05-03 13:13 ` [PATCH 12/14] manythreads.exp: Adjust to handle threads appearing/disappearing after "Program received signal SIGFOO" Yao Qi
2012-05-03 13:13 ` [PATCH 10/14] watchthreads-reorder.exp: Don't assume there is no infrun output after prompt Yao Qi
2012-05-03 13:13 ` [PATCH 05/14] Support in linux-nat target Yao Qi
2012-05-03 13:13 ` [PATCH 09/14] Set thread's state in infcall Yao Qi
2012-05-03 13:13 ` [PATCH 08/14] Uninstall infrun_async_inferior_event token in remote target Yao Qi
2012-05-03 13:13 ` [PATCH 06/14] Flip to set target-async on by default and NEWS Yao Qi
2012-05-03 13:13 ` [PATCH 07/14] Support in remote target Yao Qi
2012-05-03 13:13 ` Yao Qi [this message]
2012-05-03 13:13 ` [PATCH 13/14] ia64-sigill.exp: Don't assume there's no infrun output after the prompt Yao Qi
2012-05-03 13:13 ` [PATCH 11/14] Fix fails in gdb.trace/pending.exp Yao Qi
2012-05-03 13:13 ` [PATCH 14/14] kfail gdb/13858 Yao Qi
2012-05-03 13:14 ` [PATCH 04/14] Run all-stop on non-stop Yao Qi
2012-05-03 14:23 ` [PATCH v4 0/14] Run all-stop on non-stop target Pedro Alves
2012-05-03 14:38   ` Yao Qi
2012-05-09 17:46     ` Pedro Alves
2012-05-10 12:09       ` Yao Qi
2012-05-10 14:21         ` Pedro Alves
2012-05-26 11:08           ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336050869-29605-3-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox