From 7f13f0e32720f738d11931aae8ed7471eeac8e52 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 16 Jun 2023 17:08:21 -0700 Subject: [PATCH] libsysprof-analyze: ignore end time from syscap header We are already walking through all the frames so we can guess this better than what is in the capture file. This helps ensure that loading older captures still has the end clamped to the last event we'll see. --- src/libsysprof-analyze/sysprof-document.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libsysprof-analyze/sysprof-document.c b/src/libsysprof-analyze/sysprof-document.c index 13840a06..fcce54d6 100644 --- a/src/libsysprof-analyze/sysprof-document.c +++ b/src/libsysprof-analyze/sysprof-document.c @@ -691,6 +691,7 @@ sysprof_document_load_worker (GTask *task, g_autoptr(SysprofDocument) self = NULL; g_autoptr(GHashTable) files = NULL; GMappedFile *mapped_file = task_data; + gint64 guessed_end_nsec = 0; goffset pos; gsize len; @@ -752,8 +753,8 @@ sysprof_document_load_worker (GTask *task, pid = self->needs_swap ? GUINT32_SWAP_LE_BE (tainted->pid) : tainted->pid; t = self->needs_swap ? GUINT64_SWAP_LE_BE (tainted->time) : tainted->time; - if (t > self->time_span.end_nsec && is_data_type (tainted->type)) - self->time_span.end_nsec = t; + if (t > guessed_end_nsec && is_data_type (tainted->type)) + guessed_end_nsec = t; egg_bitset_add (self->pids, pid); @@ -819,6 +820,10 @@ sysprof_document_load_worker (GTask *task, { const SysprofCaptureMark *mark = (const SysprofCaptureMark *)tainted; const char *endptr = (const char *)tainted + frame_len; + gint64 duration = self->needs_swap ? GUINT64_SWAP_LE_BE (mark->duration) : mark->duration; + + if (t + duration > guessed_end_nsec) + guessed_end_nsec = t + duration; if (has_null_byte (mark->group, endptr) && has_null_byte (mark->name, endptr)) @@ -852,6 +857,9 @@ sysprof_document_load_worker (GTask *task, g_array_append_val (self->frames, ptr); } + if (guessed_end_nsec != 0) + self->time_span.end_nsec = guessed_end_nsec; + sysprof_document_load_mounts (self); sysprof_document_load_mountinfos (self); sysprof_document_load_memory_maps (self);