libsysprof-analyze: add some helper names to frames

This commit is contained in:
Christian Hergert
2023-07-13 17:41:20 -07:00
parent 7bc828035c
commit 36414c8ec3
6 changed files with 44 additions and 0 deletions

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <glib/gi18n.h>
#include "sysprof-document-frame-private.h" #include "sysprof-document-frame-private.h"
#include "sysprof-document-allocation.h" #include "sysprof-document-allocation.h"
@ -142,9 +144,12 @@ static void
sysprof_document_allocation_class_init (SysprofDocumentAllocationClass *klass) sysprof_document_allocation_class_init (SysprofDocumentAllocationClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
SysprofDocumentFrameClass *document_frame_class = SYSPROF_DOCUMENT_FRAME_CLASS (klass);
object_class->get_property = sysprof_document_allocation_get_property; object_class->get_property = sysprof_document_allocation_get_property;
document_frame_class->type_name = N_("Allocation");
/** /**
* SysprofDocumentAllocation:thread-id: * SysprofDocumentAllocation:thread-id:
* *

View File

@ -40,6 +40,7 @@ struct _SysprofDocumentFrame
struct _SysprofDocumentFrameClass struct _SysprofDocumentFrameClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
const char *type_name;
}; };
SysprofDocumentFrame *_sysprof_document_frame_new (GMappedFile *mapped, SysprofDocumentFrame *_sysprof_document_frame_new (GMappedFile *mapped,
@ -49,6 +50,9 @@ SysprofDocumentFrame *_sysprof_document_frame_new (GMappedFile *ma
gint64 begin_time, gint64 begin_time,
gint64 end_time); gint64 end_time);
#define SYSPROF_DOCUMENT_FRAME_GET_CLASS(obj) \
G_TYPE_INSTANCE_GET_CLASS(obj, SYSPROF_TYPE_DOCUMENT_FRAME, SysprofDocumentFrameClass)
#define SYSPROF_DOCUMENT_FRAME_ENDPTR(obj) \ #define SYSPROF_DOCUMENT_FRAME_ENDPTR(obj) \
(&((const guint8 *)SYSPROF_DOCUMENT_FRAME(obj)->frame)[SYSPROF_DOCUMENT_FRAME(obj)->frame_len]) (&((const guint8 *)SYSPROF_DOCUMENT_FRAME(obj)->frame)[SYSPROF_DOCUMENT_FRAME(obj)->frame_len])

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <glib/gi18n.h>
#include "sysprof-document-frame-private.h" #include "sysprof-document-frame-private.h"
#include "sysprof-document-allocation.h" #include "sysprof-document-allocation.h"
@ -45,11 +47,18 @@ enum {
PROP_PID, PROP_PID,
PROP_TIME, PROP_TIME,
PROP_TIME_OFFSET, PROP_TIME_OFFSET,
PROP_TYPE_NAME,
N_PROPS N_PROPS
}; };
static GParamSpec *properties[N_PROPS]; static GParamSpec *properties[N_PROPS];
static const char *
sysprof_document_frame_get_type_name (SysprofDocumentFrame *self)
{
return g_dgettext (GETTEXT_PACKAGE, SYSPROF_DOCUMENT_FRAME_GET_CLASS (self)->type_name);
}
static void static void
sysprof_document_frame_finalize (GObject *object) sysprof_document_frame_finalize (GObject *object)
{ {
@ -89,6 +98,10 @@ sysprof_document_frame_get_property (GObject *object,
g_value_set_int64 (value, sysprof_document_frame_get_time_offset (self)); g_value_set_int64 (value, sysprof_document_frame_get_time_offset (self));
break; break;
case PROP_TYPE_NAME:
g_value_set_static_string (value, sysprof_document_frame_get_type_name (self));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -102,6 +115,8 @@ sysprof_document_frame_class_init (SysprofDocumentFrameClass *klass)
object_class->finalize = sysprof_document_frame_finalize; object_class->finalize = sysprof_document_frame_finalize;
object_class->get_property = sysprof_document_frame_get_property; object_class->get_property = sysprof_document_frame_get_property;
klass->type_name = N_("Frame");
properties[PROP_CPU] = properties[PROP_CPU] =
g_param_spec_int ("cpu", NULL, NULL, g_param_spec_int ("cpu", NULL, NULL,
G_MININT32, G_MININT32,
@ -130,6 +145,11 @@ sysprof_document_frame_class_init (SysprofDocumentFrameClass *klass)
0, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties[PROP_TYPE_NAME] =
g_param_spec_string ("type-name", NULL, NULL,
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties); g_object_class_install_properties (object_class, N_PROPS, properties);
} }

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <glib/gi18n.h>
#include "sysprof-document-frame-private.h" #include "sysprof-document-frame-private.h"
#include "sysprof-document-log.h" #include "sysprof-document-log.h"
@ -76,9 +78,12 @@ static void
sysprof_document_log_class_init (SysprofDocumentLogClass *klass) sysprof_document_log_class_init (SysprofDocumentLogClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
SysprofDocumentFrameClass *document_frame_class = SYSPROF_DOCUMENT_FRAME_CLASS (klass);
object_class->get_property = sysprof_document_log_get_property; object_class->get_property = sysprof_document_log_get_property;
document_frame_class->type_name = N_("Log");
properties [PROP_SEVERITY] = properties [PROP_SEVERITY] =
g_param_spec_uint ("severity", NULL, NULL, g_param_spec_uint ("severity", NULL, NULL,
0, G_MAXUINT16, 0, 0, G_MAXUINT16, 0,

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <glib/gi18n.h>
#include "sysprof-document-frame-private.h" #include "sysprof-document-frame-private.h"
#include "sysprof-document-mark.h" #include "sysprof-document-mark.h"
@ -87,9 +89,12 @@ static void
sysprof_document_mark_class_init (SysprofDocumentMarkClass *klass) sysprof_document_mark_class_init (SysprofDocumentMarkClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
SysprofDocumentFrameClass *document_frame_class = SYSPROF_DOCUMENT_FRAME_CLASS (klass);
object_class->get_property = sysprof_document_mark_get_property; object_class->get_property = sysprof_document_mark_get_property;
document_frame_class->type_name = N_("Mark");
properties [PROP_DURATION] = properties [PROP_DURATION] =
g_param_spec_int64 ("duration", NULL, NULL, g_param_spec_int64 ("duration", NULL, NULL,
G_MININT64, G_MAXINT64, 0, G_MININT64, G_MAXINT64, 0,

View File

@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include <glib/gi18n.h>
#include "sysprof-document-frame-private.h" #include "sysprof-document-frame-private.h"
#include "sysprof-document-sample.h" #include "sysprof-document-sample.h"
@ -127,9 +129,12 @@ static void
sysprof_document_sample_class_init (SysprofDocumentSampleClass *klass) sysprof_document_sample_class_init (SysprofDocumentSampleClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
SysprofDocumentFrameClass *document_frame_class = SYSPROF_DOCUMENT_FRAME_CLASS (klass);
object_class->get_property = sysprof_document_sample_get_property; object_class->get_property = sysprof_document_sample_get_property;
document_frame_class->type_name = N_("Sample");
/** /**
* SysprofDocumentSample:thread-id: * SysprofDocumentSample:thread-id:
* *