/* We get Access Denied (5) when trying to suspend
threads that Windows started on behalf of the
debuggee, usually when those threads are just
- about to exit. */
- if (err != ERROR_ACCESS_DENIED)
+ about to exit.
+ We can get Invalid Handle (6) if the main thread
+ has exited. */
+ if (err != ERROR_INVALID_HANDLE
+ && err != ERROR_ACCESS_DENIED)
warning (_("SuspendThread (tid=0x%x) failed."
" (winerr %u)"),
(unsigned) id, (unsigned) err);
if (current_thread->reload_context)
{
-#ifdef __COPY_CONTEXT_SIZE
+#ifdef __CYGWIN__
if (have_saved_context)
{
/* Lie about where the program actually is stopped since
#ifdef __CYGWIN__
if (!startswith (s, "cYg"))
#endif
- warning (("%s"), s);
+ {
+ char *p = strchr (s, '\0');
+
+ if (p > s && *--p == '\n')
+ *p = '\0';
+ warning (("%s"), s);
+ }
}
-#ifdef __COPY_CONTEXT_SIZE
+#ifdef __CYGWIN__
else
{
/* Got a cygwin signal marker. A cygwin signal is followed by
__COPY_CONTEXT_SIZE, &n)
&& n == __COPY_CONTEXT_SIZE)
have_saved_context = 1;
- current_event.dwThreadId = retval;
}
}
#endif
current_event.dwThreadId,
continue_status);
+ if (!res)
+ error (_("Failed to resume program execution"
+ " (ContinueDebugEvent failed, error %u)"),
+ (unsigned int) GetLastError ());
+
debug_registers_changed = 0;
return res;
}
}
}
#endif
- DEBUG_EXCEPT(("Can only continue with recieved signal %d.\n",
+ DEBUG_EXCEPT(("Can only continue with received signal %d.\n",
last_sig));
}
return TRUE;
}
-/* Get the next event from the child. Return 1 if the event requires
- handling by WFI (or whatever). */
+/* Get the next event from the child. Returns a non-zero thread id if the event
+ requires handling by WFI (or whatever). */
static int
get_windows_debug_event (struct target_ops *ops,
int pid, struct target_waitstatus *ourstatus)
DWORD continue_status, event_code;
windows_thread_info *th;
static windows_thread_info dummy_thread_info;
- int retval = 0;
+ DWORD thread_id = 0;
last_sig = GDB_SIGNAL_0;
/* Kludge around a Windows bug where first event is a create
thread event. Caused when attached process does not have
a main thread. */
- retval = fake_create_process ();
- if (retval)
+ thread_id = fake_create_process ();
+ if (thread_id)
saw_create++;
}
break;
}
/* Record the existence of this thread. */
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
current_event.u.CreateThread.hThread,
current_event.dwThreadId),
current_event.u.CreateProcessInfo.hThread,
current_event.u.CreateProcessInfo.lpThreadLocalBase);
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
break;
case EXIT_PROCESS_DEBUG_EVENT:
{
ourstatus->kind = TARGET_WAITKIND_EXITED;
ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
- retval = main_thread_id;
+ thread_id = main_thread_id;
}
break;
catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL);
ourstatus->kind = TARGET_WAITKIND_LOADED;
ourstatus->value.integer = 0;
- retval = main_thread_id;
+ thread_id = main_thread_id;
break;
case UNLOAD_DLL_DEBUG_EVENT:
catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL);
ourstatus->kind = TARGET_WAITKIND_LOADED;
ourstatus->value.integer = 0;
- retval = main_thread_id;
+ thread_id = main_thread_id;
break;
case EXCEPTION_DEBUG_EVENT:
continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
case 1:
- retval = current_event.dwThreadId;
+ thread_id = current_event.dwThreadId;
break;
case -1:
last_sig = 1;
"OUTPUT_DEBUG_STRING_EVENT"));
if (saw_create != 1)
break;
- retval = handle_output_debug_string (ourstatus);
+ thread_id = handle_output_debug_string (ourstatus);
break;
default:
break;
}
- if (!retval || saw_create != 1)
+ if (!thread_id || saw_create != 1)
{
if (continue_status == -1)
windows_resume (ops, minus_one_ptid, 0, 1);
else
{
inferior_ptid = ptid_build (current_event.dwProcessId, 0,
- retval);
+ thread_id);
current_thread = th;
if (!current_thread)
- current_thread = thread_rec (current_event.dwThreadId, TRUE);
+ current_thread = thread_rec (thread_id, TRUE);
}
out:
- return retval;
+ return thread_id;
}
/* Wait for interesting events to occur in the target process. */
return t;
}
-static void
-set_windows_aliases (char *argv0)
-{
- add_info_alias ("dll", "sharedlibrary", 1);
-}
-
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_windows_nat;
add_cmd ("selector", class_info, display_selectors,
_("Display selectors infos."),
&info_w32_cmdlist);
- deprecated_init_ui_hook = set_windows_aliases;
}
/* Hardware watchpoint support, adapted from go32-nat.c code. */