libsysprof-analyze: move stack-depth to SysprofDocumentTraceable

This makes the property for depth a requirement, which will allow for
easier quierying from various listmodel filters.
This commit is contained in:
Christian Hergert
2023-04-28 13:16:07 -07:00
parent 8c5b4720c0
commit 760d573f92
4 changed files with 50 additions and 22 deletions

View File

@ -40,6 +40,7 @@ enum {
PROP_ADDRESS, PROP_ADDRESS,
PROP_IS_FREE, PROP_IS_FREE,
PROP_SIZE, PROP_SIZE,
PROP_STACK_DEPTH,
PROP_TID, PROP_TID,
N_PROPS N_PROPS
}; };
@ -95,6 +96,10 @@ sysprof_document_allocation_get_property (GObject *object,
g_value_set_int64 (value, sysprof_document_allocation_get_size (self)); g_value_set_int64 (value, sysprof_document_allocation_get_size (self));
break; break;
case PROP_STACK_DEPTH:
g_value_set_uint (value, sysprof_document_traceable_get_stack_depth (SYSPROF_DOCUMENT_TRACEABLE (self)));
break;
case PROP_TID: case PROP_TID:
g_value_set_int (value, sysprof_document_allocation_get_tid (self)); g_value_set_int (value, sysprof_document_allocation_get_tid (self));
break; break;
@ -141,17 +146,39 @@ sysprof_document_allocation_class_init (SysprofDocumentAllocationClass *klass)
* SysprofDocumentAllocation:size: * SysprofDocumentAllocation:size:
* *
* The size of the memory that was allocated or freed. * The size of the memory that was allocated or freed.
*
* Since: 45
*/ */
properties [PROP_SIZE] = properties [PROP_SIZE] =
g_param_spec_int64 ("size", NULL, NULL, g_param_spec_int64 ("size", NULL, NULL,
G_MININT64, G_MAXINT64, 0, G_MININT64, G_MAXINT64, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* SysprofDocumentAllocation:is-free:
*
* If this allocation record is a call to release
* #SysprofDocumentAllocation:address.
*
* Since: 45
*/
properties [PROP_IS_FREE] = properties [PROP_IS_FREE] =
g_param_spec_boolean ("is-free", NULL, NULL, g_param_spec_boolean ("is-free", NULL, NULL,
FALSE, FALSE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* SysprofDocumentAllocation:stack-depth:
*
* The depth of the stack trace.
*
* Since: 45
*/
properties [PROP_STACK_DEPTH] =
g_param_spec_uint ("stack-depth", NULL, NULL,
0, G_MAXUINT16, 0,
(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

@ -37,7 +37,7 @@ struct _SysprofDocumentSampleClass
enum { enum {
PROP_0, PROP_0,
PROP_DEPTH, PROP_STACK_DEPTH,
PROP_TID, PROP_TID,
N_PROPS N_PROPS
}; };
@ -81,8 +81,8 @@ sysprof_document_sample_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_DEPTH: case PROP_STACK_DEPTH:
g_value_set_uint (value, sysprof_document_sample_get_depth (self)); g_value_set_uint (value, sysprof_document_traceable_get_stack_depth (SYSPROF_DOCUMENT_TRACEABLE (self)));
break; break;
case PROP_TID: case PROP_TID:
@ -116,14 +116,14 @@ sysprof_document_sample_class_init (SysprofDocumentSampleClass *klass)
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/** /**
* SysprofDocumentSample:depth: * SysprofDocumentSample:stack-depth:
* *
* The depth of the stack trace. * The depth of the stack trace.
* *
* Since: 45 * Since: 45
*/ */
properties [PROP_DEPTH] = properties [PROP_STACK_DEPTH] =
g_param_spec_uint ("depth", NULL, NULL, g_param_spec_uint ("stack-depth", NULL, NULL,
0, G_MAXUINT32, 0, 0, G_MAXUINT32, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
@ -135,18 +135,6 @@ sysprof_document_sample_init (SysprofDocumentSample *self)
{ {
} }
guint
sysprof_document_sample_get_depth (SysprofDocumentSample *self)
{
const SysprofCaptureSample *sample;
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_SAMPLE (self), 0);
sample = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureSample);
return SYSPROF_DOCUMENT_FRAME_UINT32 (self, sample->n_addrs);
}
int int
sysprof_document_sample_get_tid (SysprofDocumentSample *self) sysprof_document_sample_get_tid (SysprofDocumentSample *self)
{ {

View File

@ -33,11 +33,9 @@ typedef struct _SysprofDocumentSample SysprofDocumentSample;
typedef struct _SysprofDocumentSampleClass SysprofDocumentSampleClass; typedef struct _SysprofDocumentSampleClass SysprofDocumentSampleClass;
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
GType sysprof_document_sample_get_type (void) G_GNUC_CONST; GType sysprof_document_sample_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL SYSPROF_AVAILABLE_IN_ALL
guint sysprof_document_sample_get_depth (SysprofDocumentSample *self); int sysprof_document_sample_get_tid (SysprofDocumentSample *self);
SYSPROF_AVAILABLE_IN_ALL
int sysprof_document_sample_get_tid (SysprofDocumentSample *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentSample, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentSample, g_object_unref)

View File

@ -28,6 +28,21 @@ G_DEFINE_INTERFACE (SysprofDocumentTraceable, sysprof_document_traceable, SYSPRO
static void static void
sysprof_document_traceable_default_init (SysprofDocumentTraceableInterface *iface) sysprof_document_traceable_default_init (SysprofDocumentTraceableInterface *iface)
{ {
/**
* SysprofDocumentTraceable:stack-depth:
*
* The "stack-depth" property contains the number of addresses collected
* in the backtrace.
*
* You may use this value to retrieve the addresses from 0 to ("stack-depth"-1)
* by calling sysprof_document_traceable_get_stack_address().
*
* Since: 45
*/
g_object_interface_install_property (iface,
g_param_spec_uint ("stack-depth", NULL, NULL,
0, G_MAXUINT16, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
} }
guint guint