1 1.7 christos # Copyright 2009-2017 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 if [get_compiler_info] { 35 1.1 christos return -1 36 1.1 christos } 37 1.1 christos 38 1.1 christos # Compile the first without debug info so that 39 1.1 christos # stepping and reverse stepping doesn't end up inside them. 40 1.1 christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } { 41 1.7 christos untested "failed to compile shared library 1" 42 1.1 christos return -1 43 1.1 christos } 44 1.1 christos 45 1.1 christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } { 46 1.7 christos untested "failed to compile shared library 2" 47 1.1 christos return -1 48 1.1 christos } 49 1.1 christos 50 1.1 christos set exec_opts [list debug shlib=${library1} shlib=${library2}] 51 1.1 christos 52 1.1 christos if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { 53 1.7 christos untested "failed to compile" 54 1.1 christos return -1 55 1.1 christos } 56 1.1 christos 57 1.1 christos # Start with a fresh gdb. 58 1.1 christos 59 1.1 christos gdb_exit 60 1.1 christos gdb_start 61 1.1 christos 62 1.1 christos # Note: The test previously did "set debug-file-directory" to (try to) 63 1.1 christos # ensure the debug info for the dynamic loader and libc weren't found. 64 1.1 christos # This doesn't work if the debug info is in the .debug subdirectory. 65 1.1 christos # Avoiding debug info for system libraries is not germaine to this test 66 1.1 christos # and is no longer attempted. Instead, the test does not make assumptions 67 1.1 christos # about whether the debug info is present or not. 68 1.1 christos 69 1.1 christos gdb_reinitialize_dir $srcdir/$subdir 70 1.1 christos gdb_load ${binfile} 71 1.6 christos gdb_load_shlib $library1 72 1.6 christos gdb_load_shlib $library2 73 1.1 christos 74 1.1 christos runto main 75 1.1 christos 76 1.1 christos if [supports_process_record] { 77 1.1 christos # Activate process record/replay 78 1.7 christos gdb_test_no_output "record" "turn on process record" 79 1.1 christos } 80 1.1 christos 81 1.1 christos # 82 1.1 christos # Test reverse-step over undebuggable solib functions. 83 1.1 christos # 84 1.1 christos 85 1.1 christos # Run forward past some solib function calls. 86 1.1 christos 87 1.1 christos set end_part_one [gdb_get_line_number " end part one" "$srcfile"] 88 1.1 christos set end_part_two [gdb_get_line_number " end part two" "$srcfile"] 89 1.1 christos gdb_test "until $end_part_one" " end part one.*" "run until end part one" 90 1.1 christos 91 1.1 christos gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1" 92 1.1 christos gdb_test "reverse-step" " shr1 two .*" "reverse-step second shr1" 93 1.1 christos gdb_test "reverse-step" " shr1 one .*" "reverse-step first shr1" 94 1.1 christos 95 1.1 christos gdb_test "reverse-step" " generic statement.*" "reverse-step generic" 96 1.1 christos 97 1.1 christos 98 1.1 christos # 99 1.1 christos # Test reverse-next over undebuggable solib functions. 100 1.1 christos # 101 1.1 christos 102 1.1 christos # Run forward again... 103 1.1 christos 104 1.1 christos gdb_test "until $end_part_one" " end part one.*" "forward to end part one" 105 1.1 christos 106 1.1 christos gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1" 107 1.1 christos gdb_test "reverse-next" " shr1 two .*" "reverse-next second shr1" 108 1.1 christos gdb_test "reverse-next" " shr1 one .*" "reverse-next first shr1" 109 1.1 christos 110 1.1 christos gdb_test "reverse-next" " generic statement.*" "reverse-next generic" 111 1.1 christos 112 1.1 christos 113 1.1 christos # 114 1.1 christos # Test reverse-step into debuggable solib function 115 1.1 christos # 116 1.1 christos 117 1.1 christos gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function one" 118 1.1 christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" 119 1.1 christos gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" 120 1.1 christos 121 1.1 christos gdb_test "reverse-step" "${lib2src}.*" "reverse-step into solib function two" 122 1.1 christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" 123 1.1 christos gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" 124 1.1 christos 125 1.1 christos # 126 1.1 christos # Test reverse-next over debuggable solib function 127 1.1 christos # 128 1.1 christos 129 1.1 christos gdb_test "until $end_part_two" " end part two.*" "run until end part two" 130 1.1 christos 131 1.1 christos gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one" 132 1.1 christos gdb_test "reverse-next" " begin part two.*" "reverse-next over solib function two" 133