diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2017-05-26 04:17:32 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-06-30 10:44:36 -0400 |
commit | bbac88ed64436201d6b6f2b00177d58081d56707 (patch) | |
tree | 487c01aa48f566b94fb22a58fc5b2a02b13a60e3 | |
parent | 63a22cd9f8400fe914ddc3d597d925594f212519 (diff) |
perf intel-pt: Factor out intel_pt_set_event_name()
Factor out intel_pt_set_event_name() so it can be reused.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1495786658-18063-32-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/intel-pt.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 81907f60e7da..a20712e1ed28 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -1931,6 +1931,21 @@ static int intel_pt_synth_event(struct perf_session *session, const char *name, | |||
1931 | return err; | 1931 | return err; |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | static void intel_pt_set_event_name(struct perf_evlist *evlist, u64 id, | ||
1935 | const char *name) | ||
1936 | { | ||
1937 | struct perf_evsel *evsel; | ||
1938 | |||
1939 | evlist__for_each_entry(evlist, evsel) { | ||
1940 | if (evsel->id && evsel->id[0] == id) { | ||
1941 | if (evsel->name) | ||
1942 | zfree(&evsel->name); | ||
1943 | evsel->name = strdup(name); | ||
1944 | break; | ||
1945 | } | ||
1946 | } | ||
1947 | } | ||
1948 | |||
1934 | static struct perf_evsel *intel_pt_evsel(struct intel_pt *pt, | 1949 | static struct perf_evsel *intel_pt_evsel(struct intel_pt *pt, |
1935 | struct perf_evlist *evlist) | 1950 | struct perf_evlist *evlist) |
1936 | { | 1951 | { |
@@ -2015,15 +2030,8 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
2015 | pt->sample_transactions = true; | 2030 | pt->sample_transactions = true; |
2016 | pt->transactions_sample_type = attr.sample_type; | 2031 | pt->transactions_sample_type = attr.sample_type; |
2017 | pt->transactions_id = id; | 2032 | pt->transactions_id = id; |
2033 | intel_pt_set_event_name(evlist, id, "transactions"); | ||
2018 | id += 1; | 2034 | id += 1; |
2019 | evlist__for_each_entry(evlist, evsel) { | ||
2020 | if (evsel->id && evsel->id[0] == pt->transactions_id) { | ||
2021 | if (evsel->name) | ||
2022 | zfree(&evsel->name); | ||
2023 | evsel->name = strdup("transactions"); | ||
2024 | break; | ||
2025 | } | ||
2026 | } | ||
2027 | } | 2035 | } |
2028 | 2036 | ||
2029 | if (pt->synth_opts.branches) { | 2037 | if (pt->synth_opts.branches) { |