* perf probe: request: Better message when no debug info is found on vmlinux
@ 2014-08-14 15:33 Arnaldo Carvalho de Melo
2014-08-14 17:54 ` Masami Hiramatsu
0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-08-14 15:33 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: Jiri Olsa, Namhyung Kim, David Ahern, Linux Kernel Mailing List
Hi Masami,
I was trying to figure out why sys_perf_event_open was returning
EACCES when trying to record, as a non priviledged user, a 'ping'
process started by this user, while it has no problem doing the same
thing if the monitored process is 'sleep' (reusing of ptrace perms seems
to be what is causing this, but I digress), when I stumbled in something
annoying:
[root@ssdandy ~]# perf probe -v -L icmp_rcv
Looking at the vmlinux_path (6 entries long)
Using /lib/modules/3.16.0+/build/vmlinux for symbols
Failed to open debuginfo file.
Error: Failed to show lines. (-2)
[root@ssdandy ~]#
Huh? Why? So I went to look to see why it was "failing to open debuginfo
file":
[root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build/vmlinux
-rwxrwxr-x. 3 acme acme 22505817 Aug 13 11:54
/lib/modules/3.16.0+/build/vmlinux
[root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build
lrwxrwxrwx. 1 root root 29 Aug 13 12:10 /lib/modules/3.16.0+/build ->
/home/acme/git/build/v3.16.0+
The file is there, but... I forgot I had disabled CONFIG_DEBUG_INFO on
this machine:
[root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build/.config
-rw-rw-r--. 1 acme acme 136217 Aug 13 11:40
/lib/modules/3.16.0+/build/.config
[root@ssdandy ~]# grep CONFIG_DEBUG_INFO
/lib/modules/3.16.0+/build/.config
# CONFIG_DEBUG_INFO is not set
[root@ssdandy ~]#
So, only the CFI ELF section was there, not the other with the -g stuff:
[root@ssdandy ~]# readelf -SW /lib/modules/3.16.0+/build/vmlinux | grep \.debug_
[29] .debug_frame PROGBITS 0000000000000000 1266030 0021d0 00 0 0 8
[root@ssdandy ~]#
So, I suggest that we improve that error message to be more clear:
[root@ssdandy ~]# perf probe -L icmp_rcv
Failed to open debuginfo file.
Error: The /lib/modules/3.16.0+/build/vmlinux file has no
debugging information, rebuild with CONFIG_DEBUG_INFO=y
[root@ssdandy ~]#
Since it knows it is a kernel image file, and that the config option to
enable it is CONFIG_DEBUG_INFO.
Thanks,
- Arnaldo
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: perf probe: request: Better message when no debug info is found on vmlinux 2014-08-14 15:33 perf probe: request: Better message when no debug info is found on vmlinux Arnaldo Carvalho de Melo @ 2014-08-14 17:54 ` Masami Hiramatsu 2014-08-14 18:29 ` [PATCH] perf probe: Warn user to rebuild target with debuginfo Masami Hiramatsu 0 siblings, 1 reply; 12+ messages in thread From: Masami Hiramatsu @ 2014-08-14 17:54 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Jiri Olsa, Namhyung Kim, David Ahern, Linux Kernel Mailing List, yrl.pp-manager.tt@hitachi.com (2014/08/15 0:33), Arnaldo Carvalho de Melo wrote: > Hi Masami, > > I was trying to figure out why sys_perf_event_open was returning > EACCES when trying to record, as a non priviledged user, a 'ping' > process started by this user, while it has no problem doing the same > thing if the monitored process is 'sleep' (reusing of ptrace perms seems > to be what is causing this, but I digress), when I stumbled in something > annoying: > > [root@ssdandy ~]# perf probe -v -L icmp_rcv > Looking at the vmlinux_path (6 entries long) > Using /lib/modules/3.16.0+/build/vmlinux for symbols > Failed to open debuginfo file. > Error: Failed to show lines. (-2) > [root@ssdandy ~]# > > Huh? Why? So I went to look to see why it was "failing to open debuginfo > file": > > [root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build/vmlinux > -rwxrwxr-x. 3 acme acme 22505817 Aug 13 11:54 > /lib/modules/3.16.0+/build/vmlinux > [root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build > lrwxrwxrwx. 1 root root 29 Aug 13 12:10 /lib/modules/3.16.0+/build -> > /home/acme/git/build/v3.16.0+ > > The file is there, but... I forgot I had disabled CONFIG_DEBUG_INFO on > this machine: > > [root@ssdandy ~]# ls -la /lib/modules/3.16.0+/build/.config > -rw-rw-r--. 1 acme acme 136217 Aug 13 11:40 > /lib/modules/3.16.0+/build/.config > [root@ssdandy ~]# grep CONFIG_DEBUG_INFO > /lib/modules/3.16.0+/build/.config > # CONFIG_DEBUG_INFO is not set > [root@ssdandy ~]# > > So, only the CFI ELF section was there, not the other with the -g stuff: > > [root@ssdandy ~]# readelf -SW /lib/modules/3.16.0+/build/vmlinux | grep \.debug_ > [29] .debug_frame PROGBITS 0000000000000000 1266030 0021d0 00 0 0 8 > [root@ssdandy ~]# > > So, I suggest that we improve that error message to be more clear: > > [root@ssdandy ~]# perf probe -L icmp_rcv > Failed to open debuginfo file. > Error: The /lib/modules/3.16.0+/build/vmlinux file has no > debugging information, rebuild with CONFIG_DEBUG_INFO=y > > [root@ssdandy ~]# > > Since it knows it is a kernel image file, and that the config option to > enable it is CONFIG_DEBUG_INFO. OK, it seems better for me too. It will be a bit different message, but I'm sure to mention that config option for users. Thank you! -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-14 17:54 ` Masami Hiramatsu @ 2014-08-14 18:29 ` Masami Hiramatsu 2014-08-14 18:55 ` Arnaldo Carvalho de Melo 2014-08-14 20:07 ` Brendan Gregg 0 siblings, 2 replies; 12+ messages in thread From: Masami Hiramatsu @ 2014-08-14 18:29 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Namhyung Kim, yrl.pp-manager.tt, Jiri Olsa, LKML, David Ahern Warn user to rebuild target with debuginfo when the perf probe fails to find debug information in the target binary. Without this, perf probe just reports the failure, but it's no hint for users. This gives more hint for users. Without this, $ strip perf $ ./perf probe -x perf -L argv_split Failed to open debuginfo file. Error: Failed to show lines. With this, $ strip perf $ ./perf probe -x perf -L argv_split The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information, rebuild with -g. Error: Failed to show lines. The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" if the target is the kernel or a kernel module. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: David Ahern <dsahern@gmail.com> --- tools/perf/util/probe-event.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 784ea42..57eb343 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -258,21 +258,32 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) #ifdef HAVE_DWARF_SUPPORT /* Open new debuginfo of given module */ -static struct debuginfo *open_debuginfo(const char *module) +static struct debuginfo *open_debuginfo(const char *module, bool silent) { const char *path = module; + struct debuginfo *ret; if (!module || !strchr(module, '/')) { path = kernel_get_module_path(module); if (!path) { - pr_err("Failed to find path of %s module.\n", - module ?: "kernel"); + if (!silent) + pr_err("Failed to find path of %s module.\n", + module ?: "kernel"); return NULL; } } - return debuginfo__new(path); + ret = debuginfo__new(path); + if (!ret && !silent) { + pr_warning("The %s file has no debug information, ", path); + if (!module || !strtailcmp(path, ".ko")) + pr_warning("rebuild with CONFIG_DEBUG_INFO=y.\n"); + else + pr_warning("rebuild with -g.\n"); + } + return ret; } + static int get_text_start_address(const char *exec, unsigned long *address) { Elf *elf; @@ -333,15 +344,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, pr_debug("try to find information at %" PRIx64 " in %s\n", addr, tp->module ? : "kernel"); - dinfo = open_debuginfo(tp->module); + dinfo = open_debuginfo(tp->module, verbose == 0); if (dinfo) { ret = debuginfo__find_probe_point(dinfo, (unsigned long)addr, pp); debuginfo__delete(dinfo); - } else { - pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); + } else ret = -ENOENT; - } if (ret > 0) { pp->retprobe = tp->retprobe; @@ -457,13 +466,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, struct debuginfo *dinfo; int ntevs, ret = 0; - dinfo = open_debuginfo(target); + dinfo = open_debuginfo(target, !need_dwarf); if (!dinfo) { - if (need_dwarf) { - pr_warning("Failed to open debuginfo file.\n"); + if (need_dwarf) return -ENOENT; - } pr_debug("Could not open debuginfo. Try to use symbols.\n"); return 0; } @@ -620,11 +627,9 @@ static int __show_line_range(struct line_range *lr, const char *module) char *tmp; /* Search a line range */ - dinfo = open_debuginfo(module); - if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); + dinfo = open_debuginfo(module, false); + if (!dinfo) return -ENOENT; - } ret = debuginfo__find_line_range(dinfo, lr); debuginfo__delete(dinfo); @@ -772,9 +777,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, if (ret < 0) return ret; - dinfo = open_debuginfo(module); + dinfo = open_debuginfo(module, false); if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); ret = -ENOENT; goto out; } ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-14 18:29 ` [PATCH] perf probe: Warn user to rebuild target with debuginfo Masami Hiramatsu @ 2014-08-14 18:55 ` Arnaldo Carvalho de Melo 2014-08-14 20:07 ` Brendan Gregg 1 sibling, 0 replies; 12+ messages in thread From: Arnaldo Carvalho de Melo @ 2014-08-14 18:55 UTC (permalink / raw) To: Masami Hiramatsu Cc: Namhyung Kim, yrl.pp-manager.tt, Jiri Olsa, LKML, David Ahern Em Thu, Aug 14, 2014 at 06:29:38PM +0000, Masami Hiramatsu escreveu: > Warn user to rebuild target with debuginfo when the perf probe > fails to find debug information in the target binary. > Without this, perf probe just reports the failure, but it's > no hint for users. This gives more hint for users. > > Without this, That was quick! The changelog also was nicely written, stating the problem, then providing an example to exhibit the problem before the patch, then the end result, with the intended behaviour, after the patch. Thanks a lot! - Arnaldo > $ strip perf > $ ./perf probe -x perf -L argv_split > Failed to open debuginfo file. > Error: Failed to show lines. > > With this, > > $ strip perf > $ ./perf probe -x perf -L argv_split > The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information, rebuild with -g. > Error: Failed to show lines. > > The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" > if the target is the kernel or a kernel module. > > Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> > Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> > Cc: Jiri Olsa <jolsa@redhat.com> > Cc: Namhyung Kim <namhyung@gmail.com> > Cc: David Ahern <dsahern@gmail.com> > --- > tools/perf/util/probe-event.c | 40 ++++++++++++++++++++++------------------ > 1 file changed, 22 insertions(+), 18 deletions(-) > > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c > index 784ea42..57eb343 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -258,21 +258,32 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) > #ifdef HAVE_DWARF_SUPPORT > > /* Open new debuginfo of given module */ > -static struct debuginfo *open_debuginfo(const char *module) > +static struct debuginfo *open_debuginfo(const char *module, bool silent) > { > const char *path = module; > + struct debuginfo *ret; > > if (!module || !strchr(module, '/')) { > path = kernel_get_module_path(module); > if (!path) { > - pr_err("Failed to find path of %s module.\n", > - module ?: "kernel"); > + if (!silent) > + pr_err("Failed to find path of %s module.\n", > + module ?: "kernel"); > return NULL; > } > } > - return debuginfo__new(path); > + ret = debuginfo__new(path); > + if (!ret && !silent) { > + pr_warning("The %s file has no debug information, ", path); > + if (!module || !strtailcmp(path, ".ko")) > + pr_warning("rebuild with CONFIG_DEBUG_INFO=y.\n"); > + else > + pr_warning("rebuild with -g.\n"); > + } > + return ret; > } > > + > static int get_text_start_address(const char *exec, unsigned long *address) > { > Elf *elf; > @@ -333,15 +344,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, > pr_debug("try to find information at %" PRIx64 " in %s\n", addr, > tp->module ? : "kernel"); > > - dinfo = open_debuginfo(tp->module); > + dinfo = open_debuginfo(tp->module, verbose == 0); > if (dinfo) { > ret = debuginfo__find_probe_point(dinfo, > (unsigned long)addr, pp); > debuginfo__delete(dinfo); > - } else { > - pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); > + } else > ret = -ENOENT; > - } > > if (ret > 0) { > pp->retprobe = tp->retprobe; > @@ -457,13 +466,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, > struct debuginfo *dinfo; > int ntevs, ret = 0; > > - dinfo = open_debuginfo(target); > + dinfo = open_debuginfo(target, !need_dwarf); > > if (!dinfo) { > - if (need_dwarf) { > - pr_warning("Failed to open debuginfo file.\n"); > + if (need_dwarf) > return -ENOENT; > - } > pr_debug("Could not open debuginfo. Try to use symbols.\n"); > return 0; > } > @@ -620,11 +627,9 @@ static int __show_line_range(struct line_range *lr, const char *module) > char *tmp; > > /* Search a line range */ > - dinfo = open_debuginfo(module); > - if (!dinfo) { > - pr_warning("Failed to open debuginfo file.\n"); > + dinfo = open_debuginfo(module, false); > + if (!dinfo) > return -ENOENT; > - } > > ret = debuginfo__find_line_range(dinfo, lr); > debuginfo__delete(dinfo); > @@ -772,9 +777,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, > if (ret < 0) > return ret; > > - dinfo = open_debuginfo(module); > + dinfo = open_debuginfo(module, false); > if (!dinfo) { > - pr_warning("Failed to open debuginfo file.\n"); > ret = -ENOENT; > goto out; > } ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-14 18:29 ` [PATCH] perf probe: Warn user to rebuild target with debuginfo Masami Hiramatsu 2014-08-14 18:55 ` Arnaldo Carvalho de Melo @ 2014-08-14 20:07 ` Brendan Gregg 2014-08-15 1:07 ` Arnaldo Carvalho de Melo 1 sibling, 1 reply; 12+ messages in thread From: Brendan Gregg @ 2014-08-14 20:07 UTC (permalink / raw) To: Masami Hiramatsu Cc: Arnaldo Carvalho de Melo, Namhyung Kim, yrl.pp-manager.tt, Jiri Olsa, LKML, David Ahern On Thu, Aug 14, 2014 at 11:29 AM, Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote: [...] > The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" > if the target is the kernel or a kernel module. Thanks, definitely an improvement! Should the kernel message also mention kernel debuginfo packages? Depends on the distribution and environment, but I think for some users the solution is to add the package. Brendan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-14 20:07 ` Brendan Gregg @ 2014-08-15 1:07 ` Arnaldo Carvalho de Melo 2014-08-15 1:29 ` Masami Hiramatsu 0 siblings, 1 reply; 12+ messages in thread From: Arnaldo Carvalho de Melo @ 2014-08-15 1:07 UTC (permalink / raw) To: Brendan Gregg Cc: Masami Hiramatsu, Namhyung Kim, yrl.pp-manager.tt, Jiri Olsa, LKML, David Ahern Em Thu, Aug 14, 2014 at 01:07:28PM -0700, Brendan Gregg escreveu: > On Thu, Aug 14, 2014 at 11:29 AM, Masami Hiramatsu > <masami.hiramatsu.pt@hitachi.com> wrote: > [...] > > The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" > > if the target is the kernel or a kernel module. > Thanks, definitely an improvement! Should the kernel message also > mention kernel debuginfo packages? Depends on the distribution and > environment, but I think for some users the solution is to add the > package. Yeah, something like what is suggested by gdb and documented here: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/intro.debuginfo.html -------------------------------------------------------------------- In some cases (such as loading a core file), GDB does not know the name, version, or release of a name-debuginfo-version-release.rpm package; it only knows the build-id. In such cases, GDB suggests a different command: gdb -c ./core [...] Missing separate debuginfo for the main executable filename Try: yum --disablerepo='*' --enablerepo='*debug*' install /usr/lib/debug/.build-id/ef/dd0b5e69b0742fa5e5bad0771df4d1df2459d1 --------------------------------------------------------------------- This is something I want to have eventually, i.e. to have per distro plugins to automatically download packages required for some features, like probing and annotation, for instance. E.g: [acme@zoo ~]$ perf record usleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.014 MB perf.data (~615 samples) ] [acme@zoo ~]$ perf buildid-list 34412145145a7561db0d0063a925c17d9af67a1f [kernel.kallsyms] efc76c94d401b3b7f0f8ecb893c829d82f10e4b2 /usr/lib64/libc-2.18.so [acme@zoo ~]$ sudo yum --disablerepo='*' --enablerepo='*debug*' install /usr/lib/debug/.build-id/34/412145145a7561db0d0063a925c17d9af67a1f Loaded plugins: auto-update-debuginfo, langpacks, refresh-packagekit Resolving Dependencies --> Running transaction check ---> Package kernel-debuginfo.x86_64 0:3.15.8-200.fc20 will be installed --> Processing Dependency: kernel-debuginfo-common-x86_64 = 3.15.8-200.fc20 for package: kernel-debuginfo-3.15.8-200.fc20.x86_64 --> Running transaction check ---> Package kernel-debuginfo-common-x86_64.x86_64 0:3.15.8-200.fc20 will be installed --> Finished Dependency Resolution Dependencies Resolved <SNIP> - Arnaldo ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 1:07 ` Arnaldo Carvalho de Melo @ 2014-08-15 1:29 ` Masami Hiramatsu 2014-08-15 1:44 ` Masami Hiramatsu 0 siblings, 1 reply; 12+ messages in thread From: Masami Hiramatsu @ 2014-08-15 1:29 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Brendan Gregg, Namhyung Kim, yrl.pp-manager.tt, Jiri Olsa, LKML, David Ahern (2014/08/15 10:07), Arnaldo Carvalho de Melo wrote: > Em Thu, Aug 14, 2014 at 01:07:28PM -0700, Brendan Gregg escreveu: >> On Thu, Aug 14, 2014 at 11:29 AM, Masami Hiramatsu >> <masami.hiramatsu.pt@hitachi.com> wrote: >> [...] >>> The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" >>> if the target is the kernel or a kernel module. > >> Thanks, definitely an improvement! Should the kernel message also >> mention kernel debuginfo packages? Depends on the distribution and >> environment, but I think for some users the solution is to add the >> package. I see, and at least fedora/rhel has debuginfo for all packages. So, not only for the kernel, but also for user applications, we'll need to do that. > Yeah, something like what is suggested by gdb and documented here: > > https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/intro.debuginfo.html > > -------------------------------------------------------------------- > In some cases (such as loading a core file), GDB does not know the > name, version, or release of a name-debuginfo-version-release.rpm > package; it only knows the build-id. In such cases, GDB suggests a > different command: > > gdb -c ./core > [...] > Missing separate debuginfo for the main executable filename > Try: yum --disablerepo='*' --enablerepo='*debug*' install /usr/lib/debug/.build-id/ef/dd0b5e69b0742fa5e5bad0771df4d1df2459d1 > --------------------------------------------------------------------- ah, that's nice :) > > This is something I want to have eventually, i.e. to have per distro > plugins to automatically download packages required for some features, > like probing and annotation, for instance. Yeah, however, it depends on the distro. AFAIK, ubuntu provides debuginfo package only for the kernel. So, at this point, I think what we can do is just say "please install debuginfo package" as below. $ ./perf probe -x perf -L argv_split The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information, rebuild with -g. Or install appropriate debuginfo package. Error: Failed to show lines. Thank you, -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 1:29 ` Masami Hiramatsu @ 2014-08-15 1:44 ` Masami Hiramatsu 2014-08-15 1:51 ` Masami Hiramatsu 2014-08-18 8:21 ` [tip:perf/core] " tip-bot for Masami Hiramatsu 0 siblings, 2 replies; 12+ messages in thread From: Masami Hiramatsu @ 2014-08-15 1:44 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Namhyung Kim, David Ahern, LKML, yrl.pp-manager.tt, Brendan Gregg, Jiri Olsa Warn user to rebuild target with debuginfo when the perf probe fails to find debug information in the target binary. Without this, perf probe just reports the failure, but it's no hint for users. This gives more hint for users. Without this, $ strip perf $ ./perf probe -x perf -L argv_split Failed to open debuginfo file. Error: Failed to show lines. With this, $ strip perf $ ./perf probe -x perf -L argv_split The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information. Rebuild with -g, or install an appropriate debuginfo pacakge. Error: Failed to show lines. The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" if the target is the kernel or a kernel module. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> --- tools/perf/util/probe-event.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 784ea42..9a29c72 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -258,21 +258,33 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) #ifdef HAVE_DWARF_SUPPORT /* Open new debuginfo of given module */ -static struct debuginfo *open_debuginfo(const char *module) +static struct debuginfo *open_debuginfo(const char *module, bool silent) { const char *path = module; + struct debuginfo *ret; if (!module || !strchr(module, '/')) { path = kernel_get_module_path(module); if (!path) { - pr_err("Failed to find path of %s module.\n", - module ?: "kernel"); + if (!silent) + pr_err("Failed to find path of %s module.\n", + module ?: "kernel"); return NULL; } } - return debuginfo__new(path); + ret = debuginfo__new(path); + if (!ret && !silent) { + pr_warning("The %s file has no debug information.\n", path); + if (!module || !strtailcmp(path, ".ko")) + pr_warning("Rebuild with CONFIG_DEBUG_INFO=y, "); + else + pr_warning("Rebuild with -g, "); + pr_warning("or install an appropriate debuginfo pacakge.\n"); + } + return ret; } + static int get_text_start_address(const char *exec, unsigned long *address) { Elf *elf; @@ -333,15 +345,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, pr_debug("try to find information at %" PRIx64 " in %s\n", addr, tp->module ? : "kernel"); - dinfo = open_debuginfo(tp->module); + dinfo = open_debuginfo(tp->module, verbose == 0); if (dinfo) { ret = debuginfo__find_probe_point(dinfo, (unsigned long)addr, pp); debuginfo__delete(dinfo); - } else { - pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); + } else ret = -ENOENT; - } if (ret > 0) { pp->retprobe = tp->retprobe; @@ -457,13 +467,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, struct debuginfo *dinfo; int ntevs, ret = 0; - dinfo = open_debuginfo(target); + dinfo = open_debuginfo(target, !need_dwarf); if (!dinfo) { - if (need_dwarf) { - pr_warning("Failed to open debuginfo file.\n"); + if (need_dwarf) return -ENOENT; - } pr_debug("Could not open debuginfo. Try to use symbols.\n"); return 0; } @@ -620,11 +628,9 @@ static int __show_line_range(struct line_range *lr, const char *module) char *tmp; /* Search a line range */ - dinfo = open_debuginfo(module); - if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); + dinfo = open_debuginfo(module, false); + if (!dinfo) return -ENOENT; - } ret = debuginfo__find_line_range(dinfo, lr); debuginfo__delete(dinfo); @@ -772,9 +778,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, if (ret < 0) return ret; - dinfo = open_debuginfo(module); + dinfo = open_debuginfo(module, false); if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); ret = -ENOENT; goto out; } ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 1:44 ` Masami Hiramatsu @ 2014-08-15 1:51 ` Masami Hiramatsu 2014-08-15 3:39 ` Brendan Gregg 2014-08-18 8:21 ` [tip:perf/core] " tip-bot for Masami Hiramatsu 1 sibling, 1 reply; 12+ messages in thread From: Masami Hiramatsu @ 2014-08-15 1:51 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Namhyung Kim, David Ahern, LKML, yrl.pp-manager.tt, Brendan Gregg, Jiri Olsa Here is v2 patch, which I've added "or install an appropriate debuginfo pacakge." :) Thank you, (2014/08/15 10:44), Masami Hiramatsu wrote: > Warn user to rebuild target with debuginfo when the perf probe > fails to find debug information in the target binary. > Without this, perf probe just reports the failure, but it's > no hint for users. This gives more hint for users. > > Without this, > > $ strip perf > $ ./perf probe -x perf -L argv_split > Failed to open debuginfo file. > Error: Failed to show lines. > > With this, > > $ strip perf > $ ./perf probe -x perf -L argv_split > The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information. > Rebuild with -g, or install an appropriate debuginfo pacakge. > Error: Failed to show lines. > > The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" > if the target is the kernel or a kernel module. > > Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> > Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> > Cc: Jiri Olsa <jolsa@redhat.com> > Cc: Namhyung Kim <namhyung@gmail.com> > Cc: David Ahern <dsahern@gmail.com> > Cc: Brendan Gregg <brendan.d.gregg@gmail.com> > --- > tools/perf/util/probe-event.c | 41 +++++++++++++++++++++++------------------ > 1 file changed, 23 insertions(+), 18 deletions(-) > > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c > index 784ea42..9a29c72 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -258,21 +258,33 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) > #ifdef HAVE_DWARF_SUPPORT > > /* Open new debuginfo of given module */ > -static struct debuginfo *open_debuginfo(const char *module) > +static struct debuginfo *open_debuginfo(const char *module, bool silent) > { > const char *path = module; > + struct debuginfo *ret; > > if (!module || !strchr(module, '/')) { > path = kernel_get_module_path(module); > if (!path) { > - pr_err("Failed to find path of %s module.\n", > - module ?: "kernel"); > + if (!silent) > + pr_err("Failed to find path of %s module.\n", > + module ?: "kernel"); > return NULL; > } > } > - return debuginfo__new(path); > + ret = debuginfo__new(path); > + if (!ret && !silent) { > + pr_warning("The %s file has no debug information.\n", path); > + if (!module || !strtailcmp(path, ".ko")) > + pr_warning("Rebuild with CONFIG_DEBUG_INFO=y, "); > + else > + pr_warning("Rebuild with -g, "); > + pr_warning("or install an appropriate debuginfo pacakge.\n"); > + } > + return ret; > } > > + > static int get_text_start_address(const char *exec, unsigned long *address) > { > Elf *elf; > @@ -333,15 +345,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, > pr_debug("try to find information at %" PRIx64 " in %s\n", addr, > tp->module ? : "kernel"); > > - dinfo = open_debuginfo(tp->module); > + dinfo = open_debuginfo(tp->module, verbose == 0); > if (dinfo) { > ret = debuginfo__find_probe_point(dinfo, > (unsigned long)addr, pp); > debuginfo__delete(dinfo); > - } else { > - pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); > + } else > ret = -ENOENT; > - } > > if (ret > 0) { > pp->retprobe = tp->retprobe; > @@ -457,13 +467,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, > struct debuginfo *dinfo; > int ntevs, ret = 0; > > - dinfo = open_debuginfo(target); > + dinfo = open_debuginfo(target, !need_dwarf); > > if (!dinfo) { > - if (need_dwarf) { > - pr_warning("Failed to open debuginfo file.\n"); > + if (need_dwarf) > return -ENOENT; > - } > pr_debug("Could not open debuginfo. Try to use symbols.\n"); > return 0; > } > @@ -620,11 +628,9 @@ static int __show_line_range(struct line_range *lr, const char *module) > char *tmp; > > /* Search a line range */ > - dinfo = open_debuginfo(module); > - if (!dinfo) { > - pr_warning("Failed to open debuginfo file.\n"); > + dinfo = open_debuginfo(module, false); > + if (!dinfo) > return -ENOENT; > - } > > ret = debuginfo__find_line_range(dinfo, lr); > debuginfo__delete(dinfo); > @@ -772,9 +778,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, > if (ret < 0) > return ret; > > - dinfo = open_debuginfo(module); > + dinfo = open_debuginfo(module, false); > if (!dinfo) { > - pr_warning("Failed to open debuginfo file.\n"); > ret = -ENOENT; > goto out; > } > > -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu.pt@hitachi.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 1:51 ` Masami Hiramatsu @ 2014-08-15 3:39 ` Brendan Gregg 2014-08-15 13:34 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 12+ messages in thread From: Brendan Gregg @ 2014-08-15 3:39 UTC (permalink / raw) To: Masami Hiramatsu Cc: Arnaldo Carvalho de Melo, Namhyung Kim, David Ahern, LKML, yrl.pp-manager.tt, Jiri Olsa On Thu, Aug 14, 2014 at 6:51 PM, Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote: > Here is v2 patch, which I've added "or install an appropriate debuginfo pacakge." :) [...] Looks good, thanks. Brendan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 3:39 ` Brendan Gregg @ 2014-08-15 13:34 ` Arnaldo Carvalho de Melo 0 siblings, 0 replies; 12+ messages in thread From: Arnaldo Carvalho de Melo @ 2014-08-15 13:34 UTC (permalink / raw) To: Masami Hiramatsu Cc: Brendan Gregg, Namhyung Kim, David Ahern, LKML, yrl.pp-manager.tt, Jiri Olsa Em Thu, Aug 14, 2014 at 08:39:51PM -0700, Brendan Gregg escreveu: > On Thu, Aug 14, 2014 at 6:51 PM, Masami Hiramatsu > <masami.hiramatsu.pt@hitachi.com> wrote: > > Here is v2 patch, which I've added "or install an appropriate debuginfo pacakge." :) > [...] > > Looks good, thanks. Thanks, applied. - Arnaldo ^ permalink raw reply [flat|nested] 12+ messages in thread
* [tip:perf/core] perf probe: Warn user to rebuild target with debuginfo 2014-08-15 1:44 ` Masami Hiramatsu 2014-08-15 1:51 ` Masami Hiramatsu @ 2014-08-18 8:21 ` tip-bot for Masami Hiramatsu 1 sibling, 0 replies; 12+ messages in thread From: tip-bot for Masami Hiramatsu @ 2014-08-18 8:21 UTC (permalink / raw) To: linux-tip-commits Cc: acme, linux-kernel, hpa, mingo, acme, namhyung, brendan.d.gregg, jolsa, masami.hiramatsu.pt, dsahern, tglx Commit-ID: 92561cb7883194714475c7a7775a11a9c40f75cb Gitweb: http://git.kernel.org/tip/92561cb7883194714475c7a7775a11a9c40f75cb Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> AuthorDate: Fri, 15 Aug 2014 01:44:32 +0000 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Fri, 15 Aug 2014 10:32:43 -0300 perf probe: Warn user to rebuild target with debuginfo Warn user to rebuild target with debuginfo when the perf probe fails to find debug information in the target binary. Without this, perf probe just reports the failure, but it's no hint for users. This gives more hint for users. Without this: $ strip perf $ ./perf probe -x perf -L argv_split Failed to open debuginfo file. Error: Failed to show lines. With this: $ strip perf $ ./perf probe -x perf -L argv_split The /home/fedora/ksrc/linux-3/tools/perf/perf file has no debug information. Rebuild with -g, or install an appropriate debuginfo package. Error: Failed to show lines. The "rebuild with ..." part changes to "rebuild with CONFIG_DEBUG_INFO" if the target is the kernel or a kernel module. Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Brendan Gregg <brendan.d.gregg@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20140815014432.29869.57941.stgit@kbuild-fedora.novalocal Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/util/probe-event.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 784ea42..ac15ff7 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -258,21 +258,33 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) #ifdef HAVE_DWARF_SUPPORT /* Open new debuginfo of given module */ -static struct debuginfo *open_debuginfo(const char *module) +static struct debuginfo *open_debuginfo(const char *module, bool silent) { const char *path = module; + struct debuginfo *ret; if (!module || !strchr(module, '/')) { path = kernel_get_module_path(module); if (!path) { - pr_err("Failed to find path of %s module.\n", - module ?: "kernel"); + if (!silent) + pr_err("Failed to find path of %s module.\n", + module ?: "kernel"); return NULL; } } - return debuginfo__new(path); + ret = debuginfo__new(path); + if (!ret && !silent) { + pr_warning("The %s file has no debug information.\n", path); + if (!module || !strtailcmp(path, ".ko")) + pr_warning("Rebuild with CONFIG_DEBUG_INFO=y, "); + else + pr_warning("Rebuild with -g, "); + pr_warning("or install an appropriate debuginfo package.\n"); + } + return ret; } + static int get_text_start_address(const char *exec, unsigned long *address) { Elf *elf; @@ -333,15 +345,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, pr_debug("try to find information at %" PRIx64 " in %s\n", addr, tp->module ? : "kernel"); - dinfo = open_debuginfo(tp->module); + dinfo = open_debuginfo(tp->module, verbose == 0); if (dinfo) { ret = debuginfo__find_probe_point(dinfo, (unsigned long)addr, pp); debuginfo__delete(dinfo); - } else { - pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); + } else ret = -ENOENT; - } if (ret > 0) { pp->retprobe = tp->retprobe; @@ -457,13 +467,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, struct debuginfo *dinfo; int ntevs, ret = 0; - dinfo = open_debuginfo(target); + dinfo = open_debuginfo(target, !need_dwarf); if (!dinfo) { - if (need_dwarf) { - pr_warning("Failed to open debuginfo file.\n"); + if (need_dwarf) return -ENOENT; - } pr_debug("Could not open debuginfo. Try to use symbols.\n"); return 0; } @@ -620,11 +628,9 @@ static int __show_line_range(struct line_range *lr, const char *module) char *tmp; /* Search a line range */ - dinfo = open_debuginfo(module); - if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); + dinfo = open_debuginfo(module, false); + if (!dinfo) return -ENOENT; - } ret = debuginfo__find_line_range(dinfo, lr); debuginfo__delete(dinfo); @@ -772,9 +778,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, if (ret < 0) return ret; - dinfo = open_debuginfo(module); + dinfo = open_debuginfo(module, false); if (!dinfo) { - pr_warning("Failed to open debuginfo file.\n"); ret = -ENOENT; goto out; } ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-08-18 8:22 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-08-14 15:33 perf probe: request: Better message when no debug info is found on vmlinux Arnaldo Carvalho de Melo 2014-08-14 17:54 ` Masami Hiramatsu 2014-08-14 18:29 ` [PATCH] perf probe: Warn user to rebuild target with debuginfo Masami Hiramatsu 2014-08-14 18:55 ` Arnaldo Carvalho de Melo 2014-08-14 20:07 ` Brendan Gregg 2014-08-15 1:07 ` Arnaldo Carvalho de Melo 2014-08-15 1:29 ` Masami Hiramatsu 2014-08-15 1:44 ` Masami Hiramatsu 2014-08-15 1:51 ` Masami Hiramatsu 2014-08-15 3:39 ` Brendan Gregg 2014-08-15 13:34 ` Arnaldo Carvalho de Melo 2014-08-18 8:21 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox