Home | History | Annotate | Line # | Download | only in gdb.reverse
solib-reverse.exp revision 1.9
      1  1.9  christos # Copyright 2009-2020 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.9  christos gdb_test_multiple "until $end_part_one" "run until end part one" {
     90  1.9  christos     -wrap -re " end part one.*" {
     91  1.9  christos 	pass $gdb_test_name
     92  1.9  christos     }
     93  1.9  christos     -wrap -re "Process record does not support instruction 0xfae64 at.*" {
     94  1.9  christos 	kfail "gdb/25038" $gdb_test_name
     95  1.9  christos 	return -1
     96  1.9  christos     }
     97  1.9  christos }
     98  1.1  christos 
     99  1.1  christos gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1"
    100  1.1  christos gdb_test "reverse-step" " shr1 two .*"   "reverse-step second shr1"
    101  1.1  christos gdb_test "reverse-step" " shr1 one .*"   "reverse-step first shr1"
    102  1.1  christos 
    103  1.1  christos gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
    104  1.1  christos 
    105  1.1  christos 
    106  1.1  christos #
    107  1.1  christos # Test reverse-next over undebuggable solib functions.
    108  1.1  christos #
    109  1.1  christos 
    110  1.1  christos # Run forward again...
    111  1.1  christos 
    112  1.1  christos gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
    113  1.1  christos 
    114  1.1  christos gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1"
    115  1.1  christos gdb_test "reverse-next" " shr1 two .*"   "reverse-next second shr1"
    116  1.1  christos gdb_test "reverse-next" " shr1 one .*"   "reverse-next first shr1"
    117  1.1  christos 
    118  1.1  christos gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
    119  1.1  christos 
    120  1.1  christos 
    121  1.1  christos #
    122  1.1  christos # Test reverse-step into debuggable solib function
    123  1.1  christos #
    124  1.1  christos 
    125  1.9  christos gdb_test_multiple "reverse-step" "reverse-step into solib function one" {
    126  1.9  christos     -re -wrap "middle part two.*" {
    127  1.9  christos 	send_gdb "reverse-step\n"
    128  1.9  christos 	exp_continue
    129  1.9  christos     }
    130  1.9  christos     -re -wrap "${lib2src}.*" {
    131  1.9  christos 	pass $gdb_test_name
    132  1.9  christos     }
    133  1.9  christos }
    134  1.1  christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one"
    135  1.1  christos gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one"
    136  1.1  christos 
    137  1.9  christos gdb_test_multiple "reverse-step" "reverse-step into solib function two" {
    138  1.9  christos     -re -wrap "begin part two.*" {
    139  1.9  christos 	send_gdb "reverse-step\n"
    140  1.9  christos 	exp_continue
    141  1.9  christos     }
    142  1.9  christos     -re -wrap "${lib2src}.*" {
    143  1.9  christos 	pass $gdb_test_name
    144  1.9  christos     }
    145  1.9  christos }
    146  1.1  christos gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two"
    147  1.1  christos gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two"
    148  1.1  christos 
    149  1.1  christos #
    150  1.1  christos # Test reverse-next over debuggable solib function
    151  1.1  christos #
    152  1.1  christos 
    153  1.1  christos gdb_test "until $end_part_two" " end part two.*" "run until end part two"
    154  1.1  christos 
    155  1.1  christos gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
    156  1.9  christos gdb_test_multiple "reverse-next" "reverse-next over solib function two" {
    157  1.9  christos     -re -wrap "middle part two.*" {
    158  1.9  christos 	send_gdb "reverse-next\n"
    159  1.9  christos 	exp_continue
    160  1.9  christos     }
    161  1.9  christos     -re -wrap " begin part two.*" {
    162  1.9  christos 	pass $gdb_test_name
    163  1.9  christos     }
    164  1.9  christos }
    165