1 // SPDX-License-Identifier: GPL-2.0
4 #include "util/debug.h"
5 #include <subcmd/parse-options.h>
6 #include "util/parse-regs-options.h"
9 __parse_regs(const struct option
*opt
, const char *str
, int unset
, bool intr
)
11 uint64_t *mode
= (uint64_t *)opt
->value
;
12 const struct sample_reg
*r
;
13 char *s
, *os
= NULL
, *p
;
27 mask
= arch__intr_reg_mask();
29 mask
= arch__user_reg_mask();
31 /* str may be NULL in case no arg is passed to -I */
33 /* because str is read-only */
43 if (!strcmp(s
, "?")) {
44 fprintf(stderr
, "available registers: ");
45 for (r
= sample_reg_masks
; r
->name
; r
++) {
47 fprintf(stderr
, "%s ", r
->name
);
50 /* just printing available regs */
53 for (r
= sample_reg_masks
; r
->name
; r
++) {
54 if ((r
->mask
& mask
) && !strcasecmp(s
, r
->name
))
58 ui__warning("Unknown register \"%s\", check man page or run \"perf record %s?\"\n",
59 s
, intr
? "-I" : "--user-regs=");
73 /* default to all possible regs */
82 parse_user_regs(const struct option
*opt
, const char *str
, int unset
)
84 return __parse_regs(opt
, str
, unset
, false);
88 parse_intr_regs(const struct option
*opt
, const char *str
, int unset
)
90 return __parse_regs(opt
, str
, unset
, true);