summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2018-01-18 17:09:09 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2018-01-18 17:09:09 +0000
commit05e5db0f0a8e75de68f8baa3a0b59bf398caebf6 (patch)
tree17f9600892c74627b70d402d90c30064ab016179
parenteadb00a03d4fe599f3dccd6d3330bee598b4464a (diff)
Add CLI tool for loading profiling aptures
Captures of profiling data are saved in a binary format, and we need a tool that can load them and turn them into user readable (or machine readable) data.
-rw-r--r--tools/Makefile.am.inc14
-rw-r--r--tools/eos-profile-tool/eos-profile-cmd-help.c27
-rw-r--r--tools/eos-profile-tool/eos-profile-cmds.h26
-rw-r--r--tools/eos-profile-tool/eos-profile-main.c41
4 files changed, 108 insertions, 0 deletions
diff --git a/tools/Makefile.am.inc b/tools/Makefile.am.inc
index 8f0015c..c2db497 100644
--- a/tools/Makefile.am.inc
+++ b/tools/Makefile.am.inc
@@ -41,3 +41,17 @@ dist_commands_DATA = \
$(NULL)
EXTRA_DIST += $(tools_test_modules)
+
+bin_PROGRAMS = \
+ eos-profile \
+ $(NULL)
+
+eos_profile_SOURCES = \
+ tools/eos-profile-tool/eos-profile-main.c \
+ tools/eos-profile-tool/eos-profile-cmds.h \
+ tools/eos-profile-tool/eos-profile-cmd-help.c \
+ $(NULL)
+
+eos_profile_CPPFLAGS = @EOS_SDK_CFLAGS@ -DG_LOG_DOMAIN=\"EosProfile\"
+eos_profile_CFLAGS = $(AM_CFLAGS)
+eos_profile_LDADD = $(top_builddir)/libendless-@EOS_SDK_API_VERSION@.la @EOS_SDK_LIBS@
diff --git a/tools/eos-profile-tool/eos-profile-cmd-help.c b/tools/eos-profile-tool/eos-profile-cmd-help.c
new file mode 100644
index 0000000..88f8b4e
--- /dev/null
+++ b/tools/eos-profile-tool/eos-profile-cmd-help.c
@@ -0,0 +1,27 @@
+#include "config.h"
+
+#include <glib.h>
+
+gboolean
+eos_profile_cmd_help_parse_args (int argc,
+ char **argv)
+{
+ return TRUE;
+}
+
+int
+eos_profile_cmd_help_main (void)
+{
+ g_print (
+ "eos-profile\n"
+ "\n"
+ "Usage: eos-profile <COMMAND> [OPTIONS...]\n"
+ "\n"
+ "Examples:\n"
+ "\n"
+ " eos-profile help - This help screen\n"
+ "\n"
+ );
+
+ return 0;
+}
diff --git a/tools/eos-profile-tool/eos-profile-cmds.h b/tools/eos-profile-tool/eos-profile-cmds.h
new file mode 100644
index 0000000..f06781c
--- /dev/null
+++ b/tools/eos-profile-tool/eos-profile-cmds.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <glib.h>
+
+typedef gboolean (* EosProfileCmdParseArgs) (int argc, char **argv);
+typedef int (* EosProfileCmdMain) (void);
+
+gboolean eos_profile_cmd_help_parse_args (int argc, char **argv);
+int eos_profile_cmd_help_main (void);
+
+const struct {
+ const char *name;
+ const char *description;
+
+ EosProfileCmdParseArgs parse_args;
+ EosProfileCmdMain main;
+} profile_commands[] = {
+ {
+ .name = "help",
+ .description = "Prints help",
+ .parse_args = eos_profile_cmd_help_parse_args,
+ .main = eos_profile_cmd_help_main,
+ },
+
+ { NULL, },
+};
diff --git a/tools/eos-profile-tool/eos-profile-main.c b/tools/eos-profile-tool/eos-profile-main.c
new file mode 100644
index 0000000..4b76870
--- /dev/null
+++ b/tools/eos-profile-tool/eos-profile-main.c
@@ -0,0 +1,41 @@
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+#include "eos-profile-cmds.h"
+
+static gboolean opt_cmd = FALSE;
+
+int
+main (int argc,
+ char *argv[])
+{
+ const char *cmd = NULL;
+
+ if (argc < 2)
+ cmd = "help";
+ else
+ cmd = argv[1];
+
+ for (int i = 0; i < G_N_ELEMENTS (profile_commands); i++)
+ {
+ if (g_strcmp0 (cmd, profile_commands[i].name) == 0)
+ {
+ argc -= 1;
+ argv += 1;
+
+ if (!profile_commands[i].parse_args (argc, argv))
+ return EXIT_FAILURE;
+
+ return profile_commands[i].main ();
+ }
+ }
+
+ g_printerr ("Usage: eos-profile <COMMAND> [OPTIONS...]\n");
+
+ return EXIT_FAILURE;
+}