1 1.10 christos # Copyright 2009-2023 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # This file is part of the GDB testsuite. It tests reverse debugging 17 1.1 christos # with shared libraries. 18 1.1 christos 19 1.1 christos if ![supports_reverse] { 20 1.1 christos return 21 1.1 christos } 22 1.1 christos if {[skip_shlib_tests]} { 23 1.1 christos return 24 1.1 christos } 25 1.1 christos 26 1.1 christos standard_testfile 27 1.1 christos set lib1file "shr1" 28 1.1 christos set lib1src ${lib1file}.c 29 1.1 christos set library1 [standard_output_file ${lib1file}.sl] 30 1.1 christos set lib2file "shr2" 31 1.1 christos set lib2src ${lib2file}.c 32 1.1 christos set library2 [standard_output_file ${lib2file}.sl] 33 1.1 christos 34 1.1 christos # Compile the first without debug info so that 35 1.1 christos # stepping and reverse stepping doesn't end up inside them. 36 1.1 christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } { 37 1.7 christos untested "failed to compile shared library 1" 38 1.1 christos return -1 39 1.1 christos } 40 1.1 christos 41 1.1 christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } { 42 1.7 christos untested "failed to compile shared library 2" 43 1.1 christos return -1 44 1.1 christos } 45 1.1 christos 46 1.1 christos set exec_opts [list debug shlib=${library1} shlib=${library2}] 47 1.1 christos 48 1.1 christos if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { 49 1.7 christos untested "failed to compile" 50 1.1 christos return -1 51 1.1 christos } 52 1.1 christos 53 1.1 christos # Start with a fresh gdb. 54 1.1 christos 55 1.1 christos gdb_exit 56 1.1 christos gdb_start 57 1.1 christos 58 1.1 christos # Note: The test previously did "set debug-file-directory" to (try to) 59 1.1 christos # ensure the debug info for the dynamic loader and libc weren't found. 60 1.1 christos # This doesn't work if the debug info is in the .debug subdirectory. 61 1.1 christos # Avoiding debug info for system libraries is not germaine to this test 62 1.1 christos # and is no longer attempted. Instead, the test does not make assumptions 63 1.1 christos # about whether the debug info is present or not. 64 1.1 christos 65 1.1 christos gdb_reinitialize_dir $srcdir/$subdir 66 1.1 christos gdb_load ${binfile} 67 1.6 christos gdb_load_shlib $library1 68 1.6 christos gdb_load_shlib $library2 69 1.1 christos 70 1.10 christos runto_main 71 1.1 christos 72 1.1 christos if [supports_process_record] { 73 1.1 christos # Activate process record/replay 74 1.7 christos gdb_test_no_output "record" "turn on process record" 75 1.1 christos } 76 1.1 christos 77 1.1 christos # 78 1.1 christos # Test reverse-step over undebuggable solib functions. 79 1.1 christos # 80 1.1 christos 81 1.1 christos # Run forward past some solib function calls. 82 1.1 christos 83 1.1 christos set end_part_one [gdb_get_line_number " end part one" "$srcfile"] 84 1.1 christos set end_part_two [gdb_get_line_number " end part two" "$srcfile"] 85 1.9 christos gdb_test_multiple "until $end_part_one" "run until end part one" { 86 1.9 christos -wrap -re " end part one.*" { 87 1.9 christos pass $gdb_test_name 88 1.9 christos } 89 1.9 christos -wrap -re "Process record does not support instruction 0xfae64 at.*" { 90 1.9 christos kfail "gdb/25038" $gdb_test_name 91 1.9 christos return -1 92 1.9 christos } 93 1.9 christos } 94 1.1 christos 95 1.1 christos gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1" 96 1.1 christos gdb_test "reverse-step" " shr1 two .*" "reverse-step second shr1" 97 1.1 christos gdb_test "reverse-step" " shr1 one .*" "reverse-step first shr1" 98 1.1 christos 99 1.1 christos gdb_test "reverse-step" " generic statement.*" "reverse-step generic" 100 1.1 christos 101 1.1 christos 102 1.1 christos # 103 1.1 christos # Test reverse-next over undebuggable solib functions. 104 1.1 christos # 105 1.1 christos 106 1.1 christos # Run forward again... 107 1.1 christos 108 1.1 christos gdb_test "until $end_part_one" " end part one.*" "forward to end part one" 109 1.1 christos 110 1.1 christos gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1" 111 1.1 christos gdb_test "reverse-next" " shr1 two .*" "reverse-next second shr1" 112 1.1 christos gdb_test "reverse-next" " shr1 one .*" "reverse-next first shr1" 113 1.1 christos 114 1.1 christos gdb_test "reverse-next" " generic statement.*" "reverse-next generic" 115 1.1 christos 116 1.1 christos 117 1.1 christos # 118 1.1 christos # Test reverse-step into debuggable solib function 119 1.1 christos # 120 1.1 christos 121 1.9 christos gdb_test_multiple "reverse-step" "reverse-step into solib function one" { 122 1.9 christos -re -wrap "middle part two.*" { 123 1.9 christos send_gdb "reverse-step\n" 124 1.9 christos exp_continue 125 1.9 christos } 126 1.9 christos -re -wrap "${lib2src}.*" { 127 1.9 christos pass $gdb_test_name 128 1.9 christos } 129 1.9 christos } 130 1.1 christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" 131 1.1 christos gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" 132 1.1 christos 133 1.9 christos gdb_test_multiple "reverse-step" "reverse-step into solib function two" { 134 1.9 christos -re -wrap "begin part two.*" { 135 1.9 christos send_gdb "reverse-step\n" 136 1.9 christos exp_continue 137 1.9 christos } 138 1.9 christos -re -wrap "${lib2src}.*" { 139 1.9 christos pass $gdb_test_name 140 1.9 christos } 141 1.9 christos } 142 1.1 christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" 143 1.1 christos gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" 144 1.1 christos 145 1.1 christos # 146 1.1 christos # Test reverse-next over debuggable solib function 147 1.1 christos # 148 1.1 christos 149 1.1 christos gdb_test "until $end_part_two" " end part two.*" "run until end part two" 150 1.1 christos 151 1.1 christos gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one" 152 1.9 christos gdb_test_multiple "reverse-next" "reverse-next over solib function two" { 153 1.9 christos -re -wrap "middle part two.*" { 154 1.9 christos send_gdb "reverse-next\n" 155 1.9 christos exp_continue 156 1.9 christos } 157 1.9 christos -re -wrap " begin part two.*" { 158 1.9 christos pass $gdb_test_name 159 1.9 christos } 160 1.9 christos } 161