mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: move timespan to analyze library
That way we can use it for the document itself, and have it update the timespan of the recording in case it didn't get updated due to ctrl+c or something prematurely stopping.
This commit is contained in:
@ -32,6 +32,7 @@ libsysprof_analyze_public_sources = [
|
||||
'sysprof-no-symbolizer.c',
|
||||
'sysprof-symbol.c',
|
||||
'sysprof-symbolizer.c',
|
||||
'sysprof-time-span.c',
|
||||
]
|
||||
|
||||
libsysprof_analyze_private_sources = [
|
||||
@ -47,6 +48,7 @@ libsysprof_analyze_private_sources = [
|
||||
'sysprof-process-info.c',
|
||||
'sysprof-strings.c',
|
||||
'sysprof-symbol-cache.c',
|
||||
'sysprof-time-span.h',
|
||||
]
|
||||
|
||||
libsysprof_analyze_public_headers = [
|
||||
|
||||
@ -56,6 +56,8 @@ struct _SysprofDocument
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
SysprofTimeSpan time_span;
|
||||
|
||||
GArray *frames;
|
||||
GMappedFile *mapped_file;
|
||||
const guint8 *base;
|
||||
@ -97,6 +99,14 @@ typedef struct _SysprofDocumentFramePointer
|
||||
guint64 length : 16;
|
||||
} SysprofDocumentFramePointer;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TIME_SPAN,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS];
|
||||
|
||||
static GType
|
||||
sysprof_document_get_item_type (GListModel *model)
|
||||
{
|
||||
@ -244,12 +254,40 @@ sysprof_document_finalize (GObject *object)
|
||||
|
||||
G_OBJECT_CLASS (sysprof_document_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofDocument *self = SYSPROF_DOCUMENT (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TIME_SPAN:
|
||||
g_value_set_boxed (value, sysprof_document_get_time_span (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_class_init (SysprofDocumentClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_document_finalize;
|
||||
object_class->get_property = sysprof_document_get_property;
|
||||
|
||||
properties [PROP_TIME_SPAN] =
|
||||
g_param_spec_boxed ("time-span", NULL, NULL,
|
||||
SYSPROF_TYPE_TIME_SPAN,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -659,11 +697,15 @@ sysprof_document_load_worker (GTask *task,
|
||||
self->header.end_time = GUINT64_SWAP_LE_BE (self->header.end_time);
|
||||
}
|
||||
|
||||
self->time_span.begin_nsec = self->header.time;
|
||||
self->time_span.end_nsec = self->header.end_time;
|
||||
|
||||
pos = sizeof self->header;
|
||||
while (pos < (len - sizeof(guint16)))
|
||||
{
|
||||
const SysprofCaptureFrame *tainted;
|
||||
SysprofDocumentFramePointer ptr;
|
||||
gint64 t;
|
||||
guint16 frame_len;
|
||||
int pid;
|
||||
|
||||
@ -680,6 +722,10 @@ sysprof_document_load_worker (GTask *task,
|
||||
tainted = (const SysprofCaptureFrame *)(gpointer)&self->base[pos];
|
||||
|
||||
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)
|
||||
self->time_span.end_nsec = t;
|
||||
|
||||
egg_bitset_add (self->pids, pid);
|
||||
|
||||
@ -1514,3 +1560,11 @@ sysprof_document_catalog_marks (SysprofDocument *self)
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
const SysprofTimeSpan *
|
||||
sysprof_document_get_time_span (SysprofDocument *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
|
||||
|
||||
return &self->time_span;
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "sysprof-document-traceable.h"
|
||||
#include "sysprof-mark-catalog.h"
|
||||
#include "sysprof-symbol.h"
|
||||
#include "sysprof-time-span.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -38,51 +39,51 @@ 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);
|
||||
const SysprofTimeSpan *sysprof_document_get_time_span (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
||||
const char *path);
|
||||
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
||||
const char *path);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_files (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_files (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_traceables (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_traceables (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_allocations (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_allocations (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_samples (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_samples (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_processes (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_processes (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_jitmaps (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_jitmaps (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_counters (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_counters (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_marks (SysprofDocument *self);
|
||||
GListModel *sysprof_document_list_marks (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_catalog_marks (SysprofDocument *self);
|
||||
GListModel *sysprof_document_catalog_marks (SysprofDocument *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GListModel *sysprof_document_list_symbols_in_traceable (SysprofDocument *self,
|
||||
SysprofDocumentTraceable *traceable);
|
||||
GListModel *sysprof_document_list_symbols_in_traceable (SysprofDocument *self,
|
||||
SysprofDocumentTraceable *traceable);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sysprof_document_symbolize_traceable (SysprofDocument *self,
|
||||
SysprofDocumentTraceable *traceable,
|
||||
SysprofSymbol **symbols,
|
||||
guint n_symbols,
|
||||
SysprofAddressContext *final_context);
|
||||
guint sysprof_document_symbolize_traceable (SysprofDocument *self,
|
||||
SysprofDocumentTraceable *traceable,
|
||||
SysprofSymbol **symbols,
|
||||
guint n_symbols,
|
||||
SysprofAddressContext *final_context);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_document_callgraph_async (SysprofDocument *self,
|
||||
SysprofCallgraphFlags flags,
|
||||
GListModel *traceables,
|
||||
gsize augment_size,
|
||||
SysprofAugmentationFunc augment_func,
|
||||
gpointer augment_func_data,
|
||||
GDestroyNotify augment_func_data_destroy,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
void sysprof_document_callgraph_async (SysprofDocument *self,
|
||||
SysprofCallgraphFlags flags,
|
||||
GListModel *traceables,
|
||||
gsize augment_size,
|
||||
SysprofAugmentationFunc augment_func,
|
||||
gpointer augment_func_data,
|
||||
GDestroyNotify augment_func_data_destroy,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCallgraph *sysprof_document_callgraph_finish (SysprofDocument *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
SysprofCallgraph *sysprof_document_callgraph_finish (SysprofDocument *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
40
src/libsysprof-analyze/sysprof-time-span.c
Normal file
40
src/libsysprof-analyze/sysprof-time-span.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* sysprof-time-span.c
|
||||
*
|
||||
* Copyright 2023 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-time-span.h"
|
||||
|
||||
G_DEFINE_BOXED_TYPE (SysprofTimeSpan, sysprof_time_span, sysprof_time_span_copy, sysprof_time_span_free)
|
||||
|
||||
SysprofTimeSpan *
|
||||
sysprof_time_span_copy (const SysprofTimeSpan *self)
|
||||
{
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_memdup2 (self, sizeof *self);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_time_span_free (SysprofTimeSpan *self)
|
||||
{
|
||||
g_free (self);
|
||||
}
|
||||
44
src/libsysprof-analyze/sysprof-time-span.h
Normal file
44
src/libsysprof-analyze/sysprof-time-span.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* sysprof-time-span.h
|
||||
*
|
||||
* Copyright 2023 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <sysprof-capture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TIME_SPAN (sysprof_time_span_get_type())
|
||||
|
||||
typedef struct _SysprofTimeSpan
|
||||
{
|
||||
gint64 begin_nsec;
|
||||
gint64 end_nsec;
|
||||
} SysprofTimeSpan;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sysprof_time_span_get_type (void) G_GNUC_CONST;
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofTimeSpan *sysprof_time_span_copy (const SysprofTimeSpan *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_time_span_free (SysprofTimeSpan *self);
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user