+# Assume yes.
+set displaced_stepping_supported 1
+
+# "set displaced on" only tells gdb to use displaced stepping if
+# possible. Probe for actual support.
+
+proc probe_displaced_stepping_support {} {
+ global displaced_stepping_supported
+ global binfile gdb_prompt
+
+ with_test_prefix "probe displaced-stepping support" {
+ clean_restart $binfile
+
+ gdb_test_no_output "set displaced on"
+ if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+ }
+
+ # We're stopped at the main breakpoint. If displaced stepping is
+ # supported, we'll see related debug output while we step past
+ # that breakpoint.
+ gdb_test_no_output "set debug displaced 1"
+ gdb_test_multiple "next" "probe" {
+ -re "displaced pc to.*$gdb_prompt $" {
+ pass "supported"
+ }
+ -re ".*$gdb_prompt $" {
+ set displaced_stepping_supported 0
+ pass "not supported"
+ }
+ }
+ }
+}
+