Skip to content

Commit

Permalink
perf script python: Move dsoname code to a new function
Browse files Browse the repository at this point in the history
This patch creates a new function get_dsoname() and move the code which
gets the dsoname string to this function.

That's because in next patch, when we process LBR data, we will also
need get_dsoname() to return dsoname for branch from/to.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1527843663-32288-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jin Yao authored and Arnaldo Carvalho de Melo committed Jun 6, 2018
1 parent 2be732c commit 5f9e0f3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tools/perf/util/scripting-engines/trace-event-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,19 @@ static PyObject *get_field_numeric_entry(struct event_format *event,
return obj;
}

static const char *get_dsoname(struct map *map)
{
const char *dsoname = "[unknown]";

if (map && map->dso) {
if (symbol_conf.show_kernel_path && map->dso->long_name)
dsoname = map->dso->long_name;
else
dsoname = map->dso->name;
}

return dsoname;
}

static PyObject *python_process_callchain(struct perf_sample *sample,
struct perf_evsel *evsel,
Expand Down Expand Up @@ -427,14 +440,8 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
}

if (node->map) {
struct map *map = node->map;
const char *dsoname = "[unknown]";
if (map && map->dso) {
if (symbol_conf.show_kernel_path && map->dso->long_name)
dsoname = map->dso->long_name;
else
dsoname = map->dso->name;
}
const char *dsoname = get_dsoname(node->map);

pydict_set_item_string_decref(pyelem, "dso",
_PyUnicode_FromString(dsoname));
}
Expand Down

0 comments on commit 5f9e0f3

Please sign in to comment.