0cb11c4456520c2ccee2436d3baea77ac2da2c12
[external/binutils.git] / gdb / testsuite / gdb.opt / solib-intra-step.exp
1 # Copyright 2015-2017 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 standard_testfile
17
18 if {[skip_shlib_tests]} {
19     return 0
20 }
21
22 # Library file.
23 set libname "${testfile}-lib"
24 set srcfile_lib ${srcdir}/${subdir}/${libname}.c
25 set binfile_lib [standard_output_file ${libname}.so]
26 set lib_flags [list debug optimize=-O2]
27 # Binary file.
28 set testfile "${testfile}-main"
29 set srcfile ${srcdir}/${subdir}/${testfile}.c
30 set binfile [standard_output_file ${testfile}]
31 set bin_flags [list debug shlib=${binfile_lib}]
32
33 if [get_compiler_info] {
34     return -1
35 }
36
37 if { [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
43 clean_restart ${binfile}
44 gdb_load_shlib $binfile_lib
45
46 if ![runto_main] then {
47   return 0
48 }
49
50 set test "first-hit"
51 gdb_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
60 set test "second-hit"
61 gdb_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
81 if ![runto_main] then {
82   return 0
83 }
84
85 gdb_breakpoint "shlib_second"
86 gdb_continue_to_breakpoint "second-hit" ".* (second-hit|second-retry) .*"