Skip to content

Commit

Permalink
perf ftrace: Show error message when fails to set ftrace files
Browse files Browse the repository at this point in the history
It'd be better for debugging to show an error message when it fails to
setup ftrace for some reason.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Jun 20, 2017
1 parent 106dacd commit e7bd9ba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/perf/builtin-ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static int __write_tracing_file(const char *name, const char *val, bool append)
int fd, ret = -1;
ssize_t size = strlen(val);
int flags = O_WRONLY;
char errbuf[512];

file = get_tracing_file(name);
if (!file) {
Expand All @@ -75,14 +76,16 @@ static int __write_tracing_file(const char *name, const char *val, bool append)

fd = open(file, flags);
if (fd < 0) {
pr_debug("cannot open tracing file: %s\n", name);
pr_debug("cannot open tracing file: %s: %s\n",
name, str_error_r(errno, errbuf, sizeof(errbuf)));
goto out;
}

if (write(fd, val, size) == size)
ret = 0;
else
pr_debug("write '%s' to tracing/%s failed\n", val, name);
pr_debug("write '%s' to tracing/%s failed: %s\n",
val, name, str_error_r(errno, errbuf, sizeof(errbuf)));

close(fd);
out:
Expand Down

0 comments on commit e7bd9ba

Please sign in to comment.