- struct regcache *regcache = get_thread_regcache (tp);
- struct gdbarch *gdbarch = regcache->arch ();
+ /* If the user disabled it explicitly, don't use displaced stepping. */
+ if (can_use_displaced_stepping == AUTO_BOOLEAN_FALSE)
+ return false;
+
+ /* If "auto", only use displaced stepping if the target operates in a non-stop
+ way. */
+ if (can_use_displaced_stepping == AUTO_BOOLEAN_AUTO
+ && !target_is_non_stop_p ())
+ return false;
+
+ gdbarch *gdbarch = get_thread_regcache (tp)->arch ();
+
+ /* If the architecture doesn't implement displaced stepping, don't use
+ it. */
+ if (!gdbarch_supports_displaced_stepping (gdbarch))
+ return false;
+
+ /* If recording, don't use displaced stepping. */
+ if (find_record_target () != nullptr)
+ return false;
+