2004-06-07 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / windows-nat.c
index c28e26ad2c7cc15a777074219fd3ac6b8b59eb86..fb785354e460b2fa04c6f041b1ff90b2000e07c2 100644 (file)
@@ -338,7 +338,8 @@ do_child_fetch_inferior_registers (int r)
   long l;
 
   if (!current_thread)
-    return;
+    return;    /* Windows sometimes uses a non-existent thread id in its
+                  events */
 
   if (current_thread->reload_context)
     {
@@ -382,6 +383,8 @@ static void
 child_fetch_inferior_registers (int r)
 {
   current_thread = thread_rec (PIDGET (inferior_ptid), TRUE);
+  /* Check if current_thread exists.  Windows sometimes uses a non-existent
+     thread id in its events */
   if (current_thread)
     do_child_fetch_inferior_registers (r);
 }
@@ -390,7 +393,7 @@ static void
 do_child_store_inferior_registers (int r)
 {
   if (!current_thread)
-    /* nothing to do */;
+    /* Windows sometimes uses a non-existent thread id in its events */;
   else if (r >= 0)
     regcache_collect (r, ((char *) &current_thread->context) + mappings[r]);
   else
@@ -405,6 +408,8 @@ static void
 child_store_inferior_registers (int r)
 {
   current_thread = thread_rec (PIDGET (inferior_ptid), TRUE);
+  /* Check if current_thread exists.  Windows sometimes uses a non-existent
+     thread id in its events */
   if (current_thread)
     do_child_store_inferior_registers (r);
 }
@@ -1207,8 +1212,10 @@ child_continue (DWORD continue_status, int id)
   return res;
 }
 
+/* Called in pathological case where Windows fails to send a
+   CREATE_PROCESS_DEBUG_EVENT after an attach.  */
 DWORD
-fake_create_process ()
+fake_create_process (void)
 {
   current_process_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE,
                                        current_event.dwProcessId);
@@ -1253,6 +1260,9 @@ get_child_debug_event (int pid, struct target_waitstatus *ourstatus)
        {
          if (!saw_create && attach_flag)
            {
+             /* Kludge around a Windows bug where first event is a create
+                thread event.  Caused when attached process does not have
+                a main thread. */
              retval = ourstatus->value.related_pid = fake_create_process ();
              saw_create++;
            }
@@ -1670,7 +1680,8 @@ child_open (char *arg, int from_tty)
    ENV is the environment vector to pass.  Errors reported with error().  */
 
 static void
-child_create_inferior (char *exec_file, char *allargs, char **env)
+child_create_inferior (char *exec_file, char *allargs, char **env,
+                      int from_tty)
 {
   char *winenv;
   char *temp;
@@ -2417,7 +2428,7 @@ static struct core_fns win32_elf_core_fns =
 void
 _initialize_core_win32 (void)
 {
-  add_core_fns (&win32_elf_core_fns);
+  deprecated_add_core_fns (&win32_elf_core_fns);
 }
 
 void
This page took 0.027523 seconds and 4 git commands to generate.