1# Copyright 2015-2020 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 [get_compiler_info] { 34 return -1 35} 36 37if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" 38 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { 39 untested "failed to compile" 40 return -1 41} 42 43clean_restart ${binfile} 44gdb_load_shlib $binfile_lib 45 46if ![runto_main] then { 47 return 0 48} 49 50set test "first-hit" 51gdb_test_multiple "step" $test { 52 -re " first-hit .*\r\n$gdb_prompt $" { 53 pass $test 54 } 55 -re " first-retry .*\r\n$gdb_prompt $" { 56 gdb_test "step" " first-hit .*" "first-hit (optimized)" 57 } 58} 59 60set test "second-hit" 61gdb_test_multiple "step" $test { 62 -re " second-hit .*\r\n$gdb_prompt $" { 63 pass $test 64 } 65 -re " first-retry .*\r\n$gdb_prompt $" { 66 set test "second-hit (optimized 1)" 67 gdb_test_multiple "step" $test { 68 -re " second-hit .*\r\n$gdb_prompt $" { 69 pass $test 70 } 71 -re " first-hit .*\r\n$gdb_prompt $" { 72 gdb_test "step" " second-hit .*" "second-hit (optimized 2)" 73 } 74 } 75 } 76 -re " second-retry .*\r\n$gdb_prompt $" { 77 gdb_test "step" " second-hit .*" "second-hit (optimized 3)" 78 } 79} 80 81if ![runto_main] then { 82 return 0 83} 84 85gdb_breakpoint "shlib_second" 86gdb_continue_to_breakpoint "second-hit" ".* (second-hit|second-retry) .*" 87