mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 08:00:53 +00:00
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:
@ -2,6 +2,7 @@
|
|||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/libsysprof-gtk">
|
<gresource prefix="/libsysprof-gtk">
|
||||||
<file preprocess="xml-stripblanks">sysprof-callgraph-view.ui</file>
|
<file preprocess="xml-stripblanks">sysprof-callgraph-view.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">sysprof-mark-table.ui</file>
|
||||||
<file preprocess="xml-stripblanks">sysprof-weighted-callgraph-view.ui</file>
|
<file preprocess="xml-stripblanks">sysprof-weighted-callgraph-view.ui</file>
|
||||||
<file>style.css</file>
|
<file>style.css</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
libsysprof_gtk_public_sources = [
|
libsysprof_gtk_public_sources = [
|
||||||
'sysprof-callgraph-view.c',
|
'sysprof-callgraph-view.c',
|
||||||
|
'sysprof-mark-table.c',
|
||||||
'sysprof-session.c',
|
'sysprof-session.c',
|
||||||
'sysprof-weighted-callgraph-view.c',
|
'sysprof-weighted-callgraph-view.c',
|
||||||
]
|
]
|
||||||
@ -15,6 +16,7 @@ libsysprof_gtk_public_headers = [
|
|||||||
'sysprof-gtk.h',
|
'sysprof-gtk.h',
|
||||||
|
|
||||||
'sysprof-callgraph-view.h',
|
'sysprof-callgraph-view.h',
|
||||||
|
'sysprof-mark-table.h',
|
||||||
'sysprof-session.h',
|
'sysprof-session.h',
|
||||||
'sysprof-weighted-callgraph-view.h',
|
'sysprof-weighted-callgraph-view.h',
|
||||||
]
|
]
|
||||||
|
|||||||
@ -62,3 +62,11 @@ callgraphview row:not(:selected) treeexpander symbol.unwindable {
|
|||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
background-color: alpha(@error_color, .1);
|
background-color: alpha(@error_color, .1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
marktable {
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
marktable row:nth-child(odd):not(:selected) {
|
||||||
|
background-color: alpha(currentColor, .05);
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#define SYSPROF_GTK_INSIDE
|
#define SYSPROF_GTK_INSIDE
|
||||||
# include "sysprof-callgraph-view.h"
|
# include "sysprof-callgraph-view.h"
|
||||||
|
# include "sysprof-mark-table.h"
|
||||||
# include "sysprof-session.h"
|
# include "sysprof-session.h"
|
||||||
# include "sysprof-weighted-callgraph-view.h"
|
# include "sysprof-weighted-callgraph-view.h"
|
||||||
#undef SYSPROF_GTK_INSIDE
|
#undef SYSPROF_GTK_INSIDE
|
||||||
|
|||||||
208
src/libsysprof-gtk/sysprof-mark-table.c
Normal file
208
src/libsysprof-gtk/sysprof-mark-table.c
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/* sysprof-mark-table.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 "sysprof-css-private.h"
|
||||||
|
#include "sysprof-mark-table.h"
|
||||||
|
#include "sysprof-time-label-private.h"
|
||||||
|
|
||||||
|
#include "libsysprof-gtk-resources.h"
|
||||||
|
|
||||||
|
struct _SysprofMarkTable
|
||||||
|
{
|
||||||
|
GtkWidget parent_instance;
|
||||||
|
|
||||||
|
SysprofSession *session;
|
||||||
|
|
||||||
|
GtkWidget *box;
|
||||||
|
GtkColumnView *column_view;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_SESSION,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE (SysprofMarkTable, sysprof_mark_table, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_disconnect (SysprofMarkTable *self)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_MARK_TABLE (self));
|
||||||
|
g_assert (SYSPROF_IS_SESSION (self->session));
|
||||||
|
|
||||||
|
gtk_column_view_set_model (self->column_view, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_connect (SysprofMarkTable *self)
|
||||||
|
{
|
||||||
|
g_autoptr(GtkSingleSelection) single = NULL;
|
||||||
|
GtkFilterListModel *model;
|
||||||
|
SysprofDocument *document;
|
||||||
|
|
||||||
|
g_assert (SYSPROF_IS_MARK_TABLE (self));
|
||||||
|
g_assert (SYSPROF_IS_SESSION (self->session));
|
||||||
|
|
||||||
|
document = sysprof_session_get_document (self->session);
|
||||||
|
model = gtk_filter_list_model_new (sysprof_document_list_marks (document), NULL);
|
||||||
|
g_object_bind_property (self->session, "filter", model, "filter",
|
||||||
|
G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
|
single = gtk_single_selection_new (G_LIST_MODEL (g_steal_pointer (&model)));
|
||||||
|
|
||||||
|
gtk_column_view_set_model (self->column_view, GTK_SELECTION_MODEL (single));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
SysprofMarkTable *self = (SysprofMarkTable *)object;
|
||||||
|
|
||||||
|
if (self->session)
|
||||||
|
{
|
||||||
|
sysprof_mark_table_disconnect (self);
|
||||||
|
g_clear_object (&self->session);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_pointer (&self->box, gtk_widget_unparent);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (sysprof_mark_table_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofMarkTable *self = SYSPROF_MARK_TABLE (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SESSION:
|
||||||
|
g_value_set_object (value, sysprof_mark_table_get_session (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofMarkTable *self = SYSPROF_MARK_TABLE (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SESSION:
|
||||||
|
sysprof_mark_table_set_session (self, g_value_get_object (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_class_init (SysprofMarkTableClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = sysprof_mark_table_dispose;
|
||||||
|
object_class->get_property = sysprof_mark_table_get_property;
|
||||||
|
object_class->set_property = sysprof_mark_table_set_property;
|
||||||
|
|
||||||
|
properties [PROP_SESSION] =
|
||||||
|
g_param_spec_object ("session", NULL, NULL,
|
||||||
|
SYSPROF_TYPE_SESSION,
|
||||||
|
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class, "/libsysprof-gtk/sysprof-mark-table.ui");
|
||||||
|
gtk_widget_class_set_css_name (widget_class, "marktable");
|
||||||
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, SysprofMarkTable, box);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, SysprofMarkTable, column_view);
|
||||||
|
|
||||||
|
g_resources_register (libsysprof_gtk_get_resource ());
|
||||||
|
|
||||||
|
g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK);
|
||||||
|
g_type_ensure (SYSPROF_TYPE_TIME_LABEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_table_init (SysprofMarkTable *self)
|
||||||
|
{
|
||||||
|
_sysprof_css_init ();
|
||||||
|
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
sysprof_mark_table_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (SYSPROF_TYPE_MARK_TABLE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_mark_table_get_session:
|
||||||
|
* @self: a #SysprofMarkTable
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (nullable): a #SysprofSession or %NULL
|
||||||
|
*/
|
||||||
|
SysprofSession *
|
||||||
|
sysprof_mark_table_get_session (SysprofMarkTable *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_MARK_TABLE (self), NULL);
|
||||||
|
|
||||||
|
return self->session;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sysprof_mark_table_set_session (SysprofMarkTable *self,
|
||||||
|
SysprofSession *session)
|
||||||
|
{
|
||||||
|
g_return_if_fail (SYSPROF_IS_MARK_TABLE (self));
|
||||||
|
g_return_if_fail (!session || SYSPROF_IS_SESSION (session));
|
||||||
|
|
||||||
|
if (self->session == session)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (self->session)
|
||||||
|
sysprof_mark_table_disconnect (self);
|
||||||
|
|
||||||
|
g_set_object (&self->session, session);
|
||||||
|
|
||||||
|
if (session)
|
||||||
|
sysprof_mark_table_connect (self);
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SESSION]);
|
||||||
|
}
|
||||||
44
src/libsysprof-gtk/sysprof-mark-table.h
Normal file
44
src/libsysprof-gtk/sysprof-mark-table.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* sysprof-mark-table.h
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include <sysprof-analyze.h>
|
||||||
|
|
||||||
|
#include "sysprof-session.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SYSPROF_TYPE_MARK_TABLE (sysprof_mark_table_get_type())
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
G_DECLARE_FINAL_TYPE (SysprofMarkTable, sysprof_mark_table, SYSPROF, MARK_TABLE, GtkWidget)
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GtkWidget *sysprof_mark_table_new (void);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
SysprofSession *sysprof_mark_table_get_session (SysprofMarkTable *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
void sysprof_mark_table_set_session (SysprofMarkTable *self,
|
||||||
|
SysprofSession *session);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
156
src/libsysprof-gtk/sysprof-mark-table.ui
Normal file
156
src/libsysprof-gtk/sysprof-mark-table.ui
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="SysprofMarkTable" parent="GtkWidget">
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="box">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScrolledWindow">
|
||||||
|
<property name="vexpand">true</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnView" id="column_view">
|
||||||
|
<style>
|
||||||
|
<class name="data-table"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnViewColumn" id="start_column">
|
||||||
|
<property name="title" translatable="yes">Start</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="SysprofTimeLabel">
|
||||||
|
<binding name="time-offset">
|
||||||
|
<lookup name="time-offset" type="SysprofDocumentFrame">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnViewColumn" id="duration_column">
|
||||||
|
<property name="title" translatable="yes">Duration</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="SysprofTimeLabel">
|
||||||
|
<binding name="duration">
|
||||||
|
<lookup name="duration" type="SysprofDocumentMark">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnViewColumn" id="group_column">
|
||||||
|
<property name="title" translatable="yes">Group</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<binding name="label">
|
||||||
|
<lookup name="group" type="SysprofDocumentMark">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnViewColumn" id="name_column">
|
||||||
|
<property name="title" translatable="yes">Type</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<binding name="label">
|
||||||
|
<lookup name="name" type="SysprofDocumentMark">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColumnViewColumn" id="description_column">
|
||||||
|
<property name="title" translatable="yes">Description</property>
|
||||||
|
<property name="expand">true</property>
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory">
|
||||||
|
<property name="bytes"><![CDATA[
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<binding name="label">
|
||||||
|
<lookup name="message" type="SysprofDocumentMark">
|
||||||
|
<lookup name="item">GtkListItem</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
|
]]>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
||||||
@ -13,6 +13,7 @@ libsysprof_gtk_testsuite_c_args = [
|
|||||||
|
|
||||||
libsysprof_gtk_testsuite = {
|
libsysprof_gtk_testsuite = {
|
||||||
'test-callgraph' : {'skip': true},
|
'test-callgraph' : {'skip': true},
|
||||||
|
'test-mark-table' : {'skip': true},
|
||||||
}
|
}
|
||||||
|
|
||||||
libsysprof_gtk_testsuite_deps = [
|
libsysprof_gtk_testsuite_deps = [
|
||||||
|
|||||||
94
src/libsysprof-gtk/tests/test-mark-table.c
Normal file
94
src/libsysprof-gtk/tests/test-mark-table.c
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user