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 03/14] Change parameters of adjust_pc_after_break.
Date: Thu, 03 May 2012 13:12:00 -0000	[thread overview]
Message-ID: <1336050869-29605-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1336050869-29605-1-git-send-email-yao@codesourcery.com>

A refactor change patch.

gdb:

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

	* infrun.c (adjust_pc_after_break): Remove parameter `ecs'.  Add
	parameter `thread' and 'ws'.  Change to return int.
	(handle_inferior_event): Caller update.
---
 gdb/infrun.c |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index c58688c..9de9674 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2937,13 +2937,18 @@ context_switch (ptid_t ptid)
   switch_to_thread (ptid);
 }
 
-static void
-adjust_pc_after_break (struct execution_control_state *ecs)
+/* Adjust PC value after thread THREAD hits breakpoint.  Return 1 if PC value
+   is adjusted, otherwise, return 0.  */
+
+static int
+adjust_pc_after_break (struct thread_info *thread,
+		       struct target_waitstatus *ws)
 {
   struct regcache *regcache;
   struct gdbarch *gdbarch;
   struct address_space *aspace;
   CORE_ADDR breakpoint_pc;
+  int ret = 0;
 
   /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP.  If
      we aren't, just return.
@@ -2966,11 +2971,11 @@ adjust_pc_after_break (struct execution_control_state *ecs)
      target with both of these set in GDB history, and it seems unlikely to be
      correct, so gdbarch_have_nonsteppable_watchpoint is not checked here.  */
 
-  if (ecs->ws.kind != TARGET_WAITKIND_STOPPED)
-    return;
+  if (ws->kind != TARGET_WAITKIND_STOPPED)
+    return 0;
 
-  if (ecs->ws.value.sig != TARGET_SIGNAL_TRAP)
-    return;
+  if (ws->value.sig != TARGET_SIGNAL_TRAP)
+    return 0;
 
   /* In reverse execution, when a breakpoint is hit, the instruction
      under it has already been de-executed.  The reported PC always
@@ -2999,14 +3004,14 @@ adjust_pc_after_break (struct execution_control_state *ecs)
      INSN1 hadn't been de-executed yet.  Doing nothing is the correct
      behaviour.  */
   if (execution_direction == EXEC_REVERSE)
-    return;
+    return 0;
 
   /* If this target does not decrement the PC after breakpoints, then
      we have nothing to do.  */
-  regcache = get_thread_regcache (ecs->ptid);
+  regcache = get_thread_regcache (thread->ptid);
   gdbarch = get_regcache_arch (regcache);
   if (gdbarch_decr_pc_after_break (gdbarch) == 0)
-    return;
+    return 0;
 
   aspace = get_regcache_aspace (regcache);
 
@@ -3050,14 +3055,19 @@ adjust_pc_after_break (struct execution_control_state *ecs)
 	 we also need to back up to the breakpoint address.  */
 
       if (singlestep_breakpoints_inserted_p
-	  || !ptid_equal (ecs->ptid, inferior_ptid)
-	  || !currently_stepping (ecs->event_thread)
-	  || ecs->event_thread->prev_pc == breakpoint_pc)
-	regcache_write_pc (regcache, breakpoint_pc);
+	  || !ptid_equal (thread->ptid, inferior_ptid)
+	  || !currently_stepping (thread)
+	  || thread->prev_pc == breakpoint_pc)
+	{
+	  regcache_write_pc (regcache, breakpoint_pc);
+	  ret = 1;
+	}
 
       if (RECORD_IS_USED)
 	do_cleanups (old_cleanups);
     }
+
+  return ret;
 }
 
 void
@@ -3264,7 +3274,7 @@ handle_inferior_event (struct execution_control_state *ecs)
   ecs->event_thread = find_thread_ptid (ecs->ptid);
 
   /* Dependent on valid ECS->EVENT_THREAD.  */
-  adjust_pc_after_break (ecs);
+  adjust_pc_after_break (ecs->event_thread, &ecs->ws);
 
   /* Dependent on the current PC value modified by adjust_pc_after_break.  */
   reinit_frame_cache ();
-- 
1.7.0.4


  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 ` Yao Qi [this message]
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:13 ` [PATCH 14/14] kfail gdb/13858 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 ` [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 02/14] Move displaced_step_fixup bits out to displaced_step_next 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 08/14] Uninstall infrun_async_inferior_event token in remote target 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 05/14] Support in linux-nat target 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 09/14] Set thread's state in infcall 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-4-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