This patch extends the current argument list in case of events by
- IP / addr of the event. Currently only the function name is passed.
- seconds and ns as the timestamp. Split into two value to stay close to
  what the trace handler passes.
- the pid of the proccess

I added a common_ prefix to stay close to the naming of the "trace"
handler. Currently I don't mind dropping it since "comm" isn't named
"common_comm". Any suggestions?

All items I added here are already exposed by the generic output i.e.
"perf script"

Signed-off-by: Sebastian Andrzej Siewior <bige...@linutronix.de>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c 
b/tools/perf/util/scripting-engines/trace-event-python.c
index 40a815a..591bd97 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -381,6 +381,8 @@ static void python_process_general_event(struct perf_sample 
*sample,
 {
        PyObject *handler, *retval, *t, *dict;
        static char handler_name[64];
+       unsigned long long nsecs = sample->time;
+       unsigned long s, ns;
        unsigned n = 0;
 
        /*
@@ -401,6 +403,9 @@ static void python_process_general_event(struct perf_sample 
*sample,
        if (!handler || !PyCallable_Check(handler))
                goto exit;
 
+       s = nsecs / NSECS_PER_SEC;
+       ns = nsecs - s * NSECS_PER_SEC;
+
        pydict_set_item_string_decref(dict, "ev_name", 
PyString_FromString(perf_evsel__name(evsel)));
        pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize(
                        (const char *)&evsel->attr, sizeof(evsel->attr)));
@@ -410,6 +415,12 @@ static void python_process_general_event(struct 
perf_sample *sample,
                        (const char *)sample->raw_data, sample->raw_size));
        pydict_set_item_string_decref(dict, "comm",
                        PyString_FromString(thread__comm_str(thread)));
+       pydict_set_item_string_decref(dict, "addr",
+                       PyLong_FromUnsignedLongLong(sample->ip));
+       pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s));
+       pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns));
+       pydict_set_item_string_decref(dict, "common_pid",
+                       PyInt_FromLong(sample->pid));
        if (al->map) {
                pydict_set_item_string_decref(dict, "dso",
                        PyString_FromString(al->map->dso->name));
-- 
2.0.0.rc4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to