Messages in this thread Patch in this message | | | From | Masami Hiramatsu <> | Subject | [RFC PATCH 2/4] perf-probe: Add offline output directory option | Date | Wed, 24 Aug 2016 14:58:12 +0900 |
| |
Add offline output direcrtory option. This allows user to store probe event definition in offline output directory.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> --- tools/perf/builtin-probe.c | 2 ++ tools/perf/util/probe-event.h | 1 + tools/perf/util/probe-file.c | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index ee5b421..5b45ec8 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -517,6 +517,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) "Show variables location range in scope (with --vars only)"), OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), + OPT_STRING(0, "outdir", &probe_conf.output_dir, + "directory", "path to offline output directory"), OPT_STRING('s', "source", &symbol_conf.source_prefix, "directory", "path to kernel source"), OPT_BOOLEAN('\0', "no-inlines", &probe_conf.no_inlines, diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index f4f45db..75b572a 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -14,6 +14,7 @@ struct probe_conf { bool no_inlines; bool cache; int max_probes; + const char *output_dir; }; extern struct probe_conf probe_conf; extern bool probe_event_dry_run; diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 6f931e4..41db430 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -73,16 +73,25 @@ static void print_both_open_warning(int kerr, int uerr) static int open_probe_events(const char *trace_file, bool readwrite) { char buf[PATH_MAX]; + const char *tracing_dir = tracing_path; + int oflag = 0; + mode_t mode = 0; int ret; + if (probe_conf.output_dir) { + tracing_dir = probe_conf.output_dir; + oflag = O_CREAT; + mode = 0644; + } + ret = e_snprintf(buf, PATH_MAX, "%s/%s", - tracing_path, trace_file); + tracing_dir, trace_file); if (ret >= 0) { pr_debug("Opening %s write=%d\n", buf, readwrite); if (readwrite && !probe_event_dry_run) - ret = open(buf, O_RDWR | O_APPEND, 0); + ret = open(buf, O_RDWR | O_APPEND | oflag, mode); else - ret = open(buf, O_RDONLY, 0); + ret = open(buf, O_RDONLY | oflag, mode); if (ret < 0) ret = -errno; @@ -242,6 +251,8 @@ int probe_file__add_event(int fd, struct probe_trace_event *tev) pr_warning("Failed to write event: %s\n", str_error_r(errno, sbuf, sizeof(sbuf))); } + if (probe_conf.output_dir) + ret = write(fd, "\n", 1) == 1 ? 0 : -errno; } free(buf); @@ -274,6 +285,8 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) ret = -errno; goto error; } + if (probe_conf.output_dir) + ret = write(fd, "\n", 1) == 1 ? 0 : -errno; return 0; error:
| |