* 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.
This commit is contained in:
Jim Kingdon 1993-08-09 16:53:32 +00:00
parent 95a98b5efa
commit 0685d95ff4
9 changed files with 104 additions and 30 deletions

View File

@ -1,3 +1,13 @@
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.

View File

@ -231,6 +231,39 @@ read_memory_unsigned_integer (memaddr, len)
return extract_unsigned_integer (buf, len);
}
/* 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()
{
@ -240,4 +273,17 @@ _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");
}

View File

@ -114,7 +114,7 @@ core_open (filename, from_tty)
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);

View File

@ -73,13 +73,13 @@ init_environ (e)
(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;
}
}
@ -106,8 +106,7 @@ get_in_environ (e, var)
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;
@ -127,8 +126,7 @@ set_in_environ (e, var, value)
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)
@ -152,14 +150,25 @@ set_in_environ (e, var, value)
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;
}
@ -175,13 +184,18 @@ unset_in_environ (e, var)
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;
}
}
}

View File

@ -412,7 +412,7 @@ hms_load (args, fromtty)
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);

View File

@ -73,7 +73,7 @@ int fromtty;
asection *s;
inferior_pid = 0;
abfd = bfd_openr(args, (char*)0);
abfd = bfd_openr (args, (char*)gnutarget);
if (!abfd)
{

View File

@ -1038,7 +1038,7 @@ download(load_arg_string, from_tty)
}
}
pbfd = bfd_openr (filename, 0);
pbfd = bfd_openr (filename, gnutarget);
if (!pbfd)
perror_with_name (filename);

View File

@ -1,3 +1,7 @@
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"

View File

@ -147,7 +147,7 @@ char *filename;
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));
@ -426,9 +426,9 @@ add_vmap(ldi)
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));