From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8622 invoked by alias); 26 Nov 2001 23:28:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8550 invoked from network); 26 Nov 2001 23:27:50 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by hostedprojects.ges.redhat.com with SMTP; 26 Nov 2001 23:27:50 -0000 Received: from creche.cygnus.com (ta0194.peakpeak.com [204.144.244.194]) by gash2.peakpeak.com (8.9.3/8.9.3) with ESMTP id QAA02367; Mon, 26 Nov 2001 16:27:44 -0700 Received: (from tromey@localhost) by creche.cygnus.com (8.9.3/8.9.3) id QAA14831; Mon, 26 Nov 2001 16:29:23 -0700 To: gdb-patches@sources.redhat.com Cc: Pierre Muller Subject: Patch: Fix Windows build from --args breakage X-Zippy: Didn't I buy a 1951 Packard from you last March in Cairo? X-Attribution: Tom Reply-To: tromey@redhat.com From: Tom Tromey Date: Tue, 13 Nov 2001 09:02:00 -0000 Message-ID: <877ksdp77z.fsf@creche.redhat.com> X-Mailer: Gnus v5.7/Emacs 20.5 X-SW-Source: 2001-11/txt/msg00248.txt.bz2 [ 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 * 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: gdb-patches@sources.redhat.com Cc: Pierre Muller Subject: Patch: Fix Windows build from --args breakage Date: Mon, 26 Nov 2001 15:28:00 -0000 Message-ID: <877ksdp77z.fsf@creche.redhat.com> X-SW-Source: 2001-11/msg00463.html Message-ID: <20011126152800.4kZF-ptkfTDe6ppYH3Flrz-vURwpngPKajh6PfUlbQc@z> [ 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 * 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