]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/frame.c
GDB: Favor full symbol main name for backtrace stop
authorRichard Bunt <richard.bunt@linaro.org>
Fri, 31 Mar 2023 14:31:40 +0000 (15:31 +0100)
committerMaciej W. Rozycki <macro@embecosm.com>
Fri, 31 Mar 2023 14:31:40 +0000 (15:31 +0100)
commit571eb2644c7a52a78250ce9906d9c5127006e164
tree707e57fbf03d7930e96e711a86ec3503e124b5dd
parent85413975d80cdb69efd09211d01fc96e00a84dd0
GDB: Favor full symbol main name for backtrace stop

In the case where a Fortran program has a program name of "main" and
there is also a minimal symbol called main, such as with programs built
with GCC version 4.4.7 or below, the backtrace will erroneously stop at
the minimal symbol rather than the user specified main, e.g.:

(gdb) bt
#0  bar () at .../gdb/testsuite/gdb.fortran/backtrace.f90:17
#1  0x0000000000402556 in foo () at .../gdb/testsuite/gdb.fortran/backtrace.f90:21
#2  0x0000000000402575 in main () at .../gdb/testsuite/gdb.fortran/backtrace.f90:31
#3  0x00000000004025aa in main ()
(gdb)

This patch fixes this issue by increasing the precedence of the full
symbol when the language of the current frame is Fortran.

Newer versions of GCC transform the program name to "MAIN__" in this
case, avoiding the problem.

Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
gdb/frame.c
gdb/testsuite/gdb.fortran/backtrace.exp [new file with mode: 0644]
gdb/testsuite/gdb.fortran/backtrace.f90 [new file with mode: 0644]