/* Target-vector operations for controlling win32 child processes, for GDB.
- Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ 2005, 2006
Free Software Foundation, Inc.
Contributed by Cygnus Solutions, A Red Hat Company.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* Originally by Steve Chamberlain, sac@cygnus.com */
/* The string sent by cygwin when it processes a signal.
FIXME: This should be in a cygwin include file. */
-#define CYGWIN_SIGNAL_STRING "cygwin: signal"
+#ifndef _CYGWIN_SIGNAL_STRING
+#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
+#endif
#define CHECK(x) check (x, __FILE__,__LINE__)
#define DEBUG_EXEC(x) if (debug_exec) printf_unfiltered x
if ((th = thread_rec (id, FALSE)))
return th;
- th = (thread_info *) xmalloc (sizeof (*th));
- memset (th, 0, sizeof (*th));
+ th = XZALLOC (thread_info);
th->id = id;
th->h = h;
th->next = thread_head.next;
GetSystemDirectory (buf, sizeof (buf));
strcat (buf, "\\ntdll.dll");
}
- so = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset (so, 0, sizeof (*so));
+ so = XZALLOC (struct so_list);
so->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
so->lm_info->load_addr = load_addr;
cygwin_conv_to_posix_path (buf, so->so_name);
return 1;
register_loaded_dll (dll_name, (DWORD) event->lpBaseOfDll + 0x1000, auto_solib_add);
+ solib_add (NULL, 0, NULL, auto_solib_add);
return 1;
}
if (!so->next)
solib_end = so;
free_so (sodel);
+ solib_add (NULL, 0, NULL, auto_solib_add);
return 1;
}
+
error (_("Error: dll starting at 0x%lx not found."), (DWORD) lpBaseOfDll);
return 0;
safe_symbol_file_add (args, from_tty, NULL, 0, OBJF_SHARED | OBJF_USERLOADED);
}
-/* List currently loaded DLLs. */
-static void
-info_dll_command (char *ignore, int from_tty)
-{
- struct so_list *so = &solib_start;
-
- if (!so->next)
- return;
-
- printf_filtered ("%*s Load Address\n", -max_dll_name_len, "DLL Name");
- while ((so = so->next) != NULL)
- printf_filtered ("%*s %08lx\n", -max_dll_name_len, so->so_name, so->lm_info->load_addr);
-
- return;
-}
-
/* Handle DEBUG_STRING output from child process.
Cygwin prepends its messages with a "cygwin:". Interpret this as
a Cygwin signal. Otherwise just print the string as a warning. */
|| !s || !*s)
return gotasig;
- if (strncmp (s, CYGWIN_SIGNAL_STRING, sizeof (CYGWIN_SIGNAL_STRING) - 1) != 0)
+ if (strncmp (s, _CYGWIN_SIGNAL_STRING, sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0)
{
if (strncmp (s, "cYg", 3) != 0)
warning (("%s"), s);
else
{
char *p;
- int sig = strtol (s + sizeof (CYGWIN_SIGNAL_STRING) - 1, &p, 0);
+ int sig = strtol (s + sizeof (_CYGWIN_SIGNAL_STRING) - 1, &p, 0);
gotasig = target_signal_from_host (sig);
ourstatus->value.sig = gotasig;
if (gotasig)
error (_("Use the \"run\" command to start a Unix child process."));
}
+/* Function called by qsort to sort environment strings. */
+static int
+env_sort (const void *a, const void *b)
+{
+ const char **p = (const char **) a;
+ const char **q = (const char **) b;
+ return strcasecmp (*p, *q);
+}
+
/* Start an inferior win32 child process and sets inferior_ptid to its pid.
EXEC_FILE is the file to run.
ALLARGS is a string containing the arguments to the program.
ENV is the environment vector to pass. Errors reported with error(). */
static void
-win32_create_inferior (char *exec_file, char *allargs, char **env,
+win32_create_inferior (char *exec_file, char *allargs, char **in_env,
int from_tty)
{
char *winenv;
strings (i.e. two nulls terminate the list). */
/* Get total size for env strings. */
- for (envlen = 0, i = 0; env[i] && *env[i]; i++)
+ for (envlen = 0, i = 0; in_env[i] && *in_env[i]; i++)
{
int j, len;
for (j = 0; conv_path_names[j]; j++)
{
len = strlen (conv_path_names[j]);
- if (strncmp (conv_path_names[j], env[i], len) == 0)
+ if (strncmp (conv_path_names[j], in_env[i], len) == 0)
{
- if (cygwin_posix_path_list_p (env[i] + len))
+ if (cygwin_posix_path_list_p (in_env[i] + len))
envlen += len
- + cygwin_posix_to_win32_path_list_buf_size (env[i] + len);
+ + cygwin_posix_to_win32_path_list_buf_size (in_env[i] + len);
else
- envlen += strlen (env[i]) + 1;
+ envlen += strlen (in_env[i]) + 1;
break;
}
}
if (conv_path_names[j] == NULL)
- envlen += strlen (env[i]) + 1;
+ envlen += strlen (in_env[i]) + 1;
}
+ size_t envsize = sizeof (in_env[0]) * (i + 1);
+ char **env = (char **) alloca (envsize);
+ memcpy (env, in_env, envsize);
+ /* Windows programs expect the environment block to be sorted. */
+ qsort (env, i, sizeof (char *), env_sort);
+
winenv = alloca (envlen + 1);
/* Copy env strings into new buffer. */
do_initial_win32_stuff (pi.dwProcessId);
/* win32_continue (DBG_CONTINUE, -1); */
- proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_0, 0);
}
static void
static struct so_list *
win32_current_sos (void)
{
- struct so_list *head = solib_start.next;
- win32_clear_solib ();
- if (!head && core_bfd)
+ struct so_list *sop;
+ struct so_list *start = NULL;
+ struct so_list *last = NULL;
+
+ if (!solib_start.next && core_bfd)
{
+ win32_clear_solib ();
bfd_map_over_sections (core_bfd, &core_section_load_dll_symbols,
&win32_ops);
- head = solib_start.next;
- win32_clear_solib ();
}
- return head;
+
+ for (sop = solib_start.next; sop; sop = sop->next)
+ {
+ struct so_list *new = XZALLOC (struct so_list);
+ strcpy (new->so_name, sop->so_name);
+ strcpy (new->so_original_name, sop->so_original_name);
+ if (!start)
+ last = start = new;
+ else
+ {
+ last->next = new;
+ last = new;
+ }
+ }
+
+ return start;
}
static void
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)
{
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."),
&info_w32_cmdlist, "info w32 ", 0, &infolist);
_("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. */