Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1566619

[PATCH 21/23] perf util: Add more debug message on failure path

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 21/23] perf util: Add more debug message on failure path
Date 2017-01-25 15:00 +0100
Message-ID <t3whd-2sl-35@gated-at.bofh.it> (permalink)
References <t3whb-2sl-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Namhyung Kim <namhyung.kim@lge.com>

It's helpful for debugging on tracing features.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jeremy Eder <jeder@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>,
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-rjysr9ljiesymgk4qblteaty@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 00fd8a8850d3..c567d9f0aa92 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2803,8 +2803,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 61c7162c31c7..27420159bf69 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -260,39 +260,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)
@@ -345,6 +359,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);
@@ -352,18 +367,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 trace_event *tevent, bool __repipe)
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/23] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 19/23] perf tools: Propagate perf_config() errors Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 15/23] tools lib bpf: Define prog_type fns with macro Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 10/23] perf script: Add "brstackasm" output for branch stacks Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 11/23] perf probe: Fix wrong register name for arm64 Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 09/23] perf script: Add support for printing assembler Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 18/23] perf scripting perl: Do not die() when not founding event for a type Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 21/23] perf util: Add more debug message on failure path Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 08/23] perf tools: Add disassembler for x86 using the XED library Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 14/23] tools lib bpf: Fix map offsets in relocation Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 02/23] perf hists browser: Put hist_entry folding logic into single function Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 22/23] perf ftrace: Introduce new 'ftrace' tool Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 01/23] perf unwind: Fix looking up dwarf unwind stack info Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 13/23] perf probe: Delete an unnecessary assignment in try_to_find_absolute_address() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 23/23] perf ftrace: Make 'function_graph' be the default tracer Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 04/23] perf c2c report: Display Total records column in offset view Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100
  [PATCH 06/23] perf tools: Add probing for the XED disassembler library Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-25 15:00 +0100

csiph-web