1# Copyright 2015-2023 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 16standard_testfile 17 18if {[skip_shlib_tests]} { 19 return 0 20} 21 22# Library file. 23set libname "${testfile}-lib" 24set srcfile_lib ${srcdir}/${subdir}/${libname}.c 25set binfile_lib [standard_output_file ${libname}.so] 26set lib_flags [list debug optimize=-O2] 27# Binary file. 28set testfile "${testfile}-main" 29set srcfile ${srcdir}/${subdir}/${testfile}.c 30set binfile [standard_output_file ${testfile}] 31set bin_flags [list debug shlib=${binfile_lib}] 32 33if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" 34 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { 35 untested "failed to compile" 36 return -1 37} 38 39clean_restart ${binfile} 40gdb_load_shlib $binfile_lib 41 42if {![runto_main]} { 43 return 0 44} 45 46set test "first-hit" 47gdb_test_multiple "step" $test { 48 -re -wrap " first-hit .*" { 49 pass $gdb_test_name 50 } 51 -re -wrap " first-retry .*" { 52 send_gdb "step\n" 53 exp_continue 54 } 55 -re -wrap "get_pc_thunk.*" { 56 send_gdb "step\n" 57 exp_continue 58 } 59} 60 61set in_second 0 62set test "second-hit" 63gdb_test_multiple "step" $test { 64 -re -wrap " first-retry .*" { 65 if { $in_second } { 66 fail $gdb_test_name 67 } else { 68 send_gdb "step\n" 69 exp_continue 70 } 71 } 72 -re -wrap " first-hit .*" { 73 if { $in_second } { 74 fail $gdb_test_name 75 } else { 76 send_gdb "step\n" 77 exp_continue 78 } 79 } 80 -re -wrap " second-hit .*" { 81 pass $gdb_test_name 82 } 83 -re -wrap " second-retry .*" { 84 set in_second 1 85 send_gdb "step\n" 86 exp_continue 87 } 88 -re -wrap "get_pc_thunk.*" { 89 set in_second 1 90 send_gdb "step\n" 91 exp_continue 92 } 93} 94 95if {![runto_main]} { 96 return 0 97} 98 99gdb_breakpoint "shlib_second" 100gdb_continue_to_breakpoint "second-hit" ".* (second-hit|second-retry) .*" 101