aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2014-09-17 04:40:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-09-17 17:01:14 -0400
commit2b394bc4468c2f5e6814a8dbb2a923c0448f8497 (patch)
tree9e118f2c74d2650eafb89b61a21ffe5bfdbb6384 /tools/perf/util/probe-event.c
parentc657f423aed0d836c807ea1d6d8d28b3914446fa (diff)
perf probe: Do not access kallsyms when analyzing user binaries
Do not access kallsyms to show available variables and show source lines in user binaries. This behavior always requires the root privilege when sysctl sets kernel.kptr_restrict=1, but we don't need it just for analyzing user binaries. Without this patch (by normal user, kptr_restrict=1): ---- $ perf probe -x ./perf -V add_cmdname Failed to init vmlinux path. Error: Failed to show vars. $ perf probe -x ./perf -L add_cmdname Failed to init vmlinux path. Error: Failed to show lines. ---- With this patch: ---- $ perf probe -x ./perf -V add_cmdname Available variables at add_cmdname @<perf_unknown_cmd_config+144> (No matched variables) @<list_commands_in_dir+160> (No matched variables) @<add_cmdname+0> char* name size_t len struct cmdnames* cmds $ perf probe -x ./perf -L add_cmdname <add_cmdname@/home/fedora/ksrc/linux-3/tools/perf/util/help.c:0> 0 void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) 1 { 2 struct cmdname *ent = malloc(sizeof(*ent) + len + 1); 4 ent->len = len; 5 memcpy(ent->name, name, len); 6 ent->name[len] = 0; ... ---- Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: david lerner <dlernerdroid@gmail.com> Cc: linux-perf-user@vger.kernel.org Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20140917084054.3722.73975.stgit@kbuild-f20.novalocal [ Added missing 'bool user' argument to the !DWARF show_line_range() stub ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index f73595fc0627..be37b5aca335 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -697,11 +697,11 @@ end:
697 return ret; 697 return ret;
698} 698}
699 699
700int show_line_range(struct line_range *lr, const char *module) 700int show_line_range(struct line_range *lr, const char *module, bool user)
701{ 701{
702 int ret; 702 int ret;
703 703
704 ret = init_symbol_maps(false); 704 ret = init_symbol_maps(user);
705 if (ret < 0) 705 if (ret < 0)
706 return ret; 706 return ret;
707 ret = __show_line_range(lr, module); 707 ret = __show_line_range(lr, module);
@@ -776,7 +776,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
776 int i, ret = 0; 776 int i, ret = 0;
777 struct debuginfo *dinfo; 777 struct debuginfo *dinfo;
778 778
779 ret = init_symbol_maps(false); 779 ret = init_symbol_maps(pevs->uprobes);
780 if (ret < 0) 780 if (ret < 0)
781 return ret; 781 return ret;
782 782
@@ -822,7 +822,8 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
822} 822}
823 823
824int show_line_range(struct line_range *lr __maybe_unused, 824int show_line_range(struct line_range *lr __maybe_unused,
825 const char *module __maybe_unused) 825 const char *module __maybe_unused,
826 bool user __maybe_unused)
826{ 827{
827 pr_warning("Debuginfo-analysis is not supported.\n"); 828 pr_warning("Debuginfo-analysis is not supported.\n");
828 return -ENOSYS; 829 return -ENOSYS;