1 // SPDX-License-Identifier: GPL-2.0
7 #include "util/debug.h"
8 #include <subcmd/parse-options.h>
9 #include "util/perf_regs.h"
10 #include "util/parse-regs-options.h"
13 __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
15 uint64_t *mode = (uint64_t *)opt->value;
16 const struct sample_reg *r = NULL;
17 char *s, *os = NULL, *p;
31 mask = arch__intr_reg_mask();
33 mask = arch__user_reg_mask();
35 /* str may be NULL in case no arg is passed to -I */
37 /* because str is read-only */
47 if (!strcmp(s, "?")) {
48 fprintf(stderr, "available registers: ");
49 for (r = arch__sample_reg_masks(); r->name; r++) {
51 fprintf(stderr, "%s ", r->name);
54 /* just printing available regs */
57 for (r = arch__sample_reg_masks(); r->name; r++) {
58 if ((r->mask & mask) && !strcasecmp(s, r->name))
62 ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n",
63 s, intr ? "-I" : "--user-regs=");
77 /* default to all possible regs */
86 parse_user_regs(const struct option *opt, const char *str, int unset)
88 return __parse_regs(opt, str, unset, false);
92 parse_intr_regs(const struct option *opt, const char *str, int unset)
94 return __parse_regs(opt, str, unset, true);