public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, David Ahern <dsahern@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Jeremy Eder <jeder@redhat.com>
Subject: Re: [PATCH 02/17] perf util: Add more debug message on failure path
Date: Tue, 30 Jul 2013 10:33:42 -0300	[thread overview]
Message-ID: <20130730133342.GB2607@ghostprotocols.net> (raw)
In-Reply-To: <1375175954-798-3-git-send-email-namhyung@kernel.org>

Em Tue, Jul 30, 2013 at 06:18:59PM +0900, Namhyung Kim escreveu:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> It's helpful for debugging on tracing features.

I wonder if we shouldn't start using 'perf probe to insert those
things... Having some shell script with a series of probe insertions...
What do you think? At least we would be eating our own dog food 8-)

Or at least have something that shows the source file name and line
number, so that things like:

 static int read_event_file(struct pevent *pevent, char *sys,
 			    unsigned long long size)
 {
+	int ret;
 	char *buf;
 
 	buf = malloc(size);
-	if (buf == NULL)
+	if (buf == NULL) {
+		pr_debug("memory allocation failure\n");
 		return -1;
+	}

actually help us 8-)

- Arnaldo
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/header.c           |  4 ++-
>  tools/perf/util/trace-event-read.c | 53 ++++++++++++++++++++++++++------------
>  2 files changed, 39 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index f558f83769af..11b08f24ba42 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -2700,8 +2700,10 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
>  	}
>  
>  	event = pevent_find_event(pevent, evsel->attr.config);
> -	if (event == NULL)
> +	if (event == NULL) {
> +		pr_debug("cannot find event format for %d\n", (int)evsel->attr.config);
>  		return -1;
> +	}
>  
>  	if (!evsel->name) {
>  		snprintf(bf, sizeof(bf), "%s:%s", event->system, event->name);
> diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
> index e084e5e654b6..0e3b3f527320 100644
> --- a/tools/perf/util/trace-event-read.c
> +++ b/tools/perf/util/trace-event-read.c
> @@ -262,39 +262,53 @@ static int read_header_files(struct pevent *pevent)
>  
>  static int read_ftrace_file(struct pevent *pevent, unsigned long long size)
>  {
> +	int ret;
>  	char *buf;
>  
>  	buf = malloc(size);
> -	if (buf == NULL)
> +	if (buf == NULL) {
> +		pr_debug("memory allocation failure\n");
>  		return -1;
> +	}
>  
> -	if (do_read(buf, size) < 0) {
> -		free(buf);
> -		return -1;
> +	ret = do_read(buf, size);
> +	if (ret < 0) {
> +		pr_debug("error reading ftrace file.\n");
> +		goto out;
>  	}
>  
> -	parse_ftrace_file(pevent, buf, size);
> +	ret = parse_ftrace_file(pevent, buf, size);
> +	if (ret < 0)
> +		pr_debug("error parsing ftrace file.\n");
> +out:
>  	free(buf);
> -	return 0;
> +	return ret;
>  }
>  
>  static int read_event_file(struct pevent *pevent, char *sys,
>  			    unsigned long long size)
>  {
> +	int ret;
>  	char *buf;
>  
>  	buf = malloc(size);
> -	if (buf == NULL)
> +	if (buf == NULL) {
> +		pr_debug("memory allocation failure\n");
>  		return -1;
> +	}
>  
> -	if (do_read(buf, size) < 0) {
> +	ret = do_read(buf, size);
> +	if (ret < 0) {
>  		free(buf);
> -		return -1;
> +		goto out;
>  	}
>  
> -	parse_event_file(pevent, buf, size, sys);
> +	ret = parse_event_file(pevent, buf, size, sys);
> +	if (ret < 0)
> +		pr_debug("error parsing event file.\n");
> +out:
>  	free(buf);
> -	return 0;
> +	return ret;
>  }
>  
>  static int read_ftrace_files(struct pevent *pevent)
> @@ -347,6 +361,7 @@ static int read_saved_cmdline(struct pevent *pevent)
>  {
>  	unsigned long long size;
>  	char *buf;
> +	int ret;
>  
>  	/* it can have 0 size */
>  	size = read8(pevent);
> @@ -354,18 +369,22 @@ static int read_saved_cmdline(struct pevent *pevent)
>  		return 0;
>  
>  	buf = malloc(size + 1);
> -	if (buf == NULL)
> +	if (buf == NULL) {
> +		pr_debug("memory allocation failure\n");
>  		return -1;
> +	}
>  
> -	if (do_read(buf, size) < 0) {
> -		free(buf);
> -		return -1;
> +	ret = do_read(buf, size);
> +	if (ret < 0) {
> +		pr_debug("error reading saved cmdlines\n");
> +		goto out;
>  	}
>  
>  	parse_saved_cmdline(pevent, buf, size);
> -
> +	ret = 0;
> +out:
>  	free(buf);
> -	return 0;
> +	return ret;
>  }
>  
>  ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)
> -- 
> 1.7.11.7

  reply	other threads:[~2013-07-30 13:33 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30  9:18 [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4) Namhyung Kim
2013-07-30  9:18 ` [PATCH 01/17] perf util: Save pid-cmdline mapping into tracing header Namhyung Kim
2013-07-30 13:28   ` Arnaldo Carvalho de Melo
2013-07-31  0:51     ` Namhyung Kim
2013-07-31 14:07       ` Arnaldo Carvalho de Melo
2013-08-05  7:17         ` Namhyung Kim
2013-08-07 13:44           ` David Ahern
2013-08-09  5:51             ` Namhyung Kim
2013-07-30  9:18 ` [PATCH 02/17] perf util: Add more debug message on failure path Namhyung Kim
2013-07-30 13:33   ` Arnaldo Carvalho de Melo [this message]
2013-07-30  9:19 ` [PATCH 03/17] perf tools: Introduce new 'ftrace' tool Namhyung Kim
2013-07-30  9:19 ` [PATCH 04/17] perf ftrace: Add support for --pid option Namhyung Kim
2013-07-30  9:19 ` [PATCH 05/17] perf ftrace: Add support for -a and -C option Namhyung Kim
2013-07-30  9:19 ` [PATCH 06/17] perf ftrace: Split "live" sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 07/17] perf ftrace: Add 'record' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 08/17] perf ftrace: Add 'show' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 09/17] perf ftrace: Add 'report' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 10/17] perf ftrace: Add dump_printf() for low-level debugging Namhyung Kim
2013-07-30  9:19 ` [PATCH 11/17] perf ftrace: Use pager for displaying result Namhyung Kim
2013-07-30  9:19 ` [PATCH 12/17] perf ftrace: Cleanup using ftrace_setup/teardown() Namhyung Kim
2013-07-30  9:19 ` [PATCH 13/17] perf tools: Add document for perf-ftrace command Namhyung Kim
2013-07-30  9:19 ` [PATCH 14/17] perf ftrace: Add a signal handler for SIGSEGV Namhyung Kim
2013-07-30  9:19 ` [PATCH 15/17] perf ftrace: Add --clock option Namhyung Kim
2013-07-30  9:19 ` [PATCH 16/17] perf ftrace: Show leaf-functions as oneliner Namhyung Kim
2013-07-30  9:19 ` [PATCH 17/17] perf ftrace: Tidy up the function graph output of 'show' subcommand Namhyung Kim
2013-08-01 12:02 ` [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4) Jiri Olsa
2013-08-02  9:16   ` Ingo Molnar
2013-08-05  7:44     ` Namhyung Kim
     [not found]   ` <51FB2B90.6090602@gmail.com>
2013-08-02 13:33     ` [PATCH] perf tools: Renaming 'time' variable in perf_time_to_tsc due to name shadowing error Jiri Olsa
2013-08-03 19:23       ` Adrian Hunter
2013-08-05  7:47         ` Jiri Olsa
2013-08-09 10:23 ` [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4) Jiri Olsa
2013-08-13  2:20   ` Namhyung Kim
2013-08-28 14:57     ` Jeremy Eder
2013-08-29  2:56       ` Namhyung Kim
2013-08-09 10:25 ` Jiri Olsa
2013-08-09 10:30   ` Jiri Olsa

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=20130730133342.GB2607@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jeder@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    /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