Commit aeea9062 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo

perf parse-regs: Split parse_regs

The available registers for --int-regs and --user-regs may be different,
e.g. XMM registers.

Split parse_regs into two dedicated functions for --int-regs and
--user-regs respectively.

Modify the warning message. "--user-regs=?" should be applied to show
the available registers for --user-regs.
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Tested-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1557865174-56264-1-git-send-email-kan.liang@linux.intel.com
[ Changed docs as suggested by Ravi and agreed by Kan ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7025fdbe
...@@ -406,7 +406,8 @@ symbolic names, e.g. on x86, ax, si. To list the available registers use ...@@ -406,7 +406,8 @@ symbolic names, e.g. on x86, ax, si. To list the available registers use
--intr-regs=ax,bx. The list of register is architecture dependent. --intr-regs=ax,bx. The list of register is architecture dependent.
--user-regs:: --user-regs::
Capture user registers at sample time. Same arguments as -I. Similar to -I, but capture user registers at sample time. To list the available
user registers use --user-regs=\?.
--running-time:: --running-time::
Record running and enabled time for read events (:S) Record running and enabled time for read events (:S)
......
...@@ -2168,10 +2168,10 @@ static struct option __record_options[] = { ...@@ -2168,10 +2168,10 @@ static struct option __record_options[] = {
"use per-thread mmaps"), "use per-thread mmaps"),
OPT_CALLBACK_OPTARG('I', "intr-regs", &record.opts.sample_intr_regs, NULL, "any register", OPT_CALLBACK_OPTARG('I', "intr-regs", &record.opts.sample_intr_regs, NULL, "any register",
"sample selected machine registers on interrupt," "sample selected machine registers on interrupt,"
" use '-I?' to list register names", parse_regs), " use '-I?' to list register names", parse_intr_regs),
OPT_CALLBACK_OPTARG(0, "user-regs", &record.opts.sample_user_regs, NULL, "any register", OPT_CALLBACK_OPTARG(0, "user-regs", &record.opts.sample_user_regs, NULL, "any register",
"sample selected machine registers on interrupt," "sample selected machine registers on interrupt,"
" use '-I?' to list register names", parse_regs), " use '--user-regs=?' to list register names", parse_user_regs),
OPT_BOOLEAN(0, "running-time", &record.opts.running_time, OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
"Record running/enabled time of read (:S) events"), "Record running/enabled time of read (:S) events"),
OPT_CALLBACK('k', "clockid", &record.opts, OPT_CALLBACK('k', "clockid", &record.opts,
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "util/parse-regs-options.h" #include "util/parse-regs-options.h"
int static int
parse_regs(const struct option *opt, const char *str, int unset) __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
{ {
uint64_t *mode = (uint64_t *)opt->value; uint64_t *mode = (uint64_t *)opt->value;
const struct sample_reg *r; const struct sample_reg *r;
...@@ -48,7 +48,8 @@ parse_regs(const struct option *opt, const char *str, int unset) ...@@ -48,7 +48,8 @@ parse_regs(const struct option *opt, const char *str, int unset)
break; break;
} }
if (!r->name) { if (!r->name) {
ui__warning("Unknown register \"%s\", check man page or run \"perf record -I?\"\n", s); ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n",
s, intr ? "-I" : "--user-regs=");
goto error; goto error;
} }
...@@ -69,3 +70,15 @@ parse_regs(const struct option *opt, const char *str, int unset) ...@@ -69,3 +70,15 @@ parse_regs(const struct option *opt, const char *str, int unset)
free(os); free(os);
return ret; return ret;
} }
int
parse_user_regs(const struct option *opt, const char *str, int unset)
{
return __parse_regs(opt, str, unset, false);
}
int
parse_intr_regs(const struct option *opt, const char *str, int unset)
{
return __parse_regs(opt, str, unset, true);
}
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
#ifndef _PERF_PARSE_REGS_OPTIONS_H #ifndef _PERF_PARSE_REGS_OPTIONS_H
#define _PERF_PARSE_REGS_OPTIONS_H 1 #define _PERF_PARSE_REGS_OPTIONS_H 1
struct option; struct option;
int parse_regs(const struct option *opt, const char *str, int unset); int parse_user_regs(const struct option *opt, const char *str, int unset);
int parse_intr_regs(const struct option *opt, const char *str, int unset);
#endif /* _PERF_PARSE_REGS_OPTIONS_H */ #endif /* _PERF_PARSE_REGS_OPTIONS_H */
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