perf tools: Check vmlinux/kallsyms arguments in all tools

Only perf report checked the validity of these arguments so apply the
same check to all tools that read them for consistency.

Signed-off-by: James Clark <james.clark@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Denis Nikitin <denik@chromium.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20211018134844.2627174-3-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
James Clark 2021-10-18 14:48:42 +01:00 committed by Arnaldo Carvalho de Melo
parent a3df50abeb
commit 7cc72553ac
7 changed files with 28 additions and 0 deletions

View File

@ -591,6 +591,10 @@ int cmd_annotate(int argc, const char **argv)
return ret; return ret;
} }
ret = symbol__validate_sym_arguments();
if (ret)
return ret;
if (quiet) if (quiet)
perf_quiet_option(); perf_quiet_option();

View File

@ -2768,6 +2768,10 @@ static int perf_c2c__report(int argc, const char **argv)
if (c2c.stats_only) if (c2c.stats_only)
c2c.use_stdio = true; c2c.use_stdio = true;
err = symbol__validate_sym_arguments();
if (err)
goto out;
if (!input_name || !strlen(input_name)) if (!input_name || !strlen(input_name))
input_name = "perf.data"; input_name = "perf.data";

View File

@ -21,6 +21,7 @@
#include "util/build-id.h" #include "util/build-id.h"
#include "util/strlist.h" #include "util/strlist.h"
#include "util/strfilter.h" #include "util/strfilter.h"
#include "util/symbol.h"
#include "util/symbol_conf.h" #include "util/symbol_conf.h"
#include "util/debug.h" #include "util/debug.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
@ -629,6 +630,10 @@ __cmd_probe(int argc, const char **argv)
params.command = 'a'; params.command = 'a';
} }
ret = symbol__validate_sym_arguments();
if (ret)
return ret;
if (params.quiet) { if (params.quiet) {
if (verbose != 0) { if (verbose != 0) {
pr_err(" Error: -v and -q are exclusive.\n"); pr_err(" Error: -v and -q are exclusive.\n");

View File

@ -2712,6 +2712,10 @@ int cmd_record(int argc, const char **argv)
if (quiet) if (quiet)
perf_quiet_option(); perf_quiet_option();
err = symbol__validate_sym_arguments();
if (err)
return err;
/* Make system wide (-a) the default target. */ /* Make system wide (-a) the default target. */
if (!argc && target__none(&rec->opts.target)) if (!argc && target__none(&rec->opts.target))
rec->opts.target.system_wide = true; rec->opts.target.system_wide = true;

View File

@ -3538,6 +3538,7 @@ int cmd_sched(int argc, const char **argv)
.fork_event = replay_fork_event, .fork_event = replay_fork_event,
}; };
unsigned int i; unsigned int i;
int ret;
for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++) for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
sched.curr_pid[i] = -1; sched.curr_pid[i] = -1;
@ -3598,6 +3599,9 @@ int cmd_sched(int argc, const char **argv)
parse_options_usage(NULL, timehist_options, "n", true); parse_options_usage(NULL, timehist_options, "n", true);
return -EINVAL; return -EINVAL;
} }
ret = symbol__validate_sym_arguments();
if (ret)
return ret;
return perf_sched__timehist(&sched); return perf_sched__timehist(&sched);
} else { } else {

View File

@ -3846,6 +3846,9 @@ int cmd_script(int argc, const char **argv)
data.path = input_name; data.path = input_name;
data.force = symbol_conf.force; data.force = symbol_conf.force;
if (symbol__validate_sym_arguments())
return -1;
if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) { if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) {
rec_script_path = get_script_path(argv[1], RECORD_SUFFIX); rec_script_path = get_script_path(argv[1], RECORD_SUFFIX);
if (!rec_script_path) if (!rec_script_path)

View File

@ -1618,6 +1618,10 @@ int cmd_top(int argc, const char **argv)
if (argc) if (argc)
usage_with_options(top_usage, options); usage_with_options(top_usage, options);
status = symbol__validate_sym_arguments();
if (status)
goto out_delete_evlist;
if (annotate_check_args(&top.annotation_opts) < 0) if (annotate_check_args(&top.annotation_opts) < 0)
goto out_delete_evlist; goto out_delete_evlist;