[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210721022442.159436-2-bholman.devel@gmail.com>
Date: Tue, 20 Jul 2021 20:24:42 -0600
From: Brett Holman <bholman.devel@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-perf-users@...r.kernel.org,
Brett Holman <bholman.devel@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] perf mem: Standardize 'perf mem' arg parsing
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@...il.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
Powered by blists - more mailing lists