aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-probe.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-11-03 19:12:21 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-04 07:02:46 -0500
commita7f4328b91fb6e71dbe1fa4d46f3597c9555014d (patch)
tree623cbc358e3cc47d6419d760c889a91ee371b9f9 /tools/perf/builtin-probe.c
parentc43f9d1e61e265c6bfafdd65c7f07c8d71a7efc3 (diff)
perf/probes: Improve error messages
Improve error messages in perf-probe so that users can figure out problems easily. Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Jason Baron <jbaron@redhat.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> LKML-Reference: <20091104001221.3454.52030.stgit@harusame> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-probe.c')
-rw-r--r--tools/perf/builtin-probe.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 81245238e341..65bcaed0ef49 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)
294{ 294{
295 int ret; 295 int ret;
296 296
297 printf("Adding new event: %s\n", buf);
298 ret = write(fd, buf, strlen(buf)); 297 ret = write(fd, buf, strlen(buf));
299 if (ret <= 0) 298 if (ret <= 0)
300 die("failed to create event."); 299 die("Failed to create event.");
300 else
301 printf("Added new event: %s\n", buf);
301 302
302 return ret; 303 return ret;
303} 304}
@@ -310,7 +311,7 @@ static int synthesize_probe_event(struct probe_point *pp)
310 int i, len, ret; 311 int i, len, ret;
311 pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char)); 312 pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char));
312 if (!buf) 313 if (!buf)
313 die("calloc"); 314 die("Failed to allocate memory by calloc.");
314 ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset); 315 ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset);
315 if (ret <= 0 || ret >= MAX_CMDLEN) 316 if (ret <= 0 || ret >= MAX_CMDLEN)
316 goto error; 317 goto error;
@@ -363,7 +364,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
363 if (ret == -E2BIG) 364 if (ret == -E2BIG)
364 semantic_error("probe point is too long."); 365 semantic_error("probe point is too long.");
365 else if (ret < 0) 366 else if (ret < 0)
366 die("snprintf"); 367 die("Failed to synthesize a probe point.");
367 } 368 }
368 369
369#ifndef NO_LIBDWARF 370#ifndef NO_LIBDWARF
@@ -375,7 +376,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
375 else 376 else
376 fd = open_default_vmlinux(); 377 fd = open_default_vmlinux();
377 if (fd < 0) 378 if (fd < 0)
378 die("vmlinux/module file open"); 379 die("Could not open vmlinux/module file.");
379 380
380 /* Searching probe points */ 381 /* Searching probe points */
381 for (j = 0; j < session.nr_probe; j++) { 382 for (j = 0; j < session.nr_probe; j++) {
@@ -396,8 +397,13 @@ setup_probes:
396 /* Settng up probe points */ 397 /* Settng up probe points */
397 snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path); 398 snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
398 fd = open(buf, O_WRONLY, O_APPEND); 399 fd = open(buf, O_WRONLY, O_APPEND);
399 if (fd < 0) 400 if (fd < 0) {
400 die("kprobe_events open"); 401 if (errno == ENOENT)
402 die("kprobe_events file does not exist - please rebuild with CONFIG_KPROBE_TRACER.");
403 else
404 die("Could not open kprobe_events file: %s",
405 strerror(errno));
406 }
401 for (j = 0; j < session.nr_probe; j++) { 407 for (j = 0; j < session.nr_probe; j++) {
402 pp = &session.probes[j]; 408 pp = &session.probes[j];
403 if (pp->found == 1) { 409 if (pp->found == 1) {