From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: --pid and --core
Date: Fri, 04 Jan 2008 05:03:00 -0000 [thread overview]
Message-ID: <20080104045813.GA28411@adacore.com> (raw)
In-Reply-To: <477D122A.4060405@codesourcery.com>
Hi Pedro,
> 2007-12-28 Pedro Alves <pedro_alves@portugalmail.pt>
>
> * main.c (captured_main): Error out if --core and --pid options
> were issued simultaneously. If an explicit pid option was passed,
> don't fallback to core file. Detect extra arguments better in the
> presence of explicit pid or core arguments.
Thanks for the patch. A couple of of comments:
> + {
> + ++count;
> + if (count == 1)
> + {
> + symarg = argv[optind];
> + execarg = argv[optind];
> + }
> + else if (count > 2
> + /* If we have a --pid or a --core argument,
> + this argument don't make sense. */
^^^^
doesn't
> + || pidarg != NULL
> + || corearg != NULL)
> + {
> + fprintf_unfiltered (gdb_stderr, _("\
> +Excess command line arguments ignored. (%s%s)\n"),
> + argv[optind],
> + (optind == argc - 1) ? "" : " ...");
> + optind = argc;
> + break;
> + }
> + else
> + /* The documentation says this can be a "ProcID" as
> + well. We will try it later as both a corefile and a
> + pid. */
> + pid_or_core_arg = argv[optind];
> + }
It took me a long while to understand this loop. I realize this was
already implemented that way before, but I think something like the code
below is simpler. What do you think?
/* The first argument, if specified, is the name of the executable. */
if (argc - optind > 0)
{
symarg = argv[optind];
execarg = argv[optind];
optind++;
}
/* If the user hasn't already specified a PID or the name of
a core file, then a second optional argument is allowed.
If present, this argument should be interpreted as either
a PID or a core file, whichever works. */
if (pidarg == NULL && corearg == NULL && argc - optind > 0)
{
pid_or_core_arg = argv[optind];
optind++;
}
/* Any argument left on the command line is unexpected and will be
ignored. Inform the user. */
for (; optind < argc; optind++)
fprintf_unfiltered (...);
Thanks,
--
Joel
next prev parent reply other threads:[~2008-01-04 5:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-03 16:56 Pedro Alves
2008-01-04 5:03 ` Joel Brobecker [this message]
2008-01-04 12:20 ` Pedro Alves
2008-01-04 15:41 ` Joel Brobecker
2008-01-05 12:47 ` Eli Zaretskii
2008-01-05 12:46 ` Eli Zaretskii
2008-01-05 13:09 ` Eli Zaretskii
2008-01-05 17:26 ` Pedro Alves
2008-01-05 17:36 ` Eli Zaretskii
2008-01-05 21:58 ` Pedro Alves
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=20080104045813.GA28411@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.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