[1/3] Change thread_fsm::return_value to thread_fsm::print_return_values

Message ID 20221210162326.854-1-ssbssa@yahoo.de
State New
Headers
Series [1/3] Change thread_fsm::return_value to thread_fsm::print_return_values |

Commit Message

Hannes Domani Dec. 10, 2022, 4:23 p.m. UTC
  A later patch implements print_return_values also for step_command_fsm,
to print the return values of all stepped-over functions.

This keeps all of the return value printing code in infrun.c, so
print_return_value could be made static.
---
 gdb/infcmd.c     | 12 ++++++------
 gdb/infrun.c     | 11 ++---------
 gdb/infrun.h     |  7 -------
 gdb/thread-fsm.h |  6 ++----
 4 files changed, 10 insertions(+), 26 deletions(-)
  

Patch

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index a27d3577b3a..a5fcf2f8ea5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1575,7 +1575,7 @@  print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv)
    RV points at an object representing the captured return value/type
    and its position in the value history.  */
 
-void
+static void
 print_return_value (struct ui_out *uiout, struct return_value_info *rv)
 {
   if (rv->type == nullptr
@@ -1623,7 +1623,7 @@  struct finish_command_fsm : public thread_fsm
 
   bool should_stop (struct thread_info *thread) override;
   void clean_up (struct thread_info *thread) override;
-  struct return_value_info *return_value () override;
+  void print_return_values (struct ui_out *uiout) override;
   enum async_reply_reason do_async_reply_reason () override;
 };
 
@@ -1684,13 +1684,13 @@  finish_command_fsm::clean_up (struct thread_info *thread)
   delete_longjmp_breakpoint (thread->global_num);
 }
 
-/* Implementation of the 'return_value' FSM method for the finish
+/* Implementation of the 'print_return_values' FSM method for the finish
    commands.  */
 
-struct return_value_info *
-finish_command_fsm::return_value ()
+void
+finish_command_fsm::print_return_values (struct ui_out *uiout)
 {
-  return &return_value_info;
+  print_return_value (uiout, &return_value_info);
 }
 
 /* Implementation of the 'async_reply_reason' FSM method for the
diff --git a/gdb/infrun.c b/gdb/infrun.c
index c67458b30b6..e8ef3677245 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8490,15 +8490,8 @@  print_stop_event (struct ui_out *uiout, bool displays)
   }
 
   tp = inferior_thread ();
-  if (tp->thread_fsm () != nullptr
-      && tp->thread_fsm ()->finished_p ())
-    {
-      struct return_value_info *rv;
-
-      rv = tp->thread_fsm ()->return_value ();
-      if (rv != nullptr)
-	print_return_value (uiout, rv);
-    }
+  if (tp->thread_fsm () != nullptr)
+    tp->thread_fsm ()->print_return_values (uiout);
 }
 
 /* See infrun.h.  */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index c711b9b21cc..79323bcc65f 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -225,13 +225,6 @@  extern void print_exited_reason (struct ui_out *uiout, int exitstatus);
    inferior has stopped.  */
 extern void print_no_history_reason (struct ui_out *uiout);
 
-/* Print the result of a function at the end of a 'finish' command.
-   RV points at an object representing the captured return value/type
-   and its position in the value history.  */
-
-extern void print_return_value (struct ui_out *uiout,
-				struct return_value_info *rv);
-
 /* Print current location without a level number, if we have changed
    functions or hit a breakpoint.  Print source line if we have one.
    If the execution command captured a return value, print it.  If
diff --git a/gdb/thread-fsm.h b/gdb/thread-fsm.h
index 96f37ac9414..575b9a5e48f 100644
--- a/gdb/thread-fsm.h
+++ b/gdb/thread-fsm.h
@@ -58,11 +58,9 @@  struct thread_fsm
      function's return value here.  */
   virtual bool should_stop (struct thread_info *thread) = 0;
 
-  /* If this FSM saved a function's return value, you can use this
-     method to retrieve it.  Otherwise, this returns NULL.  */
-  virtual struct return_value_info *return_value ()
+  /* Print return values saved by this FSM.  */
+  virtual void print_return_values (struct ui_out *uiout)
   {
-    return nullptr;
   }
 
   enum async_reply_reason async_reply_reason ()