+ regcache_raw_supply (current_regcache, r, core_reg_sect + mappings[r]);
+}
+
+static void
+init_win32_ops (void)
+{
+ win32_ops.to_shortname = "child";
+ win32_ops.to_longname = "Win32 child process";
+ win32_ops.to_doc = "Win32 child process (started by the \"run\" command).";
+ win32_ops.to_open = win32_open;
+ win32_ops.to_close = win32_close;
+ win32_ops.to_attach = win32_attach;
+ win32_ops.to_detach = win32_detach;
+ win32_ops.to_resume = win32_resume;
+ win32_ops.to_wait = win32_wait;
+ win32_ops.to_fetch_registers = win32_fetch_inferior_registers;
+ win32_ops.to_store_registers = win32_store_inferior_registers;
+ win32_ops.to_prepare_to_store = win32_prepare_to_store;
+ win32_ops.deprecated_xfer_memory = win32_xfer_memory;
+ win32_ops.to_files_info = win32_files_info;
+ win32_ops.to_insert_breakpoint = memory_insert_breakpoint;
+ win32_ops.to_remove_breakpoint = memory_remove_breakpoint;
+ win32_ops.to_terminal_init = terminal_init_inferior;
+ win32_ops.to_terminal_inferior = terminal_inferior;
+ win32_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ win32_ops.to_terminal_ours = terminal_ours;
+ win32_ops.to_terminal_save_ours = terminal_save_ours;
+ win32_ops.to_terminal_info = child_terminal_info;
+ win32_ops.to_kill = win32_kill_inferior;
+ win32_ops.to_create_inferior = win32_create_inferior;
+ win32_ops.to_mourn_inferior = win32_mourn_inferior;
+ win32_ops.to_can_run = win32_can_run;
+ win32_ops.to_thread_alive = win32_win32_thread_alive;
+ win32_ops.to_pid_to_str = cygwin_pid_to_str;
+ win32_ops.to_stop = win32_stop;
+ win32_ops.to_stratum = process_stratum;
+ win32_ops.to_has_all_memory = 1;
+ win32_ops.to_has_memory = 1;
+ win32_ops.to_has_stack = 1;
+ win32_ops.to_has_registers = 1;
+ win32_ops.to_has_execution = 1;
+ win32_ops.to_magic = OPS_MAGIC;
+ win32_ops.to_pid_to_exec_file = win32_pid_to_exec_file;
+
+ win32_so_ops.relocate_section_addresses = win32_relocate_section_addresses;
+ win32_so_ops.free_so = win32_free_so;
+ win32_so_ops.clear_solib = win32_clear_solib;
+ win32_so_ops.solib_create_inferior_hook = win32_solib_create_inferior_hook;
+ win32_so_ops.special_symbol_handling = win32_special_symbol_handling;
+ win32_so_ops.current_sos = win32_current_sos;
+ win32_so_ops.open_symbol_file_object = NULL;
+ win32_so_ops.in_dynsym_resolve_code = NULL;
+
+ /* FIXME: Don't do this here. *_gdbarch_init() should set so_ops. */
+ current_target_so_ops = &win32_so_ops;
+}
+
+static void
+set_win32_aliases (char *argv0)
+{
+ add_info_alias ("dll", "sharedlibrary", 1);
+}
+
+void
+_initialize_win32_nat (void)
+{
+ struct cmd_list_element *c;
+
+ init_win32_ops ();
+
+ c = add_com ("dll-symbols", class_files, dll_symbol_command,
+ _("Load dll library symbols from FILE."));
+ set_cmd_completer (c, filename_completer);
+
+ add_com_alias ("sharedlibrary", "dll-symbols", class_alias, 1);
+
+ add_setshow_boolean_cmd ("shell", class_support, &useshell, _("\
+Set use of shell to start subprocess."), _("\
+Show use of shell to start subprocess."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("new-console", class_support, &new_console, _("\
+Set creation of new console when creating child process."), _("\
+Show creation of new console when creating child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("new-group", class_support, &new_group, _("\
+Set creation of new group when creating child process."), _("\
+Show creation of new group when creating child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("debugexec", class_support, &debug_exec, _("\
+Set whether to display execution in child process."), _("\
+Show whether to display execution in child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("debugevents", class_support, &debug_events, _("\
+Set whether to display kernel events in child process."), _("\
+Show whether to display kernel events in child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("debugmemory", class_support, &debug_memory, _("\
+Set whether to display memory accesses in child process."), _("\
+Show whether to display memory accesses in child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_setshow_boolean_cmd ("debugexceptions", class_support,
+ &debug_exceptions, _("\
+Set whether to display kernel exceptions in child process."), _("\
+Show whether to display kernel exceptions in child process."), NULL,
+ NULL,
+ NULL, /* FIXME: i18n: */
+ &setlist, &showlist);
+
+ add_prefix_cmd ("w32", class_info, info_w32_command,
+ _("Print information specific to Win32 debugging."),
+ &info_w32_cmdlist, "info w32 ", 0, &infolist);
+
+ add_cmd ("selector", class_info, display_selectors,
+ _("Display selectors infos."),
+ &info_w32_cmdlist);
+ add_target (&win32_ops);
+ deprecated_init_ui_hook = set_win32_aliases;
+}
+
+/* Hardware watchpoint support, adapted from go32-nat.c code. */
+
+/* Pass the address ADDR to the inferior in the I'th debug register.
+ Here we just store the address in dr array, the registers will be
+ actually set up when win32_continue is called. */
+void
+cygwin_set_dr (int i, CORE_ADDR addr)
+{
+ if (i < 0 || i > 3)
+ internal_error (__FILE__, __LINE__,
+ _("Invalid register %d in cygwin_set_dr.\n"), i);
+ dr[i] = (unsigned) addr;
+ debug_registers_changed = 1;
+ debug_registers_used = 1;
+}
+
+/* Pass the value VAL to the inferior in the DR7 debug control
+ register. Here we just store the address in D_REGS, the watchpoint
+ will be actually set up in win32_wait. */
+void
+cygwin_set_dr7 (unsigned val)
+{
+ dr[7] = val;
+ debug_registers_changed = 1;
+ debug_registers_used = 1;
+}
+
+/* Get the value of the DR6 debug status register from the inferior.
+ Here we just return the value stored in dr[6]
+ by the last call to thread_rec for current_event.dwThreadId id. */
+unsigned
+cygwin_get_dr6 (void)
+{
+ return dr[6];
+}
+
+/* Determine if the thread referenced by "pid" is alive
+ by "polling" it. If WaitForSingleObject returns WAIT_OBJECT_0
+ it means that the pid has died. Otherwise it is assumed to be alive. */
+static int
+win32_win32_thread_alive (ptid_t ptid)
+{
+ int pid = PIDGET (ptid);
+
+ return WaitForSingleObject (thread_rec (pid, FALSE)->h, 0) == WAIT_OBJECT_0 ?
+ FALSE : TRUE;