perf evlist: Introduce perf_evlist__strerror_tp method
Out of 'perf trace', should be used by other tools that uses tracepoints. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ramkumar Ramachandra <artagnon@gmail.com> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-lyvtxhchz4ga8fwht15x8wou@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
ba209f8563
commit
6ef068cb8e
|
@ -1814,27 +1814,11 @@ out:
|
||||||
trace->live = false;
|
trace->live = false;
|
||||||
return err;
|
return err;
|
||||||
out_error_tp:
|
out_error_tp:
|
||||||
switch(errno) {
|
{
|
||||||
case ENOENT:
|
char errbuf[BUFSIZ];
|
||||||
fputs("Error:\tUnable to find debugfs\n"
|
perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf));
|
||||||
"Hint:\tWas your kernel was compiled with debugfs support?\n"
|
fprintf(trace->output, "%s\n", errbuf);
|
||||||
"Hint:\tIs the debugfs filesystem mounted?\n"
|
}
|
||||||
"Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'\n",
|
|
||||||
trace->output);
|
|
||||||
break;
|
|
||||||
case EACCES:
|
|
||||||
fprintf(trace->output,
|
|
||||||
"Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
|
|
||||||
"Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
|
|
||||||
debugfs_mountpoint, debugfs_mountpoint);
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
char bf[256];
|
|
||||||
fprintf(trace->output, "Can't trace: %s\n",
|
|
||||||
strerror_r(errno, bf, sizeof(bf)));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
goto out_delete_evlist;
|
goto out_delete_evlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1126,3 +1126,30 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
|
||||||
|
|
||||||
return printed + fprintf(fp, "\n");;
|
return printed + fprintf(fp, "\n");;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int perf_evlist__strerror_tp(struct perf_evlist *evlist __maybe_unused,
|
||||||
|
int err, char *buf, size_t size)
|
||||||
|
{
|
||||||
|
char sbuf[128];
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case ENOENT:
|
||||||
|
scnprintf(buf, size, "%s",
|
||||||
|
"Error:\tUnable to find debugfs\n"
|
||||||
|
"Hint:\tWas your kernel was compiled with debugfs support?\n"
|
||||||
|
"Hint:\tIs the debugfs filesystem mounted?\n"
|
||||||
|
"Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
|
||||||
|
break;
|
||||||
|
case EACCES:
|
||||||
|
scnprintf(buf, size,
|
||||||
|
"Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
|
||||||
|
"Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
|
||||||
|
debugfs_mountpoint, debugfs_mountpoint);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
scnprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -168,6 +168,8 @@ static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
|
||||||
|
|
||||||
size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
|
size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
|
||||||
|
|
||||||
|
int perf_evlist__strerror_tp(struct perf_evlist *evlist, int err, char *buf, size_t size);
|
||||||
|
|
||||||
static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
|
static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
|
||||||
{
|
{
|
||||||
struct perf_event_mmap_page *pc = mm->base;
|
struct perf_event_mmap_page *pc = mm->base;
|
||||||
|
|
Loading…
Reference in New Issue