3 #include "util/debug.h"
4 #include <subcmd/parse-options.h>
5 #include "util/parse-branch-options.h"
7 #define BRANCH_OPT(n, m) \
8 { .name = n, .mode = (m) }
10 #define BRANCH_END { .name = NULL }
17 static const struct branch_mode branch_modes
[] = {
18 BRANCH_OPT("u", PERF_SAMPLE_BRANCH_USER
),
19 BRANCH_OPT("k", PERF_SAMPLE_BRANCH_KERNEL
),
20 BRANCH_OPT("hv", PERF_SAMPLE_BRANCH_HV
),
21 BRANCH_OPT("any", PERF_SAMPLE_BRANCH_ANY
),
22 BRANCH_OPT("any_call", PERF_SAMPLE_BRANCH_ANY_CALL
),
23 BRANCH_OPT("any_ret", PERF_SAMPLE_BRANCH_ANY_RETURN
),
24 BRANCH_OPT("ind_call", PERF_SAMPLE_BRANCH_IND_CALL
),
25 BRANCH_OPT("abort_tx", PERF_SAMPLE_BRANCH_ABORT_TX
),
26 BRANCH_OPT("in_tx", PERF_SAMPLE_BRANCH_IN_TX
),
27 BRANCH_OPT("no_tx", PERF_SAMPLE_BRANCH_NO_TX
),
28 BRANCH_OPT("cond", PERF_SAMPLE_BRANCH_COND
),
29 BRANCH_OPT("ind_jmp", PERF_SAMPLE_BRANCH_IND_JUMP
),
30 BRANCH_OPT("call", PERF_SAMPLE_BRANCH_CALL
),
35 parse_branch_stack(const struct option
*opt
, const char *str
, int unset
)
38 (PERF_SAMPLE_BRANCH_USER |\
39 PERF_SAMPLE_BRANCH_KERNEL |\
40 PERF_SAMPLE_BRANCH_HV)
42 uint64_t *mode
= (uint64_t *)opt
->value
;
43 const struct branch_mode
*br
;
44 char *s
, *os
= NULL
, *p
;
51 * cannot set it twice, -b + --branch-filter for instance
56 /* str may be NULL in case no arg is passed to -b */
58 /* because str is read-only */
68 for (br
= branch_modes
; br
->name
; br
++) {
69 if (!strcasecmp(s
, br
->name
))
73 ui__warning("unknown branch filter %s,"
74 " check man page\n", s
);
88 /* default to any branch */
89 if ((*mode
& ~ONLY_PLM
) == 0) {
90 *mode
= PERF_SAMPLE_BRANCH_ANY
;