* win32-i386-low.c (i386_get_thread_context): Handle systems that
authorPedro Alves <palves@redhat.com>
Sat, 4 Jul 2009 18:13:28 +0000 (18:13 +0000)
committerPedro Alves <palves@redhat.com>
Sat, 4 Jul 2009 18:13:28 +0000 (18:13 +0000)
don't support CONTEXT_EXTENDED_REGISTERS.
(i386_win32_breakpoint, i386_win32_breakpoint_len): New.
(the_low_target): Install them.
* win32-low.c (get_child_debug_event): Handle WaitForDebugEvent
failing with ERROR_PIPE_NOT_CONNECTED.

gdb/gdbserver/ChangeLog
gdb/gdbserver/win32-i386-low.c
gdb/gdbserver/win32-low.c

index 86fe1746ae69be70bcf1d84172264f98497b353b..4c3a3a1d3e675e3ac80225bde0dbd3bb038b0cba 100644 (file)
@@ -1,3 +1,13 @@
+2009-07-04  Danny Backx  <dannybackx@users.sourceforge.net>
+           Pedro Alves  <pedro@codesourcery.com>
+
+       * win32-i386-low.c (i386_get_thread_context): Handle systems that
+       don't support CONTEXT_EXTENDED_REGISTERS.
+       (i386_win32_breakpoint, i386_win32_breakpoint_len): New.
+       (the_low_target): Install them.
+       * win32-low.c (get_child_debug_event): Handle WaitForDebugEvent
+       failing with ERROR_PIPE_NOT_CONNECTED.
+
 2009-06-30  Doug Evans  <dje@google.com>
            Pierre Muller  <muller@ics.u-strasbg.fr>
 
index 7e058a58b564866122d4ea07845a257833e92b88..b610631f49479d8a43173eb859e2da1492ae708c 100644 (file)
@@ -129,13 +129,28 @@ i386_initial_stuff (void)
 static void
 i386_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
 {
-  th->context.ContextFlags = \
-    CONTEXT_FULL | \
-    CONTEXT_FLOATING_POINT | \
-    CONTEXT_EXTENDED_REGISTERS | \
-    CONTEXT_DEBUG_REGISTERS;
+  /* Requesting the CONTEXT_EXTENDED_REGISTERS register set fails if
+     the system doesn't support extended registers.  */
+  static DWORD extended_registers = CONTEXT_EXTENDED_REGISTERS;
 
-  GetThreadContext (th->h, &th->context);
+ again:
+  th->context.ContextFlags = (CONTEXT_FULL
+                             | CONTEXT_FLOATING_POINT
+                             | CONTEXT_DEBUG_REGISTERS
+                             | extended_registers);
+
+  if (!GetThreadContext (th->h, &th->context))
+    {
+      DWORD e = GetLastError ();
+
+      if (extended_registers && e == ERROR_INVALID_PARAMETER)
+       {
+         extended_registers = 0;
+         goto again;
+       }
+
+      error ("GetThreadContext failure %ld\n", (long) e);
+    }
 
   debug_registers_changed = 0;
 
@@ -283,6 +298,9 @@ i386_store_inferior_register (win32_thread_info *th, int r)
   collect_register (r, context_offset);
 }
 
+static const unsigned char i386_win32_breakpoint = 0xcc;
+#define i386_win32_breakpoint_len 1
+
 struct win32_target_ops the_low_target = {
   init_registers_i386,
   sizeof (mappings) / sizeof (mappings[0]),
@@ -293,8 +311,8 @@ struct win32_target_ops the_low_target = {
   i386_fetch_inferior_register,
   i386_store_inferior_register,
   i386_single_step,
-  NULL, /* breakpoint */
-  0, /* breakpoint_len */
+  &i386_win32_breakpoint,
+  i386_win32_breakpoint_len,
   i386_insert_point,
   i386_remove_point,
   i386_stopped_by_watchpoint,
index a1380f6030b93bbf2117bcd9f6c366ede1b29b10..bcf16b2ece3af7d89dc6400b4de830d67df3639d 100644 (file)
@@ -1407,7 +1407,22 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
         interruption, but high enough so gdbserver doesn't become a
         bottleneck.  */
       if (!WaitForDebugEvent (&current_event, 250))
-       return 0;
+        {
+         DWORD e  = GetLastError();
+
+         if (e == ERROR_PIPE_NOT_CONNECTED)
+           {
+             /* This will happen if the loader fails to succesfully
+                load the application, e.g., if the main executable
+                tries to pull in a non-existing export from a
+                DLL.  */
+             ourstatus->kind = TARGET_WAITKIND_EXITED;
+             ourstatus->value.integer = 1;
+             return 1;
+           }
+
+         return 0;
+        }
     }
 
  gotevent: