diff options
Diffstat (limited to 'tools/perf/util/scripting-engines')
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 37 |
2 files changed, 25 insertions, 14 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index a85e4ae5f3ac..c0c9795c4f02 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
| @@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused, | |||
| 282 | 282 | ||
| 283 | event = find_cache_event(evsel); | 283 | event = find_cache_event(evsel); |
| 284 | if (!event) | 284 | if (!event) |
| 285 | die("ug! no event found for type %" PRIu64, evsel->attr.config); | 285 | die("ug! no event found for type %" PRIu64, (u64)evsel->attr.config); |
| 286 | 286 | ||
| 287 | pid = raw_field_value(event, "common_pid", data); | 287 | pid = raw_field_value(event, "common_pid", data); |
| 288 | 288 | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index cc75a3cef388..95d91a0b23af 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
| @@ -56,6 +56,17 @@ static void handler_call_die(const char *handler_name) | |||
| 56 | Py_FatalError("problem in Python trace event handler"); | 56 | Py_FatalError("problem in Python trace event handler"); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /* | ||
| 60 | * Insert val into into the dictionary and decrement the reference counter. | ||
| 61 | * This is necessary for dictionaries since PyDict_SetItemString() does not | ||
| 62 | * steal a reference, as opposed to PyTuple_SetItem(). | ||
| 63 | */ | ||
| 64 | static void pydict_set_item_string_decref(PyObject *dict, const char *key, PyObject *val) | ||
| 65 | { | ||
| 66 | PyDict_SetItemString(dict, key, val); | ||
| 67 | Py_DECREF(val); | ||
| 68 | } | ||
| 69 | |||
| 59 | static void define_value(enum print_arg_type field_type, | 70 | static void define_value(enum print_arg_type field_type, |
| 60 | const char *ev_name, | 71 | const char *ev_name, |
| 61 | const char *field_name, | 72 | const char *field_name, |
| @@ -279,11 +290,11 @@ static void python_process_tracepoint(union perf_event *perf_event | |||
| 279 | PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); | 290 | PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); |
| 280 | PyTuple_SetItem(t, n++, PyString_FromString(comm)); | 291 | PyTuple_SetItem(t, n++, PyString_FromString(comm)); |
| 281 | } else { | 292 | } else { |
| 282 | PyDict_SetItemString(dict, "common_cpu", PyInt_FromLong(cpu)); | 293 | pydict_set_item_string_decref(dict, "common_cpu", PyInt_FromLong(cpu)); |
| 283 | PyDict_SetItemString(dict, "common_s", PyInt_FromLong(s)); | 294 | pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s)); |
| 284 | PyDict_SetItemString(dict, "common_ns", PyInt_FromLong(ns)); | 295 | pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns)); |
| 285 | PyDict_SetItemString(dict, "common_pid", PyInt_FromLong(pid)); | 296 | pydict_set_item_string_decref(dict, "common_pid", PyInt_FromLong(pid)); |
| 286 | PyDict_SetItemString(dict, "common_comm", PyString_FromString(comm)); | 297 | pydict_set_item_string_decref(dict, "common_comm", PyString_FromString(comm)); |
| 287 | } | 298 | } |
| 288 | for (field = event->format.fields; field; field = field->next) { | 299 | for (field = event->format.fields; field; field = field->next) { |
| 289 | if (field->flags & FIELD_IS_STRING) { | 300 | if (field->flags & FIELD_IS_STRING) { |
| @@ -313,7 +324,7 @@ static void python_process_tracepoint(union perf_event *perf_event | |||
| 313 | if (handler) | 324 | if (handler) |
| 314 | PyTuple_SetItem(t, n++, obj); | 325 | PyTuple_SetItem(t, n++, obj); |
| 315 | else | 326 | else |
| 316 | PyDict_SetItemString(dict, field->name, obj); | 327 | pydict_set_item_string_decref(dict, field->name, obj); |
| 317 | 328 | ||
| 318 | } | 329 | } |
| 319 | if (!handler) | 330 | if (!handler) |
| @@ -370,21 +381,21 @@ static void python_process_general_event(union perf_event *perf_event | |||
| 370 | if (!handler || !PyCallable_Check(handler)) | 381 | if (!handler || !PyCallable_Check(handler)) |
| 371 | goto exit; | 382 | goto exit; |
| 372 | 383 | ||
| 373 | PyDict_SetItemString(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); | 384 | pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); |
| 374 | PyDict_SetItemString(dict, "attr", PyString_FromStringAndSize( | 385 | pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize( |
| 375 | (const char *)&evsel->attr, sizeof(evsel->attr))); | 386 | (const char *)&evsel->attr, sizeof(evsel->attr))); |
| 376 | PyDict_SetItemString(dict, "sample", PyString_FromStringAndSize( | 387 | pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize( |
| 377 | (const char *)sample, sizeof(*sample))); | 388 | (const char *)sample, sizeof(*sample))); |
| 378 | PyDict_SetItemString(dict, "raw_buf", PyString_FromStringAndSize( | 389 | pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize( |
| 379 | (const char *)sample->raw_data, sample->raw_size)); | 390 | (const char *)sample->raw_data, sample->raw_size)); |
| 380 | PyDict_SetItemString(dict, "comm", | 391 | pydict_set_item_string_decref(dict, "comm", |
| 381 | PyString_FromString(thread->comm)); | 392 | PyString_FromString(thread->comm)); |
| 382 | if (al->map) { | 393 | if (al->map) { |
| 383 | PyDict_SetItemString(dict, "dso", | 394 | pydict_set_item_string_decref(dict, "dso", |
| 384 | PyString_FromString(al->map->dso->name)); | 395 | PyString_FromString(al->map->dso->name)); |
| 385 | } | 396 | } |
| 386 | if (al->sym) { | 397 | if (al->sym) { |
| 387 | PyDict_SetItemString(dict, "symbol", | 398 | pydict_set_item_string_decref(dict, "symbol", |
| 388 | PyString_FromString(al->sym->name)); | 399 | PyString_FromString(al->sym->name)); |
| 389 | } | 400 | } |
| 390 | 401 | ||
