public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@gmail.com>,
	David Ahern <dsahern@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	yrl.pp-manager.tt@hitachi.com,
	Brendan Gregg <brendan.d.gregg@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH] perf probe: Warn user to rebuild target with debuginfo
Date: Fri, 15 Aug 2014 10:51:29 +0900	[thread overview]
Message-ID: <53ED67A1.3080607@hitachi.com> (raw)
In-Reply-To: <20140815014432.29869.57941.stgit@kbuild-fedora.novalocal>

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



  reply	other threads:[~2014-08-15  1:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53ED67A1.3080607@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=acme@kernel.org \
    --cc=brendan.d.gregg@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=yrl.pp-manager.tt@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox