From 318e9e300c8c6766b6ff836eeab6480e215cddc9 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 27 May 2019 17:17:03 -0700 Subject: [PATCH] tools: add option to list files in capture --- src/tools/sysprof-dump.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/tools/sysprof-dump.c b/src/tools/sysprof-dump.c index 513f993a..719e38c0 100644 --- a/src/tools/sysprof-dump.c +++ b/src/tools/sysprof-dump.c @@ -18,23 +18,39 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#include "config.h" + #include #include #include #define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000) +static gboolean list_files = FALSE; +static const GOptionEntry main_entries[] = { + { "list-files", 'l', 0, G_OPTION_ARG_NONE, &list_files, "List files within the capture" }, + { 0 } +}; + gint main (gint argc, gchar *argv[]) { + g_autoptr(GOptionContext) context = g_option_context_new ("- dump capture data"); + g_autoptr(GError) error = NULL; SysprofCaptureReader *reader; SysprofCaptureFrameType type; GHashTable *ctrtypes; - GError *error = NULL; gint64 begin_time; gint64 end_time; + g_option_context_add_main_entries (context, main_entries, NULL); + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + g_printerr ("%s\n", error->message); + return EXIT_FAILURE; + } + if (argc != 2) { g_printerr ("usage: %s FILENAME\n", argv[0]); @@ -42,6 +58,17 @@ main (gint argc, } reader = sysprof_capture_reader_new (argv[1], &error); + + if (list_files) + { + g_auto(GStrv) files = sysprof_capture_reader_list_files (reader); + + for (guint i = 0; files[i]; i++) + g_print ("%s\n", files[i]); + + return EXIT_SUCCESS; + } + ctrtypes = g_hash_table_new (NULL, NULL); begin_time = sysprof_capture_reader_get_start_time (reader);