public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] Replace address and aspace with thread in struct step_over_info
Date: Fri, 15 Apr 2016 13:29:00 -0000	[thread overview]
Message-ID: <1460726961-27486-3-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1460726961-27486-1-git-send-email-yao.qi@linaro.org>

This patch replaces the fields aspace and address in
'struct step_over_info' with 'thread', because aspace and thread can
be got from thread.

gdb:

2016-04-15  Yao Qi  <yao.qi@linaro.org>

	* infrun.c (struct step_over_info) <aspace>: Remove
	<address>: Remove.
	<thread>: New field.
	(set_step_over_info): Update.
	(clear_step_over_info): Update.
	(stepping_past_nonsteppable_watchpoint): Update.
---
 gdb/infrun.c | 47 +++++++++++++++++++++--------------------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9017b0a..72f7fe4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1282,16 +1282,12 @@ enum step_over_what_flag
   };
 DEF_ENUM_FLAGS_TYPE (enum step_over_what_flag, step_over_what);
 
-/* Info about an instruction that is being stepped over.  */
+/* Info about a thread that is being stepped over.  */
 
 struct step_over_info
 {
-  /* If we're stepping past a breakpoint, this is the address space
-     and address of the instruction the breakpoint is set at.  We'll
-     skip inserting all breakpoints here.  Valid iff ASPACE is
-     non-NULL.  */
-  struct address_space *aspace;
-  CORE_ADDR address;
+  /* We're stepping over the thread to pass a breakpoint.  */
+  struct thread_info *thread;
 
   /* The instruction being stepped over triggers a nonsteppable
      watchpoint.  If true, we'll skip inserting watchpoints.  */
@@ -1331,18 +1327,7 @@ static void
 set_step_over_info (struct thread_info *thread,
 		    int nonsteppable_watchpoint_p)
 {
-  if (thread != NULL)
-    {
-      struct regcache *regcache = get_thread_regcache (thread->ptid);
-
-      step_over_info.aspace = get_regcache_aspace (regcache);
-      step_over_info.address = regcache_read_pc (regcache);
-    }
-  else
-    {
-      step_over_info.aspace = NULL;
-      step_over_info.address = 0;
-    }
+  step_over_info.thread = thread;
   step_over_info.nonsteppable_watchpoint_p = nonsteppable_watchpoint_p;
 }
 
@@ -1355,8 +1340,7 @@ clear_step_over_info (void)
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
 			"infrun: clear_step_over_info\n");
-  step_over_info.aspace = NULL;
-  step_over_info.address = 0;
+  step_over_info.thread = NULL;
   step_over_info.nonsteppable_watchpoint_p = 0;
 }
 
@@ -1366,10 +1350,21 @@ int
 stepping_past_instruction_at (struct address_space *aspace,
 			      CORE_ADDR address)
 {
-  return (step_over_info.aspace != NULL
-	  && breakpoint_address_match (aspace, address,
-				       step_over_info.aspace,
-				       step_over_info.address));
+  if (step_over_info.thread != NULL)
+    {
+      struct regcache *regcache;
+
+      regcache = get_thread_regcache (step_over_info.thread->ptid);
+
+      /* The step-over isn't finished or is still valid, so the PC got
+	 from regcache is the value when thread stops, rather than the
+	 value after step-over.  */
+      return breakpoint_address_match (aspace, address,
+				       get_regcache_aspace (regcache) ,
+				       regcache_read_pc (regcache));
+    }
+  else
+    return 0;
 }
 
 /* See infrun.h.  */
@@ -1385,7 +1380,7 @@ stepping_past_nonsteppable_watchpoint (void)
 static int
 step_over_info_valid_p (void)
 {
-  return (step_over_info.aspace != NULL
+  return (step_over_info.thread != NULL
 	  || stepping_past_nonsteppable_watchpoint ());
 }
 
-- 
1.9.1

  reply	other threads:[~2016-04-15 13:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 13:29 [PATCH 0/2] Add thread info in 'struct step_over_info' Yao Qi
2016-04-15 13:29 ` Yao Qi [this message]
2016-04-19 10:43   ` [PATCH 2/2] Replace address and aspace with thread in struct step_over_info Pedro Alves
2016-04-19 13:55     ` Yao Qi
2016-04-20 18:01       ` Doug Evans
2016-04-20 18:03         ` Pedro Alves
2016-12-22 23:51           ` Doug Evans
2016-04-15 13:29 ` [PATCH 1/2] Refactor function set_step_over_info 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=1460726961-27486-3-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).