Commit e5b2c207 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Export usage string and option table of perf record

Those are shared with other builtin commands like kvm, script.  So
make it accessable from them.  This is a preparation of later change
that limiting possible options.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarHemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1413990949-13953-3-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d152d1be
...@@ -680,11 +680,12 @@ static int perf_record_config(const char *var, const char *value, void *cb) ...@@ -680,11 +680,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
return perf_default_config(var, value, cb); return perf_default_config(var, value, cb);
} }
static const char * const record_usage[] = { static const char * const __record_usage[] = {
"perf record [<options>] [<command>]", "perf record [<options>] [<command>]",
"perf record [<options>] -- <command> [<options>]", "perf record [<options>] -- <command> [<options>]",
NULL NULL
}; };
const char * const *record_usage = __record_usage;
/* /*
* XXX Ideally would be local to cmd_record() and passed to a record__new * XXX Ideally would be local to cmd_record() and passed to a record__new
...@@ -725,7 +726,7 @@ const char record_callchain_help[] = CALLCHAIN_HELP "fp"; ...@@ -725,7 +726,7 @@ const char record_callchain_help[] = CALLCHAIN_HELP "fp";
* perf_evlist__prepare_workload, etc instead of fork+exec'in 'perf record', * perf_evlist__prepare_workload, etc instead of fork+exec'in 'perf record',
* using pipes, etc. * using pipes, etc.
*/ */
const struct option record_options[] = { struct option __record_options[] = {
OPT_CALLBACK('e', "event", &record.evlist, "event", OPT_CALLBACK('e', "event", &record.evlist, "event",
"event selector. use 'perf list' to list available events", "event selector. use 'perf list' to list available events",
parse_events_option), parse_events_option),
...@@ -802,6 +803,8 @@ const struct option record_options[] = { ...@@ -802,6 +803,8 @@ const struct option record_options[] = {
OPT_END() OPT_END()
}; };
struct option *record_options = __record_options;
int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
{ {
int err = -ENOMEM; int err = -ENOMEM;
......
...@@ -23,7 +23,6 @@ static char const *generate_script_lang; ...@@ -23,7 +23,6 @@ static char const *generate_script_lang;
static bool debug_mode; static bool debug_mode;
static u64 last_timestamp; static u64 last_timestamp;
static u64 nr_unordered; static u64 nr_unordered;
extern const struct option record_options[];
static bool no_callchain; static bool no_callchain;
static bool latency_format; static bool latency_format;
static bool system_wide; static bool system_wide;
......
...@@ -1963,7 +1963,7 @@ int cmd_timechart(int argc, const char **argv, ...@@ -1963,7 +1963,7 @@ int cmd_timechart(int argc, const char **argv,
NULL NULL
}; };
const struct option record_options[] = { const struct option timechart_record_options[] = {
OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"), OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only, OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
"output processes data only"), "output processes data only"),
...@@ -1972,7 +1972,7 @@ int cmd_timechart(int argc, const char **argv, ...@@ -1972,7 +1972,7 @@ int cmd_timechart(int argc, const char **argv,
OPT_BOOLEAN('g', "callchain", &tchart.with_backtrace, "record callchain"), OPT_BOOLEAN('g', "callchain", &tchart.with_backtrace, "record callchain"),
OPT_END() OPT_END()
}; };
const char * const record_usage[] = { const char * const timechart_record_usage[] = {
"perf timechart record [<options>]", "perf timechart record [<options>]",
NULL NULL
}; };
...@@ -1985,7 +1985,8 @@ int cmd_timechart(int argc, const char **argv, ...@@ -1985,7 +1985,8 @@ int cmd_timechart(int argc, const char **argv,
} }
if (argc && !strncmp(argv[0], "rec", 3)) { if (argc && !strncmp(argv[0], "rec", 3)) {
argc = parse_options(argc, argv, record_options, record_usage, argc = parse_options(argc, argv, timechart_record_options,
timechart_record_usage,
PARSE_OPT_STOP_AT_NON_OPTION); PARSE_OPT_STOP_AT_NON_OPTION);
if (tchart.power_only && tchart.tasks_only) { if (tchart.power_only && tchart.tasks_only) {
......
...@@ -62,4 +62,7 @@ struct record_opts { ...@@ -62,4 +62,7 @@ struct record_opts {
unsigned initial_delay; unsigned initial_delay;
}; };
struct option;
extern const char * const *record_usage;
extern struct option *record_options;
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment