[4/5] windows-nat: Report an error if ContinueDebugEvent() fails

Message ID 1429212209-20548-5-git-send-email-jon.turney@dronecode.org.uk
State New, archived
Headers

Commit Message

Jon Turney April 16, 2015, 7:23 p.m. UTC
  Using error() seems appropriate here, if ContinueDebugEvent() fails, the
inferior is in an unknown state and we will probably not be debugging anymore...

gdb/ChangeLog:

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

	* windows-nat.c (windows_continue): Report an error if
	ContinueDebugEvent() fails.
---
 gdb/ChangeLog     | 5 +++++
 gdb/windows-nat.c | 4 ++++
 2 files changed, 9 insertions(+)
  

Comments

Joel Brobecker April 22, 2015, 2:10 p.m. UTC | #1
> 2015-04-16  Jon Turney  <jon.turney@dronecode.org.uk>
> 
> 	* windows-nat.c (windows_continue): Report an error if
> 	ContinueDebugEvent() fails.

Mostly OK, except that I'd like the error message to be a little
more user-friendly. Can you use something like:

    Failed to resume program execution (ContinueDebugEvent failed, error %u)

No need for the "()", use "call to ContinueDebugEvent" instead.

But before you push, would you mind ammending this commit's revision
history to include the info you provided in email 0/5? In particular,
I would just say something like this:

| windows-nat: Report an error if ContinueDebugEvent fails
|
| 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]
|
| [say what happens here, and what you are doing - in other words,
| the call to ContinueDebugEvent is failing because we're trying
| to resume the wrong thread, causing GDB to wait forever for another
| event that will never come; and you are not trying to fix the problem
| in this patch, just add error handling]
|
| With this patch applied, resuming the execution of the program
| now yields:
|
|     (gdb) c
|     Continuing.
|     main () at ../../../gdb/testsuite/gdb.base/catch-signal.c:40
|     40        raise (SIGHUP);               /* second HUP */
|     ContinueDebugEvent failed, GetLastError = 87  <<<<<---- **UPDATE**
|
| [ChangeLog]

Thanks!
  

Patch

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 05e4cee..94d295e 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1160,6 +1160,10 @@  windows_continue (DWORD continue_status, int id, int killed)
 			    current_event.dwThreadId,
 			    continue_status);
 
+  if (!res)
+    error (_("ContinueDebugEvent failed, GetLastError = %u"),
+	   (unsigned) GetLastError ());
+
   debug_registers_changed = 0;
   return res;
 }