Re: [RFC] symtab.c: Change skip_prologue_sal comparison to match main() too

Pedro Alves
2012-03-13T23:25:19Z

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