mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
build: rename all symbols to use sysprof_ as prefix
As we gain in usage, we need to be more careful about using a prefix that will not collide with other symbols. So version 3 of our ABI will change to using Sysprof/SYSPROF/sysprof as the various prefixes. The soname/api version bump will happen later on this branch so that things are easier to test up until then.
This commit is contained in:
@ -1,25 +1,25 @@
|
||||
libsysprof_capture_headers = files([
|
||||
'sp-address.h',
|
||||
'sp-clock.h',
|
||||
'sp-capture-condition.h',
|
||||
'sp-capture-cursor.h',
|
||||
'sp-capture-reader.h',
|
||||
'sp-capture-types.h',
|
||||
'sp-capture-writer.h',
|
||||
'sp-platform.h',
|
||||
'sysprof-address.h',
|
||||
'sysprof-clock.h',
|
||||
'sysprof-capture-condition.h',
|
||||
'sysprof-capture-cursor.h',
|
||||
'sysprof-capture-reader.h',
|
||||
'sysprof-capture-types.h',
|
||||
'sysprof-capture-writer.h',
|
||||
'sysprof-platform.h',
|
||||
'sysprof-capture.h',
|
||||
'sysprof-version-macros.h',
|
||||
])
|
||||
|
||||
libsysprof_capture_sources = files([
|
||||
'sp-address.c',
|
||||
'sp-capture-condition.c',
|
||||
'sp-capture-cursor.c',
|
||||
'sp-capture-reader.c',
|
||||
'sp-capture-util.c',
|
||||
'sp-capture-writer.c',
|
||||
'sp-clock.c',
|
||||
'sp-platform.c',
|
||||
'sysprof-address.c',
|
||||
'sysprof-capture-condition.c',
|
||||
'sysprof-capture-cursor.c',
|
||||
'sysprof-capture-reader.c',
|
||||
'sysprof-capture-util.c',
|
||||
'sysprof-capture-writer.c',
|
||||
'sysprof-clock.c',
|
||||
'sysprof-platform.c',
|
||||
])
|
||||
|
||||
configure_file(
|
||||
|
||||
@ -1,265 +0,0 @@
|
||||
/* sp-capture-cursor.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-capture-cursor"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-capture-condition.h"
|
||||
#include "sp-capture-cursor.h"
|
||||
#include "sp-capture-reader.h"
|
||||
|
||||
#define READ_DELEGATE(f) ((ReadDelegate)(f))
|
||||
|
||||
typedef const SpCaptureFrame *(*ReadDelegate) (SpCaptureReader *);
|
||||
|
||||
struct _SpCaptureCursor
|
||||
{
|
||||
volatile gint ref_count;
|
||||
GPtrArray *conditions;
|
||||
SpCaptureReader *reader;
|
||||
guint reversed : 1;
|
||||
};
|
||||
|
||||
static void
|
||||
sp_capture_cursor_finalize (SpCaptureCursor *self)
|
||||
{
|
||||
g_clear_pointer (&self->conditions, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->reader, sp_capture_reader_unref);
|
||||
g_slice_free (SpCaptureCursor, self);
|
||||
}
|
||||
|
||||
static SpCaptureCursor *
|
||||
sp_capture_cursor_init (void)
|
||||
{
|
||||
SpCaptureCursor *self;
|
||||
|
||||
self = g_slice_new0 (SpCaptureCursor);
|
||||
self->conditions = g_ptr_array_new_with_free_func ((GDestroyNotify) sp_capture_condition_unref);
|
||||
self->ref_count = 1;
|
||||
|
||||
return g_steal_pointer (&self);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_ref:
|
||||
* @self: a #SpCaptureCursor
|
||||
*
|
||||
* Returns: (transfer full): @self
|
||||
*
|
||||
* Since: 3.34
|
||||
*/
|
||||
SpCaptureCursor *
|
||||
sp_capture_cursor_ref (SpCaptureCursor *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (self->ref_count > 0, NULL);
|
||||
|
||||
g_atomic_int_inc (&self->ref_count);
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_unref:
|
||||
* @self: a #SpCaptureCursor
|
||||
*
|
||||
* Since: 3.34
|
||||
*/
|
||||
void
|
||||
sp_capture_cursor_unref (SpCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->ref_count > 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&self->ref_count))
|
||||
sp_capture_cursor_finalize (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_foreach:
|
||||
* @self: a #SpCaptureCursor
|
||||
* @callback: (scope call): a closure to execute
|
||||
* @user_data: user data for @callback
|
||||
*
|
||||
*/
|
||||
void
|
||||
sp_capture_cursor_foreach (SpCaptureCursor *self,
|
||||
SpCaptureCursorCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->reader != NULL);
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const SpCaptureFrame *frame;
|
||||
SpCaptureFrameType type = 0;
|
||||
ReadDelegate delegate = NULL;
|
||||
|
||||
if (!sp_capture_reader_peek_type (self->reader, &type))
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SP_CAPTURE_FRAME_TIMESTAMP:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_timestamp);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_SAMPLE:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_sample);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_MAP:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_map);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_MARK:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_mark);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_PROCESS:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_process);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_FORK:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_fork);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_EXIT:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_exit);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_JITMAP:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_jitmap);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_CTRDEF:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_counter_define);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_FRAME_CTRSET:
|
||||
delegate = READ_DELEGATE (sp_capture_reader_read_counter_set);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!sp_capture_reader_skip (self->reader))
|
||||
return;
|
||||
delegate = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (delegate == NULL)
|
||||
continue;
|
||||
|
||||
if (NULL == (frame = delegate (self->reader)))
|
||||
return;
|
||||
|
||||
if (self->conditions->len == 0)
|
||||
{
|
||||
if (!callback (frame, user_data))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (guint i = 0; i < self->conditions->len; i++)
|
||||
{
|
||||
const SpCaptureCondition *condition = g_ptr_array_index (self->conditions, i);
|
||||
|
||||
if (sp_capture_condition_match (condition, frame))
|
||||
{
|
||||
if (!callback (frame, user_data))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sp_capture_cursor_reset (SpCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->reader != NULL);
|
||||
|
||||
sp_capture_reader_reset (self->reader);
|
||||
}
|
||||
|
||||
void
|
||||
sp_capture_cursor_reverse (SpCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
self->reversed = !self->reversed;
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_add_condition:
|
||||
* @self: An #SpCaptureCursor
|
||||
* @condition: (transfer full): An #SpCaptureCondition
|
||||
*
|
||||
* Adds the condition to the cursor. This condition must evaluate to
|
||||
* true or a given #SpCapureFrame will not be matched.
|
||||
*/
|
||||
void
|
||||
sp_capture_cursor_add_condition (SpCaptureCursor *self,
|
||||
SpCaptureCondition *condition)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (condition != NULL);
|
||||
|
||||
g_ptr_array_add (self->conditions, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_new:
|
||||
* @self: a #SpCaptureCursor
|
||||
*
|
||||
* Returns: (transfer full): a new cursor for @reader
|
||||
*/
|
||||
SpCaptureCursor *
|
||||
sp_capture_cursor_new (SpCaptureReader *reader)
|
||||
{
|
||||
SpCaptureCursor *self;
|
||||
|
||||
g_return_val_if_fail (reader != NULL, NULL);
|
||||
|
||||
self = sp_capture_cursor_init ();
|
||||
self->reader = sp_capture_reader_copy (reader);
|
||||
sp_capture_reader_reset (self->reader);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_cursor_get_reader:
|
||||
*
|
||||
* Gets the underlying reader that is used by the cursor.
|
||||
*
|
||||
* Returns: (transfer none): An #SpCaptureReader
|
||||
*/
|
||||
SpCaptureReader *
|
||||
sp_capture_cursor_get_reader (SpCaptureCursor *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return self->reader;
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
/* sp-capture-reader.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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 "sp-capture-types.h"
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _SpCaptureReader SpCaptureReader;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_reader_new (const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_reader_new_from_fd (int fd,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_reader_copy (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_reader_ref (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_reader_unref (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sp_capture_reader_get_filename (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sp_capture_reader_get_time (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sp_capture_reader_get_start_time (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sp_capture_reader_get_end_time (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_skip (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_peek_type (SpCaptureReader *self,
|
||||
SpCaptureFrameType *type);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_peek_frame (SpCaptureReader *self,
|
||||
SpCaptureFrame *frame);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureMap *sp_capture_reader_read_map (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureMark *sp_capture_reader_read_mark (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureExit *sp_capture_reader_read_exit (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureFork *sp_capture_reader_read_fork (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureTimestamp *sp_capture_reader_read_timestamp (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureProcess *sp_capture_reader_read_process (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureSample *sp_capture_reader_read_sample (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GHashTable *sp_capture_reader_read_jitmap (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureFrameCounterDefine *sp_capture_reader_read_counter_define (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SpCaptureFrameCounterSet *sp_capture_reader_read_counter_set (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_reset (SpCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_splice (SpCaptureReader *self,
|
||||
SpCaptureWriter *dest,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_reader_save_as (SpCaptureReader *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureReader, sp_capture_reader_unref)
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,256 +0,0 @@
|
||||
/* sp-capture-types.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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.h>
|
||||
|
||||
#include "sp-clock.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_CAPTURE_MAGIC (GUINT32_TO_LE(0xFDCA975E))
|
||||
#define SP_CAPTURE_ALIGN (sizeof(SpCaptureAddress))
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define SP_ALIGNED_BEGIN(_N) __declspec(align (_N))
|
||||
# define SP_ALIGNED_END(_N)
|
||||
#else
|
||||
# define SP_ALIGNED_BEGIN(_N)
|
||||
# define SP_ALIGNED_END(_N) __attribute__((aligned ((_N))))
|
||||
#endif
|
||||
|
||||
#if GLIB_SIZEOF_VOID_P == 8
|
||||
# define SP_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE000000000000000)
|
||||
# define SP_CAPTURE_ADDRESS_FORMAT "0x%016lx"
|
||||
#elif GLIB_SIZEOF_VOID_P == 4
|
||||
# define SP_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE0000000)
|
||||
# define SP_CAPTURE_ADDRESS_FORMAT "0x%016llx"
|
||||
#else
|
||||
#error Unknown GLIB_SIZEOF_VOID_P
|
||||
#endif
|
||||
|
||||
#define SP_CAPTURE_CURRENT_TIME (sp_clock_get_current_time())
|
||||
#define SP_CAPTURE_COUNTER_INT64 0
|
||||
#define SP_CAPTURE_COUNTER_DOUBLE 1
|
||||
|
||||
typedef struct _SpCaptureReader SpCaptureReader;
|
||||
typedef struct _SpCaptureWriter SpCaptureWriter;
|
||||
typedef struct _SpCaptureCursor SpCaptureCursor;
|
||||
typedef struct _SpCaptureCondition SpCaptureCondition;
|
||||
|
||||
typedef guint64 SpCaptureAddress;
|
||||
|
||||
typedef union
|
||||
{
|
||||
gint64 v64;
|
||||
gdouble vdbl;
|
||||
} SpCaptureCounterValue;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SP_CAPTURE_FRAME_TIMESTAMP = 1,
|
||||
SP_CAPTURE_FRAME_SAMPLE = 2,
|
||||
SP_CAPTURE_FRAME_MAP = 3,
|
||||
SP_CAPTURE_FRAME_PROCESS = 4,
|
||||
SP_CAPTURE_FRAME_FORK = 5,
|
||||
SP_CAPTURE_FRAME_EXIT = 6,
|
||||
SP_CAPTURE_FRAME_JITMAP = 7,
|
||||
SP_CAPTURE_FRAME_CTRDEF = 8,
|
||||
SP_CAPTURE_FRAME_CTRSET = 9,
|
||||
SP_CAPTURE_FRAME_MARK = 10,
|
||||
} SpCaptureFrameType;
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
guint32 magic;
|
||||
guint32 version : 8;
|
||||
guint32 little_endian : 1;
|
||||
guint32 padding : 23;
|
||||
gchar capture_time[64];
|
||||
gint64 time;
|
||||
gint64 end_time;
|
||||
gchar suffix[168];
|
||||
} SpCaptureFileHeader
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
guint16 len;
|
||||
gint16 cpu;
|
||||
gint32 pid;
|
||||
gint64 time;
|
||||
guint32 type : 8;
|
||||
guint32 padding1 : 24;
|
||||
guint32 padding2;
|
||||
guint8 data[0];
|
||||
} SpCaptureFrame
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
guint64 start;
|
||||
guint64 end;
|
||||
guint64 offset;
|
||||
guint64 inode;
|
||||
gchar filename[0];
|
||||
} SpCaptureMap
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
guint32 n_jitmaps;
|
||||
guint8 data[0];
|
||||
} SpCaptureJitmap
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
gchar cmdline[0];
|
||||
} SpCaptureProcess
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
guint32 n_addrs : 16;
|
||||
guint32 padding1 : 16;
|
||||
gint32 tid;
|
||||
SpCaptureAddress addrs[0];
|
||||
} SpCaptureSample
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
gint32 child_pid;
|
||||
} SpCaptureFork
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
} SpCaptureExit
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
} SpCaptureTimestamp
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
gchar category[32];
|
||||
gchar name[32];
|
||||
gchar description[52];
|
||||
guint32 id : 24;
|
||||
guint32 type : 8;
|
||||
SpCaptureCounterValue value;
|
||||
} SpCaptureCounter
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
guint32 n_counters : 16;
|
||||
guint32 padding1 : 16;
|
||||
guint32 padding2;
|
||||
SpCaptureCounter counters[0];
|
||||
} SpCaptureFrameCounterDefine
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* 96 bytes might seem a bit odd, but the counter frame header is 32
|
||||
* bytes. So this makes a nice 2-cacheline aligned size which is
|
||||
* useful when the number of counters is rather small.
|
||||
*/
|
||||
guint32 ids[8];
|
||||
SpCaptureCounterValue values[8];
|
||||
} SpCaptureCounterValues
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
guint32 n_values : 16;
|
||||
guint32 padding1 : 16;
|
||||
guint32 padding2;
|
||||
SpCaptureCounterValues values[0];
|
||||
} SpCaptureFrameCounterSet
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
SP_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
gint64 duration;
|
||||
gchar group[24];
|
||||
gchar name[40];
|
||||
gchar message[0];
|
||||
} SpCaptureMark
|
||||
SP_ALIGNED_END(1);
|
||||
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureFileHeader) == 256);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureFrame) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureMap) == 56);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureJitmap) == 28);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureProcess) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureSample) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureFork) == 28);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureExit) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureTimestamp) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureCounter) == 128);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureCounterValues) == 96);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureFrameCounterDefine) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureFrameCounterSet) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SpCaptureMark) == 96);
|
||||
|
||||
static inline gint
|
||||
sp_capture_address_compare (SpCaptureAddress a,
|
||||
SpCaptureAddress b)
|
||||
{
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a > b)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-address.c
|
||||
/* sysprof-address.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -23,16 +23,16 @@
|
||||
#ifdef __linux__
|
||||
# include <linux/perf_event.h>
|
||||
#else
|
||||
# include "sp-address-fallback.h"
|
||||
# include "sysprof-address-fallback.h"
|
||||
#endif
|
||||
|
||||
#include "sp-address.h"
|
||||
#include "sysprof-address.h"
|
||||
|
||||
gboolean
|
||||
sp_address_is_context_switch (SpAddress address,
|
||||
SpAddressContext *context)
|
||||
sysprof_address_is_context_switch (SysprofAddress address,
|
||||
SysprofAddressContext *context)
|
||||
{
|
||||
SpAddressContext dummy;
|
||||
SysprofAddressContext dummy;
|
||||
|
||||
if (context == NULL)
|
||||
context = &dummy;
|
||||
@ -40,59 +40,59 @@ sp_address_is_context_switch (SpAddress address,
|
||||
switch (address)
|
||||
{
|
||||
case PERF_CONTEXT_HV:
|
||||
*context = SP_ADDRESS_CONTEXT_HYPERVISOR;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_HYPERVISOR;
|
||||
return TRUE;
|
||||
|
||||
case PERF_CONTEXT_KERNEL:
|
||||
*context = SP_ADDRESS_CONTEXT_KERNEL;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_KERNEL;
|
||||
return TRUE;
|
||||
|
||||
case PERF_CONTEXT_USER:
|
||||
*context = SP_ADDRESS_CONTEXT_USER;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_USER;
|
||||
return TRUE;
|
||||
|
||||
case PERF_CONTEXT_GUEST:
|
||||
*context = SP_ADDRESS_CONTEXT_GUEST;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_GUEST;
|
||||
return TRUE;
|
||||
|
||||
case PERF_CONTEXT_GUEST_KERNEL:
|
||||
*context = SP_ADDRESS_CONTEXT_GUEST_KERNEL;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_GUEST_KERNEL;
|
||||
return TRUE;
|
||||
|
||||
case PERF_CONTEXT_GUEST_USER:
|
||||
*context = SP_ADDRESS_CONTEXT_GUEST_USER;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_GUEST_USER;
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
*context = SP_ADDRESS_CONTEXT_NONE;
|
||||
*context = SYSPROF_ADDRESS_CONTEXT_NONE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
const gchar *
|
||||
sp_address_context_to_string (SpAddressContext context)
|
||||
sysprof_address_context_to_string (SysprofAddressContext context)
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
case SP_ADDRESS_CONTEXT_HYPERVISOR:
|
||||
case SYSPROF_ADDRESS_CONTEXT_HYPERVISOR:
|
||||
return "- - hypervisor - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_KERNEL:
|
||||
case SYSPROF_ADDRESS_CONTEXT_KERNEL:
|
||||
return "- - kernel - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_USER:
|
||||
case SYSPROF_ADDRESS_CONTEXT_USER:
|
||||
return "- - user - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_GUEST:
|
||||
case SYSPROF_ADDRESS_CONTEXT_GUEST:
|
||||
return "- - guest - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_GUEST_KERNEL:
|
||||
case SYSPROF_ADDRESS_CONTEXT_GUEST_KERNEL:
|
||||
return "- - guest kernel - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_GUEST_USER:
|
||||
case SYSPROF_ADDRESS_CONTEXT_GUEST_USER:
|
||||
return "- - guest user - -";
|
||||
|
||||
case SP_ADDRESS_CONTEXT_NONE:
|
||||
case SYSPROF_ADDRESS_CONTEXT_NONE:
|
||||
default:
|
||||
return "- - unknown - -";
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-address.h
|
||||
/* sysprof-address.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -24,30 +24,30 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef guint64 SpAddress;
|
||||
typedef guint64 SysprofAddress;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (SpAddress) >= sizeof (gpointer));
|
||||
G_STATIC_ASSERT (sizeof (SysprofAddress) >= sizeof (gpointer));
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SP_ADDRESS_CONTEXT_NONE = 0,
|
||||
SP_ADDRESS_CONTEXT_HYPERVISOR,
|
||||
SP_ADDRESS_CONTEXT_KERNEL,
|
||||
SP_ADDRESS_CONTEXT_USER,
|
||||
SP_ADDRESS_CONTEXT_GUEST,
|
||||
SP_ADDRESS_CONTEXT_GUEST_KERNEL,
|
||||
SP_ADDRESS_CONTEXT_GUEST_USER,
|
||||
} SpAddressContext;
|
||||
SYSPROF_ADDRESS_CONTEXT_NONE = 0,
|
||||
SYSPROF_ADDRESS_CONTEXT_HYPERVISOR,
|
||||
SYSPROF_ADDRESS_CONTEXT_KERNEL,
|
||||
SYSPROF_ADDRESS_CONTEXT_USER,
|
||||
SYSPROF_ADDRESS_CONTEXT_GUEST,
|
||||
SYSPROF_ADDRESS_CONTEXT_GUEST_KERNEL,
|
||||
SYSPROF_ADDRESS_CONTEXT_GUEST_USER,
|
||||
} SysprofAddressContext;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_address_is_context_switch (SpAddress address,
|
||||
SpAddressContext *context);
|
||||
gboolean sysprof_address_is_context_switch (SysprofAddress address,
|
||||
SysprofAddressContext *context);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sp_address_context_to_string (SpAddressContext context);
|
||||
const gchar *sysprof_address_context_to_string (SysprofAddressContext context);
|
||||
|
||||
static inline gint
|
||||
sp_address_compare (SpAddress a,
|
||||
SpAddress b)
|
||||
sysprof_address_compare (SysprofAddress a,
|
||||
SysprofAddress b)
|
||||
{
|
||||
if (a < b)
|
||||
return -1;
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-condition.c
|
||||
/* sysprof-capture-condition.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -18,20 +18,20 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-capture-condition"
|
||||
#define G_LOG_DOMAIN "sysprof-capture-condition"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-capture-condition.h"
|
||||
#include "sysprof-capture-condition.h"
|
||||
|
||||
/**
|
||||
* SECTION:sp-capture-condition
|
||||
* @title: SpCaptureCondition
|
||||
* SECTION:sysprof-capture-condition
|
||||
* @title: SysprofCaptureCondition
|
||||
*
|
||||
* The #SpCaptureCondition type is an abstraction on an operation
|
||||
* for a sort of AST to the #SpCaptureCursor. The goal is that if
|
||||
* The #SysprofCaptureCondition type is an abstraction on an operation
|
||||
* for a sort of AST to the #SysprofCaptureCursor. The goal is that if
|
||||
* we abstract the types of fields we want to match in the cursor
|
||||
* that we can opportunistically add indexes to speed up the operation
|
||||
* later on without changing the implementation of cursor consumers.
|
||||
@ -39,17 +39,17 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SP_CAPTURE_CONDITION_AND,
|
||||
SP_CAPTURE_CONDITION_WHERE_TYPE_IN,
|
||||
SP_CAPTURE_CONDITION_WHERE_TIME_BETWEEN,
|
||||
SP_CAPTURE_CONDITION_WHERE_PID_IN,
|
||||
SP_CAPTURE_CONDITION_WHERE_COUNTER_IN,
|
||||
} SpCaptureConditionType;
|
||||
SYSPROF_CAPTURE_CONDITION_AND,
|
||||
SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN,
|
||||
SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN,
|
||||
SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN,
|
||||
SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN,
|
||||
} SysprofCaptureConditionType;
|
||||
|
||||
struct _SpCaptureCondition
|
||||
struct _SysprofCaptureCondition
|
||||
{
|
||||
volatile gint ref_count;
|
||||
SpCaptureConditionType type;
|
||||
SysprofCaptureConditionType type;
|
||||
union {
|
||||
GArray *where_type_in;
|
||||
struct {
|
||||
@ -59,37 +59,37 @@ struct _SpCaptureCondition
|
||||
GArray *where_pid_in;
|
||||
GArray *where_counter_in;
|
||||
struct {
|
||||
SpCaptureCondition *left;
|
||||
SpCaptureCondition *right;
|
||||
SysprofCaptureCondition *left;
|
||||
SysprofCaptureCondition *right;
|
||||
} and;
|
||||
} u;
|
||||
};
|
||||
|
||||
gboolean
|
||||
sp_capture_condition_match (const SpCaptureCondition *self,
|
||||
const SpCaptureFrame *frame)
|
||||
sysprof_capture_condition_match (const SysprofCaptureCondition *self,
|
||||
const SysprofCaptureFrame *frame)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (frame != NULL);
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
case SP_CAPTURE_CONDITION_AND:
|
||||
return sp_capture_condition_match (self->u.and.left, frame) &&
|
||||
sp_capture_condition_match (self->u.and.right, frame);
|
||||
case SYSPROF_CAPTURE_CONDITION_AND:
|
||||
return sysprof_capture_condition_match (self->u.and.left, frame) &&
|
||||
sysprof_capture_condition_match (self->u.and.right, frame);
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
for (guint i = 0; i < self->u.where_type_in->len; i++)
|
||||
{
|
||||
if (frame->type == g_array_index (self->u.where_type_in, SpCaptureFrameType, i))
|
||||
if (frame->type == g_array_index (self->u.where_type_in, SysprofCaptureFrameType, i))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
return (frame->time >= self->u.where_time_between.begin && frame->time <= self->u.where_time_between.end);
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
for (guint i = 0; i < self->u.where_pid_in->len; i++)
|
||||
{
|
||||
if (frame->pid == g_array_index (self->u.where_pid_in, gint32, i))
|
||||
@ -97,10 +97,10 @@ sp_capture_condition_match (const SpCaptureCondition *self,
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
if (frame->type == SP_CAPTURE_FRAME_CTRSET)
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
if (frame->type == SYSPROF_CAPTURE_FRAME_CTRSET)
|
||||
{
|
||||
const SpCaptureFrameCounterSet *set = (SpCaptureFrameCounterSet *)frame;
|
||||
const SysprofCaptureFrameCounterSet *set = (SysprofCaptureFrameCounterSet *)frame;
|
||||
|
||||
for (guint i = 0; i < self->u.where_counter_in->len; i++)
|
||||
{
|
||||
@ -120,9 +120,9 @@ sp_capture_condition_match (const SpCaptureCondition *self,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (frame->type == SP_CAPTURE_FRAME_CTRDEF)
|
||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_CTRDEF)
|
||||
{
|
||||
const SpCaptureFrameCounterDefine *def = (SpCaptureFrameCounterDefine *)frame;
|
||||
const SysprofCaptureFrameCounterDefine *def = (SysprofCaptureFrameCounterDefine *)frame;
|
||||
|
||||
for (guint i = 0; i < self->u.where_counter_in->len; i++)
|
||||
{
|
||||
@ -147,47 +147,47 @@ sp_capture_condition_match (const SpCaptureCondition *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static SpCaptureCondition *
|
||||
sp_capture_condition_init (void)
|
||||
static SysprofCaptureCondition *
|
||||
sysprof_capture_condition_init (void)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
self = g_slice_new0 (SpCaptureCondition);
|
||||
self = g_slice_new0 (SysprofCaptureCondition);
|
||||
self->ref_count = 1;
|
||||
|
||||
return g_steal_pointer (&self);
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_copy (const SpCaptureCondition *self)
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_copy (const SysprofCaptureCondition *self)
|
||||
{
|
||||
SpCaptureCondition *copy;
|
||||
SysprofCaptureCondition *copy;
|
||||
|
||||
copy = sp_capture_condition_init ();
|
||||
copy = sysprof_capture_condition_init ();
|
||||
copy->type = self->type;
|
||||
|
||||
switch (self->type)
|
||||
{
|
||||
case SP_CAPTURE_CONDITION_AND:
|
||||
return sp_capture_condition_new_and (
|
||||
sp_capture_condition_copy (self->u.and.left),
|
||||
sp_capture_condition_copy (self->u.and.right));
|
||||
case SYSPROF_CAPTURE_CONDITION_AND:
|
||||
return sysprof_capture_condition_new_and (
|
||||
sysprof_capture_condition_copy (self->u.and.left),
|
||||
sysprof_capture_condition_copy (self->u.and.right));
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
return sp_capture_condition_new_where_type_in (
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
return sysprof_capture_condition_new_where_type_in (
|
||||
self->u.where_type_in->len,
|
||||
(const SpCaptureFrameType *)(gpointer)self->u.where_type_in->data);
|
||||
(const SysprofCaptureFrameType *)(gpointer)self->u.where_type_in->data);
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
return sp_capture_condition_new_where_pid_in (
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
return sysprof_capture_condition_new_where_pid_in (
|
||||
self->u.where_pid_in->len,
|
||||
(const gint32 *)(gpointer)self->u.where_pid_in->data);
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
return sp_capture_condition_new_where_counter_in (
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
return sysprof_capture_condition_new_where_counter_in (
|
||||
self->u.where_counter_in->len,
|
||||
(const guint *)(gpointer)self->u.where_counter_in->data);
|
||||
|
||||
@ -200,27 +200,27 @@ sp_capture_condition_copy (const SpCaptureCondition *self)
|
||||
}
|
||||
|
||||
static void
|
||||
sp_capture_condition_finalize (SpCaptureCondition *self)
|
||||
sysprof_capture_condition_finalize (SysprofCaptureCondition *self)
|
||||
{
|
||||
switch (self->type)
|
||||
{
|
||||
case SP_CAPTURE_CONDITION_AND:
|
||||
sp_capture_condition_unref (self->u.and.left);
|
||||
sp_capture_condition_unref (self->u.and.right);
|
||||
case SYSPROF_CAPTURE_CONDITION_AND:
|
||||
sysprof_capture_condition_unref (self->u.and.left);
|
||||
sysprof_capture_condition_unref (self->u.and.right);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN:
|
||||
g_array_free (self->u.where_type_in, TRUE);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN:
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN:
|
||||
g_array_free (self->u.where_pid_in, TRUE);
|
||||
break;
|
||||
|
||||
case SP_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
case SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN:
|
||||
g_array_free (self->u.where_counter_in, TRUE);
|
||||
break;
|
||||
|
||||
@ -229,11 +229,11 @@ sp_capture_condition_finalize (SpCaptureCondition *self)
|
||||
break;
|
||||
}
|
||||
|
||||
g_slice_free (SpCaptureCondition, self);
|
||||
g_slice_free (SysprofCaptureCondition, self);
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_ref (SpCaptureCondition *self)
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_ref (SysprofCaptureCondition *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (self->ref_count > 0, NULL);
|
||||
@ -243,37 +243,37 @@ sp_capture_condition_ref (SpCaptureCondition *self)
|
||||
}
|
||||
|
||||
void
|
||||
sp_capture_condition_unref (SpCaptureCondition *self)
|
||||
sysprof_capture_condition_unref (SysprofCaptureCondition *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->ref_count > 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&self->ref_count))
|
||||
sp_capture_condition_finalize (self);
|
||||
sysprof_capture_condition_finalize (self);
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_new_where_type_in (guint n_types,
|
||||
const SpCaptureFrameType *types)
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_new_where_type_in (guint n_types,
|
||||
const SysprofCaptureFrameType *types)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
g_return_val_if_fail (types != NULL, NULL);
|
||||
|
||||
self = sp_capture_condition_init ();
|
||||
self->type = SP_CAPTURE_CONDITION_WHERE_TYPE_IN;
|
||||
self->u.where_type_in = g_array_sized_new (FALSE, FALSE, sizeof (SpCaptureFrameType), n_types);
|
||||
self = sysprof_capture_condition_init ();
|
||||
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN;
|
||||
self->u.where_type_in = g_array_sized_new (FALSE, FALSE, sizeof (SysprofCaptureFrameType), n_types);
|
||||
g_array_set_size (self->u.where_type_in, n_types);
|
||||
memcpy (self->u.where_type_in->data, types, sizeof (SpCaptureFrameType) * n_types);
|
||||
memcpy (self->u.where_type_in->data, types, sizeof (SysprofCaptureFrameType) * n_types);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_new_where_time_between (gint64 begin_time,
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_new_where_time_between (gint64 begin_time,
|
||||
gint64 end_time)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
if G_UNLIKELY (begin_time > end_time)
|
||||
{
|
||||
@ -282,24 +282,24 @@ sp_capture_condition_new_where_time_between (gint64 begin_time,
|
||||
end_time = tmp;
|
||||
}
|
||||
|
||||
self = sp_capture_condition_init ();
|
||||
self->type = SP_CAPTURE_CONDITION_WHERE_TIME_BETWEEN;
|
||||
self = sysprof_capture_condition_init ();
|
||||
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN;
|
||||
self->u.where_time_between.begin = begin_time;
|
||||
self->u.where_time_between.end = end_time;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_new_where_pid_in (guint n_pids,
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_new_where_pid_in (guint n_pids,
|
||||
const gint32 *pids)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
g_return_val_if_fail (pids != NULL, NULL);
|
||||
|
||||
self = sp_capture_condition_init ();
|
||||
self->type = SP_CAPTURE_CONDITION_WHERE_PID_IN;
|
||||
self = sysprof_capture_condition_init ();
|
||||
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN;
|
||||
self->u.where_pid_in = g_array_sized_new (FALSE, FALSE, sizeof (gint32), n_pids);
|
||||
g_array_set_size (self->u.where_pid_in, n_pids);
|
||||
memcpy (self->u.where_pid_in->data, pids, sizeof (gint32) * n_pids);
|
||||
@ -307,16 +307,16 @@ sp_capture_condition_new_where_pid_in (guint n_pids,
|
||||
return self;
|
||||
}
|
||||
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_new_where_counter_in (guint n_counters,
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_new_where_counter_in (guint n_counters,
|
||||
const guint *counters)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
g_return_val_if_fail (counters != NULL || n_counters == 0, NULL);
|
||||
|
||||
self = sp_capture_condition_init ();
|
||||
self->type = SP_CAPTURE_CONDITION_WHERE_COUNTER_IN;
|
||||
self = sysprof_capture_condition_init ();
|
||||
self->type = SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN;
|
||||
self->u.where_counter_in = g_array_sized_new (FALSE, FALSE, sizeof (guint), n_counters);
|
||||
|
||||
if (n_counters > 0)
|
||||
@ -329,26 +329,26 @@ sp_capture_condition_new_where_counter_in (guint n_counters,
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_condition_new_and:
|
||||
* @left: (transfer full): An #SpCaptureCondition
|
||||
* @right: (transfer full): An #SpCaptureCondition
|
||||
* sysprof_capture_condition_new_and:
|
||||
* @left: (transfer full): An #SysprofCaptureCondition
|
||||
* @right: (transfer full): An #SysprofCaptureCondition
|
||||
*
|
||||
* Creates a new #SpCaptureCondition that requires both left and right
|
||||
* Creates a new #SysprofCaptureCondition that requires both left and right
|
||||
* to evaluate to %TRUE.
|
||||
*
|
||||
* Returns: (transfer full): A new #SpCaptureCondition.
|
||||
* Returns: (transfer full): A new #SysprofCaptureCondition.
|
||||
*/
|
||||
SpCaptureCondition *
|
||||
sp_capture_condition_new_and (SpCaptureCondition *left,
|
||||
SpCaptureCondition *right)
|
||||
SysprofCaptureCondition *
|
||||
sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
||||
SysprofCaptureCondition *right)
|
||||
{
|
||||
SpCaptureCondition *self;
|
||||
SysprofCaptureCondition *self;
|
||||
|
||||
g_return_val_if_fail (left != NULL, NULL);
|
||||
g_return_val_if_fail (right != NULL, NULL);
|
||||
|
||||
self = sp_capture_condition_init ();
|
||||
self->type = SP_CAPTURE_CONDITION_AND;
|
||||
self = sysprof_capture_condition_init ();
|
||||
self->type = SYSPROF_CAPTURE_CONDITION_AND;
|
||||
self->u.and.left = left;
|
||||
self->u.and.right = right;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-condition.h
|
||||
/* sysprof-capture-condition.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,36 +20,36 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sp-capture-types.h"
|
||||
#include "sysprof-capture-types.h"
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_copy (const SpCaptureCondition *self);
|
||||
SysprofCaptureCondition *sysprof_capture_condition_copy (const SysprofCaptureCondition *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_condition_unref (SpCaptureCondition *self);
|
||||
void sysprof_capture_condition_unref (SysprofCaptureCondition *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_ref (SpCaptureCondition *self);
|
||||
SysprofCaptureCondition *sysprof_capture_condition_ref (SysprofCaptureCondition *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_new_and (SpCaptureCondition *left,
|
||||
SpCaptureCondition *right);
|
||||
SysprofCaptureCondition *sysprof_capture_condition_new_and (SysprofCaptureCondition *left,
|
||||
SysprofCaptureCondition *right);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_new_where_type_in (guint n_types,
|
||||
const SpCaptureFrameType *types);
|
||||
SysprofCaptureCondition *sysprof_capture_condition_new_where_type_in (guint n_types,
|
||||
const SysprofCaptureFrameType *types);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_new_where_time_between (gint64 begin_time,
|
||||
SysprofCaptureCondition *sysprof_capture_condition_new_where_time_between (gint64 begin_time,
|
||||
gint64 end_time);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_new_where_pid_in (guint n_pids,
|
||||
SysprofCaptureCondition *sysprof_capture_condition_new_where_pid_in (guint n_pids,
|
||||
const gint32 *pids);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCondition *sp_capture_condition_new_where_counter_in (guint n_counters,
|
||||
SysprofCaptureCondition *sysprof_capture_condition_new_where_counter_in (guint n_counters,
|
||||
const guint *counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_condition_match (const SpCaptureCondition *self,
|
||||
const SpCaptureFrame *frame);
|
||||
gboolean sysprof_capture_condition_match (const SysprofCaptureCondition *self,
|
||||
const SysprofCaptureFrame *frame);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureCondition, sp_capture_condition_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureCondition, sysprof_capture_condition_unref)
|
||||
|
||||
G_END_DECLS
|
||||
265
src/libsysprof-capture/sysprof-capture-cursor.c
Normal file
265
src/libsysprof-capture/sysprof-capture-cursor.c
Normal file
@ -0,0 +1,265 @@
|
||||
/* sysprof-capture-cursor.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sysprof-capture-cursor"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-capture-condition.h"
|
||||
#include "sysprof-capture-cursor.h"
|
||||
#include "sysprof-capture-reader.h"
|
||||
|
||||
#define READ_DELEGATE(f) ((ReadDelegate)(f))
|
||||
|
||||
typedef const SysprofCaptureFrame *(*ReadDelegate) (SysprofCaptureReader *);
|
||||
|
||||
struct _SysprofCaptureCursor
|
||||
{
|
||||
volatile gint ref_count;
|
||||
GPtrArray *conditions;
|
||||
SysprofCaptureReader *reader;
|
||||
guint reversed : 1;
|
||||
};
|
||||
|
||||
static void
|
||||
sysprof_capture_cursor_finalize (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_clear_pointer (&self->conditions, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->reader, sysprof_capture_reader_unref);
|
||||
g_slice_free (SysprofCaptureCursor, self);
|
||||
}
|
||||
|
||||
static SysprofCaptureCursor *
|
||||
sysprof_capture_cursor_init (void)
|
||||
{
|
||||
SysprofCaptureCursor *self;
|
||||
|
||||
self = g_slice_new0 (SysprofCaptureCursor);
|
||||
self->conditions = g_ptr_array_new_with_free_func ((GDestroyNotify) sysprof_capture_condition_unref);
|
||||
self->ref_count = 1;
|
||||
|
||||
return g_steal_pointer (&self);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_ref:
|
||||
* @self: a #SysprofCaptureCursor
|
||||
*
|
||||
* Returns: (transfer full): @self
|
||||
*
|
||||
* Since: 3.34
|
||||
*/
|
||||
SysprofCaptureCursor *
|
||||
sysprof_capture_cursor_ref (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (self->ref_count > 0, NULL);
|
||||
|
||||
g_atomic_int_inc (&self->ref_count);
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_unref:
|
||||
* @self: a #SysprofCaptureCursor
|
||||
*
|
||||
* Since: 3.34
|
||||
*/
|
||||
void
|
||||
sysprof_capture_cursor_unref (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->ref_count > 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&self->ref_count))
|
||||
sysprof_capture_cursor_finalize (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_foreach:
|
||||
* @self: a #SysprofCaptureCursor
|
||||
* @callback: (scope call): a closure to execute
|
||||
* @user_data: user data for @callback
|
||||
*
|
||||
*/
|
||||
void
|
||||
sysprof_capture_cursor_foreach (SysprofCaptureCursor *self,
|
||||
SysprofCaptureCursorCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->reader != NULL);
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const SysprofCaptureFrame *frame;
|
||||
SysprofCaptureFrameType type = 0;
|
||||
ReadDelegate delegate = NULL;
|
||||
|
||||
if (!sysprof_capture_reader_peek_type (self->reader, &type))
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SYSPROF_CAPTURE_FRAME_TIMESTAMP:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_timestamp);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_SAMPLE:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_sample);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_MAP:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_map);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_MARK:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_mark);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_PROCESS:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_process);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_FORK:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_fork);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_EXIT:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_exit);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_JITMAP:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_jitmap);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_CTRDEF:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_counter_define);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_CTRSET:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_counter_set);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!sysprof_capture_reader_skip (self->reader))
|
||||
return;
|
||||
delegate = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (delegate == NULL)
|
||||
continue;
|
||||
|
||||
if (NULL == (frame = delegate (self->reader)))
|
||||
return;
|
||||
|
||||
if (self->conditions->len == 0)
|
||||
{
|
||||
if (!callback (frame, user_data))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (guint i = 0; i < self->conditions->len; i++)
|
||||
{
|
||||
const SysprofCaptureCondition *condition = g_ptr_array_index (self->conditions, i);
|
||||
|
||||
if (sysprof_capture_condition_match (condition, frame))
|
||||
{
|
||||
if (!callback (frame, user_data))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_capture_cursor_reset (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (self->reader != NULL);
|
||||
|
||||
sysprof_capture_reader_reset (self->reader);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_capture_cursor_reverse (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
self->reversed = !self->reversed;
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_add_condition:
|
||||
* @self: An #SysprofCaptureCursor
|
||||
* @condition: (transfer full): An #SysprofCaptureCondition
|
||||
*
|
||||
* Adds the condition to the cursor. This condition must evaluate to
|
||||
* true or a given #SysprofCapureFrame will not be matched.
|
||||
*/
|
||||
void
|
||||
sysprof_capture_cursor_add_condition (SysprofCaptureCursor *self,
|
||||
SysprofCaptureCondition *condition)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (condition != NULL);
|
||||
|
||||
g_ptr_array_add (self->conditions, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_new:
|
||||
* @self: a #SysprofCaptureCursor
|
||||
*
|
||||
* Returns: (transfer full): a new cursor for @reader
|
||||
*/
|
||||
SysprofCaptureCursor *
|
||||
sysprof_capture_cursor_new (SysprofCaptureReader *reader)
|
||||
{
|
||||
SysprofCaptureCursor *self;
|
||||
|
||||
g_return_val_if_fail (reader != NULL, NULL);
|
||||
|
||||
self = sysprof_capture_cursor_init ();
|
||||
self->reader = sysprof_capture_reader_copy (reader);
|
||||
sysprof_capture_reader_reset (self->reader);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_capture_cursor_get_reader:
|
||||
*
|
||||
* Gets the underlying reader that is used by the cursor.
|
||||
*
|
||||
* Returns: (transfer none): An #SysprofCaptureReader
|
||||
*/
|
||||
SysprofCaptureReader *
|
||||
sysprof_capture_cursor_get_reader (SysprofCaptureCursor *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
return self->reader;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-cursor.h
|
||||
/* sysprof-capture-cursor.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,15 +20,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sp-capture-types.h"
|
||||
#include "sysprof-capture-types.h"
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _SpCaptureCursor SpCaptureCursor;
|
||||
typedef struct _SysprofCaptureCursor SysprofCaptureCursor;
|
||||
|
||||
/**
|
||||
* SpCaptureCursorCallback:
|
||||
* SysprofCaptureCursorCallback:
|
||||
*
|
||||
* This is the prototype for callbacks that are called for each frame
|
||||
* matching the cursor query.
|
||||
@ -38,29 +38,29 @@ typedef struct _SpCaptureCursor SpCaptureCursor;
|
||||
*
|
||||
* Returns: %TRUE if iteration should stop, otherwise %FALSE.
|
||||
*/
|
||||
typedef gboolean (*SpCaptureCursorCallback) (const SpCaptureFrame *frame,
|
||||
typedef gboolean (*SysprofCaptureCursorCallback) (const SysprofCaptureFrame *frame,
|
||||
gpointer user_data);
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCursor *sp_capture_cursor_new (SpCaptureReader *reader);
|
||||
SysprofCaptureCursor *sysprof_capture_cursor_new (SysprofCaptureReader *reader);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_cursor_unref (SpCaptureCursor *self);
|
||||
void sysprof_capture_cursor_unref (SysprofCaptureCursor *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureCursor *sp_capture_cursor_ref (SpCaptureCursor *self);
|
||||
SysprofCaptureCursor *sysprof_capture_cursor_ref (SysprofCaptureCursor *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_cursor_get_reader (SpCaptureCursor *self);
|
||||
SysprofCaptureReader *sysprof_capture_cursor_get_reader (SysprofCaptureCursor *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_cursor_foreach (SpCaptureCursor *self,
|
||||
SpCaptureCursorCallback callback,
|
||||
void sysprof_capture_cursor_foreach (SysprofCaptureCursor *self,
|
||||
SysprofCaptureCursorCallback callback,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_cursor_reset (SpCaptureCursor *self);
|
||||
void sysprof_capture_cursor_reset (SysprofCaptureCursor *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_cursor_reverse (SpCaptureCursor *self);
|
||||
void sysprof_capture_cursor_reverse (SysprofCaptureCursor *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_cursor_add_condition (SpCaptureCursor *self,
|
||||
SpCaptureCondition *condition);
|
||||
void sysprof_capture_cursor_add_condition (SysprofCaptureCursor *self,
|
||||
SysprofCaptureCondition *condition);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureCursor, sp_capture_cursor_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureCursor, sysprof_capture_cursor_unref)
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-reader.c
|
||||
/* sysprof-capture-reader.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -18,7 +18,7 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-capture-reader"
|
||||
#define G_LOG_DOMAIN "sysprof-capture-reader"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -29,11 +29,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sp-capture-reader.h"
|
||||
#include "sp-capture-util-private.h"
|
||||
#include "sp-capture-writer.h"
|
||||
#include "sysprof-capture-reader.h"
|
||||
#include "sysprof-capture-util-private.h"
|
||||
#include "sysprof-capture-writer.h"
|
||||
|
||||
struct _SpCaptureReader
|
||||
struct _SysprofCaptureReader
|
||||
{
|
||||
volatile gint ref_count;
|
||||
gchar *filename;
|
||||
@ -44,24 +44,24 @@ struct _SpCaptureReader
|
||||
gsize fd_off;
|
||||
int fd;
|
||||
gint endian;
|
||||
SpCaptureFileHeader header;
|
||||
SysprofCaptureFileHeader header;
|
||||
gint64 end_time;
|
||||
};
|
||||
|
||||
#ifdef SP_ENABLE_GOBJECT
|
||||
G_DEFINE_BOXED_TYPE (SpCaptureReader, sp_capture_reader,
|
||||
sp_capture_reader_ref, sp_capture_reader_unref)
|
||||
#ifdef SYSPROF_ENABLE_GOBJECT
|
||||
G_DEFINE_BOXED_TYPE (SysprofCaptureReader, sysprof_capture_reader,
|
||||
sysprof_capture_reader_ref, sysprof_capture_reader_unref)
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
sp_capture_reader_read_file_header (SpCaptureReader *self,
|
||||
SpCaptureFileHeader *header,
|
||||
sysprof_capture_reader_read_file_header (SysprofCaptureReader *self,
|
||||
SysprofCaptureFileHeader *header,
|
||||
GError **error)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (header != NULL);
|
||||
|
||||
if (sizeof *header != _sp_pread (self->fd, header, sizeof *header, 0L))
|
||||
if (sizeof *header != _sysprof_pread (self->fd, header, sizeof *header, 0L))
|
||||
{
|
||||
g_set_error (error,
|
||||
G_FILE_ERROR,
|
||||
@ -70,7 +70,7 @@ sp_capture_reader_read_file_header (SpCaptureReader *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (header->magic != SP_CAPTURE_MAGIC)
|
||||
if (header->magic != SYSPROF_CAPTURE_MAGIC)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_FILE_ERROR,
|
||||
@ -85,7 +85,7 @@ sp_capture_reader_read_file_header (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_capture_reader_finalize (SpCaptureReader *self)
|
||||
sysprof_capture_reader_finalize (SysprofCaptureReader *self)
|
||||
{
|
||||
if (self != NULL)
|
||||
{
|
||||
@ -97,7 +97,7 @@ sp_capture_reader_finalize (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
const gchar *
|
||||
sp_capture_reader_get_time (SpCaptureReader *self)
|
||||
sysprof_capture_reader_get_time (SysprofCaptureReader *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
@ -105,7 +105,7 @@ sp_capture_reader_get_time (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
const gchar *
|
||||
sp_capture_reader_get_filename (SpCaptureReader *self)
|
||||
sysprof_capture_reader_get_filename (SysprofCaptureReader *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
@ -113,7 +113,7 @@ sp_capture_reader_get_filename (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_reader_new_from_fd:
|
||||
* sysprof_capture_reader_new_from_fd:
|
||||
* @fd: an fd to take ownership from
|
||||
* @error: a location for a #GError or %NULL
|
||||
*
|
||||
@ -121,28 +121,28 @@ sp_capture_reader_get_filename (SpCaptureReader *self)
|
||||
*
|
||||
* This is useful if you don't necessarily have access to the filename itself.
|
||||
*
|
||||
* Returns: (transfer full): an #SpCaptureReader or %NULL upon failure.
|
||||
* Returns: (transfer full): an #SysprofCaptureReader or %NULL upon failure.
|
||||
*/
|
||||
SpCaptureReader *
|
||||
sp_capture_reader_new_from_fd (int fd,
|
||||
SysprofCaptureReader *
|
||||
sysprof_capture_reader_new_from_fd (int fd,
|
||||
GError **error)
|
||||
{
|
||||
SpCaptureReader *self;
|
||||
SysprofCaptureReader *self;
|
||||
|
||||
g_assert (fd > -1);
|
||||
|
||||
self = g_new0 (SpCaptureReader, 1);
|
||||
self = g_new0 (SysprofCaptureReader, 1);
|
||||
self->ref_count = 1;
|
||||
self->bufsz = G_MAXUSHORT * 2;
|
||||
self->buf = g_malloc (self->bufsz);
|
||||
self->len = 0;
|
||||
self->pos = 0;
|
||||
self->fd = fd;
|
||||
self->fd_off = sizeof (SpCaptureFileHeader);
|
||||
self->fd_off = sizeof (SysprofCaptureFileHeader);
|
||||
|
||||
if (!sp_capture_reader_read_file_header (self, &self->header, error))
|
||||
if (!sysprof_capture_reader_read_file_header (self, &self->header, error))
|
||||
{
|
||||
sp_capture_reader_finalize (self);
|
||||
sysprof_capture_reader_finalize (self);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -154,11 +154,11 @@ sp_capture_reader_new_from_fd (int fd,
|
||||
return self;
|
||||
}
|
||||
|
||||
SpCaptureReader *
|
||||
sp_capture_reader_new (const gchar *filename,
|
||||
SysprofCaptureReader *
|
||||
sysprof_capture_reader_new (const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
SpCaptureReader *self;
|
||||
SysprofCaptureReader *self;
|
||||
int fd;
|
||||
|
||||
g_assert (filename != NULL);
|
||||
@ -172,7 +172,7 @@ sp_capture_reader_new (const gchar *filename,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (NULL == (self = sp_capture_reader_new_from_fd (fd, error)))
|
||||
if (NULL == (self = sysprof_capture_reader_new_from_fd (fd, error)))
|
||||
{
|
||||
close (fd);
|
||||
return NULL;
|
||||
@ -184,8 +184,8 @@ sp_capture_reader_new (const gchar *filename,
|
||||
}
|
||||
|
||||
static inline void
|
||||
sp_capture_reader_bswap_frame (SpCaptureReader *self,
|
||||
SpCaptureFrame *frame)
|
||||
sysprof_capture_reader_bswap_frame (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrame *frame)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (frame!= NULL);
|
||||
@ -200,8 +200,8 @@ sp_capture_reader_bswap_frame (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
static inline void
|
||||
sp_capture_reader_bswap_map (SpCaptureReader *self,
|
||||
SpCaptureMap *map)
|
||||
sysprof_capture_reader_bswap_map (SysprofCaptureReader *self,
|
||||
SysprofCaptureMap *map)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (map != NULL);
|
||||
@ -216,8 +216,8 @@ sp_capture_reader_bswap_map (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
static inline void
|
||||
sp_capture_reader_bswap_mark (SpCaptureReader *self,
|
||||
SpCaptureMark *mark)
|
||||
sysprof_capture_reader_bswap_mark (SysprofCaptureReader *self,
|
||||
SysprofCaptureMark *mark)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (mark != NULL);
|
||||
@ -227,8 +227,8 @@ sp_capture_reader_bswap_mark (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
static inline void
|
||||
sp_capture_reader_bswap_jitmap (SpCaptureReader *self,
|
||||
SpCaptureJitmap *jitmap)
|
||||
sysprof_capture_reader_bswap_jitmap (SysprofCaptureReader *self,
|
||||
SysprofCaptureJitmap *jitmap)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (jitmap != NULL);
|
||||
@ -238,7 +238,7 @@ sp_capture_reader_bswap_jitmap (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_capture_reader_ensure_space_for (SpCaptureReader *self,
|
||||
sysprof_capture_reader_ensure_space_for (SysprofCaptureReader *self,
|
||||
gsize len)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
@ -260,7 +260,7 @@ sp_capture_reader_ensure_space_for (SpCaptureReader *self,
|
||||
g_assert (self->len < self->bufsz);
|
||||
|
||||
/* Read into our buffer after our current read position */
|
||||
r = _sp_pread (self->fd,
|
||||
r = _sysprof_pread (self->fd,
|
||||
&self->buf[self->len],
|
||||
self->bufsz - self->len,
|
||||
self->fd_off);
|
||||
@ -277,56 +277,56 @@ sp_capture_reader_ensure_space_for (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_capture_reader_skip (SpCaptureReader *self)
|
||||
sysprof_capture_reader_skip (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureFrame *frame;
|
||||
SysprofCaptureFrame *frame;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof (SpCaptureFrame)))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof (SysprofCaptureFrame)))
|
||||
return FALSE;
|
||||
|
||||
frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
sp_capture_reader_bswap_frame (self, frame);
|
||||
frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
sysprof_capture_reader_bswap_frame (self, frame);
|
||||
|
||||
if (frame->len < sizeof (SpCaptureFrame))
|
||||
if (frame->len < sizeof (SysprofCaptureFrame))
|
||||
return FALSE;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, frame->len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, frame->len))
|
||||
return FALSE;
|
||||
|
||||
frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
self->pos += frame->len;
|
||||
|
||||
if ((self->pos % SP_CAPTURE_ALIGN) != 0)
|
||||
if ((self->pos % SYSPROF_CAPTURE_ALIGN) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_capture_reader_peek_frame (SpCaptureReader *self,
|
||||
SpCaptureFrame *frame)
|
||||
sysprof_capture_reader_peek_frame (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrame *frame)
|
||||
{
|
||||
SpCaptureFrame *real_frame;
|
||||
SysprofCaptureFrame *real_frame;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->len);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *real_frame))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *real_frame))
|
||||
return FALSE;
|
||||
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
|
||||
real_frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
real_frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
*frame = *real_frame;
|
||||
|
||||
sp_capture_reader_bswap_frame (self, frame);
|
||||
sysprof_capture_reader_bswap_frame (self, frame);
|
||||
|
||||
if (frame->time > self->end_time)
|
||||
self->end_time = frame->time;
|
||||
@ -335,15 +335,15 @@ sp_capture_reader_peek_frame (SpCaptureReader *self,
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_capture_reader_peek_type (SpCaptureReader *self,
|
||||
SpCaptureFrameType *type)
|
||||
sysprof_capture_reader_peek_type (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrameType *type)
|
||||
{
|
||||
SpCaptureFrame frame;
|
||||
SysprofCaptureFrame frame;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert (type != NULL);
|
||||
|
||||
if (!sp_capture_reader_peek_frame (self, &frame))
|
||||
if (!sysprof_capture_reader_peek_frame (self, &frame))
|
||||
return FALSE;
|
||||
|
||||
*type = frame.type;
|
||||
@ -351,24 +351,24 @@ sp_capture_reader_peek_type (SpCaptureReader *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const SpCaptureFrame *
|
||||
sp_capture_reader_read_basic (SpCaptureReader *self,
|
||||
SpCaptureFrameType type,
|
||||
static const SysprofCaptureFrame *
|
||||
sysprof_capture_reader_read_basic (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrameType type,
|
||||
gsize extra)
|
||||
{
|
||||
SpCaptureFrame *frame;
|
||||
SysprofCaptureFrame *frame;
|
||||
gsize len = sizeof *frame + extra;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, len))
|
||||
return NULL;
|
||||
|
||||
frame = (SpCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, frame);
|
||||
sysprof_capture_reader_bswap_frame (self, frame);
|
||||
|
||||
if (frame->len < len)
|
||||
return NULL;
|
||||
@ -381,29 +381,29 @@ sp_capture_reader_read_basic (SpCaptureReader *self,
|
||||
return frame;
|
||||
}
|
||||
|
||||
const SpCaptureTimestamp *
|
||||
sp_capture_reader_read_timestamp (SpCaptureReader *self)
|
||||
const SysprofCaptureTimestamp *
|
||||
sysprof_capture_reader_read_timestamp (SysprofCaptureReader *self)
|
||||
{
|
||||
return (SpCaptureTimestamp *)
|
||||
sp_capture_reader_read_basic (self, SP_CAPTURE_FRAME_TIMESTAMP, 0);
|
||||
return (SysprofCaptureTimestamp *)
|
||||
sysprof_capture_reader_read_basic (self, SYSPROF_CAPTURE_FRAME_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
const SpCaptureExit *
|
||||
sp_capture_reader_read_exit (SpCaptureReader *self)
|
||||
const SysprofCaptureExit *
|
||||
sysprof_capture_reader_read_exit (SysprofCaptureReader *self)
|
||||
{
|
||||
return (SpCaptureExit *)
|
||||
sp_capture_reader_read_basic (self, SP_CAPTURE_FRAME_EXIT, 0);
|
||||
return (SysprofCaptureExit *)
|
||||
sysprof_capture_reader_read_basic (self, SYSPROF_CAPTURE_FRAME_EXIT, 0);
|
||||
}
|
||||
|
||||
const SpCaptureFork *
|
||||
sp_capture_reader_read_fork (SpCaptureReader *self)
|
||||
const SysprofCaptureFork *
|
||||
sysprof_capture_reader_read_fork (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureFork *fk;
|
||||
SysprofCaptureFork *fk;
|
||||
|
||||
g_assert (self != NULL);
|
||||
|
||||
fk = (SpCaptureFork *)
|
||||
sp_capture_reader_read_basic (self, SP_CAPTURE_FRAME_FORK, sizeof(guint32));
|
||||
fk = (SysprofCaptureFork *)
|
||||
sysprof_capture_reader_read_basic (self, SYSPROF_CAPTURE_FRAME_FORK, sizeof(guint32));
|
||||
|
||||
if (fk != NULL)
|
||||
{
|
||||
@ -414,78 +414,78 @@ sp_capture_reader_read_fork (SpCaptureReader *self)
|
||||
return fk;
|
||||
}
|
||||
|
||||
const SpCaptureMap *
|
||||
sp_capture_reader_read_map (SpCaptureReader *self)
|
||||
const SysprofCaptureMap *
|
||||
sysprof_capture_reader_read_map (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureMap *map;
|
||||
SysprofCaptureMap *map;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *map))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *map))
|
||||
return NULL;
|
||||
|
||||
map = (SpCaptureMap *)(gpointer)&self->buf[self->pos];
|
||||
map = (SysprofCaptureMap *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, &map->frame);
|
||||
sysprof_capture_reader_bswap_frame (self, &map->frame);
|
||||
|
||||
if (map->frame.type != SP_CAPTURE_FRAME_MAP)
|
||||
if (map->frame.type != SYSPROF_CAPTURE_FRAME_MAP)
|
||||
return NULL;
|
||||
|
||||
if (map->frame.len < (sizeof *map + 1))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, map->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, map->frame.len))
|
||||
return NULL;
|
||||
|
||||
map = (SpCaptureMap *)(gpointer)&self->buf[self->pos];
|
||||
map = (SysprofCaptureMap *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (self->buf[self->pos + map->frame.len - 1] != '\0')
|
||||
return NULL;
|
||||
|
||||
sp_capture_reader_bswap_map (self, map);
|
||||
sysprof_capture_reader_bswap_map (self, map);
|
||||
|
||||
self->pos += map->frame.len;
|
||||
|
||||
if ((self->pos % SP_CAPTURE_ALIGN) != 0)
|
||||
if ((self->pos % SYSPROF_CAPTURE_ALIGN) != 0)
|
||||
return NULL;
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
const SpCaptureMark *
|
||||
sp_capture_reader_read_mark (SpCaptureReader *self)
|
||||
const SysprofCaptureMark *
|
||||
sysprof_capture_reader_read_mark (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureMark *mark;
|
||||
SysprofCaptureMark *mark;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *mark))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *mark))
|
||||
return NULL;
|
||||
|
||||
mark = (SpCaptureMark *)(gpointer)&self->buf[self->pos];
|
||||
mark = (SysprofCaptureMark *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, &mark->frame);
|
||||
sysprof_capture_reader_bswap_frame (self, &mark->frame);
|
||||
|
||||
if (mark->frame.type != SP_CAPTURE_FRAME_MARK)
|
||||
if (mark->frame.type != SYSPROF_CAPTURE_FRAME_MARK)
|
||||
return NULL;
|
||||
|
||||
if (mark->frame.len < (sizeof *mark + 1))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, mark->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, mark->frame.len))
|
||||
return NULL;
|
||||
|
||||
mark = (SpCaptureMark *)(gpointer)&self->buf[self->pos];
|
||||
mark = (SysprofCaptureMark *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_mark (self, mark);
|
||||
sysprof_capture_reader_bswap_mark (self, mark);
|
||||
|
||||
self->pos += mark->frame.len;
|
||||
|
||||
if ((self->pos % SP_CAPTURE_ALIGN) != 0)
|
||||
if ((self->pos % SYSPROF_CAPTURE_ALIGN) != 0)
|
||||
return NULL;
|
||||
|
||||
/* Ensure trailing \0 in name and message */
|
||||
@ -495,74 +495,74 @@ sp_capture_reader_read_mark (SpCaptureReader *self)
|
||||
return mark;
|
||||
}
|
||||
|
||||
const SpCaptureProcess *
|
||||
sp_capture_reader_read_process (SpCaptureReader *self)
|
||||
const SysprofCaptureProcess *
|
||||
sysprof_capture_reader_read_process (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureProcess *process;
|
||||
SysprofCaptureProcess *process;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *process))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *process))
|
||||
return NULL;
|
||||
|
||||
process = (SpCaptureProcess *)(gpointer)&self->buf[self->pos];
|
||||
process = (SysprofCaptureProcess *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, &process->frame);
|
||||
sysprof_capture_reader_bswap_frame (self, &process->frame);
|
||||
|
||||
if (process->frame.type != SP_CAPTURE_FRAME_PROCESS)
|
||||
if (process->frame.type != SYSPROF_CAPTURE_FRAME_PROCESS)
|
||||
return NULL;
|
||||
|
||||
if (process->frame.len < (sizeof *process + 1))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, process->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, process->frame.len))
|
||||
return NULL;
|
||||
|
||||
process = (SpCaptureProcess *)(gpointer)&self->buf[self->pos];
|
||||
process = (SysprofCaptureProcess *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (self->buf[self->pos + process->frame.len - 1] != '\0')
|
||||
return NULL;
|
||||
|
||||
self->pos += process->frame.len;
|
||||
|
||||
if ((self->pos % SP_CAPTURE_ALIGN) != 0)
|
||||
if ((self->pos % SYSPROF_CAPTURE_ALIGN) != 0)
|
||||
return NULL;
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
sp_capture_reader_read_jitmap (SpCaptureReader *self)
|
||||
sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self)
|
||||
{
|
||||
g_autoptr(GHashTable) ret = NULL;
|
||||
SpCaptureJitmap *jitmap;
|
||||
SysprofCaptureJitmap *jitmap;
|
||||
guint8 *buf;
|
||||
guint8 *endptr;
|
||||
guint i;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *jitmap))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *jitmap))
|
||||
return NULL;
|
||||
|
||||
jitmap = (SpCaptureJitmap *)(gpointer)&self->buf[self->pos];
|
||||
jitmap = (SysprofCaptureJitmap *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, &jitmap->frame);
|
||||
sysprof_capture_reader_bswap_frame (self, &jitmap->frame);
|
||||
|
||||
if (jitmap->frame.type != SP_CAPTURE_FRAME_JITMAP)
|
||||
if (jitmap->frame.type != SYSPROF_CAPTURE_FRAME_JITMAP)
|
||||
return NULL;
|
||||
|
||||
if (jitmap->frame.len < sizeof *jitmap)
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, jitmap->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, jitmap->frame.len))
|
||||
return NULL;
|
||||
|
||||
jitmap = (SpCaptureJitmap *)(gpointer)&self->buf[self->pos];
|
||||
jitmap = (SysprofCaptureJitmap *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
ret = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
||||
|
||||
@ -571,7 +571,7 @@ sp_capture_reader_read_jitmap (SpCaptureReader *self)
|
||||
|
||||
for (i = 0; i < jitmap->n_jitmaps; i++)
|
||||
{
|
||||
SpCaptureAddress addr;
|
||||
SysprofCaptureAddress addr;
|
||||
const gchar *str;
|
||||
|
||||
if (buf + sizeof addr >= endptr)
|
||||
@ -592,30 +592,30 @@ sp_capture_reader_read_jitmap (SpCaptureReader *self)
|
||||
g_hash_table_insert (ret, GSIZE_TO_POINTER (addr), g_strdup (str));
|
||||
}
|
||||
|
||||
sp_capture_reader_bswap_jitmap (self, jitmap);
|
||||
sysprof_capture_reader_bswap_jitmap (self, jitmap);
|
||||
|
||||
self->pos += jitmap->frame.len;
|
||||
|
||||
return g_steal_pointer (&ret);
|
||||
}
|
||||
|
||||
const SpCaptureSample *
|
||||
sp_capture_reader_read_sample (SpCaptureReader *self)
|
||||
const SysprofCaptureSample *
|
||||
sysprof_capture_reader_read_sample (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureSample *sample;
|
||||
SysprofCaptureSample *sample;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *sample))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *sample))
|
||||
return NULL;
|
||||
|
||||
sample = (SpCaptureSample *)(gpointer)&self->buf[self->pos];
|
||||
sample = (SysprofCaptureSample *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sp_capture_reader_bswap_frame (self, &sample->frame);
|
||||
sysprof_capture_reader_bswap_frame (self, &sample->frame);
|
||||
|
||||
if (sample->frame.type != SP_CAPTURE_FRAME_SAMPLE)
|
||||
if (sample->frame.type != SYSPROF_CAPTURE_FRAME_SAMPLE)
|
||||
return NULL;
|
||||
|
||||
if (sample->frame.len < sizeof *sample)
|
||||
@ -624,13 +624,13 @@ sp_capture_reader_read_sample (SpCaptureReader *self)
|
||||
if (self->endian != G_BYTE_ORDER)
|
||||
sample->n_addrs = GUINT16_SWAP_LE_BE (sample->n_addrs);
|
||||
|
||||
if (sample->frame.len < (sizeof *sample + (sizeof(SpCaptureAddress) * sample->n_addrs)))
|
||||
if (sample->frame.len < (sizeof *sample + (sizeof(SysprofCaptureAddress) * sample->n_addrs)))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sample->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sample->frame.len))
|
||||
return NULL;
|
||||
|
||||
sample = (SpCaptureSample *)(gpointer)&self->buf[self->pos];
|
||||
sample = (SysprofCaptureSample *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (G_UNLIKELY (self->endian != G_BYTE_ORDER))
|
||||
{
|
||||
@ -645,21 +645,21 @@ sp_capture_reader_read_sample (SpCaptureReader *self)
|
||||
return sample;
|
||||
}
|
||||
|
||||
const SpCaptureFrameCounterDefine *
|
||||
sp_capture_reader_read_counter_define (SpCaptureReader *self)
|
||||
const SysprofCaptureFrameCounterDefine *
|
||||
sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureFrameCounterDefine *def;
|
||||
SysprofCaptureFrameCounterDefine *def;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *def))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *def))
|
||||
return NULL;
|
||||
|
||||
def = (SpCaptureFrameCounterDefine *)(gpointer)&self->buf[self->pos];
|
||||
def = (SysprofCaptureFrameCounterDefine *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (def->frame.type != SP_CAPTURE_FRAME_CTRDEF)
|
||||
if (def->frame.type != SYSPROF_CAPTURE_FRAME_CTRDEF)
|
||||
return NULL;
|
||||
|
||||
if (def->frame.len < sizeof *def)
|
||||
@ -668,13 +668,13 @@ sp_capture_reader_read_counter_define (SpCaptureReader *self)
|
||||
if (G_UNLIKELY (self->endian != G_BYTE_ORDER))
|
||||
def->n_counters = GUINT16_SWAP_LE_BE (def->n_counters);
|
||||
|
||||
if (def->frame.len < (sizeof *def + (sizeof (SpCaptureFrameCounterDefine) * def->n_counters)))
|
||||
if (def->frame.len < (sizeof *def + (sizeof (SysprofCaptureFrameCounterDefine) * def->n_counters)))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, def->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, def->frame.len))
|
||||
return NULL;
|
||||
|
||||
def = (SpCaptureFrameCounterDefine *)(gpointer)&self->buf[self->pos];
|
||||
def = (SysprofCaptureFrameCounterDefine *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (G_UNLIKELY (self->endian != G_BYTE_ORDER))
|
||||
{
|
||||
@ -692,21 +692,21 @@ sp_capture_reader_read_counter_define (SpCaptureReader *self)
|
||||
return def;
|
||||
}
|
||||
|
||||
const SpCaptureFrameCounterSet *
|
||||
sp_capture_reader_read_counter_set (SpCaptureReader *self)
|
||||
const SysprofCaptureFrameCounterSet *
|
||||
sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureFrameCounterSet *set;
|
||||
SysprofCaptureFrameCounterSet *set;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SP_CAPTURE_ALIGN) == 0);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, sizeof *set))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *set))
|
||||
return NULL;
|
||||
|
||||
set = (SpCaptureFrameCounterSet *)(gpointer)&self->buf[self->pos];
|
||||
set = (SysprofCaptureFrameCounterSet *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (set->frame.type != SP_CAPTURE_FRAME_CTRSET)
|
||||
if (set->frame.type != SYSPROF_CAPTURE_FRAME_CTRSET)
|
||||
return NULL;
|
||||
|
||||
if (set->frame.len < sizeof *set)
|
||||
@ -715,13 +715,13 @@ sp_capture_reader_read_counter_set (SpCaptureReader *self)
|
||||
if (self->endian != G_BYTE_ORDER)
|
||||
set->n_values = GUINT16_SWAP_LE_BE (set->n_values);
|
||||
|
||||
if (set->frame.len < (sizeof *set + (sizeof (SpCaptureCounterValues) * set->n_values)))
|
||||
if (set->frame.len < (sizeof *set + (sizeof (SysprofCaptureCounterValues) * set->n_values)))
|
||||
return NULL;
|
||||
|
||||
if (!sp_capture_reader_ensure_space_for (self, set->frame.len))
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, set->frame.len))
|
||||
return NULL;
|
||||
|
||||
set = (SpCaptureFrameCounterSet *)(gpointer)&self->buf[self->pos];
|
||||
set = (SysprofCaptureFrameCounterSet *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (G_UNLIKELY (self->endian != G_BYTE_ORDER))
|
||||
{
|
||||
@ -745,19 +745,19 @@ sp_capture_reader_read_counter_set (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_capture_reader_reset (SpCaptureReader *self)
|
||||
sysprof_capture_reader_reset (SysprofCaptureReader *self)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
|
||||
self->fd_off = sizeof (SpCaptureFileHeader);
|
||||
self->fd_off = sizeof (SysprofCaptureFileHeader);
|
||||
self->pos = 0;
|
||||
self->len = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
SpCaptureReader *
|
||||
sp_capture_reader_ref (SpCaptureReader *self)
|
||||
SysprofCaptureReader *
|
||||
sysprof_capture_reader_ref (SysprofCaptureReader *self)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (self->ref_count > 0);
|
||||
@ -768,18 +768,18 @@ sp_capture_reader_ref (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
void
|
||||
sp_capture_reader_unref (SpCaptureReader *self)
|
||||
sysprof_capture_reader_unref (SysprofCaptureReader *self)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
g_assert (self->ref_count > 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&self->ref_count))
|
||||
sp_capture_reader_finalize (self);
|
||||
sysprof_capture_reader_finalize (self);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_capture_reader_splice (SpCaptureReader *self,
|
||||
SpCaptureWriter *dest,
|
||||
sysprof_capture_reader_splice (SysprofCaptureReader *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error)
|
||||
{
|
||||
g_assert (self != NULL);
|
||||
@ -787,7 +787,7 @@ sp_capture_reader_splice (SpCaptureReader *self,
|
||||
g_assert (dest != NULL);
|
||||
|
||||
/* Flush before writing anything to ensure consistency */
|
||||
if (!sp_capture_writer_flush (dest))
|
||||
if (!sysprof_capture_writer_flush (dest))
|
||||
{
|
||||
g_set_error (error,
|
||||
G_FILE_ERROR,
|
||||
@ -802,12 +802,12 @@ sp_capture_reader_splice (SpCaptureReader *self,
|
||||
*/
|
||||
|
||||
/* Perform the splice */
|
||||
return _sp_capture_writer_splice_from_fd (dest, self->fd, error);
|
||||
return _sysprof_capture_writer_splice_from_fd (dest, self->fd, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_reader_save_as:
|
||||
* @self: An #SpCaptureReader
|
||||
* sysprof_capture_reader_save_as:
|
||||
* @self: An #SysprofCaptureReader
|
||||
* @filename: the file to save the capture as
|
||||
* @error: a location for a #GError or %NULL.
|
||||
*
|
||||
@ -817,7 +817,7 @@ sp_capture_reader_splice (SpCaptureReader *self,
|
||||
* Returns: %TRUE on success; otherwise %FALSE and @error is set.
|
||||
*/
|
||||
gboolean
|
||||
sp_capture_reader_save_as (SpCaptureReader *self,
|
||||
sysprof_capture_reader_save_as (SysprofCaptureReader *self,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
@ -848,7 +848,7 @@ sp_capture_reader_save_as (SpCaptureReader *self,
|
||||
{
|
||||
gssize written;
|
||||
|
||||
written = _sp_sendfile (fd, self->fd, &in_off, to_write);
|
||||
written = _sysprof_sendfile (fd, self->fd, &in_off, to_write);
|
||||
|
||||
if (written < 0)
|
||||
goto handle_errno;
|
||||
@ -878,7 +878,7 @@ handle_errno:
|
||||
}
|
||||
|
||||
gint64
|
||||
sp_capture_reader_get_start_time (SpCaptureReader *self)
|
||||
sysprof_capture_reader_get_start_time (SysprofCaptureReader *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, 0);
|
||||
|
||||
@ -889,7 +889,7 @@ sp_capture_reader_get_start_time (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_reader_get_end_time:
|
||||
* sysprof_capture_reader_get_end_time:
|
||||
*
|
||||
* This function will return the end time for the capture, which is the
|
||||
* same as the last event added to the capture.
|
||||
@ -904,7 +904,7 @@ sp_capture_reader_get_start_time (SpCaptureReader *self)
|
||||
* Since: 3.22.1
|
||||
*/
|
||||
gint64
|
||||
sp_capture_reader_get_end_time (SpCaptureReader *self)
|
||||
sysprof_capture_reader_get_end_time (SysprofCaptureReader *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, 0);
|
||||
|
||||
@ -919,7 +919,7 @@ sp_capture_reader_get_end_time (SpCaptureReader *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_capture_reader_copy:
|
||||
* sysprof_capture_reader_copy:
|
||||
*
|
||||
* This function makes a copy of the reader. Since readers use
|
||||
* positioned reads with pread(), this allows you to have multiple
|
||||
@ -928,10 +928,10 @@ sp_capture_reader_get_end_time (SpCaptureReader *self)
|
||||
*
|
||||
* Returns: (transfer full): A copy of @self with a new file-descriptor.
|
||||
*/
|
||||
SpCaptureReader *
|
||||
sp_capture_reader_copy (SpCaptureReader *self)
|
||||
SysprofCaptureReader *
|
||||
sysprof_capture_reader_copy (SysprofCaptureReader *self)
|
||||
{
|
||||
SpCaptureReader *copy;
|
||||
SysprofCaptureReader *copy;
|
||||
int fd;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
@ -939,7 +939,7 @@ sp_capture_reader_copy (SpCaptureReader *self)
|
||||
if (-1 == (fd = dup (self->fd)))
|
||||
return NULL;
|
||||
|
||||
copy = g_new0 (SpCaptureReader, 1);
|
||||
copy = g_new0 (SysprofCaptureReader, 1);
|
||||
|
||||
*copy = *self;
|
||||
|
||||
91
src/libsysprof-capture/sysprof-capture-reader.h
Normal file
91
src/libsysprof-capture/sysprof-capture-reader.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* sysprof-capture-reader.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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 "sysprof-capture-types.h"
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _SysprofCaptureReader SysprofCaptureReader;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_new (const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int fd,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_copy (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_ref (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_reader_unref (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sysprof_capture_reader_get_filename (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sysprof_capture_reader_get_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sysprof_capture_reader_get_start_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sysprof_capture_reader_get_end_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_skip (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_peek_type (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrameType *type);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_peek_frame (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrame *frame);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureMap *sysprof_capture_reader_read_map (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureMark *sysprof_capture_reader_read_mark (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureExit *sysprof_capture_reader_read_exit (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFork *sysprof_capture_reader_read_fork (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureTimestamp *sysprof_capture_reader_read_timestamp (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureProcess *sysprof_capture_reader_read_process (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureSample *sysprof_capture_reader_read_sample (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GHashTable *sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFrameCounterDefine *sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFrameCounterSet *sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_reset (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_splice (SysprofCaptureReader *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_save_as (SysprofCaptureReader *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureReader, sysprof_capture_reader_unref)
|
||||
|
||||
G_END_DECLS
|
||||
256
src/libsysprof-capture/sysprof-capture-types.h
Normal file
256
src/libsysprof-capture/sysprof-capture-types.h
Normal file
@ -0,0 +1,256 @@
|
||||
/* sysprof-capture-types.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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 Lesser 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.h>
|
||||
|
||||
#include "sysprof-clock.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_CAPTURE_MAGIC (GUINT32_TO_LE(0xFDCA975E))
|
||||
#define SYSPROF_CAPTURE_ALIGN (sizeof(SysprofCaptureAddress))
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define SYSPROF_ALIGNED_BEGIN(_N) __declspec(align (_N))
|
||||
# define SYSPROF_ALIGNED_END(_N)
|
||||
#else
|
||||
# define SYSPROF_ALIGNED_BEGIN(_N)
|
||||
# define SYSPROF_ALIGNED_END(_N) __attribute__((aligned ((_N))))
|
||||
#endif
|
||||
|
||||
#if GLIB_SIZEOF_VOID_P == 8
|
||||
# define SYSPROF_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE000000000000000)
|
||||
# define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016lx"
|
||||
#elif GLIB_SIZEOF_VOID_P == 4
|
||||
# define SYSPROF_CAPTURE_JITMAP_MARK G_GUINT64_CONSTANT(0xE0000000)
|
||||
# define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016llx"
|
||||
#else
|
||||
#error Unknown GLIB_SIZEOF_VOID_P
|
||||
#endif
|
||||
|
||||
#define SYSPROF_CAPTURE_CURRENT_TIME (sysprof_clock_get_current_time())
|
||||
#define SYSPROF_CAPTURE_COUNTER_INT64 0
|
||||
#define SYSPROF_CAPTURE_COUNTER_DOUBLE 1
|
||||
|
||||
typedef struct _SysprofCaptureReader SysprofCaptureReader;
|
||||
typedef struct _SysprofCaptureWriter SysprofCaptureWriter;
|
||||
typedef struct _SysprofCaptureCursor SysprofCaptureCursor;
|
||||
typedef struct _SysprofCaptureCondition SysprofCaptureCondition;
|
||||
|
||||
typedef guint64 SysprofCaptureAddress;
|
||||
|
||||
typedef union
|
||||
{
|
||||
gint64 v64;
|
||||
gdouble vdbl;
|
||||
} SysprofCaptureCounterValue;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SYSPROF_CAPTURE_FRAME_TIMESTAMP = 1,
|
||||
SYSPROF_CAPTURE_FRAME_SAMPLE = 2,
|
||||
SYSPROF_CAPTURE_FRAME_MAP = 3,
|
||||
SYSPROF_CAPTURE_FRAME_PROCESS = 4,
|
||||
SYSPROF_CAPTURE_FRAME_FORK = 5,
|
||||
SYSPROF_CAPTURE_FRAME_EXIT = 6,
|
||||
SYSPROF_CAPTURE_FRAME_JITMAP = 7,
|
||||
SYSPROF_CAPTURE_FRAME_CTRDEF = 8,
|
||||
SYSPROF_CAPTURE_FRAME_CTRSET = 9,
|
||||
SYSPROF_CAPTURE_FRAME_MARK = 10,
|
||||
} SysprofCaptureFrameType;
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
guint32 magic;
|
||||
guint32 version : 8;
|
||||
guint32 little_endian : 1;
|
||||
guint32 padding : 23;
|
||||
gchar capture_time[64];
|
||||
gint64 time;
|
||||
gint64 end_time;
|
||||
gchar suffix[168];
|
||||
} SysprofCaptureFileHeader
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
guint16 len;
|
||||
gint16 cpu;
|
||||
gint32 pid;
|
||||
gint64 time;
|
||||
guint32 type : 8;
|
||||
guint32 padding1 : 24;
|
||||
guint32 padding2;
|
||||
guint8 data[0];
|
||||
} SysprofCaptureFrame
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
guint64 start;
|
||||
guint64 end;
|
||||
guint64 offset;
|
||||
guint64 inode;
|
||||
gchar filename[0];
|
||||
} SysprofCaptureMap
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
guint32 n_jitmaps;
|
||||
guint8 data[0];
|
||||
} SysprofCaptureJitmap
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
gchar cmdline[0];
|
||||
} SysprofCaptureProcess
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
guint32 n_addrs : 16;
|
||||
guint32 padding1 : 16;
|
||||
gint32 tid;
|
||||
SysprofCaptureAddress addrs[0];
|
||||
} SysprofCaptureSample
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
gint32 child_pid;
|
||||
} SysprofCaptureFork
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
} SysprofCaptureExit
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
} SysprofCaptureTimestamp
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
gchar category[32];
|
||||
gchar name[32];
|
||||
gchar description[52];
|
||||
guint32 id : 24;
|
||||
guint32 type : 8;
|
||||
SysprofCaptureCounterValue value;
|
||||
} SysprofCaptureCounter
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
guint32 n_counters : 16;
|
||||
guint32 padding1 : 16;
|
||||
guint32 padding2;
|
||||
SysprofCaptureCounter counters[0];
|
||||
} SysprofCaptureFrameCounterDefine
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* 96 bytes might seem a bit odd, but the counter frame header is 32
|
||||
* bytes. So this makes a nice 2-cacheline aligned size which is
|
||||
* useful when the number of counters is rather small.
|
||||
*/
|
||||
guint32 ids[8];
|
||||
SysprofCaptureCounterValue values[8];
|
||||
} SysprofCaptureCounterValues
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
guint32 n_values : 16;
|
||||
guint32 padding1 : 16;
|
||||
guint32 padding2;
|
||||
SysprofCaptureCounterValues values[0];
|
||||
} SysprofCaptureFrameCounterSet
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
gint64 duration;
|
||||
gchar group[24];
|
||||
gchar name[40];
|
||||
gchar message[0];
|
||||
} SysprofCaptureMark
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFileHeader) == 256);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFrame) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureMap) == 56);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureJitmap) == 28);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureProcess) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureSample) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFork) == 28);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureExit) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureTimestamp) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureCounter) == 128);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureCounterValues) == 96);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFrameCounterDefine) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFrameCounterSet) == 32);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureMark) == 96);
|
||||
|
||||
static inline gint
|
||||
sysprof_capture_address_compare (SysprofCaptureAddress a,
|
||||
SysprofCaptureAddress b)
|
||||
{
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a > b)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-util-private.h
|
||||
/* sysprof-capture-util-private.h
|
||||
*
|
||||
* Copyright 2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -29,27 +29,27 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# define _sp_getpagesize() getpagesize()
|
||||
# define _sp_pread(a,b,c,d) pread(a,b,c,d)
|
||||
# define _sp_pwrite(a,b,c,d) pwrite(a,b,c,d)
|
||||
# define _sp_write(a,b,c) write(a,b,c)
|
||||
# define _sp_getpid() getpid()
|
||||
# define _sp_sendfile(a,b,c,d) sendfile(a,b,c,d)
|
||||
# define _sysprof_getpagesize() getpagesize()
|
||||
# define _sysprof_pread(a,b,c,d) pread(a,b,c,d)
|
||||
# define _sysprof_pwrite(a,b,c,d) pwrite(a,b,c,d)
|
||||
# define _sysprof_write(a,b,c) write(a,b,c)
|
||||
# define _sysprof_getpid() getpid()
|
||||
# define _sysprof_sendfile(a,b,c,d) sendfile(a,b,c,d)
|
||||
#else
|
||||
size_t _sp_getpagesize (void);
|
||||
ssize_t _sp_pread (int fd,
|
||||
size_t _sysprof_getpagesize (void);
|
||||
ssize_t _sysprof_pread (int fd,
|
||||
void *buf,
|
||||
size_t count,
|
||||
off_t offset);
|
||||
ssize_t _sp_pwrite (int fd,
|
||||
ssize_t _sysprof_pwrite (int fd,
|
||||
const void *buf,
|
||||
size_t count,
|
||||
off_t offset);
|
||||
ssize_t _sp_write (int fd,
|
||||
ssize_t _sysprof_write (int fd,
|
||||
const void *buf,
|
||||
size_t count);
|
||||
gint32 _sp_getpid (void);
|
||||
ssize_t _sp_sendfile (int out_fd,
|
||||
gint32 _sysprof_getpid (void);
|
||||
ssize_t _sysprof_sendfile (int out_fd,
|
||||
int in_fd,
|
||||
off_t *offset,
|
||||
size_t count);
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-capture-util.c
|
||||
/* sysprof-capture-util.c
|
||||
*
|
||||
* Copyright 2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -18,7 +18,7 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-capture-util"
|
||||
#define G_LOG_DOMAIN "sysprof-capture-util"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -31,14 +31,14 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "sp-capture-util-private.h"
|
||||
#include "sysprof-capture-util-private.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
static G_LOCK_DEFINE (_sp_io_sync);
|
||||
static G_LOCK_DEFINE (_sysprof_io_sync);
|
||||
#endif
|
||||
|
||||
size_t
|
||||
(_sp_getpagesize) (void)
|
||||
(_sysprof_getpagesize) (void)
|
||||
{
|
||||
static size_t pgsz = 0;
|
||||
|
||||
@ -57,7 +57,7 @@ size_t
|
||||
}
|
||||
|
||||
ssize_t
|
||||
(_sp_pread) (int fd,
|
||||
(_sysprof_pread) (int fd,
|
||||
void *buf,
|
||||
size_t count,
|
||||
off_t offset)
|
||||
@ -65,11 +65,11 @@ ssize_t
|
||||
#ifdef G_OS_WIN32
|
||||
ssize_t ret = -1;
|
||||
|
||||
G_LOCK (_sp_io_sync);
|
||||
G_LOCK (_sysprof_io_sync);
|
||||
errno = 0;
|
||||
if (lseek (fd, offset, SEEK_SET) != -1)
|
||||
ret = read (fd, buf, count);
|
||||
G_UNLOCK (_sp_io_sync);
|
||||
G_UNLOCK (_sysprof_io_sync);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
@ -79,7 +79,7 @@ ssize_t
|
||||
}
|
||||
|
||||
ssize_t
|
||||
(_sp_pwrite) (int fd,
|
||||
(_sysprof_pwrite) (int fd,
|
||||
const void *buf,
|
||||
size_t count,
|
||||
off_t offset)
|
||||
@ -87,11 +87,11 @@ ssize_t
|
||||
#ifdef G_OS_WIN32
|
||||
ssize_t ret = -1;
|
||||
|
||||
G_LOCK (_sp_io_sync);
|
||||
G_LOCK (_sysprof_io_sync);
|
||||
errno = 0;
|
||||
if (lseek (fd, offset, SEEK_SET) != -1)
|
||||
ret = write (fd, buf, count);
|
||||
G_UNLOCK (_sp_io_sync);
|
||||
G_UNLOCK (_sysprof_io_sync);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
@ -101,17 +101,17 @@ ssize_t
|
||||
}
|
||||
|
||||
ssize_t
|
||||
(_sp_write) (int fd,
|
||||
(_sysprof_write) (int fd,
|
||||
const void *buf,
|
||||
size_t count)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
ssize_t ret = -1;
|
||||
|
||||
G_LOCK (_sp_io_sync);
|
||||
G_LOCK (_sysprof_io_sync);
|
||||
errno = 0;
|
||||
ret = write (fd, buf, count);
|
||||
G_UNLOCK (_sp_io_sync);
|
||||
G_UNLOCK (_sysprof_io_sync);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
@ -121,7 +121,7 @@ ssize_t
|
||||
}
|
||||
|
||||
gint32
|
||||
(_sp_getpid) (void)
|
||||
(_sysprof_getpid) (void)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
return _getpid ();
|
||||
@ -131,7 +131,7 @@ gint32
|
||||
}
|
||||
|
||||
ssize_t
|
||||
(_sp_sendfile) (int out_fd,
|
||||
(_sysprof_sendfile) (int out_fd,
|
||||
int in_fd,
|
||||
off_t *offset,
|
||||
size_t count)
|
||||
@ -163,7 +163,7 @@ ssize_t
|
||||
to_read = count;
|
||||
|
||||
errno = 0;
|
||||
n_read = _sp_pread (in_fd, buf, to_read, rpos);
|
||||
n_read = _sysprof_pread (in_fd, buf, to_read, rpos);
|
||||
|
||||
if (n_read <= 0)
|
||||
return -1;
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* sp-capture-writer.h
|
||||
/* sysprof-capture-writer.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,17 +20,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sp-capture-types.h"
|
||||
#include "sysprof-capture-types.h"
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _SpCaptureWriter SpCaptureWriter;
|
||||
typedef struct _SysprofCaptureWriter SysprofCaptureWriter;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* The number of frames indexed by SpCaptureFrameType
|
||||
* The number of frames indexed by SysprofCaptureFrameType
|
||||
*/
|
||||
gsize frame_count[16];
|
||||
|
||||
@ -38,25 +38,25 @@ typedef struct
|
||||
* Padding for future expansion.
|
||||
*/
|
||||
gsize padding[48];
|
||||
} SpCaptureStat;
|
||||
} SysprofCaptureStat;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureWriter *sp_capture_writer_new_from_env (gsize buffer_size);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_env (gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureWriter *sp_capture_writer_new (const gchar *filename,
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new (const gchar *filename,
|
||||
gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureWriter *sp_capture_writer_new_from_fd (int fd,
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_fd (int fd,
|
||||
gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureWriter *sp_capture_writer_ref (SpCaptureWriter *self);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_ref (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_writer_unref (SpCaptureWriter *self);
|
||||
void sysprof_capture_writer_unref (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_capture_writer_stat (SpCaptureWriter *self,
|
||||
SpCaptureStat *stat);
|
||||
void sysprof_capture_writer_stat (SysprofCaptureWriter *self,
|
||||
SysprofCaptureStat *stat);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_map (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_map (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
@ -66,7 +66,7 @@ gboolean sp_capture_writer_add_map (SpCaptureWriter *
|
||||
guint64 inode,
|
||||
const gchar *filename);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_mark (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_mark (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
@ -75,78 +75,78 @@ gboolean sp_capture_writer_add_mark (SpCaptureWriter *
|
||||
const gchar *name,
|
||||
const gchar *message);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint64 sp_capture_writer_add_jitmap (SpCaptureWriter *self,
|
||||
guint64 sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self,
|
||||
const gchar *name);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_process (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_process (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *cmdline);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_sample (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_sample (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
const SpCaptureAddress *addrs,
|
||||
const SysprofCaptureAddress *addrs,
|
||||
guint n_addrs);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_fork (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_fork (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 child_pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_exit (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_exit (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_add_timestamp (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_define_counters (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_define_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const SpCaptureCounter *counters,
|
||||
const SysprofCaptureCounter *counters,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_set_counters (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_set_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const guint *counters_ids,
|
||||
const SpCaptureCounterValue *values,
|
||||
const SysprofCaptureCounterValue *values,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_flush (SpCaptureWriter *self);
|
||||
gboolean sysprof_capture_writer_flush (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_save_as (SpCaptureWriter *self,
|
||||
gboolean sysprof_capture_writer_save_as (SysprofCaptureWriter *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sp_capture_writer_request_counter (SpCaptureWriter *self,
|
||||
guint sysprof_capture_writer_request_counter (SysprofCaptureWriter *self,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureReader *sp_capture_writer_create_reader (SpCaptureWriter *self,
|
||||
SysprofCaptureReader *sysprof_capture_writer_create_reader (SysprofCaptureWriter *self,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_capture_writer_splice (SpCaptureWriter *self,
|
||||
SpCaptureWriter *dest,
|
||||
gboolean sysprof_capture_writer_splice (SysprofCaptureWriter *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sp_capture_writer_splice_from_fd (SpCaptureWriter *self,
|
||||
gboolean _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self,
|
||||
int fd,
|
||||
GError **error) G_GNUC_INTERNAL;
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sp_capture_writer_set_time_range (SpCaptureWriter *self,
|
||||
gboolean _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self,
|
||||
gint64 start_time,
|
||||
gint64 end_time) G_GNUC_INTERNAL;
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureWriter, sp_capture_writer_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureWriter, sysprof_capture_writer_unref)
|
||||
|
||||
G_END_DECLS
|
||||
@ -26,12 +26,12 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_CAPTURE_INSIDE
|
||||
|
||||
# include "sp-address.h"
|
||||
# include "sp-capture-condition.h"
|
||||
# include "sp-capture-cursor.h"
|
||||
# include "sp-capture-reader.h"
|
||||
# include "sp-capture-writer.h"
|
||||
# include "sp-clock.h"
|
||||
# include "sysprof-address.h"
|
||||
# include "sysprof-capture-condition.h"
|
||||
# include "sysprof-capture-cursor.h"
|
||||
# include "sysprof-capture-reader.h"
|
||||
# include "sysprof-capture-writer.h"
|
||||
# include "sysprof-clock.h"
|
||||
# include "sysprof-version.h"
|
||||
# include "sysprof-version-macros.h"
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-clock.c
|
||||
/* sysprof-clock.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -18,16 +18,16 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-clock"
|
||||
#define G_LOG_DOMAIN "sysprof-clock"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-clock.h"
|
||||
#include "sysprof-clock.h"
|
||||
|
||||
gint sp_clock = -1;
|
||||
gint sysprof_clock = -1;
|
||||
|
||||
void
|
||||
sp_clock_init (void)
|
||||
sysprof_clock_init (void)
|
||||
{
|
||||
static const gint clock_ids[] = {
|
||||
CLOCK_MONOTONIC,
|
||||
@ -39,7 +39,7 @@ sp_clock_init (void)
|
||||
CLOCK_REALTIME,
|
||||
};
|
||||
|
||||
if (sp_clock != -1)
|
||||
if (sysprof_clock != -1)
|
||||
return;
|
||||
|
||||
for (guint i = 0; i < G_N_ELEMENTS (clock_ids); i++)
|
||||
@ -49,7 +49,7 @@ sp_clock_init (void)
|
||||
|
||||
if (0 == clock_gettime (clock_id, &ts))
|
||||
{
|
||||
sp_clock = clock_id;
|
||||
sysprof_clock = clock_id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-clock.h
|
||||
/* sysprof-clock.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -27,18 +27,18 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef gint SpClock;
|
||||
typedef gint64 SpTimeStamp;
|
||||
typedef gint32 SpTimeSpan;
|
||||
typedef gint SysprofClock;
|
||||
typedef gint64 SysprofTimeStamp;
|
||||
typedef gint32 SysprofTimeSysprofan;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpClock sp_clock;
|
||||
SysprofClock sysprof_clock;
|
||||
|
||||
static inline SpTimeStamp
|
||||
sp_clock_get_current_time (void)
|
||||
static inline SysprofTimeStamp
|
||||
sysprof_clock_get_current_time (void)
|
||||
{
|
||||
struct timespec ts;
|
||||
SpClock clock = sp_clock;
|
||||
SysprofClock clock = sysprof_clock;
|
||||
|
||||
if G_UNLIKELY (clock == -1)
|
||||
clock = CLOCK_MONOTONIC;
|
||||
@ -47,13 +47,13 @@ sp_clock_get_current_time (void)
|
||||
return (ts.tv_sec * G_GINT64_CONSTANT (1000000000)) + ts.tv_nsec;
|
||||
}
|
||||
|
||||
static inline SpTimeSpan
|
||||
sp_clock_get_relative_time (SpTimeStamp epoch)
|
||||
static inline SysprofTimeSysprofan
|
||||
sysprof_clock_get_relative_time (SysprofTimeStamp epoch)
|
||||
{
|
||||
return sp_clock_get_current_time () - epoch;
|
||||
return sysprof_clock_get_current_time () - epoch;
|
||||
}
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_clock_init (void);
|
||||
void sysprof_clock_init (void);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-platform.c
|
||||
/* sysprof-platform.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -18,7 +18,7 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sp-platform"
|
||||
#define G_LOG_DOMAIN "sysprof-platform"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sp-platform.h"
|
||||
#include "sysprof-platform.h"
|
||||
|
||||
/**
|
||||
* sp_memfd_create:
|
||||
* sysprof_memfd_create:
|
||||
* @name: (nullable): A descriptive name for the memfd or %NULL
|
||||
*
|
||||
* Creates a new memfd using the memfd_create syscall if available.
|
||||
@ -40,7 +40,7 @@
|
||||
* Returns: An fd if successful; otherwise -1 and errno is set.
|
||||
*/
|
||||
int
|
||||
sp_memfd_create (const gchar *name)
|
||||
sysprof_memfd_create (const gchar *name)
|
||||
{
|
||||
#ifdef __NR_memfd_create
|
||||
if (name == NULL)
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-platform.h
|
||||
/* sysprof-platform.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -25,6 +25,6 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
int sp_memfd_create (const gchar *desc);
|
||||
int sysprof_memfd_create (const gchar *desc);
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user