aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2022-08-05 11:40:36 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2022-08-05 11:45:10 -0400
commit78a74b13d03aeac8449bb178f8d60f931e9c55df (patch)
tree532de058897e2742aecfed20575bd7fe187d0d11
parentb37903ae5fb53db147519f3e51b28e2647ed8de9 (diff)
downloadtrace-cmd-78a74b13d03aeac8449bb178f8d60f931e9c55df.tar.gz
trace-cmd library: Allow callers to save private data in tracecmd_input handlers
Add a private field for tracecmd_input handle where callers can set it via tracecmd_set_private() and retrieve it with tracecmd_get_private(). This will allow a way to find specific information about a handle for users of tracecmd_iterate_events_multi(). Link: https://lore.kernel.org/linux-trace-devel/20220805154040.2014381-6-rostedt@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r--include/trace-cmd/trace-cmd.h3
-rw-r--r--lib/trace-cmd/trace-input.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index 86a34869..e8d72c76 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -48,6 +48,9 @@ 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);
+void tracecmd_set_private(struct tracecmd_input *handle, void *data);
+void *tracecmd_get_private(struct tracecmd_input *handle);
+
int tracecmd_iterate_events(struct tracecmd_input *handle,
cpu_set_t *cpus, int cpu_size,
int (*callback)(struct tracecmd_input *handle,
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 5df10716..a3f17070 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -215,6 +215,8 @@ struct tracecmd_input {
/* For custom profilers. */
tracecmd_show_data_func show_data_func;
+
+ void *private;
};
__thread struct tracecmd_input *tracecmd_curr_thread_handle;
@@ -245,6 +247,16 @@ enum tracecmd_file_states tracecmd_get_file_state(struct tracecmd_input *handle)
return handle->file_state;
}
+void tracecmd_set_private(struct tracecmd_input *handle, void *data)
+{
+ handle->private = data;
+}
+
+void *tracecmd_get_private(struct tracecmd_input *handle)
+{
+ return handle->private;
+}
+
#if DEBUG_RECORD
static void remove_record(struct page *page, struct tep_record *record)
{