* [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too
@ 2012-03-13 22:58 Kevin Buettner
2012-03-13 23:25 ` Pedro Alves
2012-03-21 22:01 ` Kevin Buettner
0 siblings, 2 replies; 5+ messages in thread
From: Kevin Buettner @ 2012-03-13 22:58 UTC (permalink / raw)
To: gdb-patches
I'm seeing failures in gdb.cp/koenig.exp for targets which define a
``skip_main_prologue'' gdbarch method. It turns out, however, that
most other C++ tests which run to main are not running to the correct
location either. (The test results don't show this though.)
Here is the relevant part of the log file for gdb.cp/koenig.exp for
frv-elf showing this behavior:
Breakpoint 1, main () at /ironwood1/sourceware-clean/frv-elf/../src/gdb/testsuite/gdb.cp/koenig.cc:246
246 {
(gdb) p first(c)
No symbol "c" in current context.
Note that the breakpoint did not correctly end up at the first line of
the function body.
When I look at the code in question with gdb, I see that a comparison
is being made between "main()" and "main" and is (obviously) failing.
Does the patch below look reasonable?
Kevin
* symtab.c (skip_prologue_sal): Change test to check for "main()"
in addition to "main".
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.298
diff -u -p -r1.298 symtab.c
--- symtab.c 1 Mar 2012 21:13:59 -0000 1.298
+++ symtab.c 13 Mar 2012 22:32:49 -0000
@@ -2776,7 +2776,7 @@ skip_prologue_sal (struct symtab_and_lin
to `__main' in `main' between the prologue and before user
code. */
if (gdbarch_skip_main_prologue_p (gdbarch)
- && name && strcmp (name, "main") == 0)
+ && name && strcmp_iw (name, "main") == 0)
{
pc = gdbarch_skip_main_prologue (gdbarch, pc);
/* Recalculate the line number (might not be N+1). */
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too
2012-03-13 22:58 [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too Kevin Buettner
@ 2012-03-13 23:25 ` Pedro Alves
2012-03-14 9:02 ` Jan Kratochvil
2012-03-21 22:01 ` Kevin Buettner
1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2012-03-13 23:25 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
On 03/13/2012 10:58 PM, Kevin Buettner wrote:
> I'm seeing failures in gdb.cp/koenig.exp for targets which define a
> ``skip_main_prologue'' gdbarch method. It turns out, however, that
> most other C++ tests which run to main are not running to the correct
> location either. (The test results don't show this though.)
>
> Here is the relevant part of the log file for gdb.cp/koenig.exp for
> frv-elf showing this behavior:
>
> Breakpoint 1, main () at /ironwood1/sourceware-clean/frv-elf/../src/gdb/testsuite/gdb.cp/koenig.cc:246
> 246 {
> (gdb) p first(c)
> No symbol "c" in current context.
>
> Note that the breakpoint did not correctly end up at the first line of
> the function body.
>
> When I look at the code in question with gdb, I see that a comparison
> is being made between "main()" and "main" and is (obviously) failing.
>
I'm going to guess this is fallback from physname. The code looked like
this when it was originally added:
+ /* On targets with executable formats that don't have a concept of
+ constructors (ELF with .init has, PE doesn't), gcc emits a call
+ to `__main' in `main' between the prologue and before user
+ code. */
+ if (funfirstline
+ && gdbarch_skip_main_prologue_p (current_gdbarch)
+ && SYMBOL_LINKAGE_NAME (sym)
+ && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
And SYMBOL_LINKAGE_NAME (sym) used to be "main" for C++ too.
> Does the patch below look reasonable?
Looks reasonable to me...
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too
2012-03-13 23:25 ` Pedro Alves
@ 2012-03-14 9:02 ` Jan Kratochvil
2012-03-21 22:08 ` Kevin Buettner
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2012-03-14 9:02 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches, Keith Seitz, Pedro Alves
On Wed, 14 Mar 2012 00:24:59 +0100, Pedro Alves wrote:
> I'm going to guess this is fallback from physname. The code looked like
> this when it was originally added:
>
> + /* On targets with executable formats that don't have a concept of
> + constructors (ELF with .init has, PE doesn't), gcc emits a call
> + to `__main' in `main' between the prologue and before user
> + code. */
> + if (funfirstline
> + && gdbarch_skip_main_prologue_p (current_gdbarch)
> + && SYMBOL_LINKAGE_NAME (sym)
> + && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
>
> And SYMBOL_LINKAGE_NAME (sym) used to be "main" for C++ too.
This is:
regression by physname: PE32 prologue skip vs. static initializers
http://sourceware.org/bugzilla/show_bug.cgi?id=12680
I would welcome also a testcase, though.
Thanks,
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too
2012-03-14 9:02 ` Jan Kratochvil
@ 2012-03-21 22:08 ` Kevin Buettner
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Buettner @ 2012-03-21 22:08 UTC (permalink / raw)
To: gdb-patches
On Wed, 14 Mar 2012 10:02:28 +0100
Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> On Wed, 14 Mar 2012 00:24:59 +0100, Pedro Alves wrote:
> > I'm going to guess this is fallback from physname. The code looked like
> > this when it was originally added:
> >
> > + /* On targets with executable formats that don't have a concept of
> > + constructors (ELF with .init has, PE doesn't), gcc emits a call
> > + to `__main' in `main' between the prologue and before user
> > + code. */
> > + if (funfirstline
> > + && gdbarch_skip_main_prologue_p (current_gdbarch)
> > + && SYMBOL_LINKAGE_NAME (sym)
> > + && strcmp (SYMBOL_LINKAGE_NAME (sym), "main") == 0)
> >
> > And SYMBOL_LINKAGE_NAME (sym) used to be "main" for C++ too.
>
> This is:
> regression by physname: PE32 prologue skip vs. static initializers
> http://sourceware.org/bugzilla/show_bug.cgi?id=12680
>
> I would welcome also a testcase, though.
While it wasn't really designed to test this case, gdb.cp/koenig.exp
does provide a test as the resulting failures are due to not executing
everything up to the first line in the body of main().
If you wanted a more direct test, all that's needed is to place a
breakpoint in main() in a C++ program and make sure that this
breakpoint ends up being placed on the first line of the function
body.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too
2012-03-13 22:58 [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too Kevin Buettner
2012-03-13 23:25 ` Pedro Alves
@ 2012-03-21 22:01 ` Kevin Buettner
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Buettner @ 2012-03-21 22:01 UTC (permalink / raw)
To: gdb-patches
On Tue, 13 Mar 2012 15:58:17 -0700
Kevin Buettner <kevinb@redhat.com> wrote:
> * symtab.c (skip_prologue_sal): Change test to check for "main()"
> in addition to "main".
Committed.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-21 22:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 22:58 [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too Kevin Buettner
2012-03-13 23:25 ` Pedro Alves
2012-03-14 9:02 ` Jan Kratochvil
2012-03-21 22:08 ` Kevin Buettner
2012-03-21 22:01 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox