From: Joel Brobecker <brobecker@adacore.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Fix "break foo" when `foo's prologue ends before line table
Date: Mon, 11 May 2009 12:56:00 -0000 [thread overview]
Message-ID: <20090511125644.GD14773@adacore.com> (raw)
In-Reply-To: <83skjebbef.fsf@gnu.org>
> Line table:
>
> line 6 at 0x1748
> line 8 at 0x1750
> line 9 at 0x1756
> line 11 at 0x176b
> line 13 at 0x177b
> line 14 at 0x1780
[...]
> Here's the disassembly of `main', in case someone thinks that
> skip_prologue function didn't do a good job (I think it did a
> reasonable job, but I'm far from being an expert on prologue
> analysis):
Here is what the prologue looks like:
> Dump of assembler code for function main:
> 0x0000172c <main+0>: push %ebp
> 0x0000172d <main+1>: mov %esp,%ebp
> 0x0000172f <main+3>: sub $0x8,%esp
> 0x00001732 <main+6>: and $0xfffffff0,%esp
[this is where GDB thinks the prologue stops]
> 0x00001735 <main+9>: mov $0x0,%eax
> 0x0000173a <main+14>: add $0xf,%eax
> 0x0000173d <main+17>: add $0xf,%eax
> 0x00001740 <main+20>: shr $0x4,%eax
> 0x00001743 <main+23>: shl $0x4,%eax
> 0x00001746 <main+26>: sub %eax,%esp
[this is the last instruction before the first line of code
according to the line table]
Regarding your question above, it really depends on whether you
consider the second part of the code above as prologue or not.
What the code above does is making sure that the stack is properly
aligned. I am sure that some people would want to consider this
as part of the prologue, and I wouldn't disagree, but others
could argue the opposite, and I wouldn't disagree either.
Regardless of that, however, we should really look at what
"break FUNCTION" is supposed to be doing. And looking at the doc,
it says: ``Specifies the line that begins the body of the function''
(this matches what I thought it should be doing intuitively).
So, regardless of what GDB should be doing in terms of prologue
analysis, I think we should still try to find the first line
as you're doing in your patch.
> + ALL_PSYMTABS (objfile, p)
> + {
> + if (FILENAME_CMP (symtab->filename, p->filename) != 0)
> + continue;
> + PSYMTAB_TO_SYMTAB (p);
> + }
> +
> + /* Loop over all symtabs for the function's file, looking for an
> + entry in a lineinfo table whose PC is in the range
> + [FUNC_START..FUNC_END] and whose line number is the smallest. */
> + ALL_SYMTABS (objfile, s)
I am wondering if this looping over all PSYMTAB and SYMTABs is really
necessary. Is the symtab associated to your symbol not sufficient?
Also, instead of returning the line whose number is the smallest,
I would return the smallest PC, as we're trying to skip the minimum
before inserting the breakpoint. This means that your iteration on
the line table can stop as soon as you've found a non-zero line
that's inside your function address range.
--
Joel
next prev parent reply other threads:[~2009-05-11 12:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-09 14:26 Eli Zaretskii
2009-05-11 12:56 ` Joel Brobecker [this message]
2009-05-11 18:21 ` Eli Zaretskii
2009-05-11 19:27 ` Joel Brobecker
2009-05-11 20:49 ` Eli Zaretskii
2009-05-11 21:20 ` Daniel Jacobowitz
2009-05-12 3:13 ` Eli Zaretskii
2009-05-11 21:28 ` Joel Brobecker
2009-05-16 11:18 ` Eli Zaretskii
2009-05-20 23:07 ` Joel Brobecker
2009-05-23 10:20 ` Eli Zaretskii
2009-05-25 7:26 ` Joel Brobecker
2009-05-11 19:42 ` Daniel Jacobowitz
2009-05-11 20:40 ` Eli Zaretskii
2009-05-11 21:19 ` Joel Brobecker
2009-05-12 3:09 ` Eli Zaretskii
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=20090511125644.GD14773@adacore.com \
--to=brobecker@adacore.com \
--cc=eliz@gnu.org \
--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