Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: teawater <teawater@gmail.com>
To: "Michael Snyder" <msnyder@vmware.com>,
	 	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [RFA] Deal with get ecs->stop_func_end fail
Date: Mon, 20 Oct 2008 09:17:00 -0000	[thread overview]
Message-ID: <daef60380810200216x35852677ybd8ba0167e038dfd@mail.gmail.com> (raw)

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

Hi Michael,

I try a program and got:
(gdb) start
Temporary breakpoint 1 at 0x80483c1: file 1.c, line 20.
Starting program: /media/disk/a.out

Temporary breakpoint 1, main () at 1.c:20
20	       int     b = 0;
(gdb) rec
(gdb) n
21	       int     c = 1;
(gdb)
24		printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb)
a = 0 b = 0 c = 1
25	       b = cool ();
(gdb) rn

No more reverse-execution history.
main () at 1.c:20
20	       int     b = 0;


It's clear that "rn" got error.
This is because:
  find_pc_partial_function (stop_pc, &ecs->stop_func_name,
			    &ecs->stop_func_start, &ecs->stop_func_end);
This part get ecs->stop_func_end is 0.

Then:
	      sr_sal.pc = ecs->stop_func_start;
	      insert_step_resume_breakpoint_at_sal (sr_sal, null_frame_id);
Insert breakpoint to 0 address and continue execute.  So...


So I add some code deal with it.  Maybe you remember, I send some
patch for it in before.


But I got random_signal, cause I let this part step.
So I add other code deal with that.

2008-10-20  Hui Zhu  <teawater@gmail.com>

	Deal with get ecs->stop_func_end fail.

	* infrun.c (reverse_need_step): New variable. Set to 1 if next
	reverse execute need step.
	(handle_inferior_event): Save the prev value of
	reverse_need_step to reverse_need_step_prev.
	If reverse_need_step_prev is 1 and stop_signal is
	TARGET_SIGNAL_TRAP, not set this is not random_signal.
	If find_pc_partial_function get ecs->stop_func_name and
	ecs->stop_func_end are 0 and this is reverse execute, set
	reverse_need_step to 1.
	(currently_stepping): Return 1 if reverse_need_step is 1.
	(insert_step_resume_breakpoint_at_sal): If reverse_need_step
	is 1 and sr_sal.pc is 0, not insert breakpoint.
	(stop_stepping): Reset reverse_need_step to 1 when this
	execute command complete.

This patch is both for branch and main tree.


Thanks,
Hui

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

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-20  Hui Zhu  <teawater@gmail.com>
+
+	Deal with get ecs->stop_func_end fail.
+
+	* infrun.c (reverse_need_step): New variable. Set to 1 if next
+	reverse execute need step.
+	(handle_inferior_event): If 
+
 2008-10-19  Hui Zhu  <teawater@gmail.com>
 
 	* infrun.c (handle_inferior_event): Set "stop_pc" when
--- a/infrun.c
+++ b/infrun.c
@@ -1854,6 +1854,8 @@ ensure_not_running (void)
    by an event from the inferior, figure out what it means and take
    appropriate action.  */
 
+static int reverse_need_step = 0;
+
 void
 handle_inferior_event (struct execution_control_state *ecs)
 {
@@ -1862,6 +1864,13 @@ handle_inferior_event (struct execution_
   int stepped_after_stopped_by_watchpoint = 0;
   struct symtab_and_line stop_pc_sal;
   enum stop_kind stop_soon;
+  int reverse_need_step_prev;
+
+  /* Save the reverse_need_step that is set in prev cycle to 
+     reverse_need_step_prev.  */
+  reverse_need_step_prev = reverse_need_step;
+  /* Reset the value of reverse_need_step.  */
+  reverse_need_step = 0;
 
   if (ecs->ws.kind != TARGET_WAITKIND_EXITED
       && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED
@@ -2520,6 +2529,11 @@ targets should add new threads to the th
      will both be 0 if it doesn't work.  */
   find_pc_partial_function (stop_pc, &ecs->stop_func_name,
 			    &ecs->stop_func_start, &ecs->stop_func_end);
+  /* If find_pc_partial_function get ecs->stop_func_name and ecs->stop_func_end
+     are 0 and this is reverse execute, Let inferior single step.  */
+  if (!(ecs->stop_func_name || ecs->stop_func_end)
+      && execution_direction == EXEC_REVERSE)
+    reverse_need_step = 1;
   ecs->stop_func_start
     += gdbarch_deprecated_function_start_offset (current_gdbarch);
   ecs->event_thread->stepping_over_breakpoint = 0;
@@ -2667,7 +2681,8 @@ targets should add new threads to the th
 	  = !(bpstat_explains_signal (ecs->event_thread->stop_bpstat)
 	      || ecs->event_thread->trap_expected
 	      || (ecs->event_thread->step_range_end
-		  && ecs->event_thread->step_resume_breakpoint == NULL));
+		  && ecs->event_thread->step_resume_breakpoint == NULL)
+	      || reverse_need_step_prev);
       else
 	{
 	  ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
@@ -3411,7 +3426,8 @@ currently_stepping (struct thread_info *
   return (((tp->step_range_end && tp->step_resume_breakpoint == NULL)
 	   || tp->trap_expected)
 	  || tp->stepping_through_solib_after_catch
-	  || bpstat_should_step ());
+	  || bpstat_should_step ()
+	  || reverse_need_step);
 }
 
 /* Inferior has stepped into a subroutine call with source code that
@@ -3539,6 +3555,9 @@ insert_step_resume_breakpoint_at_sal (st
      step_resume_breakpoint when one is already active.  */
   gdb_assert (inferior_thread ()->step_resume_breakpoint == NULL);
 
+  if (!sr_sal.pc && reverse_need_step)
+    return;
+
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
 			"infrun: inserting step-resume breakpoint at 0x%s\n",
@@ -3633,6 +3652,10 @@ stop_stepping (struct execution_control_
 
   /* Let callers know we don't want to wait for the inferior anymore.  */
   ecs->wait_some_more = 0;
+
+  /* Reset reverse_need_step to make it not affect reverse_need_step_prev
+  in next execute command.  */
+  reverse_need_step = 0;
 }
 
 /* This function handles various cases where we need to continue

             reply	other threads:[~2008-10-20  9:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-20  9:17 teawater [this message]
2008-10-24  1:23 ` Michael Snyder
2008-10-24  2:52   ` teawater

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=daef60380810200216x35852677ybd8ba0167e038dfd@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@vmware.com \
    /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