Skip to content

Commit a7f4328

Browse files
Masami HiramatsuIngo Molnar
authored andcommitted
perf/probes: Improve error messages
Improve error messages in perf-probe so that users can figure out problems easily. Reported-by: Ingo Molnar <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Acked-by: Frederic Weisbecker <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Jim Keniston <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Frank Ch. Eigler <[email protected]> Cc: Jason Baron <[email protected]> Cc: K.Prasad <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Srikar Dronamraju <[email protected]> LKML-Reference: <20091104001221.3454.52030.stgit@harusame> Signed-off-by: Ingo Molnar <[email protected]>
1 parent c43f9d1 commit a7f4328

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

tools/perf/builtin-probe.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,11 @@ static int write_new_event(int fd, const char *buf)
294294
{
295295
int ret;
296296

297-
printf("Adding new event: %s\n", buf);
298297
ret = write(fd, buf, strlen(buf));
299298
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);
301302

302303
return ret;
303304
}
@@ -310,7 +311,7 @@ static int synthesize_probe_event(struct probe_point *pp)
310311
int i, len, ret;
311312
pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char));
312313
if (!buf)
313-
die("calloc");
314+
die("Failed to allocate memory by calloc.");
314315
ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset);
315316
if (ret <= 0 || ret >= MAX_CMDLEN)
316317
goto error;
@@ -363,7 +364,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
363364
if (ret == -E2BIG)
364365
semantic_error("probe point is too long.");
365366
else if (ret < 0)
366-
die("snprintf");
367+
die("Failed to synthesize a probe point.");
367368
}
368369

369370
#ifndef NO_LIBDWARF
@@ -375,7 +376,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
375376
else
376377
fd = open_default_vmlinux();
377378
if (fd < 0)
378-
die("vmlinux/module file open");
379+
die("Could not open vmlinux/module file.");
379380

380381
/* Searching probe points */
381382
for (j = 0; j < session.nr_probe; j++) {
@@ -396,8 +397,13 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
396397
/* Settng up probe points */
397398
snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
398399
fd = open(buf, O_WRONLY, O_APPEND);
399-
if (fd < 0)
400-
die("kprobe_events open");
400+
if (fd < 0) {
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+
}
401407
for (j = 0; j < session.nr_probe; j++) {
402408
pp = &session.probes[j];
403409
if (pp->found == 1) {

tools/perf/util/probe-finder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ int find_probepoint(int fd, struct probe_point *pp)
688688

689689
ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error);
690690
if (ret != DW_DLV_OK)
691-
die("Failed to call dwarf_init(). Maybe, not a dwarf file.\n");
691+
die("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO.\n");
692692

693693
pp->found = 0;
694694
while (++cu_number) {

0 commit comments

Comments
 (0)