diff mbox series

[v2,3/4] libtracefs: Add new 'hist' APIs

Message ID 20210924095702.151826-4-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series Modifications of some 'hist' APIs | expand

Commit Message

Yordan Karadzhov Sept. 24, 2021, 9:57 a.m. UTC
The new APIs will be valuable in a number of different scenarios.
For example if the user wants to implement a function that does
the readout of a histogram, the only argument that will have to
be passed to this function is the histogram descriptor. The same
applies for the case when the user wants to print an adequate
error message in a case of a failure.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 include/tracefs.h  |  3 +++
 src/tracefs-hist.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/include/tracefs.h b/include/tracefs.h
index 230bc41..ebe83fe 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -329,6 +329,9 @@  struct tracefs_hist *
 tracefs_hist_alloc(struct tep_handle *tep,
 		   const char *system, const char *event_name,
 		   struct tracefs_hist_axis *axes);
+const char *tracefs_get_hist_name(struct tracefs_hist *hist);
+const char *tracefs_get_hist_event(struct tracefs_hist *hist);
+const char *tracefs_get_hist_system(struct tracefs_hist *hist);
 int tracefs_hist_add_key(struct tracefs_hist *hist, const char *key,
 			 enum tracefs_hist_key_type type);
 int tracefs_hist_add_value(struct tracefs_hist *hist, const char *value);
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index a7c20de..27bab00 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -39,6 +39,21 @@  struct tracefs_hist {
 	unsigned int		filter_state;
 };
 
+const char *tracefs_get_hist_name(struct tracefs_hist *hist)
+{
+	return hist ? hist->name : NULL;
+}
+
+const char *tracefs_get_hist_event(struct tracefs_hist *hist)
+{
+	return hist ? hist->event_name : NULL;
+}
+
+const char *tracefs_get_hist_system(struct tracefs_hist *hist)
+{
+	return hist ? hist->system : NULL;
+}
+
 static void add_list(struct trace_seq *seq, const char *start,
 		     char **list)
 {