windows-nat: Don't change current_event.dwThreadId in handle_output_debug_string()
authorJon Turney <jon.turney@dronecode.org.uk>
Wed, 15 Apr 2015 20:41:25 +0000 (21:41 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Wed, 22 Apr 2015 18:54:22 +0000 (19:54 +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.
    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)

This error occurs because 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, which can be different to the thread reporting
the signal.

Altering current_event.dwThreadId() will cause ContinueDebugEvent() to be
applied to the wrong thread and fail.

So, rather than re-writing the thread id in current_event, use the thread
id by returning it.

With this patch applied this test now yields the expected result:

    $ ./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.
    Catchpoint 1 (signal SIGHUP), main () at
    ../../../gdb/testsuite/gdb.base/catch-signal.c:42
    42        raise (SIGHUP);               /* third HUP */
    (gdb)

gdb/ChangeLog:

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

* windows-nat.c (handle_output_debug_string): Don't change
current_event.dwThreadId.
(get_windows_debug_event): Use thread_id, rather than relying on
current_event.dwThreadId being changed.

gdb/ChangeLog
gdb/windows-nat.c

index 1d64788647518404fcb5db06831bb5b1a860b8ee..f5ea3957faafdf1add1034396b6c6b318e8613ce 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-22  Jon Turney  <jon.turney@dronecode.org.uk>
+
+       * windows-nat.c (handle_output_debug_string): Don't change
+       current_event.dwThreadId.
+       (get_windows_debug_event): Use thread_id, rather than relying on
+       current_event.dwThreadId being changed.
+
 2015-04-22  Jon Turney  <jon.turney@dronecode.org.uk>
 
        * windows-nat.c (windows_continue): Report an error if
index 6942d643872d1d2c3097c476f387e43bfd0be52a..be5d7e814b9795deaa22ff9aa93557deac3754bd 100644 (file)
@@ -850,7 +850,6 @@ handle_output_debug_string (struct target_waitstatus *ourstatus)
                                         __COPY_CONTEXT_SIZE, &n)
                   && n == __COPY_CONTEXT_SIZE)
            have_saved_context = 1;
-         current_event.dwThreadId = retval;
        }
     }
 #endif
@@ -1509,7 +1508,7 @@ get_windows_debug_event (struct target_ops *ops,
                                  thread_id);
       current_thread = th;
       if (!current_thread)
-       current_thread = thread_rec (current_event.dwThreadId, TRUE);
+       current_thread = thread_rec (thread_id, TRUE);
     }
 
 out:
This page took 0.030436 seconds and 4 git commands to generate.