libsysprof-analyze: implement traceable for samples

This commit is contained in:
Christian Hergert
2023-04-28 12:19:59 -07:00
parent 98edb9c39a
commit 8c5b4720c0

View File

@ -21,7 +21,9 @@
#include "config.h"
#include "sysprof-document-frame-private.h"
#include "sysprof-document-sample.h"
#include "sysprof-document-traceable.h"
struct _SysprofDocumentSample
{
@ -40,7 +42,32 @@ enum {
N_PROPS
};
G_DEFINE_FINAL_TYPE (SysprofDocumentSample, sysprof_document_sample, SYSPROF_TYPE_DOCUMENT_FRAME)
static guint
sysprof_document_sample_get_stack_depth (SysprofDocumentTraceable *traceable)
{
const SysprofCaptureSample *sample = SYSPROF_DOCUMENT_FRAME_GET (traceable, SysprofCaptureSample);
return SYSPROF_DOCUMENT_FRAME_UINT16 (traceable, sample->n_addrs);
}
static guint64
sysprof_document_sample_get_stack_address (SysprofDocumentTraceable *traceable,
guint position)
{
const SysprofCaptureSample *sample = SYSPROF_DOCUMENT_FRAME_GET (traceable, SysprofCaptureSample);
return SYSPROF_DOCUMENT_FRAME_UINT64 (traceable, sample->addrs[position]);
}
static void
traceable_iface_init (SysprofDocumentTraceableInterface *iface)
{
iface->get_stack_depth = sysprof_document_sample_get_stack_depth;
iface->get_stack_address = sysprof_document_sample_get_stack_address;
}
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofDocumentSample, sysprof_document_sample, SYSPROF_TYPE_DOCUMENT_FRAME,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_DOCUMENT_TRACEABLE, traceable_iface_init))
static GParamSpec *properties [N_PROPS];