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 #ifdef HAVE_PERF_REGS_SUPPORT
50 for (r
= sample_reg_masks
; r
->name
; r
++) {
52 fprintf(stderr
, "%s ", r
->name
);
56 /* just printing available regs */
59 #ifdef HAVE_PERF_REGS_SUPPORT
60 for (r
= sample_reg_masks
; r
->name
; r
++) {
61 if ((r
->mask
& mask
) && !strcasecmp(s
, r
->name
))
66 ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n",
67 s
, intr
? "-I" : "--user-regs=");
81 /* default to all possible regs */
90 parse_user_regs(const struct option
*opt
, const char *str
, int unset
)
92 return __parse_regs(opt
, str
, unset
, false);
96 parse_intr_regs(const struct option
*opt
, const char *str
, int unset
)
98 return __parse_regs(opt
, str
, unset
, true);