aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2015-11-20 15:57:25 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-04-26 10:49:42 -0400
commiteaf068a84e0e238e5e06561a0bae145bf7a0b4fc (patch)
tree1109965cb09e3da2b2e3aaaf2b661b19326fd9e9
parent9b01bd9aa474c58c725388e8533b0d0a8d269e57 (diff)
downloadtrace-cmd-eaf068a84e0e238e5e06561a0bae145bf7a0b4fc.tar.gz
trace-cmd: add a function to create a top instance
We need a way to allow external applications to create an instance for doing their tracing, so add a helper function that takes care of creating an instance, setting it as the main instance and doing the heavy lifting of creating the instance in the tracing directory. Thanks, Link: http://lkml.kernel.org/r/1448053053-24188-4-git-send-email-jbacik@fb.com Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.h2
-rw-r--r--trace-record.c25
2 files changed, 24 insertions, 3 deletions
diff --git a/trace-cmd.h b/trace-cmd.h
index 5c961088..e55513a5 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -124,6 +124,8 @@ int tracecmd_buffer_instances(struct tracecmd_input *handle);
const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx);
struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
int tracecmd_is_buffer_instance(struct tracecmd_input *handle);
+void tracecmd_create_top_instance(char *name);
+void tracecmd_remove_instances(void);
void tracecmd_set_ts_offset(struct tracecmd_input *handle, unsigned long long offset);
void tracecmd_set_ts2secs(struct tracecmd_input *handle, unsigned long long hz);
diff --git a/trace-record.c b/trace-record.c
index 7b7da385..e6c056cf 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -3669,7 +3669,7 @@ static void make_instances(void)
}
}
-static void remove_instances(void)
+void tracecmd_remove_instances(void)
{
struct buffer_instance *instance;
char *path;
@@ -3691,6 +3691,25 @@ static void remove_instances(void)
}
}
+/**
+ * tracecmd_create_top_instance - create a top named instance
+ * @name: name of the instance to use.
+ *
+ * This is a library function for tools that want to do their tracing inside of
+ * an instance. All it does is create an instance and set it as a top instance,
+ * you don't want to call this more than once, and you want to call
+ * tracecmd_remove_instances to undo your work.
+ */
+void tracecmd_create_top_instance(char *name)
+{
+ struct buffer_instance *instance;
+
+ instance = create_instance(name);
+ add_instance(instance);
+ update_first_instance(instance, 0);
+ make_instances();
+}
+
static void check_plugin(const char *plugin)
{
char *buf;
@@ -4319,7 +4338,7 @@ void trace_record (int argc, char **argv)
set_buffer_size();
clear_filters();
clear_triggers();
- remove_instances();
+ tracecmd_remove_instances();
clear_func_filters();
exit(0);
} else
@@ -4795,7 +4814,7 @@ void trace_record (int argc, char **argv)
set_plugin("nop");
- remove_instances();
+ tracecmd_remove_instances();
/* If tracing_on was enabled before we started, set it on now */
for_all_instances(instance) {