This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA] Fix stepping over signal trampoline.


The following patch makes doing a "next" from the last line in a
signal handler work on Linux/i386.  What happens is that when we step
out of a signal handler we will end up at the first line of the signal
trampoline (which is only used in the return path).  GDB (mis)detects
this as a subroutine call.  This isn't that bad since stepping over
the signal handler isn't such a bad idea.  However to make this work
we have to ignore step_frame_address.  If we don't do that, we'll
typically run until the end of the program is reached.  Or if there is
a breakpoint at the point where we return from the signal trampoline,
the program might event segfault.

Mark


2000-05-01  Mark Kettenis  <kettenis@gnu.org>

	* infrun.c (handle_inferior_event): When doing a "next", and
	stepping out of a signal handler into its calling trampoline
	ignore the value of step_frame_address.
	(step_over_function): Only modify step_resume_breakpoint->frame if
	the value of step_frame_address is non-zero.


Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.8
diff -u -p -r1.8 infrun.c
--- infrun.c	2000/04/20 11:00:34	1.8
+++ infrun.c	2000/05/01 00:22:43
@@ -2745,6 +2745,20 @@ handle_inferior_event (struct execution_
 	if (step_over_calls > 0 || IGNORE_HELPER_CALL (stop_pc))
 	  {
 	    /* We're doing a "next".  */
+
+	    if (IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
+		&& INNER_THAN (step_frame_address, read_sp()))
+	      /* We stepped out of a signal handler, and into its
+                 calling trampoline.  This is misdetected as a
+                 subroutine call, but stepping over the signal
+                 trampoline isn't such a bad idea.  In order to do
+                 that, we have to ignore the value in
+                 step_frame_address, since that doesn't represent the
+                 frame that'll reach when we return from the signal
+                 trampoline.  Otherwise we'll probably continue to the
+                 end of the program.  */
+	      step_frame_address = 0;
+
 	    step_over_function (ecs);
 	    keep_going (ecs);
 	    return;
@@ -3045,7 +3059,7 @@ step_over_function (struct execution_con
   step_resume_breakpoint =
     set_momentary_breakpoint (sr_sal, get_current_frame (), bp_step_resume);
 
-  if (!IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc))
+  if (step_frame_address && !IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc))
     step_resume_breakpoint->frame = step_frame_address;
 
   if (breakpoints_inserted)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]