Home | History | Annotate | Line # | Download | only in gdb.base
      1  1.1.1.6  christos # Copyright 2012-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 # Step over breakpoints with displaced stepping on, against Valgrind.
     17      1.1  christos # We can't really use displaced stepping with Valgrind, so what this
     18      1.1  christos # really tests is that GDB falls back to in-line stepping
     19      1.1  christos # automatically instead of getting stuck or crashing.
     20      1.1  christos 
     21  1.1.1.5  christos # Valgrind gdbserver requires gdb with xml support.
     22  1.1.1.6  christos require allow_xml_test
     23  1.1.1.5  christos 
     24  1.1.1.3  christos load_lib valgrind.exp
     25  1.1.1.3  christos 
     26  1.1.1.6  christos require {!is_remote target}
     27      1.1  christos 
     28      1.1  christos standard_testfile .c
     29      1.1  christos if {[build_executable "failed to build" $testfile $srcfile {debug}] == -1} {
     30      1.1  christos     return -1
     31      1.1  christos }
     32      1.1  christos 
     33  1.1.1.3  christos if { [vgdb_start] == -1 } {
     34      1.1  christos     return -1
     35      1.1  christos }
     36      1.1  christos 
     37      1.1  christos gdb_test_no_output "set displaced-stepping off"
     38      1.1  christos gdb_breakpoint "main" "breakpoint at main"
     39      1.1  christos gdb_test "continue" " stop 0 .*" "continue to main"
     40      1.1  christos delete_breakpoints
     41      1.1  christos 
     42      1.1  christos set curr_stop 0
     43      1.1  christos foreach displaced { "off" "on" } {
     44      1.1  christos     with_test_prefix "displaced $displaced" {
     45      1.1  christos 
     46      1.1  christos 	gdb_test_no_output "set displaced-stepping $displaced"
     47      1.1  christos 
     48      1.1  christos 	foreach go { "once" "twice" } {
     49      1.1  christos 	    with_test_prefix $go {
     50      1.1  christos 		gdb_test "break" "Breakpoint .* at .*" "set breakpoint"
     51      1.1  christos 
     52      1.1  christos 		# Whether we should see a warning.
     53      1.1  christos 		set should_warn [expr {$go == "once" && $displaced == "on"}]
     54      1.1  christos 
     55      1.1  christos 		incr curr_stop
     56      1.1  christos 
     57      1.1  christos 		set msg "step over breakpoint"
     58      1.1  christos 		set pattern " stop $curr_stop .*$gdb_prompt $"
     59      1.1  christos 		gdb_test_multiple "next" $msg {
     60      1.1  christos 		    -re "warning: disabling displaced stepping.*$pattern" {
     61      1.1  christos 			gdb_assert $should_warn $msg
     62      1.1  christos 		    }
     63      1.1  christos 		    -re "$pattern" {
     64      1.1  christos 			gdb_assert !$should_warn $msg
     65      1.1  christos 		    }
     66      1.1  christos 		}
     67      1.1  christos 	    }
     68      1.1  christos 	}
     69      1.1  christos     }
     70      1.1  christos }
     71      1.1  christos 
     72  1.1.1.3  christos vgdb_stop
     73