[sysprof] libsysprof-ui: allow switching to temporary allocations
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: allow switching to temporary allocations
- Date: Wed, 19 Feb 2020 03:21:11 +0000 (UTC)
commit 16e35c1fa62531a43fb3730c9a96afe546d775ce
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 18 19:20:38 2020 -0800
libsysprof-ui: allow switching to temporary allocations
src/libsysprof-ui/sysprof-memprof-page.c | 78 ++++++++
src/libsysprof-ui/sysprof-memprof-page.ui | 298 ++++++++++++++++++------------
2 files changed, 257 insertions(+), 119 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-memprof-page.c b/src/libsysprof-ui/sysprof-memprof-page.c
index afac1f2..1800efe 100644
--- a/src/libsysprof-ui/sysprof-memprof-page.c
+++ b/src/libsysprof-ui/sysprof-memprof-page.c
@@ -59,9 +59,14 @@ typedef struct
GtkTreeViewColumn *function_size_column;
GtkCellRendererText *function_size_cell;
GtkStack *stack;
+ GtkRadioButton *summary;
+ GtkRadioButton *all_allocs;
+ GtkRadioButton *temp_allocs;
GQueue *history;
+ SysprofMemprofMode mode;
+
guint profile_size;
guint loading;
} SysprofMemprofPagePrivate;
@@ -795,6 +800,7 @@ sysprof_memprof_page_generate_cb (GObject *object,
{
SysprofProfile *profile = (SysprofProfile *)object;
SysprofMemprofPage *self;
+ SysprofMemprofPagePrivate *priv;
g_autoptr(GTask) task = user_data;
g_autoptr(GError) error = NULL;
@@ -803,11 +809,14 @@ sysprof_memprof_page_generate_cb (GObject *object,
g_assert (G_IS_TASK (task));
self = g_task_get_source_object (task);
+ priv = sysprof_memprof_page_get_instance_private (self);
if (!sysprof_profile_generate_finish (profile, result, &error))
g_task_return_error (task, g_steal_pointer (&error));
else
sysprof_memprof_page_set_profile (self, SYSPROF_MEMPROF_PROFILE (profile));
+
+ gtk_stack_set_visible_child_name (priv->stack, "callgraph");
}
static void
@@ -820,6 +829,7 @@ sysprof_memprof_page_load_async (SysprofPage *page,
gpointer user_data)
{
SysprofMemprofPage *self = (SysprofMemprofPage *)page;
+ SysprofMemprofPagePrivate *priv = sysprof_memprof_page_get_instance_private (self);
g_autoptr(SysprofCaptureReader) copy = NULL;
g_autoptr(SysprofProfile) profile = NULL;
g_autoptr(GTask) task = NULL;
@@ -829,12 +839,15 @@ sysprof_memprof_page_load_async (SysprofPage *page,
g_assert (SYSPROF_IS_SELECTION (selection));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ gtk_stack_set_visible_child_name (priv->stack, "loading");
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, sysprof_memprof_page_load_async);
copy = sysprof_capture_reader_copy (reader);
profile = sysprof_memprof_profile_new_with_selection (selection);
+ sysprof_memprof_profile_set_mode (SYSPROF_MEMPROF_PROFILE (profile), priv->mode);
sysprof_profile_set_reader (profile, reader);
sysprof_profile_generate (profile,
cancellable,
@@ -853,6 +866,51 @@ sysprof_memprof_page_load_finish (SysprofPage *page,
return g_task_propagate_boolean (G_TASK (result), error);
}
+static void
+do_summary (SysprofMemprofPage *self)
+{
+#if 0
+ SysprofMemprofPagePrivate *priv = sysprof_memprof_page_get_instance_private (self);
+
+ g_assert (SYSPROF_IS_MEMPROF_PAGE (self));
+
+ gtk_stack_set_visible_child_name (priv->stack, "summary");
+#endif
+}
+
+static void
+do_allocs (SysprofMemprofPage *self,
+ SysprofMemprofMode mode)
+{
+ SysprofMemprofPagePrivate *priv = sysprof_memprof_page_get_instance_private (self);
+
+ g_assert (SYSPROF_IS_MEMPROF_PAGE (self));
+
+ priv->mode = mode;
+ sysprof_page_reload (SYSPROF_PAGE (self));
+}
+
+static void
+mode_notify_active (SysprofMemprofPage *self,
+ GParamSpec *pspec,
+ GtkRadioButton *button)
+{
+ SysprofMemprofPagePrivate *priv = sysprof_memprof_page_get_instance_private (self);
+
+ g_assert (SYSPROF_IS_MEMPROF_PAGE (self));
+ g_assert (GTK_IS_RADIO_BUTTON (button));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ {
+ if (button == priv->summary)
+ do_summary (self);
+ else if (button == priv->all_allocs)
+ do_allocs (self, SYSPROF_MEMPROF_MODE_ALL_ALLOCS);
+ else if (button == priv->temp_allocs)
+ do_allocs (self, SYSPROF_MEMPROF_MODE_TEMP_ALLOCS);
+ }
+}
+
static void
sysprof_memprof_page_finalize (GObject *object)
{
@@ -947,6 +1005,9 @@ sysprof_memprof_page_class_init (SysprofMemprofPageClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, descendants_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, descendants_name_column);
gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, stack);
+ gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, all_allocs);
+ gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, temp_allocs);
+ gtk_widget_class_bind_template_child_private (widget_class, SysprofMemprofPage, summary);
bindings = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (bindings, GDK_KEY_Left, GDK_MOD1_MASK, "go-previous", 0);
@@ -963,11 +1024,28 @@ sysprof_memprof_page_init (SysprofMemprofPage *self)
GtkCellRenderer *cell;
priv->history = g_queue_new ();
+ priv->mode = SYSPROF_MEMPROF_MODE_ALL_ALLOCS;
gtk_widget_init_template (GTK_WIDGET (self));
gtk_stack_set_visible_child_name (priv->stack, "empty-state");
+ g_signal_connect_object (priv->all_allocs,
+ "notify::active",
+ G_CALLBACK (mode_notify_active),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (priv->temp_allocs,
+ "notify::active",
+ G_CALLBACK (mode_notify_active),
+ self,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (priv->summary,
+ "notify::active",
+ G_CALLBACK (mode_notify_active),
+ self,
+ G_CONNECT_SWAPPED);
+
selection = gtk_tree_view_get_selection (priv->functions_view);
g_signal_connect_object (selection,
diff --git a/src/libsysprof-ui/sysprof-memprof-page.ui b/src/libsysprof-ui/sysprof-memprof-page.ui
index 66899bb..a93f253 100644
--- a/src/libsysprof-ui/sysprof-memprof-page.ui
+++ b/src/libsysprof-ui/sysprof-memprof-page.ui
@@ -4,100 +4,213 @@
<object class="GtkStack" id="stack">
<property name="visible">true</property>
<child>
- <object class="GtkPaned">
- <property name="orientation">horizontal</property>
- <property name="position">450</property>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">true</property>
+ <child type="center">
+ <object class="GtkBox">
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="orientation">horizontal</property>
+ <property name="homogeneous">true</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkRadioButton" id="summary">
+ <property name="label" translatable="yes">Summary</property>
+ <property name="draw-indicator">false</property>
+ <property name="visible">false</property>
+ <property name="active">false</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="all_allocs">
+ <property name="label" translatable="yes">All Allocations</property>
+ <property name="draw-indicator">false</property>
+ <property name="visible">true</property>
+ <property name="group">summary</property>
+ <property name="active">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="temp_allocs">
+ <property name="label" translatable="yes">Temporary Allocations</property>
+ <property name="draw-indicator">false</property>
+ <property name="visible">true</property>
+ <property name="active">false</property>
+ <property name="group">summary</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="orientation">horizontal</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
<child>
<object class="GtkPaned">
- <property name="orientation">vertical</property>
+ <property name="orientation">horizontal</property>
+ <property name="position">450</property>
+ <property name="expand">true</property>
<property name="visible">true</property>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkPaned">
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
- <object class="GtkTreeView" id="functions_view">
- <property name="fixed-height-mode">true</property>
+ <object class="GtkScrolledWindow">
<property name="visible">true</property>
<child>
- <object class="GtkTreeViewColumn" id="function_name_column">
- <property name="expand">true</property>
- <property name="sizing">fixed</property>
- <property name="sort-column-id">0</property>
- <property name="title" translatable="yes">Functions</property>
+ <object class="GtkTreeView" id="functions_view">
+ <property name="fixed-height-mode">true</property>
+ <property name="visible">true</property>
<child>
- <object class="GtkCellRendererText">
- <property name="ellipsize">middle</property>
+ <object class="GtkTreeViewColumn" id="function_name_column">
+ <property name="expand">true</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">0</property>
+ <property name="title" translatable="yes">Functions</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">middle</property>
+ </object>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
</child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="function_self_column">
- <property name="expand">false</property>
- <property name="sizing">fixed</property>
- <property name="sort-column-id">1</property>
- <property name="title" translatable="yes">Self</property>
<child>
- <object class="SysprofCellRendererPercent">
- <property name="width">65</property>
+ <object class="GtkTreeViewColumn" id="function_self_column">
+ <property name="visible">false</property>
+ <property name="expand">false</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">1</property>
+ <property name="title" translatable="yes">Self</property>
+ <child>
+ <object class="SysprofCellRendererPercent">
+ <property name="width">65</property>
+ </object>
+ <attributes>
+ <attribute name="percent">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="function_total_column">
+ <property name="expand">false</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">2</property>
+ <property name="title" translatable="yes">Total</property>
+ <child>
+ <object class="SysprofCellRendererPercent">
+ <property name="width">65</property>
+ </object>
+ <attributes>
+ <attribute name="percent">2</attribute>
+ </attributes>
+ </child>
</object>
- <attributes>
- <attribute name="percent">1</attribute>
- </attributes>
</child>
</object>
</child>
+ </object>
+ <packing>
+ <property name="resize">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">true</property>
<child>
- <object class="GtkTreeViewColumn" id="function_total_column">
- <property name="expand">false</property>
- <property name="sizing">fixed</property>
- <property name="sort-column-id">2</property>
- <property name="title" translatable="yes">Total</property>
+ <object class="GtkTreeView" id="callers_view">
+ <property name="visible">true</property>
<child>
- <object class="SysprofCellRendererPercent">
- <property name="width">65</property>
+ <object class="GtkTreeViewColumn" id="callers_name_column">
+ <property name="expand">true</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">0</property>
+ <property name="title" translatable="yes">Callers</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="ellipsize">middle</property>
+ </object>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="callers_self_column">
+ <property name="visible">false</property>
+ <property name="expand">false</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">1</property>
+ <property name="title" translatable="yes">Self</property>
+ <child>
+ <object class="SysprofCellRendererPercent">
+ <property name="width">65</property>
+ </object>
+ <attributes>
+ <attribute name="percent">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="callers_total_column">
+ <property name="expand">false</property>
+ <property name="sizing">fixed</property>
+ <property name="sort-column-id">2</property>
+ <property name="title" translatable="yes">Total</property>
+ <child>
+ <object class="SysprofCellRendererPercent">
+ <property name="width">65</property>
+ </object>
+ <attributes>
+ <attribute name="percent">2</attribute>
+ </attributes>
+ </child>
</object>
- <attributes>
- <attribute name="percent">2</attribute>
- </attributes>
</child>
</object>
</child>
</object>
+ <packing>
+ <property name="resize">true</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="resize">true</property>
- </packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">true</property>
<child>
- <object class="GtkTreeView" id="callers_view">
+ <object class="GtkTreeView" id="descendants_view">
<property name="visible">true</property>
<child>
- <object class="GtkTreeViewColumn" id="callers_name_column">
+ <object class="GtkTreeViewColumn" id="descendants_name_column">
<property name="expand">true</property>
- <property name="sizing">fixed</property>
+ <property name="sizing">autosize</property>
<property name="sort-column-id">0</property>
- <property name="title" translatable="yes">Callers</property>
- <child>
- <object class="GtkCellRendererText">
- <property name="ellipsize">middle</property>
- </object>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
+ <property name="title" translatable="yes">Descendants</property>
</object>
</child>
<child>
- <object class="GtkTreeViewColumn" id="callers_self_column">
+ <object class="GtkTreeViewColumn" id="descendants_self_column">
+ <property name="visible">false</property>
<property name="expand">false</property>
<property name="sizing">fixed</property>
<property name="sort-column-id">1</property>
@@ -113,7 +226,7 @@
</object>
</child>
<child>
- <object class="GtkTreeViewColumn" id="callers_total_column">
+ <object class="GtkTreeViewColumn" id="descendants_total_column">
<property name="expand">false</property>
<property name="sizing">fixed</property>
<property name="sort-column-id">2</property>
@@ -128,69 +241,16 @@
</child>
</object>
</child>
- </object>
- </child>
- </object>
- <packing>
- <property name="resize">true</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="visible">true</property>
- <child>
- <object class="GtkTreeView" id="descendants_view">
- <property name="visible">true</property>
- <child>
- <object class="GtkTreeViewColumn" id="descendants_name_column">
- <property name="expand">true</property>
- <property name="sizing">autosize</property>
- <property name="sort-column-id">0</property>
- <property name="title" translatable="yes">Descendants</property>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="descendants_self_column">
- <property name="expand">false</property>
- <property name="sizing">fixed</property>
- <property name="sort-column-id">1</property>
- <property name="title" translatable="yes">Self</property>
- <child>
- <object class="SysprofCellRendererPercent">
- <property name="width">65</property>
- </object>
- <attributes>
- <attribute name="percent">1</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="descendants_total_column">
- <property name="expand">false</property>
- <property name="sizing">fixed</property>
- <property name="sort-column-id">2</property>
- <property name="title" translatable="yes">Total</property>
- <child>
- <object class="SysprofCellRendererPercent">
- <property name="width">65</property>
- </object>
- <attributes>
- <attribute name="percent">2</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="function_size_column">
- <property name="expand">false</property>
- <property name="sizing">fixed</property>
- <property name="title" translatable="yes">Size</property>
<child>
- <object class="GtkCellRendererText" id="function_size_cell">
- <property name="xalign">1.0</property>
+ <object class="GtkTreeViewColumn" id="function_size_column">
+ <property name="expand">false</property>
+ <property name="sizing">fixed</property>
+ <property name="title" translatable="yes">Size</property>
+ <child>
+ <object class="GtkCellRendererText" id="function_size_cell">
+ <property name="xalign">1.0</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]