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>
This commit is contained in:
parent
c43f9d1e61
commit
a7f4328b91
|
@ -294,10 +294,11 @@ static int write_new_event(int fd, const char *buf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
printf("Adding new event: %s\n", buf);
|
|
||||||
ret = write(fd, buf, strlen(buf));
|
ret = write(fd, buf, strlen(buf));
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
die("failed to create event.");
|
die("Failed to create event.");
|
||||||
|
else
|
||||||
|
printf("Added new event: %s\n", buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +311,7 @@ static int synthesize_probe_event(struct probe_point *pp)
|
||||||
int i, len, ret;
|
int i, len, ret;
|
||||||
pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char));
|
pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
die("calloc");
|
die("Failed to allocate memory by calloc.");
|
||||||
ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset);
|
ret = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset);
|
||||||
if (ret <= 0 || ret >= MAX_CMDLEN)
|
if (ret <= 0 || ret >= MAX_CMDLEN)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -363,7 +364,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
|
||||||
if (ret == -E2BIG)
|
if (ret == -E2BIG)
|
||||||
semantic_error("probe point is too long.");
|
semantic_error("probe point is too long.");
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
die("snprintf");
|
die("Failed to synthesize a probe point.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_LIBDWARF
|
#ifndef NO_LIBDWARF
|
||||||
|
@ -375,7 +376,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
|
||||||
else
|
else
|
||||||
fd = open_default_vmlinux();
|
fd = open_default_vmlinux();
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
die("vmlinux/module file open");
|
die("Could not open vmlinux/module file.");
|
||||||
|
|
||||||
/* Searching probe points */
|
/* Searching probe points */
|
||||||
for (j = 0; j < session.nr_probe; j++) {
|
for (j = 0; j < session.nr_probe; j++) {
|
||||||
|
@ -396,8 +397,13 @@ setup_probes:
|
||||||
/* Settng up probe points */
|
/* Settng up probe points */
|
||||||
snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
|
snprintf(buf, MAX_CMDLEN, "%s/../kprobe_events", debugfs_path);
|
||||||
fd = open(buf, O_WRONLY, O_APPEND);
|
fd = open(buf, O_WRONLY, O_APPEND);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
die("kprobe_events open");
|
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++) {
|
for (j = 0; j < session.nr_probe; j++) {
|
||||||
pp = &session.probes[j];
|
pp = &session.probes[j];
|
||||||
if (pp->found == 1) {
|
if (pp->found == 1) {
|
||||||
|
|
|
@ -688,7 +688,7 @@ int find_probepoint(int fd, struct probe_point *pp)
|
||||||
|
|
||||||
ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error);
|
ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error);
|
||||||
if (ret != DW_DLV_OK)
|
if (ret != DW_DLV_OK)
|
||||||
die("Failed to call dwarf_init(). Maybe, not a dwarf file.\n");
|
die("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO.\n");
|
||||||
|
|
||||||
pp->found = 0;
|
pp->found = 0;
|
||||||
while (++cu_number) {
|
while (++cu_number) {
|
||||||
|
|
Loading…
Reference in New Issue