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: Add sample flags

Add sample flags to python scripting.

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-6-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
bee272af 54cd8b03

+26
+26
tools/perf/util/scripting-engines/trace-event-python.c
··· 742 742 } 743 743 } 744 744 745 + static void set_sample_flags(PyObject *dict, u32 flags) 746 + { 747 + const char *ch = PERF_IP_FLAG_CHARS; 748 + char *p, str[33]; 749 + 750 + for (p = str; *ch; ch++, flags >>= 1) { 751 + if (flags & 1) 752 + *p++ = *ch; 753 + } 754 + *p = 0; 755 + pydict_set_item_string_decref(dict, "flags", _PyUnicode_FromString(str)); 756 + } 757 + 758 + static void python_process_sample_flags(struct perf_sample *sample, PyObject *dict_sample) 759 + { 760 + char flags_disp[SAMPLE_FLAGS_BUF_SIZE]; 761 + 762 + set_sample_flags(dict_sample, sample->flags); 763 + perf_sample__sprintf_flags(sample->flags, flags_disp, sizeof(flags_disp)); 764 + pydict_set_item_string_decref(dict_sample, "flags_disp", 765 + _PyUnicode_FromString(flags_disp)); 766 + } 767 + 745 768 static PyObject *get_perf_sample_dict(struct perf_sample *sample, 746 769 struct evsel *evsel, 747 770 struct addr_location *al, ··· 827 804 PyBool_FromLong(1)); 828 805 set_sym_in_dict(dict_sample, addr_al, "addr_dso", "addr_symbol", "addr_symoff"); 829 806 } 807 + 808 + if (sample->flags) 809 + python_process_sample_flags(sample, dict_sample); 830 810 831 811 set_regs_in_dict(dict, sample, evsel); 832 812