]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdbcore.h: New variable gnutarget.
authorJim Kingdon <jkingdon@engr.sgi.com>
Mon, 9 Aug 1993 16:53:32 +0000 (16:53 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Mon, 9 Aug 1993 16:53:32 +0000 (16:53 +0000)
* 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.

gdb/ChangeLog
gdb/core.c
gdb/corelow.c
gdb/environ.c
gdb/remote-hms.c
gdb/remote-sim.c
gdb/remote-udi.c
gdb/testsuite/ChangeLog
gdb/xcoffexec.c

index bb687295d73bf004fd78fca10835bfb2a56c8f99..fa2bb0d29346f3a0161173420ba5996510c95bdf 100644 (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.
index 4ef24d39d20027306716d721943d4c83bc37a9e9..4b8ca14ebc4c1d9cf8dfe4641409302e93a84f49 100644 (file)
@@ -231,6 +231,39 @@ read_memory_unsigned_integer (memaddr, len)
   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()
 {
@@ -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");
 }
index c2ea30c8ec6401b4437d583ad137165bc8b67ebb..dfafe4966c7cac886bde9d593826fec912b2cfd5 100644 (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);
index bdc784a2e391a09761ce07d7fd599376d27fde41..8d5dba1339342a3d04a5f25e816d6671fa015d15 100644 (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;
+       }
+    }
 }
index 22d6c2b121ca85c6510cec71d0c34d5917f66fab..126babc5f1daf0b84a79bc2ce2dd2a51a1dab04c 100644 (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);
index 005515df43ac5ea8c7e902633cfbbba34685a936..310b75d3172b8776bf6e7906e471356a24ecde3c 100644 (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) 
   {
index b796e90003b85b87205847dfa684dacff9eb4518..0dc5d953262aaa385ad1b90b29a33fc57b6a5557 100644 (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);
index 5eeb80a3a86dcee009b08c6e1aac209d61ed1a6c..ec3045e04845c5c240500cdbe870c60066b68099 100644 (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"
index 65a57b59f9f3aa2343b0dd2b8ada03d4dfa5cde2..9ede8493ead3be01594616da8f84b92d091e3591 100644 (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));