Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Ravi 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: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kan Liang and committed by
Arnaldo Carvalho de Melo
aeea9062 7025fdbe

+22 -7
+2 -1
tools/perf/Documentation/perf-record.txt
··· 406 406 --intr-regs=ax,bx. The list of register is architecture dependent. 407 407 408 408 --user-regs:: 409 - Capture user registers at sample time. Same arguments as -I. 409 + Similar to -I, but capture user registers at sample time. To list the available 410 + user registers use --user-regs=\?. 410 411 411 412 --running-time:: 412 413 Record running and enabled time for read events (:S)
+2 -2
tools/perf/builtin-record.c
··· 2168 2168 "use per-thread mmaps"), 2169 2169 OPT_CALLBACK_OPTARG('I', "intr-regs", &record.opts.sample_intr_regs, NULL, "any register", 2170 2170 "sample selected machine registers on interrupt," 2171 - " use '-I?' to list register names", parse_regs), 2171 + " use '-I?' to list register names", parse_intr_regs), 2172 2172 OPT_CALLBACK_OPTARG(0, "user-regs", &record.opts.sample_user_regs, NULL, "any register", 2173 2173 "sample selected machine registers on interrupt," 2174 - " use '-I?' to list register names", parse_regs), 2174 + " use '--user-regs=?' to list register names", parse_user_regs), 2175 2175 OPT_BOOLEAN(0, "running-time", &record.opts.running_time, 2176 2176 "Record running/enabled time of read (:S) events"), 2177 2177 OPT_CALLBACK('k', "clockid", &record.opts,
+16 -3
tools/perf/util/parse-regs-options.c
··· 5 5 #include <subcmd/parse-options.h> 6 6 #include "util/parse-regs-options.h" 7 7 8 - int 9 - parse_regs(const struct option *opt, const char *str, int unset) 8 + static int 9 + __parse_regs(const struct option *opt, const char *str, int unset, bool intr) 10 10 { 11 11 uint64_t *mode = (uint64_t *)opt->value; 12 12 const struct sample_reg *r; ··· 48 48 break; 49 49 } 50 50 if (!r->name) { 51 - ui__warning("Unknown register \"%s\", check man page or run \"perf record -I?\"\n", s); 51 + ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n", 52 + s, intr ? "-I" : "--user-regs="); 52 53 goto error; 53 54 } 54 55 ··· 69 68 error: 70 69 free(os); 71 70 return ret; 71 + } 72 + 73 + int 74 + parse_user_regs(const struct option *opt, const char *str, int unset) 75 + { 76 + return __parse_regs(opt, str, unset, false); 77 + } 78 + 79 + int 80 + parse_intr_regs(const struct option *opt, const char *str, int unset) 81 + { 82 + return __parse_regs(opt, str, unset, true); 72 83 }
+2 -1
tools/perf/util/parse-regs-options.h
··· 2 2 #ifndef _PERF_PARSE_REGS_OPTIONS_H 3 3 #define _PERF_PARSE_REGS_OPTIONS_H 1 4 4 struct option; 5 - int parse_regs(const struct option *opt, const char *str, int unset); 5 + int parse_user_regs(const struct option *opt, const char *str, int unset); 6 + int parse_intr_regs(const struct option *opt, const char *str, int unset); 6 7 #endif /* _PERF_PARSE_REGS_OPTIONS_H */