public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Use new and delete for windows_thread_info
Date: Fri, 24 Apr 2020 12:45:40 -0400	[thread overview]
Message-ID: <e9534bd257ac9ea2f7921e8000d27c5dc4477b4e@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT e9534bd257ac9ea2f7921e8000d27c5dc4477b4e ***

commit e9534bd257ac9ea2f7921e8000d27c5dc4477b4e
Author:     Tom Tromey <tromey@adacore.com>
AuthorDate: Wed Apr 8 14:33:35 2020 -0600
Commit:     Tom Tromey <tromey@adacore.com>
CommitDate: Wed Apr 8 14:47:57 2020 -0600

    Use new and delete for windows_thread_info
    
    This adds a constructor, destructor, and member initializers to
    windows_thread_info, and changes gdb and gdbserver to use new and
    delete.
    
    gdb/ChangeLog
    2020-04-08  Tom Tromey  <tromey@adacore.com>
    
            * windows-nat.c (windows_add_thread): Use new.
            (windows_init_thread_list, windows_delete_thread): Use delete.
            (get_windows_debug_event): Update.
            * nat/windows-nat.h (struct windows_thread_info): Add constructor,
            destructor, and initializers.
    
    gdbserver/ChangeLog
    2020-04-08  Tom Tromey  <tromey@adacore.com>
    
            * win32-low.c (child_add_thread): Use new.
            (delete_thread_info): Use delete.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c2e6d60fd6..f0b1f33485 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+	* windows-nat.c (windows_add_thread): Use new.
+	(windows_init_thread_list, windows_delete_thread): Use delete.
+	(get_windows_debug_event): Update.
+	* nat/windows-nat.h (struct windows_thread_info): Add constructor,
+	destructor, and initializers.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
 	* windows-nat.c (struct windows_thread_info): Remove.
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 71df097ed0..a3da268642 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -25,6 +25,20 @@
    each thread.  */
 struct windows_thread_info
 {
+  windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
+    : tid (tid_),
+      h (h_),
+      thread_local_base (tlb)
+  {
+  }
+
+  ~windows_thread_info ()
+  {
+    xfree (name);
+  }
+
+  DISABLE_COPY_AND_ASSIGN (windows_thread_info);
+
   /* The Win32 thread identifier.  */
   DWORD tid;
 
@@ -35,17 +49,17 @@ struct windows_thread_info
   CORE_ADDR thread_local_base;
 
   /* Non zero if SuspendThread was called on this thread.  */
-  int suspended;
+  int suspended = 0;
 
 #ifdef _WIN32_WCE
   /* The context as retrieved right after suspending the thread. */
-  CONTEXT base_context;
+  CONTEXT base_context {};
 #endif
 
   /* The context of the thread, including any manipulations.  */
   union
   {
-    CONTEXT context;
+    CONTEXT context {};
 #ifdef __x86_64__
     WOW64_CONTEXT wow64_context;
 #endif
@@ -53,14 +67,14 @@ struct windows_thread_info
 
   /* Whether debug registers changed since we last set CONTEXT back to
      the thread.  */
-  int debug_registers_changed;
+  int debug_registers_changed = 0;
 
   /* Nonzero if CONTEXT is invalidated and must be re-read from the
      inferior thread.  */
-  int reload_context;
+  int reload_context = 0;
 
   /* The name of the thread, allocated by xmalloc.  */
-  char *name;
+  char *name = nullptr;
 };
 
 #endif
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 9368396b0f..715cf602a0 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -468,16 +468,14 @@ windows_add_thread (ptid_t ptid, HANDLE h, void *tlb, bool main_thread_p)
   if ((th = thread_rec (id, FALSE)))
     return th;
 
-  th = XCNEW (windows_thread_info);
-  th->tid = id;
-  th->h = h;
-  th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
+  CORE_ADDR base = (CORE_ADDR) (uintptr_t) tlb;
 #ifdef __x86_64__
   /* For WOW64 processes, this is actually the pointer to the 64bit TIB,
      and the 32bit TIB is exactly 2 pages after it.  */
   if (wow64_process)
-    th->thread_local_base += 0x2000;
+    base += 0x2000;
 #endif
+  th = new windows_thread_info (id, h, base);
   thread_list.push_back (th);
 
   /* Add this new thread to the list of threads.
@@ -536,7 +534,7 @@ windows_init_thread_list (void)
   init_thread_list ();
 
   for (windows_thread_info *here : thread_list)
-    xfree (here);
+    delete here;
 
   thread_list.clear ();
 }
@@ -581,8 +579,7 @@ windows_delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p)
 
   if (iter != thread_list.end ())
     {
-      xfree ((*iter)->name);
-      xfree (*iter);
+      delete *iter;
       thread_list.erase (iter);
     }
 }
@@ -1718,7 +1715,7 @@ windows_nat_target::get_windows_debug_event (int pid,
   BOOL debug_event;
   DWORD continue_status, event_code;
   windows_thread_info *th;
-  static windows_thread_info dummy_thread_info;
+  static windows_thread_info dummy_thread_info (0, 0, 0);
   DWORD thread_id = 0;
 
   last_sig = GDB_SIGNAL_0;
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 3923429cfc..be2f767662 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+	* win32-low.c (child_add_thread): Use new.
+	(delete_thread_info): Use delete.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
 	* win32-low.h (struct windows_thread_info): Remove.
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 55e8322ceb..1284ed177c 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -212,10 +212,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
   if ((th = thread_rec (ptid, FALSE)))
     return th;
 
-  th = XCNEW (windows_thread_info);
-  th->tid = tid;
-  th->h = h;
-  th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
+  th = new windows_thread_info (tid, h, (CORE_ADDR) (uintptr_t) tlb);
 
   add_thread (ptid, th);
 
@@ -233,7 +230,7 @@ delete_thread_info (thread_info *thread)
 
   remove_thread (thread);
   CloseHandle (th->h);
-  free (th);
+  delete th;
 }
 
 /* Delete a thread from the list of threads.  */


             reply	other threads:[~2020-04-24 16:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 16:45 gdb-buildbot [this message]
2020-04-24 16:45 ` Failures on Fedora-i686, branch master gdb-buildbot
2020-04-24 16:56 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot
2020-04-24 17:47 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-04-24 18:33 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-04-24 18:47 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-04-25 21:14 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
2020-04-28 23:17 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot

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=e9534bd257ac9ea2f7921e8000d27c5dc4477b4e@gdb-build \
    --to=gdb-buildbot@sergiodj.net \
    --cc=gdb-testers@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).