mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: start indexing counter defines
And add a SysprofDocumentCounter that will represent each counter. Still to do is implementing the ctrdef type and a way to transform those into the individual counters.
This commit is contained in:
@ -2,6 +2,7 @@ libsysprof_analyze_public_sources = [
|
||||
'sysprof-bundled-symbolizer.c',
|
||||
'sysprof-document.c',
|
||||
'sysprof-document-allocation.c',
|
||||
'sysprof-document-counter.c',
|
||||
'sysprof-document-exit.c',
|
||||
'sysprof-document-file.c',
|
||||
'sysprof-document-file-chunk.c',
|
||||
@ -48,6 +49,7 @@ libsysprof_analyze_public_headers = [
|
||||
'sysprof-bundled-symbolizer.h',
|
||||
'sysprof-document.h',
|
||||
'sysprof-document-allocation.h',
|
||||
'sysprof-document-counter.h',
|
||||
'sysprof-document-exit.h',
|
||||
'sysprof-document-file.h',
|
||||
'sysprof-document-file-chunk.h',
|
||||
|
||||
@ -28,6 +28,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-bundled-symbolizer.h"
|
||||
# include "sysprof-document.h"
|
||||
# include "sysprof-document-allocation.h"
|
||||
# include "sysprof-document-counter.h"
|
||||
# include "sysprof-document-exit.h"
|
||||
# include "sysprof-document-file.h"
|
||||
# include "sysprof-document-file-chunk.h"
|
||||
|
||||
32
src/libsysprof-analyze/sysprof-document-counter-private.h
Normal file
32
src/libsysprof-analyze/sysprof-document-counter-private.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* sysprof-document-counter-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 "sysprof-document-counter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
SysprofDocumentCounter *_sysprof_document_counter_new (guint id,
|
||||
GRefString *category,
|
||||
GRefString *name,
|
||||
GRefString *description);
|
||||
|
||||
G_END_DECLS
|
||||
153
src/libsysprof-analyze/sysprof-document-counter.c
Normal file
153
src/libsysprof-analyze/sysprof-document-counter.c
Normal file
@ -0,0 +1,153 @@
|
||||
/* sysprof-document-counter.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-document-counter.h"
|
||||
|
||||
struct _SysprofDocumentCounter
|
||||
{
|
||||
GObject parent_instance;
|
||||
GRefString *category;
|
||||
GRefString *description;
|
||||
GRefString *name;
|
||||
guint id;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CATEGORY,
|
||||
PROP_DESCRIPTION,
|
||||
PROP_ID,
|
||||
PROP_NAME,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofDocumentCounter, sysprof_document_counter, G_TYPE_OBJECT)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_document_counter_finalize (GObject *object)
|
||||
{
|
||||
SysprofDocumentCounter *self = (SysprofDocumentCounter *)object;
|
||||
|
||||
g_clear_pointer (&self->category, g_ref_string_release);
|
||||
g_clear_pointer (&self->description, g_ref_string_release);
|
||||
g_clear_pointer (&self->name, g_ref_string_release);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_document_counter_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_counter_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofDocumentCounter *self = SYSPROF_DOCUMENT_COUNTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CATEGORY:
|
||||
g_value_set_string (value, sysprof_document_counter_get_category (self));
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
g_value_set_string (value, sysprof_document_counter_get_description (self));
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, sysprof_document_counter_get_name (self));
|
||||
break;
|
||||
|
||||
case PROP_ID:
|
||||
g_value_set_uint (value, sysprof_document_counter_get_id (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_counter_class_init (SysprofDocumentCounterClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_document_counter_finalize;
|
||||
object_class->get_property = sysprof_document_counter_get_property;
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_counter_init (SysprofDocumentCounter *self)
|
||||
{
|
||||
}
|
||||
|
||||
SysprofDocumentCounter *
|
||||
_sysprof_document_counter_new (guint id,
|
||||
GRefString *category,
|
||||
GRefString *name,
|
||||
GRefString *description)
|
||||
{
|
||||
SysprofDocumentCounter *self;
|
||||
|
||||
self = g_object_new (SYSPROF_TYPE_DOCUMENT_COUNTER, NULL);
|
||||
self->id = id;
|
||||
self->category = category;
|
||||
self->name = name;
|
||||
self->description = description;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_document_counter_get_category (SysprofDocumentCounter *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER (self), NULL);
|
||||
|
||||
return self->category;
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_document_counter_get_description (SysprofDocumentCounter *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER (self), NULL);
|
||||
|
||||
return self->description;
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_document_counter_get_name (SysprofDocumentCounter *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER (self), NULL);
|
||||
|
||||
return self->name;
|
||||
}
|
||||
|
||||
guint
|
||||
sysprof_document_counter_get_id (SysprofDocumentCounter *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_COUNTER (self), 0);
|
||||
|
||||
return self->id;
|
||||
}
|
||||
43
src/libsysprof-analyze/sysprof-document-counter.h
Normal file
43
src/libsysprof-analyze/sysprof-document-counter.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* sysprof-document-counter.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_DOCUMENT_COUNTER (sysprof_document_counter_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofDocumentCounter, sysprof_document_counter, SYSPROF, DOCUMENT_COUNTER, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_document_counter_get_category (SysprofDocumentCounter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_document_counter_get_description (SysprofDocumentCounter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_document_counter_get_name (SysprofDocumentCounter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sysprof_document_counter_get_id (SysprofDocumentCounter *self);
|
||||
|
||||
G_END_DECLS
|
||||
@ -27,6 +27,7 @@
|
||||
#include "sysprof-document-private.h"
|
||||
|
||||
#include "sysprof-document-bitset-index-private.h"
|
||||
#include "sysprof-document-counter-private.h"
|
||||
#include "sysprof-document-file-chunk.h"
|
||||
#include "sysprof-document-file-private.h"
|
||||
#include "sysprof-document-frame-private.h"
|
||||
@ -60,6 +61,7 @@ struct _SysprofDocument
|
||||
GtkBitset *overlays;
|
||||
GtkBitset *pids;
|
||||
GtkBitset *jitmaps;
|
||||
GtkBitset *ctrdefs;
|
||||
|
||||
GHashTable *files_first_position;
|
||||
GHashTable *pid_to_process_info;
|
||||
@ -198,6 +200,7 @@ sysprof_document_finalize (GObject *object)
|
||||
g_clear_pointer (&self->mapped_file, g_mapped_file_unref);
|
||||
g_clear_pointer (&self->frames, g_array_unref);
|
||||
|
||||
g_clear_pointer (&self->ctrdefs, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->file_chunks, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->jitmaps, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->mmaps, gtk_bitset_unref);
|
||||
@ -228,6 +231,7 @@ sysprof_document_init (SysprofDocument *self)
|
||||
|
||||
self->frames = g_array_new (FALSE, FALSE, sizeof (SysprofDocumentFramePointer));
|
||||
|
||||
self->ctrdefs = gtk_bitset_new_empty ();
|
||||
self->file_chunks = gtk_bitset_new_empty ();
|
||||
self->jitmaps = gtk_bitset_new_empty ();
|
||||
self->mmaps = gtk_bitset_new_empty ();
|
||||
@ -424,6 +428,24 @@ sysprof_document_load_overlays (SysprofDocument *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_load_counters (SysprofDocument *self)
|
||||
{
|
||||
GtkBitsetIter iter;
|
||||
guint i;
|
||||
|
||||
g_assert (SYSPROF_IS_DOCUMENT (self));
|
||||
|
||||
if (gtk_bitset_iter_init_first (&iter, self->ctrdefs, &i))
|
||||
{
|
||||
do
|
||||
{
|
||||
|
||||
}
|
||||
while (gtk_bitset_iter_next (&iter, &i));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_load_worker (GTask *task,
|
||||
gpointer source_object,
|
||||
@ -506,6 +528,10 @@ sysprof_document_load_worker (GTask *task,
|
||||
gtk_bitset_add (self->file_chunks, self->frames->len);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_CTRDEF:
|
||||
gtk_bitset_add (self->ctrdefs, self->frames->len);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_JITMAP:
|
||||
gtk_bitset_add (self->jitmaps, self->frames->len);
|
||||
break;
|
||||
@ -542,6 +568,7 @@ sysprof_document_load_worker (GTask *task,
|
||||
sysprof_document_load_mountinfos (self);
|
||||
sysprof_document_load_memory_maps (self);
|
||||
sysprof_document_load_overlays (self);
|
||||
sysprof_document_load_counters (self);
|
||||
|
||||
g_task_return_pointer (task, g_steal_pointer (&self), g_object_unref);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user