diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-07-03 16:05:50 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-07-06 09:46:36 -0400 |
commit | 12467ae4e37aab5e263cc9ab6b6909ae0588844c (patch) | |
tree | 4d14657427613c61d34639c9c006ee2dcfbb54d2 | |
parent | f47805a2af3ba83881ca52434bbbc6e9886b72fd (diff) |
perf evsel: Introduce set_filter method
Replaces existing filter string with the one provided.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jst49z83li0yx3g18o54u51a@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/evsel.c | 13 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 1 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 667677495fb0..ae925b9ce6dd 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -823,6 +823,19 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | |||
823 | (void *)filter); | 823 | (void *)filter); |
824 | } | 824 | } |
825 | 825 | ||
826 | int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter) | ||
827 | { | ||
828 | char *new_filter = strdup(filter); | ||
829 | |||
830 | if (new_filter != NULL) { | ||
831 | free(evsel->filter); | ||
832 | evsel->filter = new_filter; | ||
833 | return 0; | ||
834 | } | ||
835 | |||
836 | return -1; | ||
837 | } | ||
838 | |||
826 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads) | 839 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads) |
827 | { | 840 | { |
828 | return perf_evsel__run_ioctl(evsel, ncpus, nthreads, | 841 | return perf_evsel__run_ioctl(evsel, ncpus, nthreads, |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index a3ebb83d767e..8aea4baca080 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -182,6 +182,7 @@ void __perf_evsel__reset_sample_bit(struct perf_evsel *evsel, | |||
182 | void perf_evsel__set_sample_id(struct perf_evsel *evsel, | 182 | void perf_evsel__set_sample_id(struct perf_evsel *evsel, |
183 | bool use_sample_identifier); | 183 | bool use_sample_identifier); |
184 | 184 | ||
185 | int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter); | ||
185 | int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, | 186 | int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, |
186 | const char *filter); | 187 | const char *filter); |
187 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads); | 188 | int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 09f8d2357108..a71eeb279ed2 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -1177,8 +1177,7 @@ int parse_filter(const struct option *opt, const char *str, | |||
1177 | return -1; | 1177 | return -1; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | last->filter = strdup(str); | 1180 | if (perf_evsel__set_filter(last, str) < 0) { |
1181 | if (last->filter == NULL) { | ||
1182 | fprintf(stderr, "not enough memory to hold filter string\n"); | 1181 | fprintf(stderr, "not enough memory to hold filter string\n"); |
1183 | return -1; | 1182 | return -1; |
1184 | } | 1183 | } |