aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-python.c
diff options
context:
space:
mode:
authorJoseph Schuchart <joseph.schuchart@tu-dresden.de>2014-07-10 07:50:56 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-16 16:57:33 -0400
commit57608cfd8827a74237d264a197722e2c99f72da4 (patch)
tree1e714f5402c53f41ad2502d95d62166a9c436ec8 /tools/perf/util/scripting-engines/trace-event-python.c
parent0f5f5bcd112292f14b75750dde7461463bb1c7bb (diff)
perf script: Provide additional sample information on generic events
To python scripts, including pid, tid, and cpu for which the event was recorded. At the moment, the pointer to the sample struct is passed to scripts, which seems to be of little use. The patch puts this information in dictionaries for easy access by Python scripts. Signed-off-by: Joseph Schuchart <joseph.schuchart@tu-dresden.de> Acked-by: Thomas Ilsche <thomas.ilsche@tu-dresden.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Ilsche <thomas.ilsche@tu-dresden.de> Link: http://lkml.kernel.org/r/53BE7E20.8080500@tu-dresden.de 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.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index cf65404472cb..b366b48646ca 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -473,7 +473,7 @@ static void python_process_general_event(struct perf_sample *sample,
473 struct thread *thread, 473 struct thread *thread,
474 struct addr_location *al) 474 struct addr_location *al)
475{ 475{
476 PyObject *handler, *retval, *t, *dict, *callchain; 476 PyObject *handler, *retval, *t, *dict, *callchain, *dict_sample;
477 static char handler_name[64]; 477 static char handler_name[64];
478 unsigned n = 0; 478 unsigned n = 0;
479 479
@@ -489,6 +489,10 @@ static void python_process_general_event(struct perf_sample *sample,
489 if (!dict) 489 if (!dict)
490 Py_FatalError("couldn't create Python dictionary"); 490 Py_FatalError("couldn't create Python dictionary");
491 491
492 dict_sample = PyDict_New();
493 if (!dict_sample)
494 Py_FatalError("couldn't create Python dictionary");
495
492 snprintf(handler_name, sizeof(handler_name), "%s", "process_event"); 496 snprintf(handler_name, sizeof(handler_name), "%s", "process_event");
493 497
494 handler = PyDict_GetItemString(main_dict, handler_name); 498 handler = PyDict_GetItemString(main_dict, handler_name);
@@ -498,8 +502,21 @@ static void python_process_general_event(struct perf_sample *sample,
498 pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); 502 pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel)));
499 pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize( 503 pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
500 (const char *)&evsel->attr, sizeof(evsel->attr))); 504 (const char *)&evsel->attr, sizeof(evsel->attr)));
501 pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize( 505
502 (const char *)sample, sizeof(*sample))); 506 pydict_set_item_string_decref(dict_sample, "pid",
507 PyInt_FromLong(sample->pid));
508 pydict_set_item_string_decref(dict_sample, "tid",
509 PyInt_FromLong(sample->tid));
510 pydict_set_item_string_decref(dict_sample, "cpu",
511 PyInt_FromLong(sample->cpu));
512 pydict_set_item_string_decref(dict_sample, "ip",
513 PyLong_FromUnsignedLongLong(sample->ip));
514 pydict_set_item_string_decref(dict_sample, "time",
515 PyLong_FromUnsignedLongLong(sample->time));
516 pydict_set_item_string_decref(dict_sample, "period",
517 PyLong_FromUnsignedLongLong(sample->period));
518 pydict_set_item_string_decref(dict, "sample", dict_sample);
519
503 pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize( 520 pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
504 (const char *)sample->raw_data, sample->raw_size)); 521 (const char *)sample->raw_data, sample->raw_size));
505 pydict_set_item_string_decref(dict, "comm", 522 pydict_set_item_string_decref(dict, "comm",