From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA/ia64] Limit prologue scanning to end of function
Date: Mon, 17 Sep 2007 20:17:00 -0000 [thread overview]
Message-ID: <20070917201744.GB2598@adacore.com> (raw)
[-- 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;
next reply other threads:[~2007-09-17 20:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-17 20:17 Joel Brobecker [this message]
2007-09-17 22:04 ` Jim Blandy
2007-09-18 23:50 ` Joel Brobecker
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=20070917201744.GB2598@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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