aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2013-11-12 06:51:45 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-12 11:00:36 -0500
commit96695d440242aca871ef8d797bd98d9cbd7ad8a0 (patch)
tree86bc2a2f2e1c39a4c07471b81cb975095949512e /tools
parent73faab3a421351c342b10b0177fec9eea1a1d809 (diff)
perf trace: Separate tp syscall field caching into init routine to be reused
We need to set this in evsels coming out of a perf.data file header, not just for new ones created for live sessions. So separate the code that caches the syscall entry/exit tracepoint format fields into a new function that will be used in the next changeset. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20131112115700.GC4053@ghostprotocols.net Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-trace.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index aeb6296a76bd..3fa1dce6d43e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -149,20 +149,32 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel)
149 perf_evsel__delete(evsel); 149 perf_evsel__delete(evsel);
150} 150}
151 151
152static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler)
153{
154 evsel->priv = malloc(sizeof(struct syscall_tp));
155 if (evsel->priv != NULL) {
156 if (perf_evsel__init_sc_tp_uint_field(evsel, id))
157 goto out_delete;
158
159 evsel->handler = handler;
160 return 0;
161 }
162
163 return -ENOMEM;
164
165out_delete:
166 free(evsel->priv);
167 evsel->priv = NULL;
168 return -ENOENT;
169}
170
152static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler) 171static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler)
153{ 172{
154 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction); 173 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
155 174
156 if (evsel) { 175 if (evsel) {
157 evsel->priv = malloc(sizeof(struct syscall_tp)); 176 if (perf_evsel__init_syscall_tp(evsel, handler))
158
159 if (evsel->priv == NULL)
160 goto out_delete; 177 goto out_delete;
161
162 if (perf_evsel__init_sc_tp_uint_field(evsel, id))
163 goto out_delete;
164
165 evsel->handler = handler;
166 } 178 }
167 179
168 return evsel; 180 return evsel;