/* Target-vector operations for controlling win32 child processes, for GDB.
- Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by Cygnus Solutions, A Red Hat Company.
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
#include "target.h"
+#include "exceptions.h"
#include "gdbcore.h"
#include "command.h"
#include "completer.h"
#define DEBUG_MEM(x) if (debug_memory) printf_unfiltered x
#define DEBUG_EXCEPT(x) if (debug_exceptions) printf_unfiltered x
-/* Forward declaration */
-extern struct target_ops child_ops;
-
static void child_stop (void);
static int win32_child_thread_alive (ptid_t);
void child_kill_inferior (void);
(void) CloseHandle (here->h);
xfree (here);
}
+ thread_head.next = NULL;
}
/* Delete a thread from the list of threads */
if (r == I387_FISEG_REGNUM)
{
l = *((long *) context_offset) & 0xffff;
- supply_register (r, (char *) &l);
+ regcache_raw_supply (current_regcache, r, (char *) &l);
}
else if (r == I387_FOP_REGNUM)
{
l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1);
- supply_register (r, (char *) &l);
+ regcache_raw_supply (current_regcache, r, (char *) &l);
}
else if (r >= 0)
- supply_register (r, context_offset);
+ regcache_raw_supply (current_regcache, r, context_offset);
else
{
for (r = 0; r < NUM_REGS; r++)
if (!current_thread)
/* Windows sometimes uses a non-existent thread id in its events */;
else if (r >= 0)
- regcache_collect (r, ((char *) ¤t_thread->context) + mappings[r]);
+ regcache_raw_collect (current_regcache, r,
+ ((char *) ¤t_thread->context) + mappings[r]);
else
{
for (r = 0; r < NUM_REGS; r++)
DllHandle[i],
&mi,
sizeof (mi)))
- error ("Can't get module info");
+ error (_("Can't get module info"));
len = (*psapi_GetModuleFileNameExA) (current_process_handle,
DllHandle[i],
dll_name_ret,
MAX_PATH);
if (len == 0)
- error ("Error getting dll name: %u\n", (unsigned) GetLastError ());
+ error (_("Error getting dll name: %u."), (unsigned) GetLastError ());
if ((DWORD) (mi.lpBaseOfDll) == BaseAddress)
return 1;
xfree(sodel);
return 1;
}
- error ("Error: dll starting at 0x%lx not found.\n", (DWORD) lpBaseOfDll);
+ error (_("Error: dll starting at 0x%lx not found."), (DWORD) lpBaseOfDll);
return 0;
}
dont_repeat ();
if (args == NULL)
- error ("dll-symbols requires a file name");
+ error (_("dll-symbols requires a file name"));
n = strlen (args);
if (n > 4 && strcasecmp (args + n - 4, ".dll") != 0)
if (strncmp (s, CYGWIN_SIGNAL_STRING, sizeof (CYGWIN_SIGNAL_STRING) - 1) != 0)
{
if (strncmp (s, "cYg", 3) != 0)
- warning ("%s", s);
+ warning (("%s"), s);
}
else
{
case EXCEPTION_ACCESS_VIOLATION:
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_ACCESS_VIOLATION");
ourstatus->value.sig = TARGET_SIGNAL_SEGV;
+ {
+ char *fn;
+ if (find_pc_partial_function ((CORE_ADDR) current_event.u.Exception
+ .ExceptionRecord.ExceptionAddress,
+ &fn, NULL, NULL)
+ && strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0)
+ return 0;
+ }
break;
case STATUS_STACK_OVERFLOW:
DEBUG_EXCEPTION_SIMPLE ("STATUS_STACK_OVERFLOW");
break;
if (handle_exception (ourstatus))
retval = current_event.dwThreadId;
+ else
+ continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
case OUTPUT_DEBUG_STRING_EVENT: /* message from the kernel */
{
int detach = 0;
- if (ui_loop_hook != NULL)
- detach = ui_loop_hook (0);
+ if (deprecated_ui_loop_hook != NULL)
+ detach = deprecated_ui_loop_hook (0);
if (detach)
child_kill_inferior ();
dr[i] = 0;
current_event.dwProcessId = pid;
memset (¤t_event, 0, sizeof (current_event));
- push_target (&child_ops);
- child_init_thread_list ();
+ push_target (&deprecated_child_ops);
disable_breakpoints_in_shlibs (1);
child_clear_solibs ();
clear_proceed_status ();
DWORD pid;
if (!args)
- error_no_arg ("process-id to attach");
+ error_no_arg (_("process-id to attach"));
if (set_process_privilege (SE_DEBUG_NAME, TRUE) < 0)
{
pid = strtoul (args, 0, 0); /* Windows pid */
+ child_init_thread_list ();
ok = DebugActiveProcess (pid);
saw_create = 0;
ok = DebugActiveProcess (pid);
if (!ok)
- error ("Can't attach to process.");
+ error (_("Can't attach to process."));
}
if (has_detach_ability ())
child_continue (DBG_CONTINUE, -1);
if (!DebugActiveProcessStop (current_event.dwProcessId))
{
- error ("Can't detach process %lu (error %lu)",
+ error (_("Can't detach process %lu (error %lu)"),
current_event.dwProcessId, GetLastError ());
detached = 0;
}
gdb_flush (gdb_stdout);
}
inferior_ptid = null_ptid;
- unpush_target (&child_ops);
+ unpush_target (&deprecated_child_ops);
+}
+
+char *
+child_pid_to_exec_file (int pid)
+{
+ /* Try to find the process path using the Cygwin internal process list
+ pid isn't a valid pid, unfortunately. Use current_event.dwProcessId
+ instead. */
+ /* TODO: Also find native Windows processes using CW_GETPINFO_FULL. */
+
+ static char path[MAX_PATH + 1];
+ char *path_ptr = NULL;
+ int cpid;
+ struct external_pinfo *pinfo;
+
+ cygwin_internal (CW_LOCK_PINFO, 1000);
+ for (cpid = 0;
+ (pinfo = (struct external_pinfo *)
+ cygwin_internal (CW_GETPINFO, cpid | CW_NEXTPID));
+ cpid = pinfo->pid)
+ {
+ if (pinfo->dwProcessId == current_event.dwProcessId) /* Got it */
+ {
+ cygwin_conv_to_full_posix_path (pinfo->progname, path);
+ path_ptr = path;
+ break;
+ }
+ }
+ cygwin_internal (CW_UNLOCK_PINFO);
+ return path_ptr;
}
/* Print status information about what we're accessing. */
static void
child_open (char *arg, int from_tty)
{
- error ("Use the \"run\" command to start a Unix child process.");
+ error (_("Use the \"run\" command to start a Unix child process."));
}
/* Start an inferior win32 child process and sets inferior_ptid to its pid.
int ostdin, ostdout, ostderr;
if (!exec_file)
- error ("No executable specified, use `target exec'.\n");
+ error (_("No executable specified, use `target exec'."));
memset (&si, 0, sizeof (si));
si.cb = sizeof (si);
}
}
+ child_init_thread_list ();
ret = CreateProcess (0,
args, /* command line */
NULL, /* Security */
}
if (!ret)
- error ("Error creating process %s, (error %d)\n", exec_file, (unsigned) GetLastError ());
+ error (_("Error creating process %s, (error %d)."),
+ exec_file, (unsigned) GetLastError ());
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
{
(void) child_continue (DBG_CONTINUE, -1);
i386_cleanup_dregs();
- unpush_target (&child_ops);
+ unpush_target (&deprecated_child_ops);
generic_mourn_inferior ();
}
PIDGET (inferior_ptid)));
}
-struct target_ops child_ops;
-
static void
init_child_ops (void)
{
- child_ops.to_shortname = "child";
- child_ops.to_longname = "Win32 child process";
- child_ops.to_doc = "Win32 child process (started by the \"run\" command).";
- child_ops.to_open = child_open;
- child_ops.to_close = child_close;
- child_ops.to_attach = child_attach;
- child_ops.to_detach = child_detach;
- child_ops.to_resume = child_resume;
- child_ops.to_wait = child_wait;
- child_ops.to_fetch_registers = child_fetch_inferior_registers;
- child_ops.to_store_registers = child_store_inferior_registers;
- child_ops.to_prepare_to_store = child_prepare_to_store;
- child_ops.to_xfer_memory = child_xfer_memory;
- child_ops.to_files_info = child_files_info;
- child_ops.to_insert_breakpoint = memory_insert_breakpoint;
- child_ops.to_remove_breakpoint = memory_remove_breakpoint;
- child_ops.to_terminal_init = terminal_init_inferior;
- child_ops.to_terminal_inferior = terminal_inferior;
- child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- child_ops.to_terminal_ours = terminal_ours;
- child_ops.to_terminal_save_ours = terminal_save_ours;
- child_ops.to_terminal_info = child_terminal_info;
- child_ops.to_kill = child_kill_inferior;
- child_ops.to_create_inferior = child_create_inferior;
- child_ops.to_mourn_inferior = child_mourn_inferior;
- child_ops.to_can_run = child_can_run;
- child_ops.to_thread_alive = win32_child_thread_alive;
- child_ops.to_pid_to_str = cygwin_pid_to_str;
- child_ops.to_stop = child_stop;
- child_ops.to_stratum = process_stratum;
- child_ops.to_has_all_memory = 1;
- child_ops.to_has_memory = 1;
- child_ops.to_has_stack = 1;
- child_ops.to_has_registers = 1;
- child_ops.to_has_execution = 1;
- child_ops.to_magic = OPS_MAGIC;
+ deprecated_child_ops.to_shortname = "child";
+ deprecated_child_ops.to_longname = "Win32 child process";
+ deprecated_child_ops.to_doc = "Win32 child process (started by the \"run\" command).";
+ deprecated_child_ops.to_open = child_open;
+ deprecated_child_ops.to_close = child_close;
+ deprecated_child_ops.to_attach = child_attach;
+ deprecated_child_ops.to_detach = child_detach;
+ deprecated_child_ops.to_resume = child_resume;
+ deprecated_child_ops.to_wait = child_wait;
+ deprecated_child_ops.to_fetch_registers = child_fetch_inferior_registers;
+ deprecated_child_ops.to_store_registers = child_store_inferior_registers;
+ deprecated_child_ops.to_prepare_to_store = child_prepare_to_store;
+ deprecated_child_ops.deprecated_xfer_memory = child_xfer_memory;
+ deprecated_child_ops.to_files_info = child_files_info;
+ deprecated_child_ops.to_insert_breakpoint = memory_insert_breakpoint;
+ deprecated_child_ops.to_remove_breakpoint = memory_remove_breakpoint;
+ deprecated_child_ops.to_terminal_init = terminal_init_inferior;
+ deprecated_child_ops.to_terminal_inferior = terminal_inferior;
+ deprecated_child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ deprecated_child_ops.to_terminal_ours = terminal_ours;
+ deprecated_child_ops.to_terminal_save_ours = terminal_save_ours;
+ deprecated_child_ops.to_terminal_info = child_terminal_info;
+ deprecated_child_ops.to_kill = child_kill_inferior;
+ deprecated_child_ops.to_create_inferior = child_create_inferior;
+ deprecated_child_ops.to_mourn_inferior = child_mourn_inferior;
+ deprecated_child_ops.to_can_run = child_can_run;
+ deprecated_child_ops.to_thread_alive = win32_child_thread_alive;
+ deprecated_child_ops.to_pid_to_str = cygwin_pid_to_str;
+ deprecated_child_ops.to_stop = child_stop;
+ deprecated_child_ops.to_stratum = process_stratum;
+ deprecated_child_ops.to_has_all_memory = 1;
+ deprecated_child_ops.to_has_memory = 1;
+ deprecated_child_ops.to_has_stack = 1;
+ deprecated_child_ops.to_has_registers = 1;
+ deprecated_child_ops.to_has_execution = 1;
+ deprecated_child_ops.to_magic = OPS_MAGIC;
+ deprecated_child_ops.to_pid_to_exec_file = child_pid_to_exec_file;
}
void
init_child_ops ();
c = add_com ("dll-symbols", class_files, dll_symbol_command,
- "Load dll library symbols from FILE.");
+ _("Load dll library symbols from FILE."));
set_cmd_completer (c, filename_completer);
add_com_alias ("sharedlibrary", "dll-symbols", class_alias, 1);
- add_show_from_set (add_set_cmd ("shell", class_support, var_boolean,
- (char *) &useshell,
- "Set use of shell to start subprocess.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("new-console", class_support, var_boolean,
- (char *) &new_console,
- "Set creation of new console when creating child process.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("new-group", class_support, var_boolean,
- (char *) &new_group,
- "Set creation of new group when creating child process.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("debugexec", class_support, var_boolean,
- (char *) &debug_exec,
- "Set whether to display execution in child process.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("debugevents", class_support, var_boolean,
- (char *) &debug_events,
- "Set whether to display kernel events in child process.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("debugmemory", class_support, var_boolean,
- (char *) &debug_memory,
- "Set whether to display memory accesses in child process.",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("debugexceptions", class_support, var_boolean,
- (char *) &debug_exceptions,
- "Set whether to display kernel exceptions in child process.",
- &setlist),
- &showlist);
-
- add_info ("dll", info_dll_command, "Status of loaded DLLs.");
+ 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_info ("dll", info_dll_command, _("Status of loaded DLLs."));
add_info_alias ("sharedlibrary", "dll", 1);
add_prefix_cmd ("w32", class_info, info_w32_command,
- "Print information specific to Win32 debugging.",
+ _("Print information specific to Win32 debugging."),
&info_w32_cmdlist, "info w32 ", 0, &infolist);
add_cmd ("selector", class_info, display_selectors,
- "Display selectors infos.",
+ _("Display selectors infos."),
&info_w32_cmdlist);
- add_target (&child_ops);
+ add_target (&deprecated_child_ops);
}
/* Hardware watchpoint support, adapted from go32-nat.c code. */
{
if (i < 0 || i > 3)
internal_error (__FILE__, __LINE__,
- "Invalid register %d in cygwin_set_dr.\n", i);
+ _("Invalid register %d in cygwin_set_dr.\n"), i);
dr[i] = (unsigned) addr;
debug_registers_changed = 1;
debug_registers_used = 1;
}
}
- register_loaded_dll (dll_name, base_addr + 0x1000);
- solib_symbols_add (dll_name, 0, (CORE_ADDR) base_addr + 0x1000);
+ register_loaded_dll (dll_name, base_addr + 0x1000);
+ solib_symbols_add (dll_name, 0, (CORE_ADDR) base_addr + 0x1000);
- out:
- return 1;
- }
+ out:
+ return 1;
+}
- typedef struct
- {
- struct target_ops *target;
- bfd_vma addr;
- } map_code_section_args;
+typedef struct
+{
+ struct target_ops *target;
+ bfd_vma addr;
+} map_code_section_args;
- static void
- map_single_dll_code_section (bfd * abfd, asection * sect, void *obj)
- {
- int old;
- int update_coreops;
- struct section_table *new_target_sect_ptr;
+static void
+map_single_dll_code_section (bfd * abfd, asection * sect, void *obj)
+{
+ int old;
+ int update_coreops;
+ struct section_table *new_target_sect_ptr;
- map_code_section_args *args = (map_code_section_args *) obj;
- struct target_ops *target = args->target;
- if (sect->flags & SEC_CODE)
- {
- update_coreops = core_ops.to_sections == target->to_sections;
+ map_code_section_args *args = (map_code_section_args *) obj;
+ struct target_ops *target = args->target;
+ if (sect->flags & SEC_CODE)
+ {
+ update_coreops = core_ops.to_sections == target->to_sections;
- if (target->to_sections)
- {
- old = target->to_sections_end - target->to_sections;
- target->to_sections = (struct section_table *)
- xrealloc ((char *) target->to_sections,
- (sizeof (struct section_table)) * (1 + old));
- }
- else
- {
- old = 0;
- target->to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)));
- }
- target->to_sections_end = target->to_sections + (1 + old);
+ if (target->to_sections)
+ {
+ old = target->to_sections_end - target->to_sections;
+ target->to_sections = (struct section_table *)
+ xrealloc ((char *) target->to_sections,
+ (sizeof (struct section_table)) * (1 + old));
+ }
+ else
+ {
+ old = 0;
+ target->to_sections = (struct section_table *)
+ xmalloc ((sizeof (struct section_table)));
+ }
+ target->to_sections_end = target->to_sections + (1 + old);
- /* Update the to_sections field in the core_ops structure
- if needed. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
- new_target_sect_ptr = target->to_sections + old;
- new_target_sect_ptr->addr = args->addr + bfd_section_vma (abfd, sect);
- new_target_sect_ptr->endaddr = args->addr + bfd_section_vma (abfd, sect) +
- bfd_section_size (abfd, sect);;
- new_target_sect_ptr->the_bfd_section = sect;
- new_target_sect_ptr->bfd = abfd;
- }
- }
+ /* Update the to_sections field in the core_ops structure
+ if needed. */
+ if (update_coreops)
+ {
+ core_ops.to_sections = target->to_sections;
+ core_ops.to_sections_end = target->to_sections_end;
+ }
+ new_target_sect_ptr = target->to_sections + old;
+ new_target_sect_ptr->addr = args->addr + bfd_section_vma (abfd, sect);
+ new_target_sect_ptr->endaddr = args->addr + bfd_section_vma (abfd, sect) +
+ bfd_section_size (abfd, sect);;
+ new_target_sect_ptr->the_bfd_section = sect;
+ new_target_sect_ptr->bfd = abfd;
+ }
+}
- static int
- dll_code_sections_add (const char *dll_name, int base_addr, struct target_ops *target)
+static int
+dll_code_sections_add (const char *dll_name, int base_addr, struct target_ops *target)
{
bfd *dll_bfd;
map_code_section_args map_args;
int r;
if (core_reg_size < sizeof (CONTEXT))
{
- error ("Core file register section too small (%u bytes).", core_reg_size);
+ error (_("Core file register section too small (%u bytes)."), core_reg_size);
return;
}
for (r = 0; r < NUM_REGS; r++)
- supply_register (r, core_reg_sect + mappings[r]);
+ regcache_raw_supply (current_regcache, r, core_reg_sect + mappings[r]);
}
static struct core_fns win32_elf_core_fns =
char *newini = alloca (len + 1);
sprintf (newini, "%.*s.gdbinit",
(int) (len - (sizeof ("gdb.ini") - 1)), oldini);
- warning ("obsolete '%s' found. Rename to '%s'.", oldini, newini);
+ warning (_("obsolete '%s' found. Rename to '%s'."), oldini, newini);
}
}
}