From: Daniel Jacobowitz <drow@false.org>
To: Jonathan Larmour <jifl@eCosCentric.com>
Cc: gdb@sourceware.org
Subject: Re: Broken prologue skipping with non-returning function
Date: Mon, 22 Sep 2008 14:57:00 -0000 [thread overview]
Message-ID: <20080922145617.GA521@caradoc.them.org> (raw)
In-Reply-To: <48D3F6D5.30503@eCosCentric.com>
On Fri, Sep 19, 2008 at 08:00:37PM +0100, Jonathan Larmour wrote:
> I can check in your change too. If so, presumably you already have a
> ChangeLog entry you'd like me to use to ease your merges?
>
> Jifl
>
> 2008-09-19 Jonathan Larmour <jifl@eCosCentric.com>
>
> * arm-tdep.c (arm_skip_prologue): Call skip_prologue_using_sal
> instead of determining symbol and line info directly.
This patch is OK. Here's mine again, with changelog; I committed it.
Both patches, in essentially the same form, have been in
CodeSourcery's tree for two years. So I'm quite confident in them,
as far as GCC goes, and it's clearly an improvement from the ad-hoc
line check in arm-tdep.c. skip_prologue_using_sal does have some
limitations; it's risky with incorrect debug info, and it's a problem
for non-GCC compilers that do not emit the duplicate line note.
More on that, some other time.
--
Daniel Jacobowitz
CodeSourcery
2008-09-22 Daniel Jacobowitz <dan@codesourcery.com>
* symtab.c (skip_prologue_using_sal): Treat two consecutive lines
at the same address as a prologue marker. Do not skip an entire
function.
--- symtab.c 2008-09-05 10:11:13.000000000 -0400
+++ symtab.c 2008-09-19 10:46:03.000000000 -0400
@@ -4198,6 +4235,7 @@ skip_prologue_using_sal (CORE_ADDR func_
struct symtab_and_line prologue_sal;
CORE_ADDR start_pc;
CORE_ADDR end_pc;
+ struct block *bl;
/* Get an initial range for the function. */
find_pc_partial_function (func_addr, NULL, &start_pc, &end_pc);
@@ -4206,11 +4244,35 @@ skip_prologue_using_sal (CORE_ADDR func_
prologue_sal = find_pc_line (start_pc, 0);
if (prologue_sal.line != 0)
{
+ /* For langauges other than assembly, treat two consecutive line
+ entries at the same address as a zero-instruction prologue.
+ The GNU assembler emits separate line notes for each instruction
+ in a multi-instruction macro, but compilers generally will not
+ do this. */
+ if (prologue_sal.symtab->language != language_asm)
+ {
+ struct linetable *linetable = LINETABLE (prologue_sal.symtab);
+ int exact;
+ int idx = 0;
+
+ /* Skip any earlier lines, and any end-of-sequence marker
+ from a previous function. */
+ while (linetable->item[idx].pc != prologue_sal.pc
+ || linetable->item[idx].line == 0)
+ idx++;
+
+ if (idx+1 < linetable->nitems
+ && linetable->item[idx+1].line != 0
+ && linetable->item[idx+1].pc == start_pc)
+ return start_pc;
+ }
+
/* If there is only one sal that covers the entire function,
then it is probably a single line function, like
"foo(){}". */
if (prologue_sal.end >= end_pc)
return 0;
+
while (prologue_sal.end < end_pc)
{
struct symtab_and_line sal;
@@ -4232,7 +4313,14 @@ skip_prologue_using_sal (CORE_ADDR func_
prologue_sal = sal;
}
}
- return prologue_sal.end;
+
+ if (prologue_sal.end < end_pc)
+ /* Return the end of this line, or zero if we could not find a
+ line. */
+ return prologue_sal.end;
+ else
+ /* Don't return END_PC, which is past the end of the function. */
+ return prologue_sal.pc;
}
\f
struct symtabs_and_lines
next prev parent reply other threads:[~2008-09-22 14:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 14:34 Jonathan Larmour
2008-09-19 15:00 ` Daniel Jacobowitz
2008-09-19 19:01 ` Jonathan Larmour
2008-09-19 19:14 ` Daniel Jacobowitz
2008-09-22 14:57 ` Daniel Jacobowitz [this message]
2008-09-22 15:05 ` Jonathan Larmour
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=20080922145617.GA521@caradoc.them.org \
--to=drow@false.org \
--cc=gdb@sourceware.org \
--cc=jifl@eCosCentric.com \
/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