diff options
author | Jiri Olsa <jolsa@redhat.com> | 2011-07-14 05:25:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-07-21 04:41:11 -0400 |
commit | f120f9d51be3a7db8991e7b78dc08bab5f8ab8f3 (patch) | |
tree | 237926a6231f4009015b8ce4119935a455069395 /tools/perf/util/parse-events.c | |
parent | adc4bf9955856f8aa081ba613dbf56ffd664f0b7 (diff) |
perf tools: De-opt the parse_events function
Moving out the option parameter from parse_events function,
and adding new parse_events_option function instead.
The option parameter is used only to carry "struct perf_evlist"
pointer for chaining new events. Putting it away, enable us
to call parse_events from other places without using the
option parameter.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: acme@redhat.com
Cc: a.p.zijlstra@chello.nl
Cc: paulus@samba.org
Link: http://lkml.kernel.org/r/1310635534-4013-2-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c0e21aec4896..4ea7e19f5251 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -478,7 +478,7 @@ parse_single_tracepoint_event(char *sys_name, | |||
478 | /* sys + ':' + event + ':' + flags*/ | 478 | /* sys + ':' + event + ':' + flags*/ |
479 | #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) | 479 | #define MAX_EVOPT_LEN (MAX_EVENT_LENGTH * 2 + 2 + 128) |
480 | static enum event_result | 480 | static enum event_result |
481 | parse_multiple_tracepoint_event(const struct option *opt, char *sys_name, | 481 | parse_multiple_tracepoint_event(struct perf_evlist *evlist, char *sys_name, |
482 | const char *evt_exp, char *flags) | 482 | const char *evt_exp, char *flags) |
483 | { | 483 | { |
484 | char evt_path[MAXPATHLEN]; | 484 | char evt_path[MAXPATHLEN]; |
@@ -512,7 +512,7 @@ parse_multiple_tracepoint_event(const struct option *opt, char *sys_name, | |||
512 | if (len < 0) | 512 | if (len < 0) |
513 | return EVT_FAILED; | 513 | return EVT_FAILED; |
514 | 514 | ||
515 | if (parse_events(opt, event_opt, 0)) | 515 | if (parse_events(evlist, event_opt, 0)) |
516 | return EVT_FAILED; | 516 | return EVT_FAILED; |
517 | } | 517 | } |
518 | 518 | ||
@@ -520,7 +520,7 @@ parse_multiple_tracepoint_event(const struct option *opt, char *sys_name, | |||
520 | } | 520 | } |
521 | 521 | ||
522 | static enum event_result | 522 | static enum event_result |
523 | parse_tracepoint_event(const struct option *opt, const char **strp, | 523 | parse_tracepoint_event(struct perf_evlist *evlist, const char **strp, |
524 | struct perf_event_attr *attr) | 524 | struct perf_event_attr *attr) |
525 | { | 525 | { |
526 | const char *evt_name; | 526 | const char *evt_name; |
@@ -560,8 +560,8 @@ parse_tracepoint_event(const struct option *opt, const char **strp, | |||
560 | return EVT_FAILED; | 560 | return EVT_FAILED; |
561 | if (strpbrk(evt_name, "*?")) { | 561 | if (strpbrk(evt_name, "*?")) { |
562 | *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */ | 562 | *strp += strlen(sys_name) + evt_length + 1; /* 1 == the ':' */ |
563 | return parse_multiple_tracepoint_event(opt, sys_name, evt_name, | 563 | return parse_multiple_tracepoint_event(evlist, sys_name, |
564 | flags); | 564 | evt_name, flags); |
565 | } else { | 565 | } else { |
566 | return parse_single_tracepoint_event(sys_name, evt_name, | 566 | return parse_single_tracepoint_event(sys_name, evt_name, |
567 | evt_length, attr, strp); | 567 | evt_length, attr, strp); |
@@ -781,12 +781,12 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr) | |||
781 | * Symbolic names are (almost) exactly matched. | 781 | * Symbolic names are (almost) exactly matched. |
782 | */ | 782 | */ |
783 | static enum event_result | 783 | static enum event_result |
784 | parse_event_symbols(const struct option *opt, const char **str, | 784 | parse_event_symbols(struct perf_evlist *evlist, const char **str, |
785 | struct perf_event_attr *attr) | 785 | struct perf_event_attr *attr) |
786 | { | 786 | { |
787 | enum event_result ret; | 787 | enum event_result ret; |
788 | 788 | ||
789 | ret = parse_tracepoint_event(opt, str, attr); | 789 | ret = parse_tracepoint_event(evlist, str, attr); |
790 | if (ret != EVT_FAILED) | 790 | if (ret != EVT_FAILED) |
791 | goto modifier; | 791 | goto modifier; |
792 | 792 | ||
@@ -825,9 +825,8 @@ modifier: | |||
825 | return ret; | 825 | return ret; |
826 | } | 826 | } |
827 | 827 | ||
828 | int parse_events(const struct option *opt, const char *str, int unset __used) | 828 | int parse_events(struct perf_evlist *evlist , const char *str, int unset __used) |
829 | { | 829 | { |
830 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
831 | struct perf_event_attr attr; | 830 | struct perf_event_attr attr; |
832 | enum event_result ret; | 831 | enum event_result ret; |
833 | const char *ostr; | 832 | const char *ostr; |
@@ -835,7 +834,7 @@ int parse_events(const struct option *opt, const char *str, int unset __used) | |||
835 | for (;;) { | 834 | for (;;) { |
836 | ostr = str; | 835 | ostr = str; |
837 | memset(&attr, 0, sizeof(attr)); | 836 | memset(&attr, 0, sizeof(attr)); |
838 | ret = parse_event_symbols(opt, &str, &attr); | 837 | ret = parse_event_symbols(evlist, &str, &attr); |
839 | if (ret == EVT_FAILED) | 838 | if (ret == EVT_FAILED) |
840 | return -1; | 839 | return -1; |
841 | 840 | ||
@@ -866,6 +865,13 @@ int parse_events(const struct option *opt, const char *str, int unset __used) | |||
866 | return 0; | 865 | return 0; |
867 | } | 866 | } |
868 | 867 | ||
868 | int parse_events_option(const struct option *opt, const char *str, | ||
869 | int unset __used) | ||
870 | { | ||
871 | struct perf_evlist *evlist = *(struct perf_evlist **)opt->value; | ||
872 | return parse_events(evlist, str, unset); | ||
873 | } | ||
874 | |||
869 | int parse_filter(const struct option *opt, const char *str, | 875 | int parse_filter(const struct option *opt, const char *str, |
870 | int unset __used) | 876 | int unset __used) |
871 | { | 877 | { |