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

perf probe: Support DW_AT_const_value constant value

Support DW_AT_const_value for variable assignment instead of location.
Note that this requires ftrace supporting immediate value.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Link: http://lore.kernel.org/lkml/157406476012.24476.16096289871757175775.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu and committed by
Arnaldo Carvalho de Melo
66f69b21 72363540

+19
+7
tools/perf/util/probe-file.c
··· 1008 1008 FTRACE_README_UPROBE_REF_CTR, 1009 1009 FTRACE_README_USER_ACCESS, 1010 1010 FTRACE_README_MULTIPROBE_EVENT, 1011 + FTRACE_README_IMMEDIATE_VALUE, 1011 1012 FTRACE_README_END, 1012 1013 }; 1013 1014 ··· 1023 1022 DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"), 1024 1023 DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"), 1025 1024 DEFINE_TYPE(FTRACE_README_MULTIPROBE_EVENT, "*Create/append/*"), 1025 + DEFINE_TYPE(FTRACE_README_IMMEDIATE_VALUE, "*\\imm-value,*"), 1026 1026 }; 1027 1027 1028 1028 static bool scan_ftrace_readme(enum ftrace_readme type) ··· 1093 1091 bool multiprobe_event_is_supported(void) 1094 1092 { 1095 1093 return scan_ftrace_readme(FTRACE_README_MULTIPROBE_EVENT); 1094 + } 1095 + 1096 + bool immediate_value_is_supported(void) 1097 + { 1098 + return scan_ftrace_readme(FTRACE_README_IMMEDIATE_VALUE); 1096 1099 }
+1
tools/perf/util/probe-file.h
··· 72 72 bool uprobe_ref_ctr_is_supported(void); 73 73 bool user_access_is_supported(void); 74 74 bool multiprobe_event_is_supported(void); 75 + bool immediate_value_is_supported(void); 75 76 #else /* ! HAVE_LIBELF_SUPPORT */ 76 77 static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused) 77 78 {
+11
tools/perf/util/probe-finder.c
··· 177 177 if (dwarf_attr(vr_die, DW_AT_external, &attr) != NULL) 178 178 goto static_var; 179 179 180 + /* Constant value */ 181 + if (dwarf_attr(vr_die, DW_AT_const_value, &attr) && 182 + immediate_value_is_supported()) { 183 + Dwarf_Sword snum; 184 + 185 + dwarf_formsdata(&attr, &snum); 186 + ret = asprintf(&tvar->value, "\\%ld", (long)snum); 187 + 188 + return ret < 0 ? -ENOMEM : 0; 189 + } 190 + 180 191 /* TODO: handle more than 1 exprs */ 181 192 if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL) 182 193 return -EINVAL; /* Broken DIE ? */