Skip to content

Commit c4f4622

Browse files
Leo Yanacmel
authored andcommitted
perf scripting python: Expose dso and map information
This change adds dso build_id and corresponding map's start and end address. The info of dso build_id can be used to find dso file path, and we can validate if a branch address falls into the range of map's start and end addresses. In addition, the map's start address can be used as an offset for disassembly. Signed-off-by: Leo Yan <leo.yan@linaro.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Al Grant <al.grant@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Eelco Chaudron <echaudro@redhat.com> Cc: German Gomez <german.gomez@arm.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephen Brennan <stephen.s.brennan@oracle.com> Cc: Tanmay Jagdale <tanmay@marvell.com> Cc: coresight@lists.linaro.org Cc: zengshun . wu <zengshun.wu@outlook.com> Link: https://lore.kernel.org/r/20220521130446.4163597-2-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent f4df0db commit c4f4622

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

tools/perf/util/scripting-engines/trace-event-python.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,22 @@ static void set_regs_in_dict(PyObject *dict,
755755
}
756756

757757
static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
758-
const char *dso_field, const char *sym_field,
759-
const char *symoff_field)
758+
const char *dso_field, const char *dso_bid_field,
759+
const char *dso_map_start, const char *dso_map_end,
760+
const char *sym_field, const char *symoff_field)
760761
{
762+
char sbuild_id[SBUILD_ID_SIZE];
763+
761764
if (al->map) {
762765
pydict_set_item_string_decref(dict, dso_field,
763766
_PyUnicode_FromString(al->map->dso->name));
767+
build_id__sprintf(&al->map->dso->bid, sbuild_id);
768+
pydict_set_item_string_decref(dict, dso_bid_field,
769+
_PyUnicode_FromString(sbuild_id));
770+
pydict_set_item_string_decref(dict, dso_map_start,
771+
PyLong_FromUnsignedLong(al->map->start));
772+
pydict_set_item_string_decref(dict, dso_map_end,
773+
PyLong_FromUnsignedLong(al->map->end));
764774
}
765775
if (al->sym) {
766776
pydict_set_item_string_decref(dict, sym_field,
@@ -840,7 +850,8 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
840850
(const char *)sample->raw_data, sample->raw_size));
841851
pydict_set_item_string_decref(dict, "comm",
842852
_PyUnicode_FromString(thread__comm_str(al->thread)));
843-
set_sym_in_dict(dict, al, "dso", "symbol", "symoff");
853+
set_sym_in_dict(dict, al, "dso", "dso_bid", "dso_map_start", "dso_map_end",
854+
"symbol", "symoff");
844855

845856
pydict_set_item_string_decref(dict, "callchain", callchain);
846857

@@ -856,7 +867,9 @@ static PyObject *get_perf_sample_dict(struct perf_sample *sample,
856867
if (addr_al) {
857868
pydict_set_item_string_decref(dict_sample, "addr_correlates_sym",
858869
PyBool_FromLong(1));
859-
set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_symbol", "addr_symoff");
870+
set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_dso_bid",
871+
"addr_dso_map_start", "addr_dso_map_end",
872+
"addr_symbol", "addr_symoff");
860873
}
861874

862875
if (sample->flags)

0 commit comments

Comments
 (0)