aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-10-30 10:09:43 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-03 16:06:40 -0500
commitf2bff007679e7d293cb07bb26e18ccf11cc1c4b2 (patch)
tree86ac27cc32eec0977767684006c6d1963e9efe26
parent92a9e4f7db89a013e1bdef2e548928fc71e9867c (diff)
perf tools: Add branch type to db export
Add the ability to export branch types through the database export facility. Signed-off-by: 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: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1414678188-14946-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/db-export.c48
-rw-r--r--tools/perf/util/db-export.h6
2 files changed, 54 insertions, 0 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index be128b075a32..bccb83120971 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -208,6 +208,15 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
208 return 0; 208 return 0;
209} 209}
210 210
211int db_export__branch_type(struct db_export *dbe, u32 branch_type,
212 const char *name)
213{
214 if (dbe->export_branch_type)
215 return dbe->export_branch_type(dbe, branch_type, name);
216
217 return 0;
218}
219
211int db_export__sample(struct db_export *dbe, union perf_event *event, 220int db_export__sample(struct db_export *dbe, union perf_event *event,
212 struct perf_sample *sample, struct perf_evsel *evsel, 221 struct perf_sample *sample, struct perf_evsel *evsel,
213 struct thread *thread, struct addr_location *al) 222 struct thread *thread, struct addr_location *al)
@@ -268,3 +277,42 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
268 277
269 return 0; 278 return 0;
270} 279}
280
281static struct {
282 u32 branch_type;
283 const char *name;
284} branch_types[] = {
285 {0, "no branch"},
286 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"},
287 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"},
288 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "conditional jump"},
289 {PERF_IP_FLAG_BRANCH, "unconditional jump"},
290 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT,
291 "software interrupt"},
292 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT,
293 "return from interrupt"},
294 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET,
295 "system call"},
296 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET,
297 "return from system call"},
298 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "asynchronous branch"},
299 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC |
300 PERF_IP_FLAG_INTERRUPT, "hardware interrupt"},
301 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "transaction abort"},
302 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "trace begin"},
303 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "trace end"},
304 {0, NULL}
305};
306
307int db_export__branch_types(struct db_export *dbe)
308{
309 int i, err = 0;
310
311 for (i = 0; branch_types[i].name ; i++) {
312 err = db_export__branch_type(dbe, branch_types[i].branch_type,
313 branch_types[i].name);
314 if (err)
315 break;
316 }
317 return err;
318}
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index b3643e8e5750..e4baa45ead70 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -54,6 +54,8 @@ struct db_export {
54 struct machine *machine); 54 struct machine *machine);
55 int (*export_symbol)(struct db_export *dbe, struct symbol *sym, 55 int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
56 struct dso *dso); 56 struct dso *dso);
57 int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
58 const char *name);
57 int (*export_sample)(struct db_export *dbe, struct export_sample *es); 59 int (*export_sample)(struct db_export *dbe, struct export_sample *es);
58 u64 evsel_last_db_id; 60 u64 evsel_last_db_id;
59 u64 machine_last_db_id; 61 u64 machine_last_db_id;
@@ -79,8 +81,12 @@ int db_export__dso(struct db_export *dbe, struct dso *dso,
79 struct machine *machine); 81 struct machine *machine);
80int db_export__symbol(struct db_export *dbe, struct symbol *sym, 82int db_export__symbol(struct db_export *dbe, struct symbol *sym,
81 struct dso *dso); 83 struct dso *dso);
84int db_export__branch_type(struct db_export *dbe, u32 branch_type,
85 const char *name);
82int db_export__sample(struct db_export *dbe, union perf_event *event, 86int db_export__sample(struct db_export *dbe, union perf_event *event,
83 struct perf_sample *sample, struct perf_evsel *evsel, 87 struct perf_sample *sample, struct perf_evsel *evsel,
84 struct thread *thread, struct addr_location *al); 88 struct thread *thread, struct addr_location *al);
85 89
90int db_export__branch_types(struct db_export *dbe);
91
86#endif 92#endif