libsysprof-analyze: create arrays for counter values

And assign them to the SysprofDocumentCounter so that they can pick them
up once we index/add them during counter loading of ctrset.
This commit is contained in:
Christian Hergert
2023-05-22 15:32:31 -07:00
parent 8f98af9b12
commit c3a5771da0
3 changed files with 20 additions and 3 deletions

View File

@ -28,6 +28,7 @@ SysprofDocumentCounter *_sysprof_document_counter_new (guint id,
guint type, guint type,
GRefString *category, GRefString *category,
GRefString *name, GRefString *name,
GRefString *description); GRefString *description,
GArray *values);
G_END_DECLS G_END_DECLS

View File

@ -28,6 +28,7 @@ struct _SysprofDocumentCounter
GRefString *category; GRefString *category;
GRefString *description; GRefString *description;
GRefString *name; GRefString *name;
GArray *values;
guint id; guint id;
guint type; guint type;
}; };
@ -53,6 +54,7 @@ sysprof_document_counter_finalize (GObject *object)
g_clear_pointer (&self->category, g_ref_string_release); g_clear_pointer (&self->category, g_ref_string_release);
g_clear_pointer (&self->description, g_ref_string_release); g_clear_pointer (&self->description, g_ref_string_release);
g_clear_pointer (&self->name, g_ref_string_release); g_clear_pointer (&self->name, g_ref_string_release);
g_clear_pointer (&self->values, g_array_unref);
G_OBJECT_CLASS (sysprof_document_counter_parent_class)->finalize (object); G_OBJECT_CLASS (sysprof_document_counter_parent_class)->finalize (object);
} }
@ -129,7 +131,8 @@ _sysprof_document_counter_new (guint id,
guint type, guint type,
GRefString *category, GRefString *category,
GRefString *name, GRefString *name,
GRefString *description) GRefString *description,
GArray *values)
{ {
SysprofDocumentCounter *self; SysprofDocumentCounter *self;
@ -139,6 +142,7 @@ _sysprof_document_counter_new (guint id,
self->category = category; self->category = category;
self->name = name; self->name = name;
self->description = description; self->description = description;
self->values = values;
return self; return self;
} }

View File

@ -52,7 +52,9 @@ struct _SysprofDocument
GArray *frames; GArray *frames;
GMappedFile *mapped_file; GMappedFile *mapped_file;
const guint8 *base; const guint8 *base;
GListStore *counters; GListStore *counters;
GHashTable *counter_id_to_values;
SysprofStrings *strings; SysprofStrings *strings;
@ -212,6 +214,8 @@ sysprof_document_finalize (GObject *object)
g_clear_pointer (&self->traceables, gtk_bitset_unref); g_clear_pointer (&self->traceables, gtk_bitset_unref);
g_clear_object (&self->counters); g_clear_object (&self->counters);
g_clear_pointer (&self->counter_id_to_values, g_hash_table_unref);
g_clear_object (&self->mount_namespace); g_clear_object (&self->mount_namespace);
g_clear_object (&self->symbols); g_clear_object (&self->symbols);
@ -235,6 +239,8 @@ sysprof_document_init (SysprofDocument *self)
self->frames = g_array_new (FALSE, FALSE, sizeof (SysprofDocumentFramePointer)); self->frames = g_array_new (FALSE, FALSE, sizeof (SysprofDocumentFramePointer));
self->counters = g_list_store_new (SYSPROF_TYPE_DOCUMENT_COUNTER); self->counters = g_list_store_new (SYSPROF_TYPE_DOCUMENT_COUNTER);
self->counter_id_to_values = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify)g_array_unref);
self->ctrdefs = gtk_bitset_new_empty (); self->ctrdefs = gtk_bitset_new_empty ();
self->file_chunks = gtk_bitset_new_empty (); self->file_chunks = gtk_bitset_new_empty ();
@ -453,6 +459,7 @@ sysprof_document_load_counters (SysprofDocument *self)
for (guint j = 0; j < n_counters; j++) for (guint j = 0; j < n_counters; j++)
{ {
g_autoptr(GArray) values = g_array_new (FALSE, FALSE, 8);
const char *category; const char *category;
const char *name; const char *name;
const char *description; const char *description;
@ -461,12 +468,17 @@ sysprof_document_load_counters (SysprofDocument *self)
sysprof_document_ctrdef_get_counter (ctrdef, j, &id, &type, &category, &name, &description); sysprof_document_ctrdef_get_counter (ctrdef, j, &id, &type, &category, &name, &description);
g_hash_table_insert (self->counter_id_to_values,
GUINT_TO_POINTER (id),
g_array_ref (values));
g_ptr_array_add (counters, g_ptr_array_add (counters,
_sysprof_document_counter_new (id, _sysprof_document_counter_new (id,
type, type,
sysprof_strings_get (self->strings, category), sysprof_strings_get (self->strings, category),
sysprof_strings_get (self->strings, name), sysprof_strings_get (self->strings, name),
sysprof_strings_get (self->strings, description))); sysprof_strings_get (self->strings, description),
g_steal_pointer (&values)));
} }
} }
while (gtk_bitset_iter_next (&iter, &i)); while (gtk_bitset_iter_next (&iter, &i));