diff mbox series

[09/11] libtracefs/Documentation: Update libtracefs-hist-cont.txt to new API

Message ID 20211122234956.788401-10-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit f62492fd538ebddc9b48165424045a4e5d77f0ec
Headers show
Series libtracefs: Have all man page examples be executable | expand

Commit Message

Steven Rostedt Nov. 22, 2021, 11:49 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The histogram API has changed. Update the man page example to reflect
that.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Documentation/libtracefs-hist-cont.txt | 27 +++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/Documentation/libtracefs-hist-cont.txt b/Documentation/libtracefs-hist-cont.txt
index 778b8ee..5cdcc0a 100644
--- a/Documentation/libtracefs-hist-cont.txt
+++ b/Documentation/libtracefs-hist-cont.txt
@@ -66,6 +66,7 @@  int main (int argc, char **argv, char **env)
 {
 	struct tracefs_instance *instance;
 	struct tracefs_hist *hist;
+	struct tep_handle *tep;
 	enum commands cmd;
 	char *cmd_str;
 	int ret;
@@ -94,22 +95,29 @@  int main (int argc, char **argv, char **env)
 		exit(-1);
 	}
 
+	tep = tracefs_local_events(NULL);
+	if (!tep) {
+		perror("Reading tracefs");
+		exit(-1);
+	}
+
 	instance = tracefs_instance_create("hist_test");
 	if (!instance) {
 		fprintf(stderr, "Failed instance create\n");
 		exit(-1);
 	}
 
-	hist = tracefs_hist_alloc(instance, "kmem", "kmalloc",
-				  "call_site", TRACEFS_HIST_KEY_SYM,
-				  "bytes_req", 0);
+	hist = tracefs_hist2d_alloc(tep, "kmem", "kmalloc",
+				    "call_site",TRACEFS_HIST_KEY_SYM,
+				    "bytes_req", 0);
 	if (!hist) {
 		fprintf(stderr, "Failed hist create\n");
 		exit(-1);
 	}
 
 	ret = tracefs_hist_add_value(hist, "bytes_alloc");
-	ret |= tracefs_hist_add_sort_key(hist, "bytes_req", "bytes_alloc", NULL);
+	ret |= tracefs_hist_add_sort_key(hist, "bytes_req");
+	ret |= tracefs_hist_add_sort_key(hist, "bytes_alloc");
 
 	ret |= tracefs_hist_sort_key_direction(hist, "bytes_alloc",
 					       TRACEFS_HIST_SORT_DESCENDING);
@@ -122,7 +130,7 @@  int main (int argc, char **argv, char **env)
 
 	switch (cmd) {
 	case START:
-		ret = tracefs_hist_start(hist);
+		ret = tracefs_hist_start(instance, hist);
 		if (ret) {
 			char *err = tracefs_error_last(instance);
 			if (err)
@@ -130,16 +138,16 @@  int main (int argc, char **argv, char **env)
 		}
 		break;
 	case PAUSE:
-		ret = tracefs_hist_pause(hist);
+		ret = tracefs_hist_pause(instance, hist);
 		break;
 	case CONT:
-		ret = tracefs_hist_continue(hist);
+		ret = tracefs_hist_continue(instance, hist);
 		break;
 	case RESET:
-		ret = tracefs_hist_reset(hist);
+		ret = tracefs_hist_reset(instance, hist);
 		break;
 	case DELETE:
-		ret = tracefs_hist_destroy(hist);
+		ret = tracefs_hist_destroy(instance, hist);
 		break;
 	case SHOW: {
 		char *content;
@@ -157,6 +165,7 @@  int main (int argc, char **argv, char **env)
 		fprintf(stderr, "Failed: command\n");
 	exit(ret);
 }
+
 --
 
 FILES