1 # Copyright 2014-2025 Free Software Foundation, Inc. 2 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. 7 # 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. 12 # 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/>. 15 16 # This file is part of the gdb testsuite 17 18 set additional_flags "" 19 20 require allow_cplus_tests 21 22 standard_testfile .cc 23 24 set i1 i1 25 set i2 i2 26 27 if {[have_fvar_tracking]} { 28 set additional_flags "additional_flags= -fvar-tracking" 29 30 if { [gcc_major_version] < 14 } { 31 # For armv7, target board unix/-mthumb, -fvar-tracking and gcc 13 we 32 # get incorrect location info. Work around this by using constants instead. 33 set i1 23 34 set i2 100 35 } 36 } 37 38 if {[prepare_for_testing "failed to prepare" $testfile $srcfile [list debug c++ $additional_flags]]} { 39 40 return -1 41 } 42 43 if {![runto_main]} { 44 return -1 45 } 46 47 gdb_breakpoint [gdb_get_line_number "Break here"] 48 gdb_continue_to_breakpoint "Break here" 49 50 gdb_test "p f1 ($i1, $i2)" ".* = {a = 123}" \ 51 "p f1 (i1, i2)" 52 gdb_test "p f2 ($i1, $i2)" ".* = {b = 123}" \ 53 "p f2 (i1, i2)" 54 gdb_test "p f22 ($i1, $i2)" ".* = {b1 = 123}" \ 55 "p f22 (i1, i2)" 56 gdb_test "p f3 ($i1, $i2)" ".* = {.* c = 123}" \ 57 "p f3 (i1, i2)" 58 gdb_test "p f4 ($i1, $i2)" ".* = {.* e = 123}" \ 59 "p f4 (i1, i2)" 60 gdb_test "p f5 ($i1, $i2)" ".* = {f = 123}" \ 61 "p f5 (i1, i2)" 62 63 gdb_breakpoint "f1" 64 gdb_breakpoint "f2" 65 gdb_breakpoint "f22" 66 gdb_breakpoint "f3" 67 gdb_breakpoint "f4" 68 gdb_breakpoint "f5" 69 70 gdb_continue_to_breakpoint "Break in f1" 71 gdb_test "finish" " = {a = 123}" \ 72 "finish from f1" 73 74 gdb_continue_to_breakpoint "Break in f2" 75 gdb_test "finish" " = {b = 123}" \ 76 "finish from f2" 77 78 gdb_continue_to_breakpoint "Break in f22" 79 gdb_test "finish" " = {b1 = 123}" \ 80 "finish from f22" 81 82 gdb_continue_to_breakpoint "Break in f3" 83 gdb_test "finish" " = {.* c = 123}" \ 84 "finish from f3" 85 86 gdb_continue_to_breakpoint "Break in f4" 87 gdb_test "finish" " = {.* e = 123}" \ 88 "finish from f4" 89 90 gdb_continue_to_breakpoint "Break in f5" 91 gdb_test "finish" " = {f = 123}" \ 92 "finish from f5" 93