mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-analyze: add SysprofMarkCatalog
This will get used to group marks together by group->name->marks from the SysprofDocument.
This commit is contained in:
@ -27,6 +27,7 @@ libsysprof_analyze_public_sources = [
|
|||||||
'sysprof-elf-symbolizer.c',
|
'sysprof-elf-symbolizer.c',
|
||||||
'sysprof-jitmap-symbolizer.c',
|
'sysprof-jitmap-symbolizer.c',
|
||||||
'sysprof-kallsyms-symbolizer.c',
|
'sysprof-kallsyms-symbolizer.c',
|
||||||
|
'sysprof-mark-catalog.c',
|
||||||
'sysprof-multi-symbolizer.c',
|
'sysprof-multi-symbolizer.c',
|
||||||
'sysprof-no-symbolizer.c',
|
'sysprof-no-symbolizer.c',
|
||||||
'sysprof-symbol.c',
|
'sysprof-symbol.c',
|
||||||
@ -78,6 +79,7 @@ libsysprof_analyze_public_headers = [
|
|||||||
'sysprof-elf-symbolizer.h',
|
'sysprof-elf-symbolizer.h',
|
||||||
'sysprof-jitmap-symbolizer.h',
|
'sysprof-jitmap-symbolizer.h',
|
||||||
'sysprof-kallsyms-symbolizer.h',
|
'sysprof-kallsyms-symbolizer.h',
|
||||||
|
'sysprof-mark-catalog.h',
|
||||||
'sysprof-mount.h',
|
'sysprof-mount.h',
|
||||||
'sysprof-multi-symbolizer.h',
|
'sysprof-multi-symbolizer.h',
|
||||||
'sysprof-no-symbolizer.h',
|
'sysprof-no-symbolizer.h',
|
||||||
|
|||||||
@ -53,6 +53,7 @@ G_BEGIN_DECLS
|
|||||||
# include "sysprof-elf-symbolizer.h"
|
# include "sysprof-elf-symbolizer.h"
|
||||||
# include "sysprof-jitmap-symbolizer.h"
|
# include "sysprof-jitmap-symbolizer.h"
|
||||||
# include "sysprof-kallsyms-symbolizer.h"
|
# include "sysprof-kallsyms-symbolizer.h"
|
||||||
|
# include "sysprof-mark-catalog.h"
|
||||||
# include "sysprof-mount.h"
|
# include "sysprof-mount.h"
|
||||||
# include "sysprof-multi-symbolizer.h"
|
# include "sysprof-multi-symbolizer.h"
|
||||||
# include "sysprof-no-symbolizer.h"
|
# include "sysprof-no-symbolizer.h"
|
||||||
|
|||||||
32
src/libsysprof-analyze/sysprof-mark-catalog-private.h
Normal file
32
src/libsysprof-analyze/sysprof-mark-catalog-private.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* sysprof-mark-catalog-private.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 <gio/gio.h>
|
||||||
|
|
||||||
|
#include "sysprof-mark-catalog.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
SysprofMarkCatalog *_sysprof_mark_catalog_new (const char *name,
|
||||||
|
GListModel *items);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
143
src/libsysprof-analyze/sysprof-mark-catalog.c
Normal file
143
src/libsysprof-analyze/sysprof-mark-catalog.c
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/* sysprof-mark-catalog.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-mark-catalog-private.h"
|
||||||
|
|
||||||
|
struct _SysprofMarkCatalog
|
||||||
|
{
|
||||||
|
GObject parent_instance;
|
||||||
|
GListModel *items;
|
||||||
|
char *name;
|
||||||
|
} SysprofMarkCatalogPrivate;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_NAME,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
static GType
|
||||||
|
sysprof_mark_catalog_get_item_type (GListModel *model)
|
||||||
|
{
|
||||||
|
return g_list_model_get_item_type (SYSPROF_MARK_CATALOG (model)->items);
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
sysprof_mark_catalog_get_n_items (GListModel *model)
|
||||||
|
{
|
||||||
|
return g_list_model_get_n_items (SYSPROF_MARK_CATALOG (model)->items);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
sysprof_mark_catalog_get_item (GListModel *model,
|
||||||
|
guint position)
|
||||||
|
{
|
||||||
|
return g_list_model_get_item (SYSPROF_MARK_CATALOG (model)->items, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_model_iface_init (GListModelInterface *iface)
|
||||||
|
{
|
||||||
|
iface->get_n_items = sysprof_mark_catalog_get_n_items;
|
||||||
|
iface->get_item_type = sysprof_mark_catalog_get_item_type;
|
||||||
|
iface->get_item = sysprof_mark_catalog_get_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofMarkCatalog, sysprof_mark_catalog, G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_catalog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
SysprofMarkCatalog *self = (SysprofMarkCatalog *)object;
|
||||||
|
|
||||||
|
g_clear_pointer (&self->name, g_free);
|
||||||
|
g_clear_object (&self->items);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (sysprof_mark_catalog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_catalog_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofMarkCatalog *self = SYSPROF_MARK_CATALOG (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, sysprof_mark_catalog_get_name (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_catalog_class_init (SysprofMarkCatalogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = sysprof_mark_catalog_dispose;
|
||||||
|
object_class->get_property = sysprof_mark_catalog_get_property;
|
||||||
|
|
||||||
|
properties[PROP_NAME] =
|
||||||
|
g_param_spec_string ("name", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_catalog_init (SysprofMarkCatalog *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_mark_catalog_get_name (SysprofMarkCatalog *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_MARK_CATALOG (self), NULL);
|
||||||
|
|
||||||
|
return self->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
SysprofMarkCatalog *
|
||||||
|
_sysprof_mark_catalog_new (const char *name,
|
||||||
|
GListModel *items)
|
||||||
|
{
|
||||||
|
SysprofMarkCatalog *self;
|
||||||
|
|
||||||
|
g_return_val_if_fail (name != NULL, NULL);
|
||||||
|
g_return_val_if_fail (G_IS_LIST_MODEL (items), NULL);
|
||||||
|
|
||||||
|
self = g_object_new (SYSPROF_TYPE_MARK_CATALOG, NULL);
|
||||||
|
self->name = g_strdup (name);
|
||||||
|
self->items = g_object_ref (items);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
37
src/libsysprof-analyze/sysprof-mark-catalog.h
Normal file
37
src/libsysprof-analyze/sysprof-mark-catalog.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* sysprof-mark-catalog.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 <glib-object.h>
|
||||||
|
|
||||||
|
#include <sysprof-capture.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SYSPROF_TYPE_MARK_CATALOG (sysprof_mark_catalog_get_type())
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
G_DECLARE_FINAL_TYPE (SysprofMarkCatalog, sysprof_mark_catalog, SYSPROF, MARK_CATALOG, GObject)
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const char *sysprof_mark_catalog_get_name (SysprofMarkCatalog *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
Reference in New Issue
Block a user