diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eos-profile-tool/eos-profile-utils.c | 51 | ||||
-rw-r--r-- | tools/eos-profile-tool/eos-profile-utils.h | 14 |
2 files changed, 65 insertions, 0 deletions
diff --git a/tools/eos-profile-tool/eos-profile-utils.c b/tools/eos-profile-tool/eos-profile-utils.c index 2d63804..483f375 100644 --- a/tools/eos-profile-tool/eos-profile-utils.c +++ b/tools/eos-profile-tool/eos-profile-utils.c @@ -2,6 +2,8 @@ #include "eos-profile-utils.h" +#include "endless/eosprofile-private.h" + #include <stdlib.h> #include <stdarg.h> #include <stdio.h> @@ -91,3 +93,52 @@ eos_profile_util_print_warning (const char *fmt, g_printerr ("%s\n", msg); } + +void +eos_profile_util_foreach_probe_v1 (GvdbTable *db, + EosProfileProbeCallback callback, + gpointer callback_data) +{ + int names_len = 0; + g_auto(GStrv) names = gvdb_table_get_names (db, &names_len); + + const char * const meta_keys[] = { + PROBE_DB_META_VERSION_KEY, + PROBE_DB_META_APPID_KEY, + PROBE_DB_META_PROFILE_KEY, + PROBE_DB_META_START_KEY, + NULL, + }; + + for (int i = 0; i < names_len; i++) + { + const char *key_name = names[i]; + + if (g_strv_contains (meta_keys, key_name)) + continue; + + if (!gvdb_table_has_value (db, key_name)) + continue; + + g_autoptr(GVariant) value = gvdb_table_get_raw_value (db, key_name); + if (value == NULL) + continue; + + const char *file = NULL; + const char *function = NULL; + const char *probe_name = NULL; + g_autoptr(GVariant) samples = NULL; + gint32 line, n_samples; + + g_variant_get (value, "(&s&s&suu@a(xx))", + &probe_name, + &function, + &file, + &line, + &n_samples, + &samples); + + if (!callback (probe_name, function, file, line, n_samples, samples, callback_data)) + break; + } +} diff --git a/tools/eos-profile-tool/eos-profile-utils.h b/tools/eos-profile-tool/eos-profile-utils.h index b6030c2..44d69f0 100644 --- a/tools/eos-profile-tool/eos-profile-utils.h +++ b/tools/eos-profile-tool/eos-profile-utils.h @@ -2,6 +2,8 @@ #include <glib.h> +#include "endless/gvdb/gvdb-reader.h" + typedef enum { EOS_PRINT_COLOR_GREEN, EOS_PRINT_COLOR_BLUE, @@ -21,3 +23,15 @@ void eos_profile_util_print_error (const char *msg, void eos_profile_util_print_warning (const char *msg, ...) G_GNUC_PRINTF (1, 2); + +typedef gboolean (* EosProfileProbeCallback) (const char *probe_name, + const char *function, + const char *file, + gint32 line, + gint32 n_samples, + GVariant *samples, + gpointer user_data); + +void eos_profile_util_foreach_probe_v1 (GvdbTable *db, + EosProfileProbeCallback callback, + gpointer callback_data); |