windows-nat: Also ignore ERROR_INVALID_HANDLE from SuspendThread()
authorJon Turney <jon.turney@dronecode.org.uk>
Wed, 3 Jun 2015 13:28:29 +0000 (14:28 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Wed, 10 Jun 2015 12:28:19 +0000 (13:28 +0100)
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
gdb/windows-nat.c

index bfc6a0ebf270433d2a46295087f25bf6c9d0107a..c9f527c7270b707ff697119c783b2033c9258589 100644 (file)
@@ -1,3 +1,8 @@
+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 (handle_output_debug_string): Trim trailing '\n'
index 851eb5192d646f5b6a9354d31c4baf44da1a5cc2..8a425113a058977454d33b10350ed03354eb3200 100644 (file)
@@ -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);