1 # Copyright 2023-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test that a very long file is ok.
18 load_lib gdb-python.exp
19 require allow_python_tests
23 # Create a source file with many lines.
24 set c_file [standard_output_file $srcfile]
26 set chan [open $c_file w]
27 puts $chan "int callee (int x) { return x; }"
28 for {set i 2} {$i < 65538} {incr i} {
29 puts $chan "int call$i () { return callee ($i); }"
31 puts $chan "int main() { return call65537(); }"
34 if {[prepare_for_testing "failed to prepare" ${testfile} \
35 [list $c_file] {debug}]} {
39 if {![runto callee]} {
43 gdb_test "print x" " = 65537"
45 # This doesn't actually demonstrate the bug, because it takes a code
46 # path not checking symbol::line.
47 gdb_test "frame 1" "call65537.*lotsa-lines.c:65537.*"
49 # This is the simplest way to see the problem.
50 gdb_test "python print(gdb.selected_frame().function().line)" "65537" \
51 "print function line number"