public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA v2 1/6] Use new and delete for struct infcall_suspend_state
Date: Wed, 18 Jul 2018 14:09:00 -0000	[thread overview]
Message-ID: <20180718140904.16811-2-tom@tromey.com> (raw)
In-Reply-To: <20180718140904.16811-1-tom@tromey.com>

This changes infrun.c to use new and delete for infcall_suspend_state.
This enables the coming cleanups.

gdb/ChangeLog
2018-07-18  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   |  8 ++++++++
 gdb/gdbthread.h | 12 ++++++------
 gdb/infrun.c    | 10 +++++-----
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7e7f88a12b9..79675a060ce 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2018-07-18  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-07-17  Tom Tromey  <tom@tromey.com>
 
 	* guile/scm-param.c (pascm_set_func, pascm_show_func)
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 2c402543ddb..99de5ff0d80 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -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;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index dd7e69e718e..c9d3a0075ba 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8813,15 +8813,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 *
@@ -8853,7 +8853,7 @@ save_infcall_suspend_state (void)
 	}
     }
 
-  inf_state = XCNEW (struct infcall_suspend_state);
+  inf_state = new struct infcall_suspend_state;
 
   if (siginfo_data)
     {
@@ -8919,7 +8919,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 *
-- 
2.17.1

  reply	other threads:[~2018-07-18 14:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18 14:09 [RFA v2 0/6] remove some infrun-related cleanups Tom Tromey
2018-07-18 14:09 ` Tom Tromey [this message]
2018-07-18 14:09 ` [RFA v2 3/6] Use new and delete for struct infcall_control_state Tom Tromey
2018-07-18 14:09 ` [RFA v2 6/6] Make save_infcall_*_state return unique pointers Tom Tromey
2018-07-18 14:09 ` [RFA v2 4/6] Remove two infrun cleanups Tom Tromey
2018-07-18 14:09 ` [RFA v2 5/6] Remove release_stop_context_cleanup Tom Tromey
2018-07-18 14:12 ` [RFA v2 2/6] Remove cleanup from infrun.c Tom Tromey
2018-09-17  6:42 ` [RFA v2 0/6] remove some infrun-related cleanups Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180718140904.16811-2-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).