Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Deal with get ecs->stop_func_end fail
@ 2008-10-20  9:17 teawater
  2008-10-24  1:23 ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: teawater @ 2008-10-20  9:17 UTC (permalink / raw)
  To: Michael Snyder, gdb-patches

[-- 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

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

* Re: [RFA] Deal with get ecs->stop_func_end fail
  2008-10-20  9:17 [RFA] Deal with get ecs->stop_func_end fail teawater
@ 2008-10-24  1:23 ` Michael Snyder
  2008-10-24  2:52   ` teawater
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2008-10-24  1:23 UTC (permalink / raw)
  To: teawater; +Cc: gdb-patches

teawater wrote:
> 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.

Aha.  This is because we have stepped backward into
a shared-library trampoline.  You understand trampoline?

It means that this was the first time the program calls
"printf", which is in a shared library, so the program
jumps into a jump table which causes the dymanic runtime
resolver (ld-linux.so) to be called.

We actually succeeded in "nexting" backward through printf,
and then we succeeded in "nexting" backward thru _dl_runtime_resolver,
but we failed when we hit the trampoline (backward).

Give me some time, I need to figure out how to handle
trampolines backward!   ;-)

Meanwhile, this is obviously a problem in infrun, so
it does not need to affect your work on record/replay.

Leave this to me.   ;-)


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

* Re: [RFA] Deal with get ecs->stop_func_end fail
  2008-10-24  1:23 ` Michael Snyder
@ 2008-10-24  2:52   ` teawater
  0 siblings, 0 replies; 3+ messages in thread
From: teawater @ 2008-10-24  2:52 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

OK. Thanks Michael.

Hui

On Fri, Oct 24, 2008 at 09:18, Michael Snyder <msnyder@vmware.com> wrote:
> teawater wrote:
>>
>> 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.
>
> Aha.  This is because we have stepped backward into
> a shared-library trampoline.  You understand trampoline?
>
> It means that this was the first time the program calls
> "printf", which is in a shared library, so the program
> jumps into a jump table which causes the dymanic runtime
> resolver (ld-linux.so) to be called.
>
> We actually succeeded in "nexting" backward through printf,
> and then we succeeded in "nexting" backward thru _dl_runtime_resolver,
> but we failed when we hit the trampoline (backward).
>
> Give me some time, I need to figure out how to handle
> trampolines backward!   ;-)
>
> Meanwhile, this is obviously a problem in infrun, so
> it does not need to affect your work on record/replay.
>
> Leave this to me.   ;-)
>
>


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

end of thread, other threads:[~2008-10-24  2:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-20  9:17 [RFA] Deal with get ecs->stop_func_end fail teawater
2008-10-24  1:23 ` Michael Snyder
2008-10-24  2:52   ` teawater

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