-extern struct cleanup *make_cleanup_restore_infcall_suspend_state
- (struct infcall_suspend_state *);
-extern struct cleanup *make_cleanup_restore_infcall_control_state
- (struct infcall_control_state *);
+/* A deleter for infcall_suspend_state that calls
+ restore_infcall_suspend_state. */
+struct infcall_suspend_state_deleter
+{
+ void operator() (struct infcall_suspend_state *state) const
+ {
+ try
+ {
+ restore_infcall_suspend_state (state);
+ }
+ catch (const gdb_exception_error &e)
+ {
+ /* If we are restoring the inferior state due to an exception,
+ some error message will be printed. So, only warn the user
+ when we cannot restore during normal execution. */
+ if (!std::uncaught_exception ())
+ warning (_("Failed to restore inferior state: %s"), e.what ());
+ }
+ }
+};
+
+/* A unique_ptr specialization for infcall_suspend_state. */
+typedef std::unique_ptr<infcall_suspend_state, infcall_suspend_state_deleter>
+ infcall_suspend_state_up;
+
+extern infcall_suspend_state_up save_infcall_suspend_state ();
+
+/* A deleter for infcall_control_state that calls
+ restore_infcall_control_state. */
+struct infcall_control_state_deleter
+{
+ void operator() (struct infcall_control_state *state) const
+ {
+ restore_infcall_control_state (state);
+ }
+};
+
+/* A unique_ptr specialization for infcall_control_state. */
+typedef std::unique_ptr<infcall_control_state, infcall_control_state_deleter>
+ infcall_control_state_up;
+
+extern infcall_control_state_up save_infcall_control_state ();