aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-10-30 10:09:46 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-03 16:09:33 -0500
commit88f50d602f500d206f2f5a9a9751dd45f2d97739 (patch)
treef0952bc6ec3226f6921aece5e444e30b82115667
parentc29414f5cfd641d956c5287848fdd8f25bb2afa3 (diff)
perf tools: Add call information to the database export API
Make it possible for the database export API to use the enhanced thread stack and export detailed information about paired calls and returns. 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-6-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.c52
-rw-r--r--tools/perf/util/db-export.h12
2 files changed, 63 insertions, 1 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index bccb83120971..017ecbb0ec05 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -21,6 +21,7 @@
21#include "comm.h" 21#include "comm.h"
22#include "symbol.h" 22#include "symbol.h"
23#include "event.h" 23#include "event.h"
24#include "thread-stack.h"
24#include "db-export.h" 25#include "db-export.h"
25 26
26int db_export__init(struct db_export *dbe) 27int db_export__init(struct db_export *dbe)
@@ -29,8 +30,10 @@ int db_export__init(struct db_export *dbe)
29 return 0; 30 return 0;
30} 31}
31 32
32void db_export__exit(struct db_export *dbe __maybe_unused) 33void db_export__exit(struct db_export *dbe)
33{ 34{
35 call_return_processor__free(dbe->crp);
36 dbe->crp = NULL;
34} 37}
35 38
36int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel) 39int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel)
@@ -270,6 +273,13 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
270 &es.addr_sym_db_id, &es.addr_offset); 273 &es.addr_sym_db_id, &es.addr_offset);
271 if (err) 274 if (err)
272 return err; 275 return err;
276 if (dbe->crp) {
277 err = thread_stack__process(thread, comm, sample, al,
278 &addr_al, es.db_id,
279 dbe->crp);
280 if (err)
281 return err;
282 }
273 } 283 }
274 284
275 if (dbe->export_sample) 285 if (dbe->export_sample)
@@ -316,3 +326,43 @@ int db_export__branch_types(struct db_export *dbe)
316 } 326 }
317 return err; 327 return err;
318} 328}
329
330int db_export__call_path(struct db_export *dbe, struct call_path *cp)
331{
332 int err;
333
334 if (cp->db_id)
335 return 0;
336
337 if (cp->parent) {
338 err = db_export__call_path(dbe, cp->parent);
339 if (err)
340 return err;
341 }
342
343 cp->db_id = ++dbe->call_path_last_db_id;
344
345 if (dbe->export_call_path)
346 return dbe->export_call_path(dbe, cp);
347
348 return 0;
349}
350
351int db_export__call_return(struct db_export *dbe, struct call_return *cr)
352{
353 int err;
354
355 if (cr->db_id)
356 return 0;
357
358 err = db_export__call_path(dbe, cr->cp);
359 if (err)
360 return err;
361
362 cr->db_id = ++dbe->call_return_last_db_id;
363
364 if (dbe->export_call_return)
365 return dbe->export_call_return(dbe, cr);
366
367 return 0;
368}
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h
index e4baa45ead70..dd5ac2ae97d4 100644
--- a/tools/perf/util/db-export.h
+++ b/tools/perf/util/db-export.h
@@ -25,6 +25,9 @@ struct comm;
25struct dso; 25struct dso;
26struct perf_sample; 26struct perf_sample;
27struct addr_location; 27struct addr_location;
28struct call_return_processor;
29struct call_path;
30struct call_return;
28 31
29struct export_sample { 32struct export_sample {
30 union perf_event *event; 33 union perf_event *event;
@@ -57,6 +60,10 @@ struct db_export {
57 int (*export_branch_type)(struct db_export *dbe, u32 branch_type, 60 int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
58 const char *name); 61 const char *name);
59 int (*export_sample)(struct db_export *dbe, struct export_sample *es); 62 int (*export_sample)(struct db_export *dbe, struct export_sample *es);
63 int (*export_call_path)(struct db_export *dbe, struct call_path *cp);
64 int (*export_call_return)(struct db_export *dbe,
65 struct call_return *cr);
66 struct call_return_processor *crp;
60 u64 evsel_last_db_id; 67 u64 evsel_last_db_id;
61 u64 machine_last_db_id; 68 u64 machine_last_db_id;
62 u64 thread_last_db_id; 69 u64 thread_last_db_id;
@@ -65,6 +72,8 @@ struct db_export {
65 u64 dso_last_db_id; 72 u64 dso_last_db_id;
66 u64 symbol_last_db_id; 73 u64 symbol_last_db_id;
67 u64 sample_last_db_id; 74 u64 sample_last_db_id;
75 u64 call_path_last_db_id;
76 u64 call_return_last_db_id;
68}; 77};
69 78
70int db_export__init(struct db_export *dbe); 79int db_export__init(struct db_export *dbe);
@@ -89,4 +98,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
89 98
90int db_export__branch_types(struct db_export *dbe); 99int db_export__branch_types(struct db_export *dbe);
91 100
101int db_export__call_path(struct db_export *dbe, struct call_path *cp);
102int db_export__call_return(struct db_export *dbe, struct call_return *cr);
103
92#endif 104#endif