diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-08-09 16:53:32 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-08-09 16:53:32 +0000 |
commit | 0685d95ff4b448c413fe9717c45116820f35ac58 (patch) | |
tree | c7adafcc1119e58e3ea529f719c9013362d5749b /gdb | |
parent | 95a98b5efa7b4ca7bffb156f1af26235611a3923 (diff) | |
download | gdb-0685d95ff4b448c413fe9717c45116820f35ac58.zip gdb-0685d95ff4b448c413fe9717c45116820f35ac58.tar.gz gdb-0685d95ff4b448c413fe9717c45116820f35ac58.tar.bz2 |
* 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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/core.c | 46 | ||||
-rw-r--r-- | gdb/corelow.c | 2 | ||||
-rw-r--r-- | gdb/environ.c | 60 | ||||
-rw-r--r-- | gdb/remote-hms.c | 2 | ||||
-rw-r--r-- | gdb/remote-sim.c | 2 | ||||
-rw-r--r-- | gdb/remote-udi.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/xcoffexec.c | 6 |
9 files changed, 104 insertions, 30 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb68729..fa2bb0d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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. @@ -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"); } diff --git a/gdb/corelow.c b/gdb/corelow.c index c2ea30c..dfafe49 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -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); diff --git a/gdb/environ.c b/gdb/environ.c index bdc784a..8d5dba1 100644 --- a/gdb/environ.c +++ b/gdb/environ.c @@ -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; + } + } } diff --git a/gdb/remote-hms.c b/gdb/remote-hms.c index 22d6c2b..126babc 100644 --- a/gdb/remote-hms.c +++ b/gdb/remote-hms.c @@ -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); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 005515d..310b75d 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -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) { diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index b796e90..0dc5d95 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -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); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5eeb80a..ec3045e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -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" diff --git a/gdb/xcoffexec.c b/gdb/xcoffexec.c index 65a57b5..9ede849 100644 --- a/gdb/xcoffexec.c +++ b/gdb/xcoffexec.c @@ -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)); |