Use new and delete for struct infcall_control_state
authorTom Tromey <tom@tromey.com>
Thu, 14 Jun 2018 22:59:55 +0000 (15:59 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 17 Sep 2018 06:42:18 +0000 (00:42 -0600)
This changes infrun.c to use new and delete for infcall_control_state.

gdb/ChangeLog
2018-09-17  Tom Tromey  <tom@tromey.com>

* gdbthread.h (struct thread_control_state): Add initializer.
(class thread_info) <control>: Remove initializer.
* inferior.h (struct inferior_control_state): Add initializer.
(class inferior) <control>: Remove initializer.
(exit_inferior_1): Update.
* infrun.c (struct infcall_control_state): Add constructors.
(save_infcall_control_state): Use new.
(restore_infcall_control_state, discard_infcall_control_state):
Use delete.

gdb/ChangeLog
gdb/gdbthread.h
gdb/inferior.c
gdb/inferior.h
gdb/infrun.c

index d5441c812b060516ea3412ab77213fdc3c4e0285..681ed3a232f53cf77778ac426968159a6c65d898 100644 (file)
@@ -1,3 +1,15 @@
+2018-09-17  Tom Tromey  <tom@tromey.com>
+
+       * gdbthread.h (struct thread_control_state): Add initializer.
+       (class thread_info) <control>: Remove initializer.
+       * inferior.h (struct inferior_control_state): Add initializer.
+       (class inferior) <control>: Remove initializer.
+       (exit_inferior_1): Update.
+       * infrun.c (struct infcall_control_state): Add constructors.
+       (save_infcall_control_state): Use new.
+       (restore_infcall_control_state, discard_infcall_control_state):
+       Use delete.
+
 2018-09-17  Tom Tromey  <tom@tromey.com>
 
        * infrun.c (struct infcall_suspend_state) <registers>: Now a
index 99de5ff0d8021330fe2841349556425e10c21e16..2738e44da9f52bff7d1c7363c2a4c30041ab7e75 100644 (file)
@@ -52,17 +52,17 @@ struct thread_control_state
   /* User/external stepping state.  */
 
   /* Step-resume or longjmp-resume breakpoint.  */
-  struct breakpoint *step_resume_breakpoint;
+  struct breakpoint *step_resume_breakpoint = nullptr;
 
   /* Exception-resume breakpoint.  */
-  struct breakpoint *exception_resume_breakpoint;
+  struct breakpoint *exception_resume_breakpoint = nullptr;
 
   /* Breakpoints used for software single stepping.  Plural, because
      it may have multiple locations.  E.g., if stepping over a
      conditional branch instruction we can't decode the condition for,
      we'll need to put a breakpoint at the branch destination, and
      another at the instruction after the branch.  */
-  struct breakpoint *single_step_breakpoints;
+  struct breakpoint *single_step_breakpoints = nullptr;
 
   /* Range to single step within.
 
@@ -74,11 +74,11 @@ struct thread_control_state
      wait_for_inferior in a minor way if this were changed to the
      address of the instruction and that address plus one.  But maybe
      not).  */
-  CORE_ADDR step_range_start;  /* Inclusive */
-  CORE_ADDR step_range_end;    /* Exclusive */
+  CORE_ADDR step_range_start = 0;      /* Inclusive */
+  CORE_ADDR step_range_end = 0;                /* Exclusive */
 
   /* Function the thread was in as of last it started stepping.  */
-  struct symbol *step_start_function;
+  struct symbol *step_start_function = nullptr;
 
   /* If GDB issues a target step request, and this is nonzero, the
      target should single-step this thread once, and then continue
@@ -86,16 +86,16 @@ struct thread_control_state
      thread stops in the step range above.  If this is zero, the
      target should ignore the step range, and only issue one single
      step.  */
-  int may_range_step;
+  int may_range_step = 0;
 
   /* Stack frame address as of when stepping command was issued.
      This is how we know when we step into a subroutine call, and how
      to set the frame for the breakpoint used to step out.  */
-  struct frame_id step_frame_id;
+  struct frame_id step_frame_id {};
 
   /* Similarly, the frame ID of the underlying stack frame (skipping
      any inlined frames).  */
-  struct frame_id step_stack_frame_id;
+  struct frame_id step_stack_frame_id {};
 
   /* Nonzero if we are presently stepping over a breakpoint.
 
@@ -119,29 +119,29 @@ struct thread_control_state
      wait_for_inferior, which calls handle_inferior_event in a loop,
      and until wait_for_inferior exits, this variable is changed only
      by keep_going.  */
-  int trap_expected;
+  int trap_expected = 0;
 
   /* Nonzero if the thread is being proceeded for a "finish" command
      or a similar situation when return value should be printed.  */
-  int proceed_to_finish;
+  int proceed_to_finish = 0;
 
   /* Nonzero if the thread is being proceeded for an inferior function
      call.  */
-  int in_infcall;
+  int in_infcall = 0;
 
-  enum step_over_calls_kind step_over_calls;
+  enum step_over_calls_kind step_over_calls = STEP_OVER_NONE;
 
   /* Nonzero if stopped due to a step command.  */
-  int stop_step;
+  int stop_step = 0;
 
   /* Chain containing status of breakpoint(s) the thread stopped
      at.  */
-  bpstat stop_bpstat;
+  bpstat stop_bpstat = nullptr;
 
   /* Whether the command that started the thread was a stepping
      command.  This is used to decide whether "set scheduler-locking
      step" behaves like "on" or "off".  */
-  int stepping_command;
+  int stepping_command = 0;
 };
 
 /* Inferior thread specific part of `struct infcall_suspend_state'.  */
