* [review] Use new and delete for windows_thread_info
@ 2019-10-29 17:58 Tom Tromey (Code Review)
2019-10-31 3:59 ` Luis Machado (Code Review)
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-29 17:58 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/408
......................................................................
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
2019-10-29 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.
gdb/gdbserver/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* win32-low.c (child_add_thread): Use new.
(delete_thread_info): Use delete.
Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
5 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index da276ab..d014dc8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2019-10-29 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.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (struct windows_thread_info): Remove.
* nat/windows-nat.h: New file.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index bf0f3e0..5819b74 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (child_add_thread): Use new.
+ (delete_thread_info): Use delete.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* win32-low.h (struct windows_thread_info): Remove.
2019-10-29 Tom Tromey <tromey@adacore.com>
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 6a081e2..7e3afff 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -213,10 +213,7 @@
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);
@@ -234,7 +231,7 @@
remove_thread (thread);
CloseHandle (th->h);
- free (th);
+ delete th;
}
/* Delete a thread from the list of threads. */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 30fce27..2fe2a2f 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -23,6 +23,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;
@@ -33,26 +47,26 @@
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. */
- CONTEXT context;
+ CONTEXT context {};
/* 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 19a2b2d..d18c37b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -429,10 +429,7 @@
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;
+ th = new windows_thread_info (id, h, (CORE_ADDR) (uintptr_t) tlb);
thread_list.push_back (th);
/* Add this new thread to the list of threads.
@@ -472,7 +469,7 @@
init_thread_list ();
for (windows_thread_info *here : thread_list)
- xfree (here);
+ delete here;
thread_list.clear ();
}
@@ -517,8 +514,7 @@
if (iter != thread_list.end ())
{
- xfree ((*iter)->name);
- xfree (*iter);
+ delete *iter;
thread_list.erase (iter);
}
}
@@ -1501,7 +1497,7 @@
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;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
Gerrit-Change-Number: 408
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Use new and delete for windows_thread_info
2019-10-29 17:58 [review] Use new and delete for windows_thread_info Tom Tromey (Code Review)
@ 2019-10-31 3:59 ` Luis Machado (Code Review)
2019-10-31 18:15 ` Simon Marchi (Code Review)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luis Machado (Code Review) @ 2019-10-31 3:59 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Luis Machado has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/408
......................................................................
Patch Set 1: Code-Review+1
I don't have any comments.
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
Gerrit-Change-Number: 408
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Comment-Date: Thu, 31 Oct 2019 03:59:44 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Use new and delete for windows_thread_info
2019-10-29 17:58 [review] Use new and delete for windows_thread_info Tom Tromey (Code Review)
2019-10-31 3:59 ` Luis Machado (Code Review)
@ 2019-10-31 18:15 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
2019-11-29 17:59 ` Pedro Alves (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi (Code Review) @ 2019-10-31 18:15 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Luis Machado
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/408
......................................................................
Patch Set 1: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
Gerrit-Change-Number: 408
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Thu, 31 Oct 2019 18:15:03 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review v2] Use new and delete for windows_thread_info
2019-10-29 17:58 [review] Use new and delete for windows_thread_info Tom Tromey (Code Review)
2019-10-31 3:59 ` Luis Machado (Code Review)
2019-10-31 18:15 ` Simon Marchi (Code Review)
@ 2019-11-26 17:11 ` Tom Tromey (Code Review)
2019-11-29 17:59 ` Pedro Alves (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 17:11 UTC (permalink / raw)
To: Luis Machado, Simon Marchi, gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/408
......................................................................
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
2019-11-26 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.
gdb/gdbserver/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* win32-low.c (child_add_thread): Use new.
(delete_thread_info): Use delete.
Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
5 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e24159a..07b5cee 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2019-11-26 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.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (struct windows_thread_info): Remove.
* nat/windows-nat.h: New file.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 8c0c8ba..e376af3 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (child_add_thread): Use new.
+ (delete_thread_info): Use delete.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* win32-low.h (struct windows_thread_info): Remove.
2019-11-26 Tom Tromey <tromey@adacore.com>
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 6a081e2..7e3afff 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -213,10 +213,7 @@
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);
@@ -234,7 +231,7 @@
remove_thread (thread);
CloseHandle (th->h);
- free (th);
+ delete th;
}
/* Delete a thread from the list of threads. */
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 30fce27..2fe2a2f 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -23,6 +23,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;
@@ -33,26 +47,26 @@
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. */
- CONTEXT context;
+ CONTEXT context {};
/* 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 f6d4010..31039d5 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -429,10 +429,7 @@
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;
+ th = new windows_thread_info (id, h, (CORE_ADDR) (uintptr_t) tlb);
thread_list.push_back (th);
/* Add this new thread to the list of threads.
@@ -472,7 +469,7 @@
init_thread_list ();
for (windows_thread_info *here : thread_list)
- xfree (here);
+ delete here;
thread_list.clear ();
}
@@ -517,8 +514,7 @@
if (iter != thread_list.end ())
{
- xfree ((*iter)->name);
- xfree (*iter);
+ delete *iter;
thread_list.erase (iter);
}
}
@@ -1501,7 +1497,7 @@
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;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
Gerrit-Change-Number: 408
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review v2] Use new and delete for windows_thread_info
2019-10-29 17:58 [review] Use new and delete for windows_thread_info Tom Tromey (Code Review)
` (2 preceding siblings ...)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
@ 2019-11-29 17:59 ` Pedro Alves (Code Review)
3 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-29 17:59 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Simon Marchi, Luis Machado
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/408
......................................................................
Patch Set 2: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2100e91f371b1fa0ae51aabb2a59ae393f789923
Gerrit-Change-Number: 408
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Fri, 29 Nov 2019 17:59:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-29 17:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29 17:58 [review] Use new and delete for windows_thread_info Tom Tromey (Code Review)
2019-10-31 3:59 ` Luis Machado (Code Review)
2019-10-31 18:15 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
2019-11-29 17:59 ` Pedro Alves (Code Review)
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).