Patchwork [review] Call CloseHandle from ~windows_thread_info

login
register
mail settings
Submitter Simon Marchi (Code Review)
Date Nov. 26, 2019, 5:11 p.m.
Message ID <gerrit.1574788288000.I4bae7f2551aa55be2bc5bd93d566a5c2e369247f@gnutoolchain-gerrit.osci.io>
Download mbox | patch
Permalink /patch/36219/
State New
Headers show

Comments

Simon Marchi (Code Review) - Nov. 26, 2019, 5:11 p.m.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/706
......................................................................

Call CloseHandle from ~windows_thread_info

Add a destructor to windows_thread_info that calls CloseHandle.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tromey@adacore.com>

	* nat/windows-nat.h (struct windows_thread_info): Declare
	destructor.
	* nat/windows-nat.c (~windows_thread_info): New.

gdb/gdbserver/ChangeLog
2019-11-26  Tom Tromey  <tromey@adacore.com>

	* win32-low.c (delete_thread_info): Don't call CloseHandle.

Change-Id: I4bae7f2551aa55be2bc5bd93d566a5c2e369247f
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.c
M gdb/nat/windows-nat.h
5 files changed, 17 insertions(+), 1 deletion(-)
Simon Marchi (Code Review) - Nov. 29, 2019, 7:08 p.m.
Pedro Alves has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/706
......................................................................


Patch Set 1: Code-Review+2

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bb441a1..08d2ecb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@ 
 2019-11-26  Tom Tromey  <tromey@adacore.com>
 
+	* nat/windows-nat.h (struct windows_thread_info): Declare
+	destructor.
+	* nat/windows-nat.c (~windows_thread_info): New.
+
+2019-11-26  Tom Tromey  <tromey@adacore.com>
+
 	PR gdb/22992
 	* windows-nat.c (current_event): Update comment.
 	(last_wait_event, desired_stop_thread_id): New globals.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 99b949a..6dcb274 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,9 @@ 
 2019-11-26  Tom Tromey  <tromey@adacore.com>
 
+	* win32-low.c (delete_thread_info): Don't call CloseHandle.
+
+2019-11-26  Tom Tromey  <tromey@adacore.com>
+
 	* win32-low.c (win32_require_context, suspend_one_thread): Use
 	windows_thread_info::suspend.
 	(continue_one_thread): Use windows_thread_info::resume.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 59749f0..9d69af7 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -219,7 +219,6 @@ 
   windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
 
   remove_thread (thread);
-  CloseHandle (th->h);
   delete th;
 }
 
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 59b0fac..e5a12c3 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -19,6 +19,11 @@ 
 #include "gdbsupport/common-defs.h"
 #include "nat/windows-nat.h"
 
+windows_thread_info::~windows_thread_info ()
+{
+  CloseHandle (h);
+}
+
 void
 windows_thread_info::suspend ()
 {
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index d64ef8e..8535a15 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -32,6 +32,8 @@ 
   {
   }
 
+  ~windows_thread_info ();
+
   DISABLE_COPY_AND_ASSIGN (windows_thread_info);
 
   /* Ensure that this thread has been suspended.  */