windows-nat: Report an error if ContinueDebugEvent() fails
authorJon Turney <jon.turney@dronecode.org.uk>
Wed, 15 Apr 2015 20:37:11 +0000 (21:37 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Wed, 22 Apr 2015 18:40:11 +0000 (19:40 +0100)
Using the 'catch-signal' test from the testsuite, on x86_64 Cygwin:

    $ ./gdb testsuite/outputs/gdb.base/catch-signal/catch-signal.exe
    [...]
    (gdb) catch signal
    Catchpoint 1 (standard signals)
    (gdb) r
    [...]
    Catchpoint 1 (signal SIGHUP), main () at
    ../../../gdb/testsuite/gdb.base/catch-signal.c:40
    40        raise (SIGHUP);               /* second HUP */
    (gdb) c
    Continuing.
    [hangs]

This is due to a defect in the way Cygwin signals are handled: When
handle_output_debug_string processes a Cygwin signal message, it re-writes
current_event.dwThreadId to reflect the thread that the signal will be delivered
to.

Subsequently, the call to ContinueDebugEvent will fail, because we're trying to
resume the wrong thread.  GDB is then stuck waiting forever for another event
that will never come.

This patch doesn't fix the problem, it just adds appropriate error handling.

Using error() seems appropriate here, if ContinueDebugEvent() fails, the
inferior is in an unknown state and we will probably not be debugging it
anymore.

With this patch applied, resuming the execution of the program now yields:

    $ ./gdb testsuite/outputs/gdb.base/catch-signal/catch-signal.exe
    [...]
    (gdb) catch signal
    Catchpoint 1 (standard signals)
    (gdb) r
    [...]
    Catchpoint 1 (signal SIGHUP), main () at
    ../../../gdb/testsuite/gdb.base/catch-signal.c:40
    40        raise (SIGHUP);               /* second HUP */
    (gdb) c
    Continuing.
    main () at ../../../gdb/testsuite/gdb.base/catch-signal.c:40
    40        raise (SIGHUP);               /* second HUP */
    Failed to resume program execution (ContinueDebugEvent failed, error 87)
    (gdb)

gdb/ChangeLog:

2015-04-22  Jon Turney  <jon.turney@dronecode.org.uk>

* windows-nat.c (windows_continue): Report an error if
ContinueDebugEvent() fails.

gdb/ChangeLog
gdb/windows-nat.c

index d5edf3c8b1b1e4ee0506aea60d38c40fd93a607b..1d64788647518404fcb5db06831bb5b1a860b8ee 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-22  Jon Turney  <jon.turney@dronecode.org.uk>
+
+       * windows-nat.c (windows_continue): Report an error if
+       ContinueDebugEvent() fails.
+
 2015-04-16  Jon Turney  <jon.turney@dronecode.org.uk>
 
        * windows-nat.c (windows_resume): Fix misspelling in debug output.
index 05e4ceec614d226db1feffaaf656daf4b0ae1037..6942d643872d1d2c3097c476f387e43bfd0be52a 100644 (file)
@@ -1160,6 +1160,11 @@ windows_continue (DWORD continue_status, int id, int killed)
                            current_event.dwThreadId,
                            continue_status);
 
+  if (!res)
+    error (_("Failed to resume program execution"
+            " (ContinueDebugEvent failed, error %u)"),
+          (unsigned int) GetLastError ());
+
   debug_registers_changed = 0;
   return res;
 }
This page took 0.030565 seconds and 4 git commands to generate.