From 0c51dff12474b4981d970b7ad7a30c11b91cafb8 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 10 Jul 2023 14:23:15 -0700 Subject: [PATCH] sysprof: add memory allocations section Still a bunch to do here to restore what we had previously, but this gets the section into place. --- src/sysprof/meson.build | 1 + src/sysprof/sysprof-memory-section.c | 68 +++++++++++++++++++++++++++ src/sysprof/sysprof-memory-section.h | 31 ++++++++++++ src/sysprof/sysprof-memory-section.ui | 40 ++++++++++++++++ src/sysprof/sysprof-window.c | 2 + src/sysprof/sysprof-window.ui | 8 ++++ src/sysprof/sysprof.gresource.xml | 1 + 7 files changed, 151 insertions(+) create mode 100644 src/sysprof/sysprof-memory-section.c create mode 100644 src/sysprof/sysprof-memory-section.h create mode 100644 src/sysprof/sysprof-memory-section.ui diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build index dcb653c0..854b46ff 100644 --- a/src/sysprof/meson.build +++ b/src/sysprof/meson.build @@ -5,6 +5,7 @@ sysprof_sources = [ 'sysprof-greeter.c', 'sysprof-logs-section.c', 'sysprof-marks-section.c', + 'sysprof-memory-section.c', 'sysprof-metadata-section.c', 'sysprof-processes-section.c', 'sysprof-recording-pad.c', diff --git a/src/sysprof/sysprof-memory-section.c b/src/sysprof/sysprof-memory-section.c new file mode 100644 index 00000000..1281e96e --- /dev/null +++ b/src/sysprof/sysprof-memory-section.c @@ -0,0 +1,68 @@ +/* sysprof-memory-section.c + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "config.h" + +#include + +#include "sysprof-memory-section.h" + +struct _SysprofMemorySection +{ + SysprofSection parent_instance; + + SysprofWeightedCallgraphView *callgraph_view; +}; + +G_DEFINE_FINAL_TYPE (SysprofMemorySection, sysprof_memory_section, SYSPROF_TYPE_SECTION) + +static void +sysprof_memory_section_dispose (GObject *object) +{ + SysprofMemorySection *self = (SysprofMemorySection *)object; + + gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_MEMORY_SECTION); + + G_OBJECT_CLASS (sysprof_memory_section_parent_class)->dispose (object); +} + +static void +sysprof_memory_section_class_init (SysprofMemorySectionClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->dispose = sysprof_memory_section_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-memory-section.ui"); + gtk_widget_class_bind_template_child (widget_class, SysprofMemorySection, callgraph_view); + + g_type_ensure (SYSPROF_TYPE_CHART); + g_type_ensure (SYSPROF_TYPE_XY_SERIES); + g_type_ensure (SYSPROF_TYPE_COLUMN_LAYER); + g_type_ensure (SYSPROF_TYPE_VALUE_AXIS); + g_type_ensure (SYSPROF_TYPE_MEMORY_CALLGRAPH_VIEW); +} + +static void +sysprof_memory_section_init (SysprofMemorySection *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} diff --git a/src/sysprof/sysprof-memory-section.h b/src/sysprof/sysprof-memory-section.h new file mode 100644 index 00000000..a437d2e7 --- /dev/null +++ b/src/sysprof/sysprof-memory-section.h @@ -0,0 +1,31 @@ +/* sysprof-memory-section.h + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "sysprof-section.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_MEMORY_SECTION (sysprof_memory_section_get_type()) + +G_DECLARE_FINAL_TYPE (SysprofMemorySection, sysprof_memory_section, SYSPROF, MEMORY_SECTION, SysprofSection) + +G_END_DECLS diff --git a/src/sysprof/sysprof-memory-section.ui b/src/sysprof/sysprof-memory-section.ui new file mode 100644 index 00000000..7cccaaf7 --- /dev/null +++ b/src/sysprof/sysprof-memory-section.ui @@ -0,0 +1,40 @@ + + + + + diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c index b3d95f59..5f54e8e1 100644 --- a/src/sysprof/sysprof-window.c +++ b/src/sysprof/sysprof-window.c @@ -28,6 +28,7 @@ #include "sysprof-greeter.h" #include "sysprof-logs-section.h" #include "sysprof-marks-section.h" +#include "sysprof-memory-section.h" #include "sysprof-metadata-section.h" #include "sysprof-processes-section.h" #include "sysprof-samples-section.h" @@ -199,6 +200,7 @@ sysprof_window_class_init (SysprofWindowClass *klass) g_type_ensure (SYSPROF_TYPE_FILES_SECTION); g_type_ensure (SYSPROF_TYPE_LOGS_SECTION); g_type_ensure (SYSPROF_TYPE_MARKS_SECTION); + g_type_ensure (SYSPROF_TYPE_MEMORY_SECTION); g_type_ensure (SYSPROF_TYPE_METADATA_SECTION); g_type_ensure (SYSPROF_TYPE_PROCESSES_SECTION); g_type_ensure (SYSPROF_TYPE_SAMPLES_SECTION); diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index 72416072..c2d8d9b0 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -105,6 +105,14 @@ + + + callgraph + + SysprofWindow + + + processes diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index 6bea8c39..655506b9 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -7,6 +7,7 @@ sysprof-greeter.ui sysprof-logs-section.ui sysprof-marks-section.ui + sysprof-memory-section.ui sysprof-metadata-section.ui sysprof-processes-section.ui sysprof-recording-pad.ui