-# Copyright 2010-2012 Free Software Foundation, Inc.
+# Copyright 2010-2016 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# Test arm displaced stepping.
-if $tracelevel {
- strace $tracelevel
-}
-
-if {![istarget "arm*-*-*"]} then {
+if {![is_aarch32_target]} then {
verbose "Skipping arm displaced stepping tests."
return
}
-set testfile "arm-disp-step"
-set srcfile ${testfile}.S
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .S
set additional_flags "-Wa,-g"
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
- untested arm-disp-step.exp
+if { [prepare_for_testing $testfile.exp $testfile $srcfile [list debug $additional_flags]] } {
return -1
}
".*bx lr.*"
}
-# Get things started.
+# Test 16 bit thumb instruction 'add rd, pc'.
-clean_restart ${testfile}
+proc test_add_rn_pc {} {
+ global srcfile gdb_prompt
+
+ set test "break test_add_rn_pc"
+ gdb_test_multiple "break *test_add_rn_pc" $test {
+ -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "No symbol.*\r\n$gdb_prompt $" {
+ return
+ }
+ }
+
+ gdb_continue_to_breakpoint "continue to test_add_rn_pc" \
+ ".*mov.*r3, 4.*"
+
+ gdb_test "break *test_add_rn_pc_start" \
+ "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "break test_add_rn_pc_start"
+
+ gdb_continue_to_breakpoint "continue to test_add_rn_pc_start" \
+ ".*add.*r3,.*pc.*"
+
+ set pc_val [get_integer_valueof "\$pc" 0]
+
+ gdb_test "break *test_add_rn_pc_end" \
+ "Breakpoint.*at.* file .*$srcfile, line.*" \
+ "break test_add_rn_pc_end"
+
+ gdb_continue_to_breakpoint "continue to test_add_rn_pc_end" \
+ ".*bx lr.*"
+
+ set r3_val [get_integer_valueof "\$r3" 0]
+ # Test the value in r3 is correct.
+ gdb_assert { [expr {$pc_val + 4 + 4} == $r3_val] }
+}
# Turn displaced stepping off before runto main. When displaced stepping
# is on, and we type 'run', GDB will first try to single step on _dl_debug_state,
gdb_test_no_output "set displaced-stepping off"
if ![runto_main] then {
- fail "Can't run to main"
+ fail "can't run to main"
return 0
}
test_str_pc
+test_add_rn_pc
+
##########################################
# Done, run program to exit.