* core.c: Add commands to set and show it.
* Callers to bfd_*open*: Pass gnutarget instead of NULL as target.
* environ.c (set_in_environ): For GNUTARGET, use set_gnutarget not
putenv.
* symtab.c (decode_line_1): Give error on unmatched single quote.
+Mon Aug 9 09:53:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * gdbcore.h: New variable gnutarget.
+ * core.c: Add commands to set and show it.
+ * Callers to bfd_*open*: Pass gnutarget instead of NULL as target.
+ * environ.c (set_in_environ): For GNUTARGET, use set_gnutarget not
+ putenv.
+
+ * symtab.c (decode_line_1): Give error on unmatched single quote.
+
Sun Aug 8 13:59:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* ser-unix.c (hardwire_send_break) [HAVE_SGTTY]: Use select not usleep.
return extract_unsigned_integer (buf, len);
}
\f
+/* The current default bfd target. Points to storage allocated for
+ gnutarget_string. */
+char *gnutarget;
+
+/* Same thing, except it is "auto" not NULL for the default case. */
+static char *gnutarget_string;
+
+static void set_gnutarget_command
+ PARAMS ((char *, int, struct cmd_list_element *));
+
+static void
+set_gnutarget_command (ignore, from_tty, c)
+ char *ignore;
+ int from_tty;
+ struct cmd_list_element *c;
+{
+ if (STREQ (gnutarget_string, "auto"))
+ gnutarget = NULL;
+ else
+ gnutarget = gnutarget_string;
+}
+
+/* Set the gnutarget. */
+void
+set_gnutarget (newtarget)
+ char *newtarget;
+{
+ if (gnutarget_string != NULL)
+ free (gnutarget_string);
+ gnutarget_string = savestring (newtarget, strlen (newtarget));
+ set_gnutarget_command (NULL, 0, NULL);
+}
+
void
_initialize_core()
{
No arg means have no core file. This command has been superseded by the\n\
`target core' and `detach' commands.", &cmdlist);
c->completer = filename_completer;
+
+ c = add_set_cmd ("gnutarget", class_files, var_string_noescape,
+ (char *) &gnutarget_string,
+ "Set the current BFD target.\n\
+Use `set gnutarget auto' to specify automatic detection.",
+ &setlist);
+ c->function.sfunc = set_gnutarget_command;
+ add_show_from_set (c, &showlist);
+
+ if (getenv ("GNUTARGET"))
+ set_gnutarget (getenv ("GNUTARGET"));
+ else
+ set_gnutarget ("auto");
}
if (scratch_chan < 0)
perror_with_name (filename);
- temp_bfd = bfd_fdopenr (filename, NULL, scratch_chan);
+ temp_bfd = bfd_fdopenr (filename, gnutarget, scratch_chan);
if (temp_bfd == NULL)
{
perror_with_name (filename);
(e->allocated + 1) * sizeof (char *));
}
- (void) memcpy (e->vector, environ, (i + 1) * sizeof (char *));
+ memcpy (e->vector, environ, (i + 1) * sizeof (char *));
while (--i >= 0)
{
register int len = strlen (e->vector[i]);
register char *new = (char *) xmalloc (len + 1);
- (void) memcpy (new, e->vector[i], len + 1);
+ memcpy (new, e->vector[i], len + 1);
e->vector[i] = new;
}
}
register char *s;
for (; (s = *vector) != NULL; vector++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
+ if (STREQN (s, var, len) && s[len] == '=')
return &s[len + 1];
return 0;
register char *s;
for (i = 0; (s = vector[i]) != NULL; i++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
+ if (STREQN (s, var, len) && s[len] == '=')
break;
if (s == 0)
vector[i] = s;
/* Certain variables get exported back to the parent (e.g. our)
- environment, too. */
- if (!strcmp(var, "PATH") /* Object file location */
- || !strcmp (var, "G960BASE") /* Intel 960 downloads */
- || !strcmp (var, "G960BIN") /* Intel 960 downloads */
- || !strcmp (var, "GNUTARGET") /* BFD object file type */
- ) {
- putenv (strsave (s));
- }
+ environment, too. FIXME: this is a hideous hack and should not be
+ allowed to live. What if we want to change the environment we pass to
+ the program without affecting GDB's behavior? */
+ if (STREQ(var, "PATH") /* Object file location */
+ || STREQ (var, "G960BASE") /* Intel 960 downloads */
+ || STREQ (var, "G960BIN") /* Intel 960 downloads */
+ )
+ {
+ putenv (strsave (s));
+ }
+
+ /* This is a compatibility hack, since GDB 4.10 and older didn't have
+ `set gnutarget'. Eventually it should go away, so that (for example)
+ you can debug objdump's handling of GNUTARGET without affecting GDB's
+ behavior. */
+ if (STREQ (var, "GNUTARGET"))
+ {
+ set_gnutarget (value);
+ }
return;
}
register char *s;
for (; (s = *vector) != NULL; vector++)
- if (!strncmp (s, var, len)
- && s[len] == '=')
- {
- free (s);
- (void) memcpy (vector, vector + 1,
- (e->allocated - (vector - e->vector)) * sizeof (char *));
- e->vector[e->allocated - 1] = 0;
- return;
- }
+ {
+ if (STREQN (s, var, len) && s[len] == '=')
+ {
+ free (s);
+ /* Walk through the vector, shuffling args down by one, including
+ the NULL terminator. Can't use memcpy() here since the regions
+ overlap, and memmove() might not be available. */
+ while ((vector[0] = vector[1]) != NULL)
+ {
+ vector++;
+ }
+ break;
+ }
+ }
}
dcache_flush ();
inferior_pid = 0;
- abfd = bfd_openr (args, 0);
+ abfd = bfd_openr (args, gnutarget);
if (!abfd)
{
printf_filtered ("Unable to open file %s\n", args);
asection *s;
inferior_pid = 0;
- abfd = bfd_openr(args, (char*)0);
+ abfd = bfd_openr (args, (char*)gnutarget);
if (!abfd)
{
}
}
- pbfd = bfd_openr (filename, 0);
+ pbfd = bfd_openr (filename, gnutarget);
if (!pbfd)
perror_with_name (filename);
+Mon Aug 9 10:13:34 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * gdb.t10/crossload.exp: Add `set gnutarget auto' at end of tests.
+
Sun Aug 8 14:21:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* gdb.t20/inherit.exp: Change message for "print tagless struct"
if (scratch_chan < 0)
perror_with_name(filename);
- exec_bfd = bfd_fdopenr(scratch_pathname, NULL, scratch_chan);
+ exec_bfd = bfd_fdopenr(scratch_pathname, gnutarget, scratch_chan);
if (!exec_bfd)
error("Could not open `%s' as an executable file: %s"
, scratch_pathname, bfd_errmsg(bfd_error));
if (ldi->ldinfo_fd < 0)
/* Note that this opens it once for every member; a possible
enhancement would be to only open it once for every object. */
- bfd = bfd_openr (objname, NULL);
+ bfd = bfd_openr (objname, gnutarget);
else
- bfd = bfd_fdopenr(objname, NULL, ldi->ldinfo_fd);
+ bfd = bfd_fdopenr(objname, gnutarget, ldi->ldinfo_fd);
if (!bfd)
error("Could not open `%s' as an executable file: %s",
objname, bfd_errmsg(bfd_error));