From: Brett Holman <bholman.devel@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-perf-users@vger.kernel.org,
Brett Holman <bholman.devel@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] perf mem: Standardize 'perf mem' arg parsing
Date: Tue, 20 Jul 2021 20:24:42 -0600 [thread overview]
Message-ID: <20210721022442.159436-2-bholman.devel@gmail.com> (raw)
In-Reply-To: <20210721022442.159436-1-bholman.devel@gmail.com>
Arguments are parsed differently by 'perf record' and 'perf mem
record'. While '--' can be used to stop parsing arguments in both,
'perf record' stops parsing when an unknown argument is found and 'perf
mem record' does not. This may lead to surprise when flags are stripped
from the command being tested with 'perf mem record'. This patch
eliminates this difference in behavior.
Signed-off-by: Brett Holman <bholman.devel@gmail.com>
---
tools/perf/builtin-mem.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 0fd2a74dbaca..ce734774b552 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -89,7 +89,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
}
argc = parse_options(argc, argv, options, record_mem_usage,
- PARSE_OPT_KEEP_UNKNOWN);
+ PARSE_OPT_STOP_AT_NON_OPTION);
if (!perf_pmu__has_hybrid())
rec_argc = argc + 9; /* max number of arguments */
@@ -484,9 +484,14 @@ int cmd_mem(int argc, const char **argv)
NULL
};
- argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
+ if (!strncmp(argv[1], "rec", 3))
+ argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
+ mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);
+ else
+ argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
mem_usage, PARSE_OPT_KEEP_UNKNOWN);
+
if (!argc || !(strncmp(argv[0], "rec", 3) || mem.operation))
usage_with_options(mem_usage, mem_options);
--
2.31.1
prev parent reply other threads:[~2021-07-21 2:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 2:24 [PATCH] perf mem: Standardize \'perf mem\' arg parsing Brett Holman
2021-07-21 2:24 ` Brett Holman [this message]
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=20210721022442.159436-2-bholman.devel@gmail.com \
--to=bholman.devel@gmail.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).