This is the mail archive of the gdb-patches@sources.redhat.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]
Other format: [Raw text]

Re: [patch] missing case in epilogue stub detection


On Tue, Aug 26, 2003 at 04:01:52PM -0700, Jafa wrote:
> Hi Daniel,
> 
> My appologies...
> (description below)
> 
> diff -u -6 -r1.10 infrun.c
> --- infrun.c 20 Aug 2003 17:15:33 -0000 1.10
> +++ infrun.c 26 Aug 2003 23:00:59 -0000
> @@ -2443,15 +2443,15 @@
> 
>        ecs->remove_breakpoints_on_following_step = 1;
>        keep_going (ecs);
>        return;
>      }
> 
> -  if (stop_pc == ecs->stop_func_start /* Quick test */
> -      || (in_prologue (stop_pc, ecs->stop_func_start) &&
> -   !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
> +  if (((stop_pc == ecs->stop_func_start /* Quick test.  */
> +          || in_prologue (stop_pc, ecs->stop_func_start))
> +             && !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
>        || IN_SOLIB_CALL_TRAMPOLINE (stop_pc, ecs->stop_func_name)
>        || ecs->stop_func_name == 0)
>      {
>        /* It's a subroutine call.  */
> 
>        if ((step_over_calls == STEP_OVER_NONE)
> 
> 
> The first thing the original code does is "if (stop_pc ==
> ecs->stop_func_start /* Quick test */" which means if the stop_pc is equal
> to the first instrucion of a function or stub then it bypasses all of the
> other checks and blindly assumes it is a function. The "in_prologue" and
> "IN_SOLIB_RETURN_TRAMPOLINE" functions never get called because it has
> already decided that it is a function.
> 
> I believe the original code is valid in assuming that if the pc is at the
> start of the func/stub then it can skip the prologue test, however it still
> needs to check to see if it is in an epilogue stub.
> 
> This is critical because an epilogue stub (by definition) does not return to
> the caller, thus cannot be treated as a subroutine.
> 
> BTW - Thanks for the feedback, you are probably right, the comment is still
> reasonably relavant and my editor doesn't pick up lines being too long.
> 
> If there is a better way to solve this problem then I would appreciate your
> advice.

Hi Nick,

OK, thank you for the explanation.  Presumably, for whatever target
this code was originally added, the return stubs didn't show up as
functions in the symbol table and so the first check never triggered.
Your explanation makes sense, so I've committed this patch.

[I don't believe this patch requires copyright assignment, but do
you/Ubicom have one in place?  I don't remember.]

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-09-07  Daniel Jacobowitz  <drow@mvista.com>

	From Nick Kelsey <nickk@ubicom.com>:
	* infrun.c (handle_inferior_event): Check IN_SOLIB_RETURN_TRAMPOLINE
	when the stop PC is at the beginning of a function also.

Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.110
diff -u -p -r1.110 infrun.c
--- infrun.c	19 Jun 2003 15:04:57 -0000	1.110
+++ infrun.c	7 Sep 2003 04:34:55 -0000
@@ -2446,9 +2446,9 @@ process_event_stop_test:
       return;
     }
 
-  if (stop_pc == ecs->stop_func_start	/* Quick test */
-      || (in_prologue (stop_pc, ecs->stop_func_start) &&
-	  !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
+  if (((stop_pc == ecs->stop_func_start	/* Quick test */
+	|| in_prologue (stop_pc, ecs->stop_func_start))
+       && !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
       || IN_SOLIB_CALL_TRAMPOLINE (stop_pc, ecs->stop_func_name)
       || ecs->stop_func_name == 0)
     {


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