libsysprof-gtk: add SysprofMarkTable

This is a raw view of the marks in a session which should help for just
finding the information you care about when the visual model is too
cumbersome or lacks searching capabilities.
This commit is contained in:
Christian Hergert
2023-06-14 17:02:19 -07:00
parent be1d56f5db
commit 45465f7d9a
9 changed files with 515 additions and 0 deletions

View File

@ -13,6 +13,7 @@ libsysprof_gtk_testsuite_c_args = [
libsysprof_gtk_testsuite = {
'test-callgraph' : {'skip': true},
'test-mark-table' : {'skip': true},
}
libsysprof_gtk_testsuite_deps = [

View File

@ -0,0 +1,94 @@
/* test-callgraph.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <sysprof-analyze.h>
#include <sysprof-gtk.h>
static GMainLoop *main_loop;
static char *filename;
static const GOptionEntry entries[] = {
{ 0 }
};
int
main (int argc,
char *argv[])
{
g_autoptr(GOptionContext) context = g_option_context_new ("- show a callgraph");
g_autoptr(SysprofDocumentLoader) loader = NULL;
g_autoptr(SysprofDocument) document = NULL;
g_autoptr(SysprofSession) session = NULL;
g_autoptr(GError) error = NULL;
SysprofMarkTable *table;
GtkWindow *window;
sysprof_clock_init ();
gtk_init ();
adw_init ();
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error))
{
g_printerr ("%s\n", error->message);
return 1;
}
if (argc != 2)
{
g_print ("usage: %s [OPTIONS] CAPTURE_FILE\n", argv[0]);
return 1;
}
filename = argv[1];
main_loop = g_main_loop_new (NULL, FALSE);
loader = sysprof_document_loader_new (filename);
sysprof_document_loader_set_symbolizer (loader, sysprof_no_symbolizer_get ());
g_print ("Loading %s, ignoring embedded symbols...\n", filename);
if (!(document = sysprof_document_loader_load (loader, NULL, &error)))
g_error ("Failed to load document: %s", error->message);
session = sysprof_session_new (document);
window = g_object_new (GTK_TYPE_WINDOW,
"default-width", 800,
"default-height", 600,
NULL);
table = g_object_new (SYSPROF_TYPE_MARK_TABLE,
"session", session,
NULL);
g_signal_connect_swapped (window,
"close-request",
G_CALLBACK (g_main_loop_quit),
main_loop);
gtk_window_set_child (window, GTK_WIDGET (table));
gtk_window_present (window);
g_main_loop_run (main_loop);
return 0;
}