Home | History | Annotate | Line # | Download | only in gdb.reverse
solib-reverse.exp revision 1.11
      1  1.11  christos # Copyright 2009-2024 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.11  christos require supports_reverse allow_shlib_tests
     20   1.1  christos 
     21   1.1  christos standard_testfile
     22   1.1  christos set lib1file "shr1"
     23   1.1  christos set lib1src  ${lib1file}.c
     24   1.1  christos set library1 [standard_output_file ${lib1file}.sl]
     25   1.1  christos set lib2file "shr2"
     26   1.1  christos set lib2src  ${lib2file}.c
     27   1.1  christos set library2 [standard_output_file ${lib2file}.sl]
     28   1.1  christos 
     29   1.1  christos # Compile the first without debug info so that
     30   1.1  christos # stepping and reverse stepping doesn't end up inside them.
     31   1.1  christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1src} ${library1} ""] != "" } {
     32   1.7  christos     untested "failed to compile shared library 1"
     33   1.1  christos     return -1
     34   1.1  christos }
     35   1.1  christos 
     36   1.1  christos if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2src} ${library2} "debug"] != "" } {
     37   1.7  christos     untested "failed to compile shared library 2"
     38   1.1  christos     return -1
     39   1.1  christos }
     40   1.1  christos 
     41   1.1  christos set exec_opts [list debug shlib=${library1} shlib=${library2}]
     42   1.1  christos 
     43   1.1  christos if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
     44   1.7  christos     untested "failed to compile"
     45   1.1  christos     return -1
     46   1.1  christos }
     47   1.1  christos 
     48   1.1  christos # Note: The test previously did "set debug-file-directory" to (try to)
     49   1.1  christos # ensure the debug info for the dynamic loader and libc weren't found.
     50   1.1  christos # This doesn't work if the debug info is in the .debug subdirectory.
     51   1.1  christos # Avoiding debug info for system libraries is not germaine to this test
     52   1.1  christos # and is no longer attempted.  Instead, the test does not make assumptions
     53   1.1  christos # about whether the debug info is present or not.
     54   1.1  christos 
     55  1.11  christos clean_restart $binfile
     56   1.6  christos gdb_load_shlib $library1
     57   1.6  christos gdb_load_shlib $library2
     58   1.1  christos 
     59  1.10  christos runto_main
     60   1.1  christos 
     61   1.1  christos if [supports_process_record] {
     62   1.1  christos     # Activate process record/replay
     63   1.7  christos     gdb_test_no_output "record" "turn on process record"
     64   1.1  christos }
     65   1.1  christos 
     66   1.1  christos #
     67   1.1  christos # Test reverse-step over undebuggable solib functions.
     68   1.1  christos #
     69   1.1  christos 
     70   1.1  christos # Run forward past some solib function calls.
     71   1.1  christos 
     72   1.1  christos set end_part_one [gdb_get_line_number " end part one" "$srcfile"]
     73   1.1  christos set end_part_two [gdb_get_line_number " end part two" "$srcfile"]
     74   1.9  christos gdb_test_multiple "until $end_part_one" "run until end part one" {
     75   1.9  christos     -wrap -re " end part one.*" {
     76   1.9  christos 	pass $gdb_test_name
     77   1.9  christos     }
     78   1.9  christos     -wrap -re "Process record does not support instruction 0xfae64 at.*" {
     79   1.9  christos 	kfail "gdb/25038" $gdb_test_name
     80   1.9  christos 	return -1
     81   1.9  christos     }
     82   1.9  christos }
     83   1.1  christos 
     84   1.1  christos gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1"
     85   1.1  christos gdb_test "reverse-step" " shr1 two .*"   "reverse-step second shr1"
     86   1.1  christos gdb_test "reverse-step" " shr1 one .*"   "reverse-step first shr1"
     87   1.1  christos 
     88   1.1  christos gdb_test "reverse-step" " generic statement.*" "reverse-step generic"
     89   1.1  christos 
     90   1.1  christos 
     91   1.1  christos #
     92   1.1  christos # Test reverse-next over undebuggable solib functions.
     93   1.1  christos #
     94   1.1  christos 
     95   1.1  christos # Run forward again...
     96   1.1  christos 
     97   1.1  christos gdb_test "until $end_part_one" " end part one.*" "forward to end part one"
     98   1.1  christos 
     99   1.1  christos gdb_test "reverse-next" " shr1 three .*" "reverse-next third shr1"
    100   1.1  christos gdb_test "reverse-next" " shr1 two .*"   "reverse-next second shr1"
    101   1.1  christos gdb_test "reverse-next" " shr1 one .*"   "reverse-next first shr1"
    102   1.1  christos 
    103   1.1  christos gdb_test "reverse-next" " generic statement.*" "reverse-next generic"
    104   1.1  christos 
    105   1.1  christos 
    106   1.1  christos #
    107   1.1  christos # Test reverse-step into debuggable solib function
    108   1.1  christos #
    109   1.1  christos 
    110   1.9  christos gdb_test_multiple "reverse-step" "reverse-step into solib function one" {
    111   1.9  christos     -re -wrap "middle part two.*" {
    112   1.9  christos 	send_gdb "reverse-step\n"
    113   1.9  christos 	exp_continue
    114   1.9  christos     }
    115   1.9  christos     -re -wrap "${lib2src}.*" {
    116   1.9  christos 	pass $gdb_test_name
    117   1.9  christos     }
    118   1.9  christos }
    119  1.11  christos # Depending on wether the closing } has a line associated, we might have
    120  1.11  christos # different acceptable results here
    121  1.11  christos gdb_test_multiple "reverse-step" "reverse-step within solib function one" {
    122  1.11  christos     -re -wrap "return y;.*" {
    123  1.11  christos 	pass $gdb_test_name
    124  1.11  christos     }
    125  1.11  christos     -re -wrap "int y =.*" {
    126  1.11  christos 	pass $gdb_test_name
    127  1.11  christos     }
    128  1.11  christos }
    129  1.11  christos repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main one"
    130   1.1  christos 
    131   1.9  christos gdb_test_multiple "reverse-step" "reverse-step into solib function two" {
    132   1.9  christos     -re -wrap "begin part two.*" {
    133   1.9  christos 	send_gdb "reverse-step\n"
    134   1.9  christos 	exp_continue
    135   1.9  christos     }
    136   1.9  christos     -re -wrap "${lib2src}.*" {
    137   1.9  christos 	pass $gdb_test_name
    138   1.9  christos     }
    139   1.9  christos }
    140  1.11  christos gdb_test_multiple "reverse-step" "reverse-step within solib function two" {
    141  1.11  christos     -re -wrap "return y;.*" {
    142  1.11  christos 	pass $gdb_test_name
    143  1.11  christos     }
    144  1.11  christos     -re -wrap "int y =.*" {
    145  1.11  christos 	pass $gdb_test_name
    146  1.11  christos     }
    147  1.11  christos }
    148  1.11  christos repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main two"
    149   1.1  christos 
    150   1.1  christos #
    151   1.1  christos # Test reverse-next over debuggable solib function
    152   1.1  christos #
    153   1.1  christos 
    154   1.1  christos gdb_test "until $end_part_two" " end part two.*" "run until end part two"
    155   1.1  christos 
    156   1.1  christos gdb_test "reverse-next" " middle part two.*" "reverse-next over solib function one"
    157   1.9  christos gdb_test_multiple "reverse-next" "reverse-next over solib function two" {
    158   1.9  christos     -re -wrap "middle part two.*" {
    159   1.9  christos 	send_gdb "reverse-next\n"
    160   1.9  christos 	exp_continue
    161   1.9  christos     }
    162   1.9  christos     -re -wrap " begin part two.*" {
    163   1.9  christos 	pass $gdb_test_name
    164   1.9  christos     }
    165   1.9  christos }
    166