Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/ia64] Limit prologue scanning to end of function
@ 2007-09-17 20:17 Joel Brobecker
  2007-09-17 22:04 ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2007-09-17 20:17 UTC (permalink / raw)
  To: gdb-patches

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

Hello,

This is a local fix that we made a couple of years ago, which we
forgot to submit for inclusion, somehow.

Basically, it's kind of hard to determine the end of a function
prologue on ia64 just by scanning the function code. So the examine_prologue
routine in ia64-tdep.c often ends up scanning a bit more code
than is necessary. As a consequence, this might cause us to go
too far when trying to skip the prologue.

To help in that task, we have a routine, called refine_prologue_limit,
whose job is to try using the line number information to find a better
limit for our function prologue. The problem is that this function needs
to handle optimizations where the compiler intermingles the different
lines:

      /* Handle the case in which compiler's optimizer/scheduler
         has moved instructions into the prologue.  We scan ahead
         in the function looking for address ranges whose corresponding
         line number is less than or equal to the first one that we
         found for the function.  (It can be less than when the
         scheduler puts a body instruction before the first prologue
         instruction.)  */
      for (i = 2 * max_skip_non_prologue_insns;
           i > 0 && (lim_pc == 0 || addr < lim_pc);
           i--)

In some cases, the PC range given is larger than the function size.
As a result, we end up testing some line numbers that are actually
not part of the same routine, and sometimes selecting it (if the line
number is smaller).

The fix is simply to reduce the initial range to the function end
address.

2007-09-17  Joel Brobecker  <brobecker@adacore.com>

        * ia64-tdep.c (refine_prologue_limit): Make sure we don't scan
        the linetable past the function end.

Tested on ia64-linux, no regression.
OK to commit? I also suggest this fix for gdb-6.7, since it looks
pretty safe. However, I think that the chances of a function whose
associated lines are smaller, and yet have a higher PC are relatively
small. So perhaps not worth the risk.

Thanks,
-- 
Joel

[-- Attachment #2: refine_limit.diff --]
[-- Type: text/plain, Size: 724 bytes --]

Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.159
diff -u -p -r1.159 ia64-tdep.c
--- ia64-tdep.c	23 Aug 2007 18:08:35 -0000	1.159
+++ ia64-tdep.c	17 Sep 2007 19:15:51 -0000
@@ -967,6 +967,12 @@ refine_prologue_limit (CORE_ADDR pc, COR
 {
   struct symtab_and_line prologue_sal;
   CORE_ADDR start_pc = pc;
+  CORE_ADDR end_pc;
+
+  /* The prologue can not possibly go past the function end itself,
+     so we can already adjust LIM_PC accordingly.  */
+  if (find_pc_partial_function (pc, NULL, NULL, &end_pc) && end_pc < lim_pc)
+    lim_pc = end_pc;
 
   /* Start off not trusting the limit.  */
   *trust_limit = 0;

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

* Re: [RFA/ia64] Limit prologue scanning to end of function
  2007-09-17 20:17 [RFA/ia64] Limit prologue scanning to end of function Joel Brobecker
@ 2007-09-17 22:04 ` Jim Blandy
  2007-09-18 23:50   ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2007-09-17 22:04 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches


Joel Brobecker <brobecker@adacore.com> writes:
> 2007-09-17  Joel Brobecker  <brobecker@adacore.com>
>
>         * ia64-tdep.c (refine_prologue_limit): Make sure we don't scan
>         the linetable past the function end.
>
> Tested on ia64-linux, no regression.
> OK to commit?

Seems reasonable to me.


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

* Re: [RFA/ia64] Limit prologue scanning to end of function
  2007-09-17 22:04 ` Jim Blandy
@ 2007-09-18 23:50   ` Joel Brobecker
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2007-09-18 23:50 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

> > 2007-09-17  Joel Brobecker  <brobecker@adacore.com>
> >
> >         * ia64-tdep.c (refine_prologue_limit): Make sure we don't scan
> >         the linetable past the function end.
> >
> > Tested on ia64-linux, no regression.
> > OK to commit?
> 
> Seems reasonable to me.

Thanks, Jim. Now checked in.

Given that it's pretty simple, and given that we've had this fix in the
AdaCore tree for a couple of years without any problem, I think it's
safe enough for the gdb-6.7 branch. So I'll put it in too.

-- 
Joel


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

end of thread, other threads:[~2007-09-18 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-17 20:17 [RFA/ia64] Limit prologue scanning to end of function Joel Brobecker
2007-09-17 22:04 ` Jim Blandy
2007-09-18 23:50   ` Joel Brobecker

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