* windows-nat.c (windows_initialization_done): New variable.
authorChristopher Faylor <me+cygwin@cgf.cx>
Wed, 27 Jan 2010 19:57:54 +0000 (19:57 +0000)
committerChristopher Faylor <me+cygwin@cgf.cx>
Wed, 27 Jan 2010 19:57:54 +0000 (19:57 +0000)
(get_windows_debug_event): Issue error when process dies before completely
initializing.
(do_initial_windows_stuff): Set flag to indicate when we are done with the
initial steps of attaching to the child.

gdb/ChangeLog
gdb/windows-nat.c

index cbfe494881a755cbabd403cfe632d2d5bfdbe2c7..0c6d99f54efcde0febff93e22199039115a9d12b 100644 (file)
@@ -1,3 +1,11 @@
+2010-01-27  Christopher Faylor  <me+cygwin@cgf.cx>
+
+       * windows-nat.c (windows_initialization_done): New variable.
+       (get_windows_debug_event): Issue error when process dies before
+       completely initializing.
+       (do_initial_windows_stuff): Set flag to indicate when we are done with
+       the initial steps of attaching to the child.
+
 2010-01-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * symtab.h (struct symbol <symtab>): New comment on NULL values.
index f91ca322707885c635a1f55f04e4abd893fc37b4..2740366a8b03367c2ef22cfc73c1689a7d6bce74 100644 (file)
@@ -123,6 +123,8 @@ enum
 static uintptr_t dr[8];
 static int debug_registers_changed;
 static int debug_registers_used;
+
+static int windows_initialization_done;
 #define DR6_CLEAR_VALUE 0xffff0ff0
 
 /* The string sent by cygwin when it processes a signal.
@@ -1399,11 +1401,19 @@ get_windows_debug_event (struct target_ops *ops,
                     (unsigned) current_event.dwProcessId,
                     (unsigned) current_event.dwThreadId,
                     "EXIT_PROCESS_DEBUG_EVENT"));
-      if (saw_create != 1)
-       break;
-      ourstatus->kind = TARGET_WAITKIND_EXITED;
-      ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
-      retval = main_thread_id;
+      if (!windows_initialization_done)
+       {
+         target_terminal_ours ();
+         target_mourn_inferior ();
+         error (_("During startup program exited with code 0x%x."),
+                (unsigned int) current_event.u.ExitProcess.dwExitCode);
+       }
+      else if (saw_create == 1)
+       {
+         ourstatus->kind = TARGET_WAITKIND_EXITED;
+         ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
+         retval = main_thread_id;
+       }
       break;
 
     case LOAD_DLL_DEBUG_EVENT:
@@ -1598,6 +1608,7 @@ do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching)
   terminal_init_inferior_with_pgrp (pid);
   target_terminal_inferior ();
 
+  windows_initialization_done = 0;
   inf->stop_soon = STOP_QUIETLY;
   while (1)
     {
@@ -1610,6 +1621,7 @@ do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching)
        break;
     }
 
+  windows_initialization_done = 1;
   inf->stop_soon = NO_STOP_QUIETLY;
   stop_after_trap = 0;
   return;