diff mbox

[4/4] windows-nat: Also ignore ERROR_INVALID_HANDLE from SuspendThread()

Message ID 1433352592-9728-6-git-send-email-jon.turney@dronecode.org.uk
State New
Headers show

Commit Message

Jon TURNEY June 3, 2015, 5:29 p.m. UTC
Discussed somewhat in the thread at
https://cygwin.com/ml/gdb-patches/2013-06/msg00680.html

This is pretty straightforward to demonstrate on Cygwin currently:

$ cat main.c

int main()
{
  return 0;
}

$ gcc -g -O0 main.c -o main

$ ./gdb ./main
[...]
(gdb) r
Starting program: /wip/binutils-gdb/build.x86_64/gdb/main
warning: SuspendThread (tid=0x1cf0) failed. (winerr 6)
[Inferior 1 (process 976) exited normally]

with this patch applied:

$ ./gdb ./main
[...]
(gdb) r
Starting program: /wip/binutils-gdb/build.x86_64/gdb/main
[Inferior 1 (process 4852) exited normally]

gdb/ChangeLog:

2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
	from SuspendThread().

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 gdb/ChangeLog     | 5 +++++
 gdb/windows-nat.c | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

Comments

Joel Brobecker June 9, 2015, 7:17 p.m. UTC | #1
> 2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>
> 
> 	* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
> 	from SuspendThread().

OK to push, after one slight formatting nit gets fixed.

> -		    if (err != ERROR_ACCESS_DENIED)
> +		       about to exit.
> +		       We can get Invalid Handle (6) if the main thread
> +		       has exited. */

GNU Coding Style: 2 spacces after a period.

Thank you,
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 996dffe..eddcf4d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@ 
 2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>
 
+	* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
+	from SuspendThread().
+
+2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>
+
 	* windows-nat.c : Consistently use numeric get_context parameter
 	to thread_rec() throughout.
 
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ce1513f..75d9414 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -310,8 +310,11 @@  thread_rec (DWORD id, int get_context)
 		    /* We get Access Denied (5) when trying to suspend
 		       threads that Windows started on behalf of the
 		       debuggee, usually when those threads are just
-		       about to exit.  */
-		    if (err != ERROR_ACCESS_DENIED)
+		       about to exit.
+		       We can get Invalid Handle (6) if the main thread
+		       has exited. */
+		    if (err != ERROR_INVALID_HANDLE
+			&& err != ERROR_ACCESS_DENIED)
 		      warning (_("SuspendThread (tid=0x%x) failed."
 				 " (winerr %u)"),
 			       (unsigned) id, (unsigned) err);