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]

[PATCH]: Support for long command lines passed to debuggee


FYI, I've just committed the attached.

2001-07-15  Eli Zaretskii  <eliz@is.elta.co.il>

	* go32-nat.c (go32_create_inferior): Support command lines longer
	than 126 characters.

--- gdb/go32-nat.c~4	Sat Jul 14 12:04:50 2001
+++ gdb/go32-nat.c	Sat Jul 14 15:32:28 2001
@@ -585,6 +585,7 @@ go32_create_inferior (char *exec_file, c
   jmp_buf start_state;
   char *cmdline;
   char **env_save = environ;
+  size_t cmdlen;
 
   /* If no exec file handed to us, get it from the exec-file command -- with
      a good, common error message if none is specified.  */
@@ -619,10 +620,24 @@ go32_create_inferior (char *exec_file, c
   else
     child_cmd.command = xstrdup (args);
 
-  cmdline = (char *) alloca (strlen (args) + 4);
-  cmdline[0] = strlen (args);
+  cmdlen = strlen (args);
+  /* v2loadimage passes command lines via DOS memory, so it cannot
+     possibly handle commands longer than 1MB.  */
+  if (cmdlen > 1024*1024)
+    error ("Command line too long.");
+
+  cmdline = xmalloc (cmdlen + 4);
   strcpy (cmdline + 1, args);
-  cmdline[strlen (args) + 1] = 13;
+  /* If the command-line length fits into DOS 126-char limits, use the
+     DOS command tail format; otherwise, tell v2loadimage to pass it
+     through a buffer in conventional memory.  */
+  if (cmdlen < 127)
+    {
+      cmdline[0] = strlen (args);
+      cmdline[cmdlen + 1] = 13;
+    }
+  else
+    cmdline[0] = 0xff;	/* signal v2loadimage it's a long command */
 
   environ = env;
 
@@ -633,6 +648,7 @@ go32_create_inferior (char *exec_file, c
       exit (1);
     }
   environ = env_save;
+  free (cmdline);
 
   edi_init (start_state);
 #if __DJGPP_MINOR__ < 3


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