Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753615AbZKDARw (ORCPT ); Tue, 3 Nov 2009 19:17:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753523AbZKDARu (ORCPT ); Tue, 3 Nov 2009 19:17:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28583 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479AbZKDARs (ORCPT ); Tue, 3 Nov 2009 19:17:48 -0500 From: Masami Hiramatsu Subject: [PATCH -tip perf/probes 2/5] perf/probes: Improve error messages To: Ingo Molnar , Frederic Weisbecker , lkml Cc: systemtap , DLE , Masami Hiramatsu , Steven Rostedt , Jim Keniston , Ananth N Mavinakayanahalli , Christoph Hellwig , "Frank Ch. Eigler" , Frederic Weisbecker , Jason Baron , "K.Prasad" , Peter Zijlstra , Srikar Dronamraju Date: Tue, 03 Nov 2009 19:12:21 -0500 Message-ID: <20091104001221.3454.52030.stgit@harusame> In-Reply-To: <20091104001204.3454.75999.stgit@harusame> References: <20091104001204.3454.75999.stgit@harusame> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3676 Lines: 112 Improve error messages in perf-probe so that users can figure out problems easily. Signed-off-by: Masami Hiramatsu Reported-by: Ingo Molnar Cc: Steven Rostedt Cc: Jim Keniston Cc: Ananth N Mavinakayanahalli Cc: Christoph Hellwig Cc: Frank Ch. Eigler Cc: Frederic Weisbecker Cc: Jason Baron Cc: K.Prasad Cc: Peter Zijlstra Cc: Srikar Dronamraju --- tools/perf/builtin-probe.c | 21 ++++++++++++++------- tools/perf/util/probe-finder.c | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index a99a366..454ddfc 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -294,10 +294,11 @@ static int write_new_event(int fd, const char *buf) { int ret; - printf("Adding new event: %s\n", buf); ret = write(fd, buf, strlen(buf)); if (ret <= 0) - die("failed to create event."); + die("Failed to create event."); + else + printf("Added new event: %s\n", buf); return ret; } @@ -310,7 +311,7 @@ static int synthesize_probe_event(struct probe_point *pp) int i, len, ret; pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char)); if (!buf) - die("calloc"); + die("Failed to allocate memory by calloc."); ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset); if (ret <= 0 || ret >= MAX_CMDLEN) goto error; @@ -363,7 +364,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) if (ret == -E2BIG) semantic_error("probe point is too long."); else if (ret < 0) - die("snprintf"); + die("Failed to synthesize a probe point."); } #ifndef NO_LIBDWARF @@ -375,7 +376,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) else fd = open_default_vmlinux(); if (fd < 0) - die("vmlinux/module file open"); + die("Could not open vmlinux/module file."); /* Searching probe points */ for (j = 0; j < session.nr_probe; j++) { @@ -396,8 +397,14 @@ setup_probes: /* Settng up probe points */ snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path); fd = open(buf, O_WRONLY, O_APPEND); - if (fd < 0) - die("kprobe_events open"); + if (fd < 0) { + if (errno == ENOENT) + die("kprobe_events file does not exist" + " - please rebuild with CONFIG_KPROBE_TRACER."); + else + die("Could not open kprobe_events file: %s", + strerror(errno)); + } for (j = 0; j < session.nr_probe; j++) { pp = &session.probes[j]; if (pp->found == 1) { diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index db96186..86cead3 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -688,7 +688,8 @@ int find_probepoint(int fd, struct probe_point *pp) ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error); if (ret != DW_DLV_OK) - die("Failed to call dwarf_init(). Maybe, not a dwarf file.\n"); + die("Not found dwarf info in the vmlinux" + " - please rebuild with CONFIG_DEBUG_INFO.\n"); pp->found = 0; while (++cu_number) { -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America), Inc. Software Solutions Division e-mail: mhiramat@redhat.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/