From 760d573f92dd18352434d3f27e80bc6153bc8a1f Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 28 Apr 2023 13:16:07 -0700 Subject: [PATCH] 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. --- .../sysprof-document-allocation.c | 27 +++++++++++++++++++ .../sysprof-document-sample.c | 24 +++++------------ .../sysprof-document-sample.h | 6 ++--- .../sysprof-document-traceable.c | 15 +++++++++++ 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/libsysprof-analyze/sysprof-document-allocation.c b/src/libsysprof-analyze/sysprof-document-allocation.c index 33314fb5..0a287339 100644 --- a/src/libsysprof-analyze/sysprof-document-allocation.c +++ b/src/libsysprof-analyze/sysprof-document-allocation.c @@ -40,6 +40,7 @@ enum { PROP_ADDRESS, PROP_IS_FREE, PROP_SIZE, + PROP_STACK_DEPTH, PROP_TID, N_PROPS }; @@ -95,6 +96,10 @@ sysprof_document_allocation_get_property (GObject *object, g_value_set_int64 (value, sysprof_document_allocation_get_size (self)); break; + case PROP_STACK_DEPTH: + g_value_set_uint (value, sysprof_document_traceable_get_stack_depth (SYSPROF_DOCUMENT_TRACEABLE (self))); + break; + case PROP_TID: g_value_set_int (value, sysprof_document_allocation_get_tid (self)); break; @@ -141,17 +146,39 @@ sysprof_document_allocation_class_init (SysprofDocumentAllocationClass *klass) * SysprofDocumentAllocation:size: * * The size of the memory that was allocated or freed. + * + * Since: 45 */ properties [PROP_SIZE] = g_param_spec_int64 ("size", NULL, NULL, G_MININT64, G_MAXINT64, 0, (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] = g_param_spec_boolean ("is-free", NULL, NULL, FALSE, (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); } diff --git a/src/libsysprof-analyze/sysprof-document-sample.c b/src/libsysprof-analyze/sysprof-document-sample.c index a7c8fa23..685668d7 100644 --- a/src/libsysprof-analyze/sysprof-document-sample.c +++ b/src/libsysprof-analyze/sysprof-document-sample.c @@ -37,7 +37,7 @@ struct _SysprofDocumentSampleClass enum { PROP_0, - PROP_DEPTH, + PROP_STACK_DEPTH, PROP_TID, N_PROPS }; @@ -81,8 +81,8 @@ sysprof_document_sample_get_property (GObject *object, switch (prop_id) { - case PROP_DEPTH: - g_value_set_uint (value, sysprof_document_sample_get_depth (self)); + case PROP_STACK_DEPTH: + g_value_set_uint (value, sysprof_document_traceable_get_stack_depth (SYSPROF_DOCUMENT_TRACEABLE (self))); break; case PROP_TID: @@ -116,14 +116,14 @@ sysprof_document_sample_class_init (SysprofDocumentSampleClass *klass) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * SysprofDocumentSample:depth: + * SysprofDocumentSample:stack-depth: * * The depth of the stack trace. * * Since: 45 */ - properties [PROP_DEPTH] = - g_param_spec_uint ("depth", NULL, NULL, + properties [PROP_STACK_DEPTH] = + g_param_spec_uint ("stack-depth", NULL, NULL, 0, G_MAXUINT32, 0, (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 sysprof_document_sample_get_tid (SysprofDocumentSample *self) { diff --git a/src/libsysprof-analyze/sysprof-document-sample.h b/src/libsysprof-analyze/sysprof-document-sample.h index 6868fc84..b722540b 100644 --- a/src/libsysprof-analyze/sysprof-document-sample.h +++ b/src/libsysprof-analyze/sysprof-document-sample.h @@ -33,11 +33,9 @@ typedef struct _SysprofDocumentSample SysprofDocumentSample; typedef struct _SysprofDocumentSampleClass SysprofDocumentSampleClass; 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 -guint sysprof_document_sample_get_depth (SysprofDocumentSample *self); -SYSPROF_AVAILABLE_IN_ALL -int sysprof_document_sample_get_tid (SysprofDocumentSample *self); +int sysprof_document_sample_get_tid (SysprofDocumentSample *self); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentSample, g_object_unref) diff --git a/src/libsysprof-analyze/sysprof-document-traceable.c b/src/libsysprof-analyze/sysprof-document-traceable.c index 2b6442c7..6525be20 100644 --- a/src/libsysprof-analyze/sysprof-document-traceable.c +++ b/src/libsysprof-analyze/sysprof-document-traceable.c @@ -28,6 +28,21 @@ G_DEFINE_INTERFACE (SysprofDocumentTraceable, sysprof_document_traceable, SYSPRO static void 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