diff options
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 7f8afacd08ee..f863e96fb7bc 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
| @@ -372,6 +372,19 @@ static PyObject *get_field_numeric_entry(struct event_format *event, | |||
| 372 | return obj; | 372 | return obj; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | static const char *get_dsoname(struct map *map) | ||
| 376 | { | ||
| 377 | const char *dsoname = "[unknown]"; | ||
| 378 | |||
| 379 | if (map && map->dso) { | ||
| 380 | if (symbol_conf.show_kernel_path && map->dso->long_name) | ||
| 381 | dsoname = map->dso->long_name; | ||
| 382 | else | ||
| 383 | dsoname = map->dso->name; | ||
| 384 | } | ||
| 385 | |||
| 386 | return dsoname; | ||
| 387 | } | ||
| 375 | 388 | ||
| 376 | static PyObject *python_process_callchain(struct perf_sample *sample, | 389 | static PyObject *python_process_callchain(struct perf_sample *sample, |
| 377 | struct perf_evsel *evsel, | 390 | struct perf_evsel *evsel, |
| @@ -427,14 +440,8 @@ static PyObject *python_process_callchain(struct perf_sample *sample, | |||
| 427 | } | 440 | } |
| 428 | 441 | ||
| 429 | if (node->map) { | 442 | if (node->map) { |
| 430 | struct map *map = node->map; | 443 | const char *dsoname = get_dsoname(node->map); |
| 431 | const char *dsoname = "[unknown]"; | 444 | |
| 432 | if (map && map->dso) { | ||
| 433 | if (symbol_conf.show_kernel_path && map->dso->long_name) | ||
| 434 | dsoname = map->dso->long_name; | ||
| 435 | else | ||
| 436 | dsoname = map->dso->name; | ||
| 437 | } | ||
| 438 | pydict_set_item_string_decref(pyelem, "dso", | 445 | pydict_set_item_string_decref(pyelem, "dso", |
| 439 | _PyUnicode_FromString(dsoname)); | 446 | _PyUnicode_FromString(dsoname)); |
| 440 | } | 447 | } |
