Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
8271b509 d04c1ff0

+17 -8
+17 -8
tools/perf/util/scripting-engines/trace-event-python.c
··· 726 726 _PyUnicode_FromString(bf)); 727 727 } 728 728 729 + static void set_sym_in_dict(PyObject *dict, struct addr_location *al, 730 + const char *dso_field, const char *sym_field, 731 + const char *symoff_field) 732 + { 733 + if (al->map) { 734 + pydict_set_item_string_decref(dict, dso_field, 735 + _PyUnicode_FromString(al->map->dso->name)); 736 + } 737 + if (al->sym) { 738 + pydict_set_item_string_decref(dict, sym_field, 739 + _PyUnicode_FromString(al->sym->name)); 740 + pydict_set_item_string_decref(dict, symoff_field, 741 + PyLong_FromUnsignedLong(get_offset(al->sym, al))); 742 + } 743 + } 744 + 729 745 static PyObject *get_perf_sample_dict(struct perf_sample *sample, 730 746 struct evsel *evsel, 731 747 struct addr_location *al, ··· 788 772 (const char *)sample->raw_data, sample->raw_size)); 789 773 pydict_set_item_string_decref(dict, "comm", 790 774 _PyUnicode_FromString(thread__comm_str(al->thread))); 791 - if (al->map) { 792 - pydict_set_item_string_decref(dict, "dso", 793 - _PyUnicode_FromString(al->map->dso->name)); 794 - } 795 - if (al->sym) { 796 - pydict_set_item_string_decref(dict, "symbol", 797 - _PyUnicode_FromString(al->sym->name)); 798 - } 775 + set_sym_in_dict(dict, al, "dso", "symbol", "symoff"); 799 776 800 777 pydict_set_item_string_decref(dict, "callchain", callchain); 801 778