diff options
author | Ingo Molnar <mingo@elte.hu> | 2011-01-27 13:23:20 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-01-27 13:23:20 -0500 |
commit | d380eaaea70d775c0520dcb5702ea5d2a56b7be9 (patch) | |
tree | 3a4c2d15f8b558c68f9d275aba411180088f4a9d /tools/perf/util/parse-events.c | |
parent | dda99116969142cc41e945a1047a419b937536af (diff) | |
parent | ef1d1af28ca37fdbc2745da040529cd2953c1af5 (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/core
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 135f69baf966..cf082daa43e3 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; |
@@ -449,8 +446,8 @@ parse_single_tracepoint_event(char *sys_name, | |||
449 | /* sys + ':' + event + ':' + flags*/ | 446 | /* sys + ':' + event + ':' + flags*/ |
450 | #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) | 447 | #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) |
451 | static enum event_result | 448 | static enum event_result |
452 | parse_multiple_tracepoint_event(char *sys_name, const char *evt_exp, | 449 | parse_multiple_tracepoint_event(const struct option *opt, char *sys_name, |
453 | char *flags) | 450 | const char *evt_exp, char *flags) |
454 | { | 451 | { |
455 | char evt_path[MAXPATHLEN]; | 452 | char evt_path[MAXPATHLEN]; |
456 | struct dirent *evt_ent; | 453 | struct dirent *evt_ent; |
@@ -483,15 +480,16 @@ parse_multiple_tracepoint_event(char *sys_name, const char *evt_exp, | |||
483 | if (len < 0) | 480 | if (len < 0) |
484 | return EVT_FAILED; | 481 | return EVT_FAILED; |
485 | 482 | ||
486 | if (parse_events(NULL, event_opt, 0)) | 483 | if (parse_events(opt, event_opt, 0)) |
487 | return EVT_FAILED; | 484 | return EVT_FAILED; |
488 | } | 485 | } |
489 | 486 | ||
490 | return EVT_HANDLED_ALL; | 487 | return EVT_HANDLED_ALL; |
491 | } | 488 | } |
492 | 489 | ||
493 | static enum event_result parse_tracepoint_event(const char **strp, | 490 | static enum event_result |
494 | struct perf_event_attr *attr) | 491 | parse_tracepoint_event(const struct option *opt, const char **strp, |
492 | struct perf_event_attr *attr) | ||
495 | { | 493 | { |
496 | const char *evt_name; | 494 | const char *evt_name; |
497 | char *flags = NULL, *comma_loc; | 495 | char *flags = NULL, *comma_loc; |
@@ -530,7 +528,7 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
530 | return EVT_FAILED; | 528 | return EVT_FAILED; |
531 | if (strpbrk(evt_name, "*?")) { | 529 | if (strpbrk(evt_name, "*?")) { |
532 | *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */ | 530 | *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */ |
533 | return parse_multiple_tracepoint_event(sys_name, evt_name, | 531 | return parse_multiple_tracepoint_event(opt, sys_name, evt_name, |
534 | flags); | 532 | flags); |
535 | } else { | 533 | } else { |
536 | return parse_single_tracepoint_event(sys_name, evt_name, | 534 | return parse_single_tracepoint_event(sys_name, evt_name, |
@@ -740,11 +738,12 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr) | |||
740 | * Symbolic names are (almost) exactly matched. | 738 | * Symbolic names are (almost) exactly matched. |
741 | */ | 739 | */ |
742 | static enum event_result | 740 | static enum event_result |
743 | parse_event_symbols(const char **str, struct perf_event_attr *attr) | 741 | parse_event_symbols(const struct option *opt, const char **str, |
742 | struct perf_event_attr *attr) | ||
744 | { | 743 | { |
745 | enum event_result ret; | 744 | enum event_result ret; |
746 | 745 | ||
747 | ret = parse_tracepoint_event(str, attr); | 746 | ret = parse_tracepoint_event(opt, str, attr); |
748 | if (ret != EVT_FAILED) | 747 | if (ret != EVT_FAILED) |
749 | goto modifier; | 748 | goto modifier; |
750 | 749 | ||
@@ -778,14 +777,15 @@ modifier: | |||
778 | return ret; | 777 | return ret; |
779 | } | 778 | } |
780 | 779 | ||
781 | int parse_events(const struct option *opt __used, const char *str, int unset __used) | 780 | int parse_events(const struct option *opt, const char *str, int unset __used) |
782 | { | 781 | { |
782 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
783 | struct perf_event_attr attr; | 783 | struct perf_event_attr attr; |
784 | enum event_result ret; | 784 | enum event_result ret; |
785 | 785 | ||
786 | for (;;) { | 786 | for (;;) { |
787 | memset(&attr, 0, sizeof(attr)); | 787 | memset(&attr, 0, sizeof(attr)); |
788 | ret = parse_event_symbols(&str, &attr); | 788 | ret = parse_event_symbols(opt, &str, &attr); |
789 | if (ret == EVT_FAILED) | 789 | if (ret == EVT_FAILED) |
790 | return -1; | 790 | return -1; |
791 | 791 | ||
@@ -794,12 +794,10 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u | |||
794 | 794 | ||
795 | if (ret != EVT_HANDLED_ALL) { | 795 | if (ret != EVT_HANDLED_ALL) { |
796 | struct perf_evsel *evsel; | 796 | struct perf_evsel *evsel; |
797 | evsel = perf_evsel__new(&attr, | 797 | evsel = perf_evsel__new(&attr, evlist->nr_entries); |
798 | nr_counters); | ||
799 | if (evsel == NULL) | 798 | if (evsel == NULL) |
800 | return -1; | 799 | return -1; |
801 | list_add_tail(&evsel->node, &evsel_list); | 800 | perf_evlist__add(evlist, evsel); |
802 | ++nr_counters; | ||
803 | } | 801 | } |
804 | 802 | ||
805 | if (*str == 0) | 803 | if (*str == 0) |
@@ -813,13 +811,14 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u | |||
813 | return 0; | 811 | return 0; |
814 | } | 812 | } |
815 | 813 | ||
816 | int parse_filter(const struct option *opt __used, const char *str, | 814 | int parse_filter(const struct option *opt, const char *str, |
817 | int unset __used) | 815 | int unset __used) |
818 | { | 816 | { |
817 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
819 | struct perf_evsel *last = NULL; | 818 | struct perf_evsel *last = NULL; |
820 | 819 | ||
821 | if (!list_empty(&evsel_list)) | 820 | if (evlist->nr_entries > 0) |
822 | last = list_entry(evsel_list.prev, struct perf_evsel, node); | 821 | last = list_entry(evlist->entries.prev, struct perf_evsel, node); |
823 | 822 | ||
824 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { | 823 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { |
825 | fprintf(stderr, | 824 | fprintf(stderr, |
@@ -981,33 +980,3 @@ void print_events(void) | |||
981 | 980 | ||
982 | exit(129); | 981 | exit(129); |
983 | } | 982 | } |
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 | } | ||