mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +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-no-symbolizer.c',
|
||||||
'sysprof-symbol.c',
|
'sysprof-symbol.c',
|
||||||
'sysprof-symbolizer.c',
|
'sysprof-symbolizer.c',
|
||||||
|
'sysprof-time-span.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
libsysprof_analyze_private_sources = [
|
libsysprof_analyze_private_sources = [
|
||||||
@ -47,6 +48,7 @@ libsysprof_analyze_private_sources = [
|
|||||||
'sysprof-process-info.c',
|
'sysprof-process-info.c',
|
||||||
'sysprof-strings.c',
|
'sysprof-strings.c',
|
||||||
'sysprof-symbol-cache.c',
|
'sysprof-symbol-cache.c',
|
||||||
|
'sysprof-time-span.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
libsysprof_analyze_public_headers = [
|
libsysprof_analyze_public_headers = [
|
||||||
|
|||||||
@ -56,6 +56,8 @@ struct _SysprofDocument
|
|||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
|
SysprofTimeSpan time_span;
|
||||||
|
|
||||||
GArray *frames;
|
GArray *frames;
|
||||||
GMappedFile *mapped_file;
|
GMappedFile *mapped_file;
|
||||||
const guint8 *base;
|
const guint8 *base;
|
||||||
@ -97,6 +99,14 @@ typedef struct _SysprofDocumentFramePointer
|
|||||||
guint64 length : 16;
|
guint64 length : 16;
|
||||||
} SysprofDocumentFramePointer;
|
} SysprofDocumentFramePointer;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_TIME_SPAN,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[N_PROPS];
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
sysprof_document_get_item_type (GListModel *model)
|
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);
|
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
|
static void
|
||||||
sysprof_document_class_init (SysprofDocumentClass *klass)
|
sysprof_document_class_init (SysprofDocumentClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = sysprof_document_finalize;
|
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
|
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->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;
|
pos = sizeof self->header;
|
||||||
while (pos < (len - sizeof(guint16)))
|
while (pos < (len - sizeof(guint16)))
|
||||||
{
|
{
|
||||||
const SysprofCaptureFrame *tainted;
|
const SysprofCaptureFrame *tainted;
|
||||||
SysprofDocumentFramePointer ptr;
|
SysprofDocumentFramePointer ptr;
|
||||||
|
gint64 t;
|
||||||
guint16 frame_len;
|
guint16 frame_len;
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
@ -680,6 +722,10 @@ sysprof_document_load_worker (GTask *task,
|
|||||||
tainted = (const SysprofCaptureFrame *)(gpointer)&self->base[pos];
|
tainted = (const SysprofCaptureFrame *)(gpointer)&self->base[pos];
|
||||||
|
|
||||||
pid = self->needs_swap ? GUINT32_SWAP_LE_BE (tainted->pid) : tainted->pid;
|
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);
|
egg_bitset_add (self->pids, pid);
|
||||||
|
|
||||||
@ -1514,3 +1560,11 @@ sysprof_document_catalog_marks (SysprofDocument *self)
|
|||||||
|
|
||||||
return G_LIST_MODEL (store);
|
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-document-traceable.h"
|
||||||
#include "sysprof-mark-catalog.h"
|
#include "sysprof-mark-catalog.h"
|
||||||
#include "sysprof-symbol.h"
|
#include "sysprof-symbol.h"
|
||||||
|
#include "sysprof-time-span.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
G_DECLARE_FINAL_TYPE (SysprofDocument, sysprof_document, SYSPROF, DOCUMENT, GObject)
|
G_DECLARE_FINAL_TYPE (SysprofDocument, sysprof_document, SYSPROF, DOCUMENT, GObject)
|
||||||
|
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
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
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|||||||
@ -27,6 +27,9 @@ G_DEFINE_BOXED_TYPE (SysprofTimeSpan, sysprof_time_span, sysprof_time_span_copy,
|
|||||||
SysprofTimeSpan *
|
SysprofTimeSpan *
|
||||||
sysprof_time_span_copy (const SysprofTimeSpan *self)
|
sysprof_time_span_copy (const SysprofTimeSpan *self)
|
||||||
{
|
{
|
||||||
|
if (self == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
return g_memdup2 (self, sizeof *self);
|
return g_memdup2 (self, sizeof *self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3,7 +3,6 @@ libsysprof_gtk_public_sources = [
|
|||||||
'sysprof-mark-chart.c',
|
'sysprof-mark-chart.c',
|
||||||
'sysprof-mark-table.c',
|
'sysprof-mark-table.c',
|
||||||
'sysprof-session.c',
|
'sysprof-session.c',
|
||||||
'sysprof-time-span.c',
|
|
||||||
'sysprof-weighted-callgraph-view.c',
|
'sysprof-weighted-callgraph-view.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -22,7 +21,6 @@ libsysprof_gtk_public_headers = [
|
|||||||
'sysprof-mark-chart.h',
|
'sysprof-mark-chart.h',
|
||||||
'sysprof-mark-table.h',
|
'sysprof-mark-table.h',
|
||||||
'sysprof-session.h',
|
'sysprof-session.h',
|
||||||
'sysprof-time-span.h',
|
|
||||||
'sysprof-weighted-callgraph-view.h',
|
'sysprof-weighted-callgraph-view.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@ G_BEGIN_DECLS
|
|||||||
# include "sysprof-mark-chart.h"
|
# include "sysprof-mark-chart.h"
|
||||||
# include "sysprof-mark-table.h"
|
# include "sysprof-mark-table.h"
|
||||||
# include "sysprof-session.h"
|
# include "sysprof-session.h"
|
||||||
# include "sysprof-time-span.h"
|
|
||||||
# include "sysprof-weighted-callgraph-view.h"
|
# include "sysprof-weighted-callgraph-view.h"
|
||||||
#undef SYSPROF_GTK_INSIDE
|
#undef SYSPROF_GTK_INSIDE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user