Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fernando Nasser <fnasser@redhat.com>
To: deephan@erols.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] specify arguments to debugee from commandline
Date: Fri, 30 Mar 2001 05:20:00 -0000	[thread overview]
Message-ID: <3AC4874E.A630A31D@redhat.com> (raw)
In-Reply-To: <20010330005457.A21793@llamedos.org>

David,

First of all, do you have a valid assignment with the FSF?
Maybe your patch is small enough so that we are able to use it without
an assignment, I will defer this decision to Andrew.

I am not the maintainer of these files (although I keep meddling with
them) but I have two objections (easy to fix) with regards to the patch
below.

1) I don't like the changes to infcmd.c.  The initialization should not
be conditional and the use of inferior_args both as a flag causes it to
be "initialized" twice -- first time with zero and second time with a
pointer to an empty string.

You can avoid this by storing your arguments in a temporary place in
main.c until you can process it (it should be done around where the
files are loaded).

2) The external definition for set_inferior_args() and possibly for
get_inferior_args() should go into a header file.  If people decide to
incorporate your patch one of us can create a infcmd.h for you.
There was a discussion about this header file issue recently and it was
decided (AFAICT) that we would keep declarations in header files
associated with the one where things are defined.


Anyway, beofore concerning yourself with these details, we must know
what people think of the syntax.  Alexandre Oliva has made a comment
with regards to that and so did Pierre Muller.  I believe that should be
addressed first.


But your patch is a good initiative.  Thanks for bringing this command
line issue back to discussion.

Regards,
Fernando



