From: Phil Muldoon <pmuldoon@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch][python] 2 of 5 - Frame filter MI code changes.
Date: Tue, 07 May 2013 08:23:00 -0000 [thread overview]
Message-ID: <5188BA12.4050508@redhat.com> (raw)
In-Reply-To: <87ppx3x2k3.fsf@fleche.redhat.com>
On 06/05/13 21:42, Tom Tromey wrote:
>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> @@ -52,14 +78,43 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc)
>
> Phil> + if ((argc > 3) || (argc == 2 && oind) || (argc == 1 && ! oind))
> Phil> + error (_("-stack-list-frames: Usage: [--no-frame-filters] [FRAME_LOW FRAME_HIGH]"));
>
> Phil> - if (argc == 2)
> Phil> + if (argc == 3 || argc == 2)
>
> It seems to me that these checks should use oind rather than argc.
> Then they would be simpler.
>
> As it is I think they are wrong for the weird but accepted input:
>
> -stack-list-frames --no-frame-filters --no-frame-filters 0 15
I'm not sure how I would write them just using oind. oind will be an
integer index to the last option in the argv list parsed.
-stack-list-frames --no-frame-filters 0 15
mi_getopt stops parsing when it reaches the first non-option argument.
So in this case it would be 1. argc is the total number of arguments,
which is in that case is 3.
Your example:
-stack-list-frames --no-frame-filters --no-frame-filters 0 15
Would fail on the first "if" condition check:
if ((argc > 3) || (argc == 2 && oind) || (argc == 1 && ! oind))
As argc is > 3. Typically from what I have found all MI commands do
an argc check for the accepted number of arguments. Because MI relies
on integer arguments for ranges (i.e. FRAME LOW - FRAME HIGH), and also
some MI commands allow integer substitutions for some options (i.e., 1
or --all-values), and mi_getopt stops parsing on the first non-option
it encounters, MI arguments are inherently limited to strict
positional adherence.
Anyway, that "if" statement just checks for permutations of
-stack-list-frames --no-frame-filters 1 2 3 4
-stack-list-frames --no-frame-filters 1
-stack-list-frames 1
It looks like I am missing a check for:
if (argc == 3 && ! oind).
I will add that.
If there is a way to write the test solely using oind I will happily
do it, but I must admit to being puzzled how to do it.
Cheers
Phil
next prev parent reply other threads:[~2013-05-07 8:23 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 8:23 Phil Muldoon
2013-05-06 20:42 ` Tom Tromey
2013-05-07 8:23 ` Phil Muldoon [this message]
2013-05-07 14:02 ` Tom Tromey
2013-05-08 10:18 ` Phil Muldoon
2013-05-08 19:47 ` Tom Tromey
2013-05-10 10:45 ` Phil Muldoon
-- strict thread matches above, loose matches on Subject: below --
2013-04-22 16:01 Phil Muldoon
2013-04-26 11:19 ` Tom Tromey
2013-03-11 22:13 Phil Muldoon
2013-03-12 20:43 ` Tom Tromey
2013-03-12 20:52 ` Phil Muldoon
2013-03-13 12:15 ` Phil Muldoon
2013-03-13 17:48 ` Tom Tromey
2013-03-13 19:41 ` Phil Muldoon
2013-03-13 20:27 ` Tom Tromey
2013-03-13 20:53 ` Phil Muldoon
2013-03-13 20:56 ` Tom Tromey
2013-03-13 21:10 ` Phil Muldoon
2013-03-14 17:54 ` Tom Tromey
2013-03-14 19:35 ` Phil Muldoon
2012-11-30 14:31 Phil Muldoon
2012-12-05 17:11 ` Tom Tromey
2012-12-07 13:56 ` Phil Muldoon
2012-12-10 21:03 ` Tom Tromey
2013-02-05 12:08 ` Phil Muldoon
2013-02-07 21:32 ` Tom Tromey
2013-02-20 15:17 ` Phil Muldoon
2013-02-20 20:37 ` Tom Tromey
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=5188BA12.4050508@redhat.com \
--to=pmuldoon@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@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