From 0529cfb2f0c7c176e73f8b76442773e6fa291d6e Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 12 Jun 2023 15:11:42 -0700 Subject: [PATCH] libsysprof-analyze: add helper to get clock start time --- src/libsysprof-analyze/sysprof-document.c | 16 ++++++++++++++++ src/libsysprof-analyze/sysprof-document.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-document.c b/src/libsysprof-analyze/sysprof-document.c index c353cb9b..47ca0fb2 100644 --- a/src/libsysprof-analyze/sysprof-document.c +++ b/src/libsysprof-analyze/sysprof-document.c @@ -1286,3 +1286,19 @@ _sysprof_document_kernel_symbol (SysprofDocument *self) return self->symbols->context_switches[SYSPROF_ADDRESS_CONTEXT_KERNEL]; } + +/** + * sysprof_document_get_clock_at_start: + * @self: a #SysprofDocument + * + * Gets the clock time when the recording started. + * + * Returns: the clock time, generally of `CLOCK_MONOTONIC` + */ +gint64 +sysprof_document_get_clock_at_start (SysprofDocument *self) +{ + g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), 0); + + return self->header.time; +} diff --git a/src/libsysprof-analyze/sysprof-document.h b/src/libsysprof-analyze/sysprof-document.h index cd0ac1a4..fe87ae4d 100644 --- a/src/libsysprof-analyze/sysprof-document.h +++ b/src/libsysprof-analyze/sysprof-document.h @@ -36,6 +36,8 @@ G_BEGIN_DECLS SYSPROF_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (SysprofDocument, sysprof_document, SYSPROF, DOCUMENT, GObject) +SYSPROF_AVAILABLE_IN_ALL +gint64 sysprof_document_get_clock_at_start (SysprofDocument *self); SYSPROF_AVAILABLE_IN_ALL SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self, const char *path);