sysprof: add scaffolding for flamegraph

This commit is contained in:
Christian Hergert
2023-08-23 14:07:17 -07:00
parent 8588058a8f
commit 2cf6701adf
7 changed files with 322 additions and 49 deletions

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="16px"
viewBox="0 0 16 16"
width="16px"
version="1.1"
id="svg5033"
sodipodi:docname="threads-symbolic.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs5037" />
<sodipodi:namedview
id="namedview5035"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="4.3979077"
inkscape:cx="-115.1684"
inkscape:cy="34.902961"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg5033" />
<path
d="M 2.188,2 C 0.982,2 0,3.018 0,4.219 v 7.562 C 0,12.982 0.982,14 2.188,14 H 13.812 C 15.018,14 16,12.981999 16,11.781 V 4.22 C 16,3.018 15.018,2 13.812,2 Z m 0,2 H 13.812 C 13.932,4 14,4.08 14,4.219 v 7.562 C 14,11.919999 13.933,12 13.812,12 H 2.188 C 2.068,12 2,11.919999 2,11.781 V 4.22 C 2,4.08 2.067,4 2.188,4 Z"
style="font-weight:400;line-height:normal;-inkscape-font-specification:'Bitstream Vera Sans';text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;fill:#2e3436;marker:none"
color="#bebebe"
font-family="'Bitstream Vera Sans'"
overflow="visible"
id="path113" />
<path
d="m 3,9 h 1 v 2 H 3 Z m 0,0"
id="path5029"
style="stroke-width:0.392232" />
<path
d="m 5,5 h 1 v 6 H 5 Z m 0,0"
id="path5029-3"
style="stroke-width:0.679374" />
<path
d="m 7,8 h 1 v 3 H 7 Z m 0,0"
id="path5029-3-7"
style="stroke-width:0.48039" />
<path
d="m 9,6 h 1 v 5 H 9 Z m 0,0"
id="path5029-3-7-5"
style="stroke-width:0.620181" />
<path
d="m 3,10 h 10 v 1 H 3 Z m 0,0"
id="path5029-3-3"
style="stroke-width:0.877071" />
<path
d="m 12,8 h 1 v 3 h -1 z m 0,0"
id="path5029-3-3-6"
style="stroke-width:0.480391" />
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -20,6 +20,7 @@ sysprof_sources = [
'sysprof-energy-section.c',
'sysprof-entry-popover.c',
'sysprof-files-section.c',
'sysprof-flame-graph.c',
'sysprof-frame-utility.c',
'sysprof-graphics-section.c',
'sysprof-greeter.c',

View File

@ -0,0 +1,138 @@
/* sysprof-flame-graph.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-flame-graph.h"
struct _SysprofFlameGraph
{
GtkWidget parent_instance;
SysprofCallgraph *callgraph;
};
enum {
PROP_0,
PROP_CALLGRAPH,
N_PROPS
};
G_DEFINE_FINAL_TYPE (SysprofFlameGraph, sysprof_flame_graph, GTK_TYPE_WIDGET)
static GParamSpec *properties [N_PROPS];
static void
sysprof_flame_graph_dispose (GObject *object)
{
SysprofFlameGraph *self = (SysprofFlameGraph *)object;
g_clear_object (&self->callgraph);
G_OBJECT_CLASS (sysprof_flame_graph_parent_class)->dispose (object);
}
static void
sysprof_flame_graph_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SysprofFlameGraph *self = SYSPROF_FLAME_GRAPH (object);
switch (prop_id)
{
case PROP_CALLGRAPH:
g_value_set_object (value, sysprof_flame_graph_get_callgraph (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_flame_graph_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SysprofFlameGraph *self = SYSPROF_FLAME_GRAPH (object);
switch (prop_id)
{
case PROP_CALLGRAPH:
sysprof_flame_graph_set_callgraph (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_flame_graph_class_init (SysprofFlameGraphClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = sysprof_flame_graph_dispose;
object_class->get_property = sysprof_flame_graph_get_property;
object_class->set_property = sysprof_flame_graph_set_property;
properties[PROP_CALLGRAPH] =
g_param_spec_object ("callgraph", NULL, NULL,
SYSPROF_TYPE_CALLGRAPH,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
sysprof_flame_graph_init (SysprofFlameGraph *self)
{
}
GtkWidget *
sysprof_flame_graph_new (void)
{
return g_object_new (SYSPROF_TYPE_FLAME_GRAPH, NULL);
}
SysprofCallgraph *
sysprof_flame_graph_get_callgraph (SysprofFlameGraph *self)
{
g_return_val_if_fail (SYSPROF_IS_FLAME_GRAPH (self), NULL);
return self->callgraph;
}
void
sysprof_flame_graph_set_callgraph (SysprofFlameGraph *self,
SysprofCallgraph *callgraph)
{
g_return_if_fail (SYSPROF_IS_FLAME_GRAPH (self));
g_return_if_fail (!callgraph || SYSPROF_IS_CALLGRAPH (callgraph));
if (g_set_object (&self->callgraph, callgraph))
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CALLGRAPH]);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
}

View File

@ -0,0 +1,38 @@
/* sysprof-flame-graph.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.h>
G_BEGIN_DECLS
#define SYSPROF_TYPE_FLAME_GRAPH (sysprof_flame_graph_get_type())
G_DECLARE_FINAL_TYPE (SysprofFlameGraph, sysprof_flame_graph, SYSPROF, FLAME_GRAPH, GtkWidget)
GtkWidget *sysprof_flame_graph_new (void);
SysprofCallgraph *sysprof_flame_graph_get_callgraph (SysprofFlameGraph *self);
void sysprof_flame_graph_set_callgraph (SysprofFlameGraph *self,
SysprofCallgraph *callgraph);
G_END_DECLS

View File

@ -22,6 +22,7 @@
#include "sysprof-chart.h"
#include "sysprof-column-layer.h"
#include "sysprof-flame-graph.h"
#include "sysprof-sampled-model.h"
#include "sysprof-samples-section.h"
#include "sysprof-session-model-item.h"
@ -80,6 +81,7 @@ sysprof_samples_section_class_init (SysprofSamplesSectionClass *klass)
g_type_ensure (SYSPROF_TYPE_COLUMN_LAYER);
g_type_ensure (SYSPROF_TYPE_DOCUMENT_SAMPLE);
g_type_ensure (SYSPROF_TYPE_DOCUMENT_TRACEABLE);
g_type_ensure (SYSPROF_TYPE_FLAME_GRAPH);
g_type_ensure (SYSPROF_TYPE_SAMPLED_MODEL);
g_type_ensure (SYSPROF_TYPE_TIME_FILTER_MODEL);
g_type_ensure (SYSPROF_TYPE_TIME_SCRUBBER);

View File

@ -80,64 +80,91 @@
</object>
</child>
<child>
<object class="SysprofWeightedCallgraphView" id="callgraph_view">
<object class="AdwViewStack" id="stack">
<property name="vexpand">true</property>
<binding name="include-threads">
<lookup name="include-threads" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="hide-system-libraries">
<lookup name="hide-system-libraries" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="bottom-up">
<lookup name="bottom-up" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="categorize-frames">
<lookup name="categorize-frames" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="ignore-process-0">
<lookup name="ignore-process-0" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="document">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="traceables">
<object class="GtkFilterListModel">
<binding name="filter">
<lookup name="filter">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="model">
<object class="SysprofTimeFilterModel">
<property name="inclusive">false</property>
<binding name="time-span">
<lookup name="selected-time" type="SysprofSession">
<child>
<object class="AdwViewStackPage">
<property name="icon-name">threads-symbolic</property>
<property name="title" translatable="yes">Callgraph</property>
<property name="child">
<object class="SysprofWeightedCallgraphView" id="callgraph_view">
<property name="vexpand">true</property>
<binding name="include-threads">
<lookup name="include-threads" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="model">
<lookup name="samples" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
<binding name="hide-system-libraries">
<lookup name="hide-system-libraries" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="bottom-up">
<lookup name="bottom-up" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="categorize-frames">
<lookup name="categorize-frames" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="ignore-process-0">
<lookup name="ignore-process-0" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="document">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="traceables">
<object class="GtkFilterListModel">
<binding name="filter">
<lookup name="filter">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="model">
<object class="SysprofTimeFilterModel">
<property name="inclusive">false</property>
<binding name="time-span">
<lookup name="selected-time" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<binding name="model">
<lookup name="samples" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</property>
</object>
</property>
</object>
</property>
</child>
<child>
<object class="AdwViewStackPage">
<property name="icon-name">flamegraph-symbolic</property>
<property name="title" translatable="yes">Flame Graph</property>
<property name="child">
<object class="SysprofFlameGraph">
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwViewSwitcherBar" id="switcher">
<property name="reveal">true</property>
<property name="stack">stack</property>
</object>
</child>
</object>

View File

@ -7,6 +7,7 @@
<file preprocess="xml-stripblanks">icons/scalable/actions/dbus-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/empty-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/energy-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/flamegraph-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/graphics-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/mark-chart-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/mark-table-symbolic.svg</file>