@@ -296,7 +296,7 @@ public:
 
   /* State of GDB control of inferior thread execution.
      See `struct thread_control_state'.  */
-  thread_control_state control {};
+  thread_control_state control;
 
   /* State of inferior thread to restore after GDB is done with an inferior
      call.  See `struct thread_suspend_state'.  */
index 76f5581b7dbe4e00100d1e2d846d24fc160ebfa5..17d28c4cf5486f594fb2713238350701c41e860b 100644 (file)
@@ -226,7 +226,7 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
 
   inf->pending_detach = 0;
   /* Reset it.  */
-  inf->control = {NO_STOP_QUIETLY};
+  inf->control = inferior_control_state (NO_STOP_QUIETLY);
 }
 
 void
index 8d38429838718f5f75f757991f943cff152ace86..9f431de7bf477d618331d406b603e7e4762d8737 100644 (file)
@@ -283,6 +283,16 @@ struct private_inferior
 
 struct inferior_control_state
 {
+  inferior_control_state ()
+    : stop_soon (NO_STOP_QUIETLY)
+  {
+  }
+
+  explicit inferior_control_state (enum stop_kind when)
+    : stop_soon (when)
+  {
+  }
+
   /* See the definition of stop_kind above.  */
   enum stop_kind stop_soon;
 };
@@ -341,7 +351,7 @@ public:
 
   /* State of GDB control of inferior process execution.
      See `struct inferior_control_state'.  */
-  inferior_control_state control {NO_STOP_QUIETLY};
+  inferior_control_state control;
 
   /* True if this was an auto-created inferior, e.g. created from
      following a fork; false, if this inferior was manually added by
index d350ad121fdc81a935f94bc7455ab2d79ac1cd4d..0df539af169efcc578a130006c8044835bcf666a 100644 (file)
@@ -8928,11 +8928,11 @@ struct infcall_control_state
   struct inferior_control_state inferior_control;
 
   /* Other fields:  */
-  enum stop_stack_kind stop_stack_dummy;
-  int stopped_by_random_signal;
+  enum stop_stack_kind stop_stack_dummy = STOP_NONE;
+  int stopped_by_random_signal = 0;
 
   /* ID if the selected frame when the inferior function call was made.  */
-  struct frame_id selected_frame_id;
+  struct frame_id selected_frame_id {};
 };
 
 /* Save all of the information associated with the inferior<==>gdb
@@ -8941,8 +8941,7 @@ struct infcall_control_state
 struct infcall_control_state *
 save_infcall_control_state (void)
 {
-  struct infcall_control_state *inf_status =
-    XNEW (struct infcall_control_state);
+  struct infcall_control_state *inf_status = new struct infcall_control_state;
   struct thread_info *tp = inferior_thread ();
   struct inferior *inf = current_inferior ();
 
@@ -9028,7 +9027,7 @@ restore_infcall_control_state (struct infcall_control_state *inf_status)
       END_CATCH
     }
 
-  xfree (inf_status);
+  delete inf_status;
 }
 
 static void
@@ -9058,7 +9057,7 @@ discard_infcall_control_state (struct infcall_control_state *inf_status)
   /* See save_infcall_control_state for info on stop_bpstat.  */
   bpstat_clear (&inf_status->thread_control.stop_bpstat);
 
-  xfree (inf_status);
+  delete inf_status;
 }
 \f
 /* See infrun.h.  */
This page took 0.035404 seconds and 4 git commands to generate.