diff options
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 135f69baf966..d3086cecd2dd 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "../../../include/linux/hw_breakpoint.h" | 1 | #include "../../../include/linux/hw_breakpoint.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | #include "evlist.h" | ||
4 | #include "evsel.h" | 5 | #include "evsel.h" |
5 | #include "parse-options.h" | 6 | #include "parse-options.h" |
6 | #include "parse-events.h" | 7 | #include "parse-events.h" |
@@ -11,10 +12,6 @@ | |||
11 | #include "header.h" | 12 | #include "header.h" |
12 | #include "debugfs.h" | 13 | #include "debugfs.h" |
13 | 14 | ||
14 | int nr_counters; | ||
15 | |||
16 | LIST_HEAD(evsel_list); | ||
17 | |||
18 | struct event_symbol { | 15 | struct event_symbol { |
19 | u8 type; | 16 | u8 type; |
20 | u64 config; | 17 | u64 config; |
@@ -778,8 +775,9 @@ modifier: | |||
778 | return ret; | 775 | return ret; |
779 | } | 776 | } |
780 | 777 | ||
781 | int parse_events(const struct option *opt __used, const char *str, int unset __used) | 778 | int parse_events(const struct option *opt, const char *str, int unset __used) |
782 | { | 779 | { |
780 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
783 | struct perf_event_attr attr; | 781 | struct perf_event_attr attr; |
784 | enum event_result ret; | 782 | enum event_result ret; |
785 | 783 | ||
@@ -794,12 +792,10 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u | |||
794 | 792 | ||
795 | if (ret != EVT_HANDLED_ALL) { | 793 | if (ret != EVT_HANDLED_ALL) { |
796 | struct perf_evsel *evsel; | 794 | struct perf_evsel *evsel; |
797 | evsel = perf_evsel__new(&attr, | 795 | evsel = perf_evsel__new(&attr, evlist->nr_entries); |
798 | nr_counters); | ||
799 | if (evsel == NULL) | 796 | if (evsel == NULL) |
800 | return -1; | 797 | return -1; |
801 | list_add_tail(&evsel->node, &evsel_list); | 798 | perf_evlist__add(evlist, evsel); |
802 | ++nr_counters; | ||
803 | } | 799 | } |
804 | 800 | ||
805 | if (*str == 0) | 801 | if (*str == 0) |
@@ -813,13 +809,14 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u | |||
813 | return 0; | 809 | return 0; |
814 | } | 810 | } |
815 | 811 | ||
816 | int parse_filter(const struct option *opt __used, const char *str, | 812 | int parse_filter(const struct option *opt, const char *str, |
817 | int unset __used) | 813 | int unset __used) |
818 | { | 814 | { |
815 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
819 | struct perf_evsel *last = NULL; | 816 | struct perf_evsel *last = NULL; |
820 | 817 | ||
821 | if (!list_empty(&evsel_list)) | 818 | if (evlist->nr_entries > 0) |
822 | last = list_entry(evsel_list.prev, struct perf_evsel, node); | 819 | last = list_entry(evlist->entries.prev, struct perf_evsel, node); |
823 | 820 | ||
824 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { | 821 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { |
825 | fprintf(stderr, | 822 | fprintf(stderr, |
@@ -981,33 +978,3 @@ void print_events(void) | |||
981 | 978 | ||
982 | exit(129); | 979 | exit(129); |
983 | } | 980 | } |
984 | |||
985 | int perf_evsel_list__create_default(void) | ||
986 | { | ||
987 | struct perf_evsel *evsel; | ||
988 | struct perf_event_attr attr; | ||
989 | |||
990 | memset(&attr, 0, sizeof(attr)); | ||
991 | attr.type = PERF_TYPE_HARDWARE; | ||
992 | attr.config = PERF_COUNT_HW_CPU_CYCLES; | ||
993 | |||
994 | evsel = perf_evsel__new(&attr, 0); | ||
995 | |||
996 | if (evsel == NULL) | ||
997 | return -ENOMEM; | ||
998 | |||
999 | list_add(&evsel->node, &evsel_list); | ||
1000 | ++nr_counters; | ||
1001 | return 0; | ||
1002 | } | ||
1003 | |||
1004 | void perf_evsel_list__delete(void) | ||
1005 | { | ||
1006 | struct perf_evsel *pos, *n; | ||
1007 | |||
1008 | list_for_each_entry_safe(pos, n, &evsel_list, node) { | ||
1009 | list_del_init(&pos->node); | ||
1010 | perf_evsel__delete(pos); | ||
1011 | } | ||
1012 | nr_counters = 0; | ||
1013 | } | ||