perf scripting python: Factor out set_sym_in_dict()
Factor out set_sym_in_dict() so it can be reused. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/20210525095112.1399-3-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Родитель
d04c1ff0b3
Коммит
8271b50958
|
@ -726,6 +726,22 @@ static void set_regs_in_dict(PyObject *dict,
|
||||||
_PyUnicode_FromString(bf));
|
_PyUnicode_FromString(bf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
|
||||||
|
const char *dso_field, const char *sym_field,
|
||||||
|
const char *symoff_field)
|
||||||
|
{
|
||||||
|
if (al->map) {
|
||||||
|
pydict_set_item_string_decref(dict, dso_field,
|
||||||
|
_PyUnicode_FromString(al->map->dso->name));
|
||||||
|
}
|
||||||
|
if (al->sym) {
|
||||||
|
pydict_set_item_string_decref(dict, sym_field,
|
||||||
|
_PyUnicode_FromString(al->sym->name));
|
||||||
|
pydict_set_item_string_decref(dict, symoff_field,
|
||||||
|
PyLong_FromUnsignedLong(get_offset(al->sym, al)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *get_perf_sample_dict(struct perf_sample *sample,
|
static PyObject *get_perf_sample_dict(struct perf_sample *sample,
|
||||||
struct evsel *evsel,
|
struct evsel *evsel,
|
||||||
struct addr_location *al,
|
struct addr_location *al,
|
||||||
|
@ -772,14 +788,7 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
|
||||||
(const char *)sample->raw_data, sample->raw_size));
|
(const char *)sample->raw_data, sample->raw_size));
|
||||||
pydict_set_item_string_decref(dict, "comm",
|
pydict_set_item_string_decref(dict, "comm",
|
||||||
_PyUnicode_FromString(thread__comm_str(al->thread)));
|
_PyUnicode_FromString(thread__comm_str(al->thread)));
|
||||||
if (al->map) {
|
set_sym_in_dict(dict, al, "dso", "symbol", "symoff");
|
||||||
pydict_set_item_string_decref(dict, "dso",
|
|
||||||
_PyUnicode_FromString(al->map->dso->name));
|
|
||||||
}
|
|
||||||
if (al->sym) {
|
|
||||||
pydict_set_item_string_decref(dict, "symbol",
|
|
||||||
_PyUnicode_FromString(al->sym->name));
|
|
||||||
}
|
|
||||||
|
|
||||||
pydict_set_item_string_decref(dict, "callchain", callchain);
|
pydict_set_item_string_decref(dict, "callchain", callchain);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче