aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-10-30 10:09:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-03 16:07:34 -0500
commitc29414f5cfd641d956c5287848fdd8f25bb2afa3 (patch)
tree62ea8a2067fb13d3d76466eeb4a0317ac6403184 /tools/perf/util/scripting-engines/trace-event-python.c
parentf2bff007679e7d293cb07bb26e18ccf11cc1c4b2 (diff)
perf tools: Add branch_type and in_tx to Python export
Add branch_type and in_tx to Python db export and the export-to-postgresql.py script. 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-4-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-python.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 2fd7ee8f18c7..f3ca7798b3d0 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -66,6 +66,7 @@ struct tables {
66 PyObject *comm_thread_handler; 66 PyObject *comm_thread_handler;
67 PyObject *dso_handler; 67 PyObject *dso_handler;
68 PyObject *symbol_handler; 68 PyObject *symbol_handler;
69 PyObject *branch_type_handler;
69 PyObject *sample_handler; 70 PyObject *sample_handler;
70 bool db_export_mode; 71 bool db_export_mode;
71}; 72};
@@ -664,13 +665,31 @@ static int python_export_symbol(struct db_export *dbe, struct symbol *sym,
664 return 0; 665 return 0;
665} 666}
666 667
668static int python_export_branch_type(struct db_export *dbe, u32 branch_type,
669 const char *name)
670{
671 struct tables *tables = container_of(dbe, struct tables, dbe);
672 PyObject *t;
673
674 t = tuple_new(2);
675
676 tuple_set_s32(t, 0, branch_type);
677 tuple_set_string(t, 1, name);
678
679 call_object(tables->branch_type_handler, t, "branch_type_table");
680
681 Py_DECREF(t);
682
683 return 0;
684}
685
667static int python_export_sample(struct db_export *dbe, 686static int python_export_sample(struct db_export *dbe,
668 struct export_sample *es) 687 struct export_sample *es)
669{ 688{
670 struct tables *tables = container_of(dbe, struct tables, dbe); 689 struct tables *tables = container_of(dbe, struct tables, dbe);
671 PyObject *t; 690 PyObject *t;
672 691
673 t = tuple_new(19); 692 t = tuple_new(21);
674 693
675 tuple_set_u64(t, 0, es->db_id); 694 tuple_set_u64(t, 0, es->db_id);
676 tuple_set_u64(t, 1, es->evsel->db_id); 695 tuple_set_u64(t, 1, es->evsel->db_id);
@@ -691,6 +710,8 @@ static int python_export_sample(struct db_export *dbe,
691 tuple_set_u64(t, 16, es->sample->weight); 710 tuple_set_u64(t, 16, es->sample->weight);
692 tuple_set_u64(t, 17, es->sample->transaction); 711 tuple_set_u64(t, 17, es->sample->transaction);
693 tuple_set_u64(t, 18, es->sample->data_src); 712 tuple_set_u64(t, 18, es->sample->data_src);
713 tuple_set_s32(t, 19, es->sample->flags & PERF_BRANCH_MASK);
714 tuple_set_s32(t, 20, !!(es->sample->flags & PERF_IP_FLAG_IN_TX));
694 715
695 call_object(tables->sample_handler, t, "sample_table"); 716 call_object(tables->sample_handler, t, "sample_table");
696 717
@@ -861,6 +882,7 @@ static void set_table_handlers(struct tables *tables)
861 SET_TABLE_HANDLER(comm_thread); 882 SET_TABLE_HANDLER(comm_thread);
862 SET_TABLE_HANDLER(dso); 883 SET_TABLE_HANDLER(dso);
863 SET_TABLE_HANDLER(symbol); 884 SET_TABLE_HANDLER(symbol);
885 SET_TABLE_HANDLER(branch_type);
864 SET_TABLE_HANDLER(sample); 886 SET_TABLE_HANDLER(sample);
865} 887}
866 888
@@ -910,6 +932,12 @@ static int python_start_script(const char *script, int argc, const char **argv)
910 932
911 set_table_handlers(tables); 933 set_table_handlers(tables);
912 934
935 if (tables->db_export_mode) {
936 err = db_export__branch_types(&tables->dbe);
937 if (err)
938 goto error;
939 }
940
913 return err; 941 return err;
914error: 942error:
915 Py_Finalize(); 943 Py_Finalize();