gdb/testsuite: some additional tests in gdb.tui/scroll.exp
[binutils-gdb.git] / gdb / dummy-frame.c
index 99d3d7c8bc3ce28aabaf4bef82a899173028a659..40b455c7e4a49338c982de1a3fb62bbbc5a21eff 100644 (file)
@@ -1,6 +1,6 @@
 /* Code dealing with dummy stack frames, for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2019 Free Software Foundation, Inc.
+   Copyright (C) 1986-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 
 #include "defs.h"
-
-/* Local non-gdb includes.  */
-#include "command.h"
 #include "dummy-frame.h"
-#include "frame-unwind.h"
+#include "regcache.h"
 #include "frame.h"
+#include "inferior.h"
+#include "frame-unwind.h"
+#include "command.h"
 #include "gdbcmd.h"
+#include "observable.h"
 #include "gdbthread.h"
 #include "infcall.h"
-#include "inferior.h"
-#include "observable.h"
-#include "regcache.h"
+#include "gdbarch.h"
 
 struct dummy_frame_id
 {
@@ -127,11 +126,9 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr)
 /* Delete any breakpoint B which is a momentary breakpoint for return from
    inferior call matching DUMMY_VOIDP.  */
 
-static int
-pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp)
+static bool
+pop_dummy_frame_bpt (struct breakpoint *b, struct dummy_frame *dummy)
 {
-  struct dummy_frame *dummy = (struct dummy_frame *) dummy_voidp;
-
   if (b->thread == dummy->id.thread->global_num
       && b->disposition == disp_del && frame_id_eq (b->frame_id, dummy->id.id))
     {
@@ -141,11 +138,11 @@ pop_dummy_frame_bpt (struct breakpoint *b, void *dummy_voidp)
       delete_breakpoint (b);
 
       /* Stop the traversal.  */
-      return 1;
+      return true;
     }
 
   /* Continue the traversal.  */
-  return 0;
+  return false;
 }
 
 /* Pop *DUMMY_PTR, restoring program state to that before the
@@ -169,7 +166,9 @@ pop_dummy_frame (struct dummy_frame **dummy_ptr)
 
   restore_infcall_suspend_state (dummy->caller_state);
 
-  iterate_over_breakpoints (pop_dummy_frame_bpt, dummy);
+  for (breakpoint *bp : all_breakpoints_safe ())
+    if (pop_dummy_frame_bpt (bp, dummy))
+      break;
 
   /* restore_infcall_control_state frees inf_state,
      all that remains is to pop *dummy_ptr.  */
@@ -273,7 +272,7 @@ find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor, void *dtor_data)
    them up at least once whenever we start a new inferior.  */
 
 static void
-cleanup_dummy_frames (struct target_ops *target, int from_tty)
+cleanup_dummy_frames (inferior *inf)
 {
   while (dummy_frame_stack != NULL)
     remove_dummy_frame (&dummy_frame_stack);
@@ -354,8 +353,8 @@ dummy_frame_prev_register (struct frame_info *this_frame,
   /* Use the regcache_cooked_read() method so that it, on the fly,
      constructs either a raw or pseudo register from the raw
      register cache.  */
-  cache->prev_regcache->cooked_read (regnum,
-                                    value_contents_writeable (reg_val));
+  cache->prev_regcache->cooked_read
+    (regnum, value_contents_writeable (reg_val).data ());
   return reg_val;
 }
 
@@ -379,6 +378,7 @@ dummy_frame_this_id (struct frame_info *this_frame,
 
 const struct frame_unwind dummy_frame_unwind =
 {
+  "dummy",
   DUMMY_FRAME,
   default_frame_unwind_stop_reason,
   dummy_frame_this_id,
@@ -405,15 +405,10 @@ fprint_dummy_frames (struct ui_file *file)
   struct dummy_frame *s;
 
   for (s = dummy_frame_stack; s != NULL; s = s->next)
-    {
-      gdb_print_host_address (s, file);
-      fprintf_unfiltered (file, ":");
-      fprintf_unfiltered (file, " id=");
-      fprint_frame_id (file, s->id.id);
-      fprintf_unfiltered (file, ", ptid=%s",
-                         target_pid_to_str (s->id.thread->ptid).c_str ());
-      fprintf_unfiltered (file, "\n");
-    }
+    gdb_printf (file, "%s: id=%s, ptid=%s\n",
+               host_address_to_string (s),
+               s->id.id.to_string ().c_str (),
+               s->id.thread->ptid.to_string ().c_str ());
 }
 
 static void
@@ -431,12 +426,13 @@ maintenance_print_dummy_frames (const char *args, int from_tty)
     }
 }
 
+void _initialize_dummy_frame ();
 void
-_initialize_dummy_frame (void)
+_initialize_dummy_frame ()
 {
   add_cmd ("dummy-frames", class_maintenance, maintenance_print_dummy_frames,
           _("Print the contents of the internal dummy-frame stack."),
           &maintenanceprintlist);
 
-  gdb::observers::inferior_created.attach (cleanup_dummy_frames);
+  gdb::observers::inferior_created.attach (cleanup_dummy_frames, "dummy-frame");
 }