Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Add support of software single step to process record
@ 2009-12-18  8:21 Hui Zhu
  2009-12-18 19:37 ` Michael Snyder
  2009-12-22 18:23 ` Tom Tromey
  0 siblings, 2 replies; 18+ messages in thread
From: Hui Zhu @ 2009-12-18  8:21 UTC (permalink / raw)
  To: gdb-patches ml; +Cc: Michael Snyder, shuchang zhou, paawan oza

[-- Attachment #1: Type: text/plain, Size: 4235 bytes --]

Hi guys,

This patch to make prec support software single step.
I just try it with i386.  Shuchang, please help me try it on mips.  :)

BTW, There are still some other patches for record_resume and
record_wait. And other arch patch is still not begin to be review.  So
this patch is not very urgency.  It just help the guys that are
working on prec arch porting.

Thanks,
Hui

2009-12-18  Hui Zhu  <teawater@gmail.com>

	* breakpoint.c (inserted_single_step_breakpoint_p): New
	function.
	* breakpoint.h (inserted_single_step_breakpoint_p): Extern.
	* record.c (record_resume): Add code for software single step.
	(record_wait): Ditto.

---
 breakpoint.c |   12 ++++++++++++
 breakpoint.h |    1 +
 record.c     |   35 ++++++++++++++++++++++++++++++-----
 3 files changed, 43 insertions(+), 5 deletions(-)

--- a/breakpoint.c
+++ b/breakpoint.c
@@ -9624,6 +9624,18 @@ insert_single_step_breakpoint (struct gd
 	     paddress (gdbarch, next_pc));
 }

+/* Check if the breakpoints used for software single stepping
inserted or not.  */
+
+int
+inserted_single_step_breakpoint_p (void)
+{
+  if (single_step_breakpoints[0] != NULL
+      || single_step_breakpoints[1] != NULL)
+    return 1;
+
+  return 1;
+}
+
 /* Remove and delete any breakpoints used for software single step.  */

 void
--- a/breakpoint.h
+++ b/breakpoint.h
@@ -944,6 +944,7 @@ extern int remove_hw_watchpoints (void);
    twice before remove is called.  */
 extern void insert_single_step_breakpoint (struct gdbarch *,
 					   struct address_space *, CORE_ADDR);
+extern int inserted_single_step_breakpoint_p (void);
 extern void remove_single_step_breakpoints (void);

 /* Manage manual breakpoints, separate from the normal chain of
--- a/record.c
+++ b/record.c
@@ -995,6 +995,8 @@ record_resume (struct target_ops *ops, p

   if (!RECORD_IS_REPLAY)
     {
+      struct gdbarch *gdbarch = get_current_arch ();
+
       if (do_record_message (get_current_regcache (), signal))
         {
           record_resume_error = 0;
@@ -1004,8 +1006,18 @@ record_resume (struct target_ops *ops, p
           record_resume_error = 1;
           return;
         }
-      record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
-                                signal);
+
+      if (gdbarch_software_single_step_p (gdbarch))
+        {
+          if (!inserted_single_step_breakpoint_p ())
+            gdbarch_software_single_step (gdbarch, get_current_frame ());
+          record_beneath_to_resume (record_beneath_to_resume_ops,
+                                    ptid, step, signal);
+          record_resume_step = 0;
+        }
+      else
+        record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
+                                  signal);
     }
 }

@@ -1086,6 +1098,7 @@ record_wait (struct target_ops *ops,
 	  /* This is not a single step.  */
 	  ptid_t ret;
 	  CORE_ADDR tmp_pc;