David Deephanphongs wrote:
> 
> This patch will add the option --args=<args> to gdb.
> It assumes that <args> is one argument (i.e., is in quotes, or has the
> spaces escaped).
> --args acts just like calling 'set args <args>' does from the gdb prompt:
> gdb --args '--color=never -l gdb' /bin/ls
> is equivalent to:
> gdb /bin/ls
> gdb> set args --color=never -l gdb
> 
> It also adds a description of --args when 'gdb -h' is run,
> and adds a description of --args to the manpage.
> 
> The patch is against the 20010327 snapshot.
> 
> ======= Changelog =========
> 2001-03-30  David Deephanphongs  <david@llamedos.org>
> 
>         * main.c:
>         (set_inferior_args): Added extern prototype of set_inferior_args.
>         (captured_main): Add --args option to gdb.
>         * infcmd.c:
>         (inferior_args): initialize to zero.
>         (_initialize_infcmd): only call set_inferior_args (xtrdup (""))
>         if inferior_args is set to zero.
>         * gdb.1, main.c (print_gdb_help):
>         Document --args option
> 
> ====== Patch =======
> diff -c3p gdb-orig/gdb.1 gdb/gdb.1
> *** gdb-orig/gdb.1      Tue Mar  6 03:21:07 2001
> --- gdb/gdb.1   Fri Mar 30 00:22:00 2001
> *************** gdb \- The GNU Debugger
> *** 38,43 ****
> --- 38,46 ----
>   .RB "[\|" "\-d "\c
>   .I dir\c
>   \&\|]
> + .RB "[\|" "\-args "\c
> + .I args\c
> + \&\|]
>   .RB "[\|" \c
>   .I prog\c
>   .RB "[\|" \c
> *************** Execute GDB commands from file \c
> *** 264,269 ****
> --- 267,280 ----
>   Add \c
>   .I directory\c
>   \& to the path to search for source files.
> +
> +
> + .TP
> + .BI "\-args=" "args"\c
> + \&
> + Set \c
> + .I args\c
> + \& as the default arguments for the program to be debugged.
>   .PP
> 
>   .TP
> diff -c3p gdb-orig/infcmd.c gdb/infcmd.c
> *** gdb-orig/infcmd.c   Wed Mar 21 11:42:38 2001
> --- gdb/infcmd.c        Thu Mar 29 23:27:07 2001
> *************** static void breakpoint_auto_delete_conte
> *** 121,127 ****
>   /* String containing arguments to give to the program, separated by spaces.
>      Empty string (pointer to '\0') means no args.  */
> 
> ! static char *inferior_args;
> 
>   /* File name for default use for standard in/out in the inferior.  */
> 
> --- 121,127 ----
>   /* String containing arguments to give to the program, separated by spaces.
>      Empty string (pointer to '\0') means no args.  */
> 
> ! static char *inferior_args = 0;
> 
>   /* File name for default use for standard in/out in the inferior.  */
> 
> *************** Register name as argument means describe
> *** 1967,1973 ****
>     add_info ("float", float_info,
>             "Print the status of the floating point unit\n");
> 
> !   set_inferior_args (xstrdup (""));   /* Initially no args */
>     inferior_environ = make_environ ();
>     init_environ (inferior_environ);
>   }
> --- 1967,1974 ----
>     add_info ("float", float_info,
>             "Print the status of the floating point unit\n");
> 
> !   if (inferior_args == 0)
> !       set_inferior_args (xstrdup (""));       /* Initially no args */
>     inferior_environ = make_environ ();
>     init_environ (inferior_environ);
>   }
> diff -c3p gdb-orig/main.c gdb/main.c
> *** gdb-orig/main.c     Tue Mar  6 03:21:10 2001
> --- gdb/main.c  Fri Mar 30 00:14:39 2001
> *************** static void print_gdb_help (struct ui_fi
> *** 89,94 ****
> --- 89,98 ----
>   extern int enable_external_editor;
>   extern char *external_editor_command;
> 
> + /* Used to set the arguments to the inferior program (i.e., the program that
> +    is being debugged.) */
> + extern char *set_inferior_args (char *newargs);
> +
>   #ifdef __CYGWIN__
>   #include <windows.h>          /* for MAX_PATH */
>   #include <sys/cygwin.h>               /* for cygwin32_conv_to_posix_path */
> *************** captured_main (void *data)
> *** 284,289 ****
> --- 288,294 ----
>         {"windows", no_argument, &use_windows, 1},
>         {"statistics", no_argument, 0, 13},
>         {"write", no_argument, &write_files, 1},
> +         {"args", required_argument, 0, 14},
>   /* Allow machine descriptions to add more options... */
>   #ifdef ADDITIONAL_OPTIONS
>         ADDITIONAL_OPTIONS
> *************** captured_main (void *data)
> *** 325,330 ****
> --- 330,339 ----
>             display_time = 1;
>             display_space = 1;
>             break;
> +         case 14:
> +           /* Set the arguments for the inferior program. */
> +           set_inferior_args ( xstrdup (optarg) );
> +           break;
>           case 'f':
>             annotation_level = 1;
>   /* We have probably been invoked from emacs.  Disable window interface.  */
> *************** Options:\n\n\
> *** 824,829 ****
> --- 833,841 ----
>     -w                 Use a window interface.\n\
>     --write            Set writing into executable and core files.\n\
>     --xdb              XDB compatibility mode.\n\
> + ", stream);
> +   fputs_unfiltered ("\
> +   --args=args        Set arguments to give debugged program when it is run.\n\
>   ", stream);
>   #ifdef ADDITIONAL_OPTION_HELP
>     fputs_unfiltered (ADDITIONAL_OPTION_HELP, stream);

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


  parent reply	other threads:[~2001-03-30  5:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20010330005457.A21793@llamedos.org>
2001-03-29 23:13 ` Eli Zaretskii
2001-03-30  0:26   ` David Deephanphongs
2001-03-30  1:32     ` Eli Zaretskii
2001-03-30  3:00     ` Alexandre Oliva
2001-03-30  3:47       ` Pierre Muller
2001-03-30  8:01         ` David Deephanphongs
2001-03-30 12:37           ` Andrew Cagney
2001-03-30  5:06     ` Fernando Nasser
2001-03-30  5:20 ` Fernando Nasser [this message]
2001-03-30 13:28 ` [PATCH] specify arguments to debugee from commandline (second try) David Deephanphongs
2001-04-02 22:27   ` David Deephanphongs
2001-04-02 22:48     ` Alexandre Oliva
2001-04-05 21:27       ` Tom Tromey
2001-04-05 21:47         ` Alexandre Oliva
2001-04-05 21:21     ` Tom Tromey
2001-04-06  1:32       ` Eli Zaretskii
     [not found]         ` <87vgoi58lr.fsf@creche.redhat.com>
2001-04-06  9:26           ` Eli Zaretskii
2001-04-06  9:35             ` Pierre Muller
2001-04-06 11:00               ` Tom Tromey
2001-04-17 10:38                 ` Andrew Cagney
2001-04-20  2:39                   ` David Deephanphongs
2001-06-06 23:40                     ` David Deephanphongs
2001-06-07  0:00                       ` Eli Zaretskii
2001-04-06 11:03             ` Tom Tromey
2001-04-06 13:13               ` Eli Zaretskii
2001-04-10 22:27                 ` David Deephanphongs
2001-04-11  1:55                   ` Eli Zaretskii
2001-04-11 19:05                     ` David Deephanphongs
2001-04-12  8:26                       ` Tom Tromey
2001-04-12 14:13                         ` David Deephanphongs
2001-04-12 17:21                           ` Tom Tromey
2001-04-13  1:30                             ` Todd Whitesel
2001-04-06 22:46       ` David Deephanphongs
2001-04-05 21:12   ` Tom Tromey
2001-04-06  1:36     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3AC4874E.A630A31D@redhat.com \
    --to=fnasser@redhat.com \
    --cc=deephan@erols.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox