Use new and delete for struct infcall_suspend_state
authorTom Tromey <tom@tromey.com>
Thu, 14 Jun 2018 22:32:46 +0000 (15:32 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 17 Sep 2018 06:42:17 +0000 (00:42 -0600)
This changes infrun.c to use new and delete for infcall_suspend_state.
This enables the coming cleanups.

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

* gdbthread.h (struct thread_suspend_state): Add initializers.
(class thread_info) <suspend>: Remove initializer.
* infrun.c (struct infcall_suspend_state): Add initializers.
(save_infcall_suspend_state): Use new.
(discard_infcall_suspend_state): Use delete.

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

index 6f66a35e2de3403152d3f2eeb50d58c99a8d6483..af8db7ae073e8572e26c29674091e9eb80a1d22a 100644 (file)
@@ -1,3 +1,11 @@
+2018-09-17  Tom Tromey  <tom@tromey.com>
+
+       * gdbthread.h (struct thread_suspend_state): Add initializers.
+       (class thread_info) <suspend>: Remove initializer.
+       * infrun.c (struct infcall_suspend_state): Add initializers.
+       (save_infcall_suspend_state): Use new.
+       (discard_infcall_suspend_state): Use delete.
+
 2018-09-16  Tom Tromey  <tom@tromey.com>
 
        * python/python-internal.h (CPYCHECKER_STEALS_REFERENCE_TO_ARG):
index 2c402543ddbea731775b9321aa606fec7687ba5c..99de5ff0d8021330fe2841349556425e10c21e16 100644 (file)
@@ -155,16 +155,16 @@ struct thread_suspend_state
      "signal" command, which overrides "handle nopass".  If the signal
      should be suppressed, the core will take care of clearing this
      before the target is resumed.  */
-  enum gdb_signal stop_signal;
+  enum gdb_signal stop_signal = GDB_SIGNAL_0;
 
   /* The reason the thread last stopped, if we need to track it
      (breakpoint, watchpoint, etc.)  */
-  enum target_stop_reason stop_reason;
+  enum target_stop_reason stop_reason = TARGET_STOPPED_BY_NO_REASON;
 
   /* The waitstatus for this thread's last event.  */
-  struct target_waitstatus waitstatus;
+  struct target_waitstatus waitstatus {};
   /* If true WAITSTATUS hasn't been handled yet.  */
-  int waitstatus_pending_p;
+  int waitstatus_pending_p = 0;
 
   /* Record the pc of the thread the last time it stopped.  (This is
      not the current thread's PC as that may have changed since the
@@ -181,7 +181,7 @@ struct thread_suspend_state
 
      - If the thread is running, this is set to -1, to avoid leaving
        it with a stale value, to make it easier to catch bugs.  */
-  CORE_ADDR stop_pc;
+  CORE_ADDR stop_pc = 0;
 };
 
 /* Base class for target-specific thread data.  */
@@ -300,7 +300,7 @@ public:
 
   /* State of inferior thread to restore after GDB is done with an inferior
      call.  See `struct thread_suspend_state'.  */
-  thread_suspend_state suspend {};
+  thread_suspend_state suspend;
 
   int current_line = 0;
   struct symtab *current_symtab = NULL;
index 7731ccda68343b0118b9806615ff45b9f4d56c63..6039ae3c185857d90b352ae9b7bf05c4b298490b 100644 (file)
@@ -8810,15 +8810,15 @@ struct infcall_suspend_state
   struct thread_suspend_state thread_suspend;
 
   /* Other fields:  */
-  readonly_detached_regcache *registers;
+  readonly_detached_regcache *registers = nullptr;
 
   /* Format of SIGINFO_DATA or NULL if it is not present.  */
-  struct gdbarch *siginfo_gdbarch;
+  struct gdbarch *siginfo_gdbarch = nullptr;
 
   /* The inferior format depends on SIGINFO_GDBARCH and it has a length of
      TYPE_LENGTH (gdbarch_get_siginfo_type ()).  For different gdbarch the
      content would be invalid.  */
-  gdb_byte *siginfo_data;
+  gdb_byte *siginfo_data = nullptr;
 };
 
 struct infcall_suspend_state *
@@ -8850,7 +8850,7 @@ save_infcall_suspend_state (void)
        }
     }
 
-  inf_state = XCNEW (struct infcall_suspend_state);
+  inf_state = new struct infcall_suspend_state;
 
   if (siginfo_data)
     {
@@ -8916,7 +8916,7 @@ discard_infcall_suspend_state (struct infcall_suspend_state *inf_state)
 {
   delete inf_state->registers;
   xfree (inf_state->siginfo_data);
-  xfree (inf_state);
+  delete inf_state;
 }
 
 readonly_detached_regcache *