+          struct gdbarch *gdbarch = get_current_arch ();

 	  while (1)
 	    {
@@ -1108,6 +1121,9 @@ record_wait (struct target_ops *ops,
 		  tmp_pc = regcache_read_pc (regcache);
 		  aspace = get_regcache_aspace (regcache);

+                  if (gdbarch_software_single_step_p (gdbarch))
+                    remove_single_step_breakpoints ();
+
 		  if (target_stopped_by_watchpoint ())
 		    {
 		      /* Always interested in watchpoints.  */
@@ -1133,9 +1149,18 @@ record_wait (struct target_ops *ops,
 		      if (!do_record_message (regcache, TARGET_SIGNAL_0))
 			break;

-		      record_beneath_to_resume (record_beneath_to_resume_ops,
-						ptid, 1,
-						TARGET_SIGNAL_0);
+                      if (gdbarch_software_single_step_p (gdbarch))
+                        {
+                          gdbarch_software_single_step (gdbarch,
+                                                        get_current_frame ());
+                          record_beneath_to_resume
(record_beneath_to_resume_ops,
+                                                    ptid, 0,
+                                                    TARGET_SIGNAL_0);
+                        }
+                      else
+		        record_beneath_to_resume (record_beneath_to_resume_ops,
+						  ptid, 1,
+						  TARGET_SIGNAL_0);
 		      continue;
 		    }
 		}

[-- Attachment #2: prec_software_single_step.txt --]
[-- Type: text/plain, Size: 3606 bytes --]

---
 breakpoint.c |   12 ++++++++++++
 breakpoint.h |    1 +
 record.c     |   35 ++++++++++++++++++++++++++++++-----
 3 files changed, 43 insertions(+), 5 deletions(-)

--- a/breakpoint.c
+++ b/breakpoint.c
@@ -9624,6 +9624,18 @@ insert_single_step_breakpoint (struct gd
 	     paddress (gdbarch, next_pc));
 }
 
+/* Check if the breakpoints used for software single stepping inserted or not.  */
+
+int
+inserted_single_step_breakpoint_p (void)
+{
+  if (single_step_breakpoints[0] != NULL
+      || single_step_breakpoints[1] != NULL)
+    return 1;
+
+  return 1;
+}
+
 /* Remove and delete any breakpoints used for software single step.  */
 
 void
--- a/breakpoint.h
+++ b/breakpoint.h
@@ -944,6 +944,7 @@ extern int remove_hw_watchpoints (void);
    twice before remove is called.  */
 extern void insert_single_step_breakpoint (struct gdbarch *,
 					   struct address_space *, CORE_ADDR);
+extern int inserted_single_step_breakpoint_p (void);
 extern void remove_single_step_breakpoints (void);
 
 /* Manage manual breakpoints, separate from the normal chain of
--- a/record.c
+++ b/record.c
@@ -995,6 +995,8 @@ record_resume (struct target_ops *ops, p
 
   if (!RECORD_IS_REPLAY)
     {
+      struct gdbarch *gdbarch = get_current_arch ();
+
       if (do_record_message (get_current_regcache (), signal))
         {
           record_resume_error = 0;
@@ -1004,8 +1006,18 @@ record_resume (struct target_ops *ops, p
           record_resume_error = 1;
           return;
         }
-      record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
-                                signal);
+
+      if (gdbarch_software_single_step_p (gdbarch))
+        {
+          if (!inserted_single_step_breakpoint_p ())
+            gdbarch_software_single_step (gdbarch, get_current_frame ());
+          record_beneath_to_resume (record_beneath_to_resume_ops,
+                                    ptid, step, signal);
+          record_resume_step = 0;
+        }
+      else
+        record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
+                                  signal);
     }
 }
 
@@ -1086,6 +1098,7 @@ record_wait (struct target_ops *ops,
 	  /* This is not a single step.  */
 	  ptid_t ret;
 	  CORE_ADDR tmp_pc;
+          struct gdbarch *gdbarch = get_current_arch ();
 
 	  while (1)
 	    {
@@ -1108,6 +1121,9 @@ record_wait (struct target_ops *ops,
 		  tmp_pc = regcache_read_pc (regcache);
 		  aspace = get_regcache_aspace (regcache);
 
+                  if (gdbarch_software_single_step_p (gdbarch))
+                    remove_single_step_breakpoints ();
+
 		  if (target_stopped_by_watchpoint ())
 		    {
 		      /* Always interested in watchpoints.  */
@@ -1133,9 +1149,18 @@ record_wait (struct target_ops *ops,
 		      if (!do_record_message (regcache, TARGET_SIGNAL_0))
 			break;
 
-		      record_beneath_to_resume (record_beneath_to_resume_ops,
-						ptid, 1,
-						TARGET_SIGNAL_0);
+                      if (gdbarch_software_single_step_p (gdbarch))
+                        {
+                          gdbarch_software_single_step (gdbarch,
+                                                        get_current_frame ());
+                          record_beneath_to_resume (record_beneath_to_resume_ops,
+                                                    ptid, 0,
+                                                    TARGET_SIGNAL_0);
+                        }
+                      else
+		        record_beneath_to_resume (record_beneath_to_resume_ops,
+						  ptid, 1,
+						  TARGET_SIGNAL_0);
 		      continue;
 		    }
 		}

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-07-19  7:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-18  8:21 [RFC] Add support of software single step to process record Hui Zhu
2009-12-18 19:37 ` Michael Snyder
2009-12-20 13:48   ` Joel Brobecker
2009-12-23  6:38     ` Hui Zhu
2009-12-23  6:52       ` Joel Brobecker
2009-12-23  9:24         ` Hui Zhu
     [not found]           ` <8d62b6fe0912231751p1202294cw83430e8d53af0951@mail.gmail.com>
2009-12-24  1:54             ` Fwd: " shuchang zhou
2009-12-24 17:38           ` Pedro Alves
2010-01-04 14:23             ` Hui Zhu
2010-01-08 16:24               ` Pedro Alves
2010-05-25  5:14                 ` Hui Zhu
2010-05-27  6:51                   ` Hui Zhu
2010-06-11 13:55                     ` Pedro Alves
2010-06-20  7:29                       ` Hui Zhu
2010-06-22 10:13                         ` Pedro Alves
2010-07-19  7:58                           ` Hui Zhu
2009-12-22 18:23 ` Tom Tromey
2009-12-23  3:09   ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox