Files
binutils-gdb/gdb/testsuite/gdb.fortran/backtrace.exp
Richard Bunt 571eb2644c 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>
2023-03-31 15:31:40 +01:00

39 lines
1.2 KiB
Plaintext

# Copyright 2023 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require allow_fortran_tests
load_lib fortran.exp
standard_testfile .f90
if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}]} {
return -1
}
if {![fortran_runto_main]} {
perror "Could not run to main."
return
}
gdb_breakpoint [gdb_get_line_number "Break here"]
gdb_continue_to_breakpoint "continue to bar"
gdb_test "bt" \
[multi_line \
"#0\[ \t\]*bar \\(\\) at \[^\r\n\]+" \
"#1\[ \t\]*$hex in foo \\(\\) at \[^\r\n\]+" \
"#2\[ \t\]*$hex in \(?:MAIN__\|main\) \\(\\) at \[^\r\n\]+" ]