This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: Fix Windows build from --args breakage


[ Not sure if this bounced or not; resending.  Apologies if you see it
twice. ]

This is an attempt to fix the Windows build breakage I inadvertently
introduced with my `--args' patch.  This patch also updates NEWS,
which Andrew pointed out I forgot to update.

I moved the function into infcmd.c because that is where the other
`--args' processing code lies.  I don't know if that is correct;
Pierre suggested infrun.c.  If that is preferable tell me and I will
generate a new patch.

I have no way of testing whether this actually fixes the Windows
build.  Pierre, could you try it out?

Assuming it does fix the build, is this ok to commit?

Tom

Index: gdb/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* NEWS: Update for --args.
	* infcmd.c (construct_inferior_arguments): Moved from ...
	* fork-child.c: ... here.

Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.36
diff -u -r1.36 NEWS
--- gdb/NEWS 2001/11/23 23:01:53 1.36
+++ gdb/NEWS 2001/11/26 20:11:58
@@ -7,6 +7,11 @@
 
 x86 OpenBSD					i[3456]86-*-openbsd*
 
+* Changes to command line processing
+
+The new `--args' feature can be used to specify command-line arguments
+for the inferior from gdb's command line.
+
 *** Changes in GDB 5.1:
 
 * New native configurations
Index: gdb/fork-child.c
===================================================================
RCS file: /cvs/src/src/gdb/fork-child.c,v
retrieving revision 1.15
diff -u -r1.15 fork-child.c
--- gdb/fork-child.c 2001/11/22 00:23:11 1.15
+++ gdb/fork-child.c 2001/11/26 20:11:58
@@ -568,74 +568,3 @@
 #endif /* STARTUP_INFERIOR */
   stop_soon_quietly = 0;
 }
-
-/* Compute command-line string given argument vector.  This does the
-   same shell processing as fork_inferior.  */
-/* ARGSUSED */
-char *
-construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
-{
-  char *result;
-
-  if (STARTUP_WITH_SHELL)
-    {
-      /* This holds all the characters considered special to the
-	 typical Unix shells.  We include `^' because the SunOS
-	 /bin/sh treats it as a synonym for `|'.  */
-      char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
-      int i;
-      int length = 0;
-      char *out, *cp;
-
-      /* We over-compute the size.  It shouldn't matter.  */
-      for (i = 0; i < argc; ++i)
-	length += 2 * strlen (argv[i]) + 1;
-
-      result = (char *) xmalloc (length);
-      out = result;
-
-      for (i = 0; i < argc; ++i)
-	{
-	  if (i > 0)
-	    *out++ = ' ';
-
-	  for (cp = argv[i]; *cp; ++cp)
-	    {
-	      if (strchr (special, *cp) != NULL)
-		*out++ = '\\';
-	      *out++ = *cp;
-	    }
-	}
-      *out = '\0';
-    }
-  else
-    {
-      /* In this case we can't handle arguments that contain spaces,
-	 tabs, or newlines -- see breakup_args().  */
-      int i;
-      int length = 0;
-
-      for (i = 0; i < argc; ++i)
-	{
-	  char *cp = strchr (argv[i], ' ');
-	  if (cp == NULL)
-	    cp = strchr (argv[i], '\t');
-	  if (cp == NULL)
-	    cp = strchr (argv[i], '\n');
-	  if (cp != NULL)
-	    error ("can't handle command-line argument containing whitespace");
-	  length += strlen (argv[i]) + 1;
-	}
-
-      result = (char *) xmalloc (length);
-      result[0] = '\0';
-      for (i = 0; i < argc; ++i)
-	{
-	  if (i > 0)
-	    strcat (result, " ");
-	  strcat (result, argv[i]);
-	}
-    }
-
-  return result;
-}
Index: gdb/infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.34
diff -u -r1.34 infcmd.c
--- gdb/infcmd.c 2001/11/22 00:23:12 1.34
+++ gdb/infcmd.c 2001/11/26 20:12:00
@@ -257,6 +257,77 @@
 }
 
 
+/* Compute command-line string given argument vector.  This does the
+   same shell processing as fork_inferior.  */
+/* ARGSUSED */
+char *
+construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
+{
+  char *result;
+
+  if (STARTUP_WITH_SHELL)
+    {
+      /* This holds all the characters considered special to the
+	 typical Unix shells.  We include `^' because the SunOS
+	 /bin/sh treats it as a synonym for `|'.  */
+      char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
+      int i;
+      int length = 0;
+      char *out, *cp;
+
+      /* We over-compute the size.  It shouldn't matter.  */
+      for (i = 0; i < argc; ++i)
+	length += 2 * strlen (argv[i]) + 1;
+
+      result = (char *) xmalloc (length);
+      out = result;
+
+      for (i = 0; i < argc; ++i)
+	{
+	  if (i > 0)
+	    *out++ = ' ';
+
+	  for (cp = argv[i]; *cp; ++cp)
+	    {
+	      if (strchr (special, *cp) != NULL)
+		*out++ = '\\';
+	      *out++ = *cp;
+	    }
+	}
+      *out = '\0';
+    }
+  else
+    {
+      /* In this case we can't handle arguments that contain spaces,
+	 tabs, or newlines -- see breakup_args().  */
+      int i;
+      int length = 0;
+
+      for (i = 0; i < argc; ++i)
+	{
+	  char *cp = strchr (argv[i], ' ');
+	  if (cp == NULL)
+	    cp = strchr (argv[i], '\t');
+	  if (cp == NULL)
+	    cp = strchr (argv[i], '\n');
+	  if (cp != NULL)
+	    error ("can't handle command-line argument containing whitespace");
+	  length += strlen (argv[i]) + 1;
+	}
+
+      result = (char *) xmalloc (length);
+      result[0] = '\0';
+      for (i = 0; i < argc; ++i)
+	{
+	  if (i > 0)
+	    strcat (result, " ");
+	  strcat (result, argv[i]);
+	}
+    }
+
+  return result;
+}
+
 
 /* This function detects whether or not a '&' character (indicating
    background execution) has been added as *the last* of the arguments ARGS


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]