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:
Christian Hergert
2019-05-08 12:03:46 -07:00
parent 4821883bfa
commit 53c718b708
143 changed files with 5792 additions and 5789 deletions

View File

@ -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(

View 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;
}

View File

@ -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

View File

@ -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

View File

@ -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 - -";
}

View File

@ -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;

View File

@ -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;

View File

@ -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

View 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;
}

View File

@ -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

View File

@ -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;

View 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

View 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

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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"

View File

@ -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;
}
}

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -1,49 +1,49 @@
libsysprof_ui_public_sources = [
'sp-callgraph-view.c',
'sp-color-cycle.c',
'sp-cpu-visualizer-row.c',
'sp-empty-state-view.c',
'sp-failed-state-view.c',
'sp-line-visualizer-row.c',
'sp-mark-visualizer-row.c',
'sp-model-filter.c',
'sp-multi-paned.c',
'sp-process-model-row.c',
'sp-profiler-menu-button.c',
'sp-recording-state-view.c',
'sp-visualizer-list.c',
'sp-visualizer-row.c',
'sp-visualizer-ticks.c',
'sp-visualizer-view.c',
'sp-zoom-manager.c',
'sysprof-callgraph-view.c',
'sysprof-color-cycle.c',
'sysprof-cpu-visualizer-row.c',
'sysprof-empty-state-view.c',
'sysprof-failed-state-view.c',
'sysprof-line-visualizer-row.c',
'sysprof-mark-visualizer-row.c',
'sysprof-model-filter.c',
'sysprof-multi-paned.c',
'sysprof-process-model-row.c',
'sysprof-profiler-menu-button.c',
'sysprof-recording-state-view.c',
'sysprof-visualizer-list.c',
'sysprof-visualizer-row.c',
'sysprof-visualizer-ticks.c',
'sysprof-visualizer-view.c',
'sysprof-zoom-manager.c',
]
libsysprof_ui_private_sources = [
'pointcache.c',
'rectangles.c',
'sp-cell-renderer-percent.c',
'sp-theme-manager.c',
'sysprof-cell-renderer-percent.c',
'sysprof-theme-manager.c',
'../stackstash.c',
]
libsysprof_ui_public_headers = [
'sp-callgraph-view.h',
'sp-cell-renderer-percent.h',
'sp-cpu-visualizer-row.h',
'sp-empty-state-view.h',
'sp-failed-state-view.h',
'sp-line-visualizer-row.h',
'sp-mark-visualizer-row.h',
'sp-model-filter.h',
'sp-multi-paned.h',
'sp-process-model-row.h',
'sp-profiler-menu-button.h',
'sp-recording-state-view.h',
'sp-visualizer-list.h',
'sp-visualizer-row.h',
'sp-visualizer-ticks.h',
'sp-visualizer-view.h',
'sp-zoom-manager.h',
'sysprof-callgraph-view.h',
'sysprof-cell-renderer-percent.h',
'sysprof-cpu-visualizer-row.h',
'sysprof-empty-state-view.h',
'sysprof-failed-state-view.h',
'sysprof-line-visualizer-row.h',
'sysprof-mark-visualizer-row.h',
'sysprof-model-filter.h',
'sysprof-multi-paned.h',
'sysprof-process-model-row.h',
'sysprof-profiler-menu-button.h',
'sysprof-recording-state-view.h',
'sysprof-visualizer-list.h',
'sysprof-visualizer-row.h',
'sysprof-visualizer-ticks.h',
'sysprof-visualizer-view.h',
'sysprof-zoom-manager.h',
'sysprof-ui.h',
]

View File

@ -19,8 +19,8 @@
*/
#include "rectangles.h"
#include "sp-color-cycle.h"
#include "sp-visualizer-row.h"
#include "sysprof-color-cycle.h"
#include "sysprof-visualizer-row.h"
typedef struct
{
@ -37,7 +37,7 @@ struct _Rectangles
GArray *rectangles;
GHashTable *y_indexes;
GHashTable *colors;
SpColorCycle *cycle;
SysprofColorCycle *cycle;
gint64 begin_time;
gint64 end_time;
guint sorted : 1;
@ -54,7 +54,7 @@ rectangles_new (gint64 begin_time,
self->rectangles = g_array_new (FALSE, FALSE, sizeof (Rectangle));
self->y_indexes = g_hash_table_new (g_str_hash, g_str_equal);
self->colors = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
self->cycle = sp_color_cycle_new ();
self->cycle = sysprof_color_cycle_new ();
self->begin_time = begin_time;
self->end_time = end_time;
self->sorted = FALSE;
@ -97,7 +97,7 @@ rectangles_free (Rectangles *self)
g_array_unref (self->rectangles);
g_hash_table_unref (self->colors);
g_hash_table_unref (self->y_indexes);
sp_color_cycle_unref (self->cycle);
sysprof_color_cycle_unref (self->cycle);
g_slice_free (Rectangles, self);
}
@ -137,7 +137,7 @@ rectangles_sort (Rectangles *self)
{
GdkRGBA rgba;
sp_color_cycle_next (self->cycle, &rgba);
sysprof_color_cycle_next (self->cycle, &rgba);
g_hash_table_insert (self->y_indexes, (gchar *)rect->name, GUINT_TO_POINTER (++sequence));
g_hash_table_insert (self->colors, (gchar *)rect->name, g_memdup (&rgba, sizeof rgba));
}
@ -156,7 +156,7 @@ rectangles_draw (Rectangles *self,
guint n_rows;
g_assert (self != NULL);
g_assert (SP_IS_VISUALIZER_ROW (row));
g_assert (SYSPROF_IS_VISUALIZER_ROW (row));
g_assert (cr != NULL);
if (!self->sorted)
@ -173,8 +173,8 @@ rectangles_draw (Rectangles *self,
{
Rectangle *rect = &g_array_index (self->rectangles, Rectangle, i);
guint y_index = GPOINTER_TO_UINT (g_hash_table_lookup (self->y_indexes, rect->name));
SpVisualizerRowRelativePoint in_points[2];
SpVisualizerRowAbsolutePoint out_points[2];
SysprofVisualizerRowRelativePoint in_points[2];
SysprofVisualizerRowAbsolutePoint out_points[2];
GdkRectangle r;
GdkRGBA *rgba;
@ -186,9 +186,9 @@ rectangles_draw (Rectangles *self,
in_points[1].x = (rect->end - self->begin_time) / range;
in_points[1].y = 0;
sp_visualizer_row_translate_points (SP_VISUALIZER_ROW (row),
in_points, G_N_ELEMENTS (in_points),
out_points, G_N_ELEMENTS (out_points));
sysprof_visualizer_row_translate_points (SYSPROF_VISUALIZER_ROW (row),
in_points, G_N_ELEMENTS (in_points),
out_points, G_N_ELEMENTS (out_points));
r.height = alloc.height / (gdouble)n_rows;
r.x = out_points[0].x;

View File

@ -1,62 +0,0 @@
/* sp-cell-renderer-percent.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_CELL_RENDERER_PERCENT (sp_cell_renderer_percent_get_type())
#define SP_CELL_RENDERER_PERCENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CELL_RENDERER_PERCENT, SpCellRendererPercent))
#define SP_CELL_RENDERER_PERCENT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CELL_RENDERER_PERCENT, SpCellRendererPercent const))
#define SP_CELL_RENDERER_PERCENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CELL_RENDERER_PERCENT, SpCellRendererPercentClass))
#define SP_IS_CELL_RENDERER_PERCENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CELL_RENDERER_PERCENT))
#define SP_IS_CELL_RENDERER_PERCENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CELL_RENDERER_PERCENT))
#define SP_CELL_RENDERER_PERCENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SP_TYPE_CELL_RENDERER_PERCENT, SpCellRendererPercentClass))
typedef struct _SpCellRendererPercent SpCellRendererPercent;
typedef struct _SpCellRendererPercentClass SpCellRendererPercentClass;
struct _SpCellRendererPercent
{
GtkCellRendererText parent;
};
struct _SpCellRendererPercentClass
{
GtkCellRendererTextClass parent_class;
gpointer padding[4];
};
SYSPROF_AVAILABLE_IN_ALL
GType sp_cell_renderer_percent_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
GtkCellRenderer *sp_cell_renderer_percent_new (void);
SYSPROF_AVAILABLE_IN_ALL
gdouble sp_cell_renderer_percent_get_percent (SpCellRendererPercent *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_cell_renderer_percent_set_percent (SpCellRendererPercent *self,
gdouble percent);
G_END_DECLS

View File

@ -1,173 +0,0 @@
/* sp-cpu-visualizer-row.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-cpu-visualizer-row"
#include "config.h"
#include "sp-capture-condition.h"
#include "sp-capture-cursor.h"
#include "sp-color-cycle.h"
#include "sp-cpu-visualizer-row.h"
struct _SpCpuVisualizerRow
{
SpLineVisualizerRow parent_instance;
SpColorCycle *colors;
};
G_DEFINE_TYPE (SpCpuVisualizerRow, sp_cpu_visualizer_row, SP_TYPE_LINE_VISUALIZER_ROW)
static gboolean
sp_cpu_visualizer_counter_found (const SpCaptureFrame *frame,
gpointer user_data)
{
const SpCaptureFrameCounterDefine *def = (SpCaptureFrameCounterDefine *)frame;
GArray *counters = user_data;
gboolean found = FALSE;
g_assert (frame->type == SP_CAPTURE_FRAME_CTRDEF);
/*
* In practice, all the CPU counters are defined at once, so we can avoid
* walking the rest of the capture by returning after we find our CTRDEF.
*/
for (guint i = 0; i < def->n_counters; i++)
{
if (g_str_equal (def->counters[i].category, "CPU Percent"))
{
guint id = def->counters[i].id;
g_array_append_val (counters, id);
found = TRUE;
}
}
return !found;
}
static void
sp_cpu_visualizer_row_discover_counters (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *canellable)
{
const SpCaptureFrameType types[] = { SP_CAPTURE_FRAME_CTRDEF };
SpCaptureReader *reader = task_data;
g_autoptr(SpCaptureCursor) cursor = NULL;
g_autoptr(GArray) counters = NULL;
g_assert (G_IS_TASK (task));
g_assert (SP_IS_CPU_VISUALIZER_ROW (source_object));
g_assert (reader != NULL);
counters = g_array_new (FALSE, FALSE, sizeof (guint));
cursor = sp_capture_cursor_new (reader);
sp_capture_cursor_add_condition (cursor, sp_capture_condition_new_where_type_in (G_N_ELEMENTS (types), types));
sp_capture_cursor_foreach (cursor, sp_cpu_visualizer_counter_found, counters);
g_task_return_pointer (task, g_steal_pointer (&counters), (GDestroyNotify)g_array_unref);
}
static void
complete_counters (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SpCpuVisualizerRow *self = (SpCpuVisualizerRow *)object;
g_autoptr(GArray) counters = NULL;
g_assert (SP_IS_CPU_VISUALIZER_ROW (self));
g_assert (G_IS_TASK (result));
counters = g_task_propagate_pointer (G_TASK (result), NULL);
if (counters != NULL)
{
for (guint i = 0; i < counters->len; i++)
{
guint counter_id = g_array_index (counters, guint, i);
GdkRGBA color;
sp_color_cycle_next (self->colors, &color);
sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (self), counter_id, &color);
}
}
/* Hide ourself if we failed to locate counters */
gtk_widget_set_visible (GTK_WIDGET (self), counters != NULL && counters->len > 0);
}
static void
sp_cpu_visualizer_row_set_reader (SpVisualizerRow *row,
SpCaptureReader *reader)
{
SpCpuVisualizerRow *self = (SpCpuVisualizerRow *)row;
g_autoptr(GTask) task = NULL;
g_assert (SP_IS_CPU_VISUALIZER_ROW (row));
sp_color_cycle_reset (self->colors);
sp_line_visualizer_row_clear (SP_LINE_VISUALIZER_ROW (row));
SP_VISUALIZER_ROW_CLASS (sp_cpu_visualizer_row_parent_class)->set_reader (row, reader);
if (reader != NULL)
{
task = g_task_new (self, NULL, complete_counters, NULL);
g_task_set_source_tag (task, sp_cpu_visualizer_row_set_reader);
g_task_set_task_data (task, sp_capture_reader_copy (reader),
(GDestroyNotify)sp_capture_reader_unref);
g_task_run_in_thread (task, sp_cpu_visualizer_row_discover_counters);
}
}
static void
sp_cpu_visualizer_row_finalize (GObject *object)
{
SpCpuVisualizerRow *self = (SpCpuVisualizerRow *)object;
g_clear_pointer (&self->colors, sp_color_cycle_unref);
G_OBJECT_CLASS (sp_cpu_visualizer_row_parent_class)->finalize (object);
}
static void
sp_cpu_visualizer_row_class_init (SpCpuVisualizerRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
SpVisualizerRowClass *row_class = SP_VISUALIZER_ROW_CLASS (klass);
object_class->finalize = sp_cpu_visualizer_row_finalize;
row_class->set_reader = sp_cpu_visualizer_row_set_reader;
}
static void
sp_cpu_visualizer_row_init (SpCpuVisualizerRow *self)
{
self->colors = sp_color_cycle_new ();
}
GtkWidget *
sp_cpu_visualizer_row_new (void)
{
return g_object_new (SP_TYPE_CPU_VISUALIZER_ROW, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-callgraph-view.c
/* sysprof-callgraph-view.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -43,12 +43,12 @@
#include "../stackstash.h"
#include "sp-callgraph-view.h"
#include "sp-cell-renderer-percent.h"
#include "sysprof-callgraph-view.h"
#include "sysprof-cell-renderer-percent.h"
typedef struct
{
SpCallgraphProfile *profile;
SysprofCallgraphProfile *profile;
GtkTreeView *callers_view;
GtkTreeView *functions_view;
@ -58,9 +58,9 @@ typedef struct
GQueue *history;
guint profile_size;
} SpCallgraphViewPrivate;
} SysprofCallgraphViewPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SpCallgraphView, sp_callgraph_view, GTK_TYPE_BIN)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofCallgraphView, sysprof_callgraph_view, GTK_TYPE_BIN)
enum {
PROP_0,
@ -81,21 +81,21 @@ enum {
};
static void sp_callgraph_view_update_descendants (SpCallgraphView *self,
static void sysprof_callgraph_view_update_descendants (SysprofCallgraphView *self,
StackNode *node);
static GParamSpec *properties [N_PROPS];
static guint signals [N_SIGNALS];
static guint
sp_callgraph_view_get_profile_size (SpCallgraphView *self)
sysprof_callgraph_view_get_profile_size (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
StackStash *stash;
StackNode *node;
guint size = 0;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
if (priv->profile_size != 0)
return priv->profile_size;
@ -103,7 +103,7 @@ sp_callgraph_view_get_profile_size (SpCallgraphView *self)
if (priv->profile == NULL)
return 0;
if (NULL == (stash = sp_callgraph_profile_get_stash (priv->profile)))
if (NULL == (stash = sysprof_callgraph_profile_get_stash (priv->profile)))
return 0;
for (node = stack_stash_get_root (stash); node != NULL; node = node->siblings)
@ -148,10 +148,10 @@ build_functions_store (StackNode *node,
}
static void
sp_callgraph_view_load (SpCallgraphView *self,
SpCallgraphProfile *profile)
sysprof_callgraph_view_load (SysprofCallgraphView *self,
SysprofCallgraphProfile *profile)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkListStore *functions;
StackStash *stash;
StackNode *n;
@ -161,8 +161,8 @@ sp_callgraph_view_load (SpCallgraphView *self,
gdouble profile_size;
} state = { 0 };
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SP_IS_CALLGRAPH_PROFILE (profile));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (profile));
/*
* TODO: This is probably the type of thing we want to do off the main
@ -175,7 +175,7 @@ sp_callgraph_view_load (SpCallgraphView *self,
g_set_object (&priv->profile, profile);
if (NULL == (stash = sp_callgraph_profile_get_stash (profile)))
if (NULL == (stash = sysprof_callgraph_profile_get_stash (profile)))
return;
for (n = stack_stash_get_root (stash); n; n = n->siblings)
@ -206,12 +206,12 @@ sp_callgraph_view_load (SpCallgraphView *self,
}
static void
sp_callgraph_view_unload (SpCallgraphView *self)
sysprof_callgraph_view_unload (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SP_IS_CALLGRAPH_PROFILE (priv->profile));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (priv->profile));
g_queue_clear (priv->history);
g_clear_object (&priv->profile);
@ -223,45 +223,45 @@ sp_callgraph_view_unload (SpCallgraphView *self)
}
/**
* sp_callgraph_view_get_profile:
* sysprof_callgraph_view_get_profile:
*
* Returns: (transfer none): An #SpCallgraphProfile.
* Returns: (transfer none): An #SysprofCallgraphProfile.
*/
SpCallgraphProfile *
sp_callgraph_view_get_profile (SpCallgraphView *self)
SysprofCallgraphProfile *
sysprof_callgraph_view_get_profile (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
g_return_val_if_fail (SP_IS_CALLGRAPH_VIEW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), NULL);
return priv->profile;
}
void
sp_callgraph_view_set_profile (SpCallgraphView *self,
SpCallgraphProfile *profile)
sysprof_callgraph_view_set_profile (SysprofCallgraphView *self,
SysprofCallgraphProfile *profile)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
g_return_if_fail (SP_IS_CALLGRAPH_VIEW (self));
g_return_if_fail (!profile || SP_IS_CALLGRAPH_PROFILE (profile));
g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_return_if_fail (!profile || SYSPROF_IS_CALLGRAPH_PROFILE (profile));
if (profile != priv->profile)
{
if (priv->profile)
sp_callgraph_view_unload (self);
sysprof_callgraph_view_unload (self);
if (profile)
sp_callgraph_view_load (self, profile);
sysprof_callgraph_view_load (self, profile);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PROFILE]);
}
}
static void
sp_callgraph_view_expand_descendants (SpCallgraphView *self)
sysprof_callgraph_view_expand_descendants (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeModel *model;
GList *all_paths = NULL;
GtkTreePath *first_path;
@ -270,7 +270,7 @@ sp_callgraph_view_expand_descendants (SpCallgraphView *self)
gint max_rows = 40; /* FIXME */
gint n_rows;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
model = gtk_tree_view_get_model (priv->descendants_view);
first_path = gtk_tree_path_new_first ();
@ -384,10 +384,10 @@ caller_free (gpointer data)
}
static void
sp_callgraph_view_function_selection_changed (SpCallgraphView *self,
sysprof_callgraph_view_function_selection_changed (SysprofCallgraphView *self,
GtkTreeSelection *selection)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeModel *model = NULL;
GtkTreeIter iter;
GtkListStore *callers_store;
@ -396,7 +396,7 @@ sp_callgraph_view_function_selection_changed (SpCallgraphView *self,
StackNode *callees = NULL;
StackNode *node;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (GTK_IS_TREE_SELECTION (selection));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
@ -410,7 +410,7 @@ sp_callgraph_view_function_selection_changed (SpCallgraphView *self,
COLUMN_POINTER, &callees,
-1);
sp_callgraph_view_update_descendants (self, callees);
sysprof_callgraph_view_update_descendants (self, callees);
callers_store = gtk_list_store_new (4,
G_TYPE_STRING,
@ -479,7 +479,7 @@ sp_callgraph_view_function_selection_changed (SpCallgraphView *self,
gpointer key, value;
guint size = 0;
size = MAX (1, sp_callgraph_view_get_profile_size (self));
size = MAX (1, sysprof_callgraph_view_get_profile_size (self));
g_hash_table_iter_init (&hiter, callers);
@ -506,14 +506,14 @@ sp_callgraph_view_function_selection_changed (SpCallgraphView *self,
}
static void
sp_callgraph_view_set_node (SpCallgraphView *self,
sysprof_callgraph_view_set_node (SysprofCallgraphView *self,
StackNode *node)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeModel *model;
GtkTreeIter iter;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (node != NULL);
if (priv->profile == NULL)
@ -546,7 +546,7 @@ sp_callgraph_view_set_node (SpCallgraphView *self,
}
static void
sp_callgraph_view_descendant_activated (SpCallgraphView *self,
sysprof_callgraph_view_descendant_activated (SysprofCallgraphView *self,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkTreeView *tree_view)
@ -555,7 +555,7 @@ sp_callgraph_view_descendant_activated (SpCallgraphView *self,
StackNode *node = NULL;
GtkTreeIter iter;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (GTK_IS_TREE_VIEW (tree_view));
g_assert (path != NULL);
g_assert (GTK_IS_TREE_VIEW_COLUMN (column));
@ -570,11 +570,11 @@ sp_callgraph_view_descendant_activated (SpCallgraphView *self,
-1);
if (node != NULL)
sp_callgraph_view_set_node (self, node);
sysprof_callgraph_view_set_node (self, node);
}
static void
sp_callgraph_view_caller_activated (SpCallgraphView *self,
sysprof_callgraph_view_caller_activated (SysprofCallgraphView *self,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkTreeView *tree_view)
@ -583,7 +583,7 @@ sp_callgraph_view_caller_activated (SpCallgraphView *self,
StackNode *node = NULL;
GtkTreeIter iter;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
g_assert (GTK_IS_TREE_VIEW (tree_view));
g_assert (path != NULL);
g_assert (GTK_IS_TREE_VIEW_COLUMN (column));
@ -598,18 +598,18 @@ sp_callgraph_view_caller_activated (SpCallgraphView *self,
-1);
if (node != NULL)
sp_callgraph_view_set_node (self, node);
sysprof_callgraph_view_set_node (self, node);
}
static void
sp_callgraph_view_tag_data_func (GtkTreeViewColumn *column,
sysprof_callgraph_view_tag_data_func (GtkTreeViewColumn *column,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
SpCallgraphView *self = data;
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphView *self = data;
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
StackNode *node = NULL;
const gchar *str = NULL;
@ -622,7 +622,7 @@ sp_callgraph_view_tag_data_func (GtkTreeViewColumn *column,
{
GQuark tag;
tag = sp_callgraph_profile_get_tag (priv->profile, GSIZE_TO_POINTER (node->data));
tag = sysprof_callgraph_profile_get_tag (priv->profile, GSIZE_TO_POINTER (node->data));
if (tag != 0)
str = g_quark_to_string (tag);
}
@ -631,39 +631,39 @@ sp_callgraph_view_tag_data_func (GtkTreeViewColumn *column,
}
static void
sp_callgraph_view_real_go_previous (SpCallgraphView *self)
sysprof_callgraph_view_real_go_previous (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
StackNode *node;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
node = g_queue_pop_head (priv->history);
if (NULL != (node = g_queue_peek_head (priv->history)))
sp_callgraph_view_set_node (self, node);
sysprof_callgraph_view_set_node (self, node);
}
static void
sp_callgraph_view_finalize (GObject *object)
sysprof_callgraph_view_finalize (GObject *object)
{
SpCallgraphView *self = (SpCallgraphView *)object;
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphView *self = (SysprofCallgraphView *)object;
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
g_clear_pointer (&priv->history, g_queue_free);
g_clear_object (&priv->profile);
G_OBJECT_CLASS (sp_callgraph_view_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_callgraph_view_parent_class)->finalize (object);
}
static void
sp_callgraph_view_get_property (GObject *object,
sysprof_callgraph_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpCallgraphView *self = SP_CALLGRAPH_VIEW (object);
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphView *self = SYSPROF_CALLGRAPH_VIEW (object);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
switch (prop_id)
{
@ -677,17 +677,17 @@ sp_callgraph_view_get_property (GObject *object,
}
static void
sp_callgraph_view_set_property (GObject *object,
sysprof_callgraph_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpCallgraphView *self = SP_CALLGRAPH_VIEW (object);
SysprofCallgraphView *self = SYSPROF_CALLGRAPH_VIEW (object);
switch (prop_id)
{
case PROP_PROFILE:
sp_callgraph_view_set_profile (self, g_value_get_object (value));
sysprof_callgraph_view_set_profile (self, g_value_get_object (value));
break;
default:
@ -723,23 +723,23 @@ descendants_view_move_cursor_cb (GtkTreeView *descendants_view,
}
static void
sp_callgraph_view_class_init (SpCallgraphViewClass *klass)
sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkBindingSet *bindings;
object_class->finalize = sp_callgraph_view_finalize;
object_class->get_property = sp_callgraph_view_get_property;
object_class->set_property = sp_callgraph_view_set_property;
object_class->finalize = sysprof_callgraph_view_finalize;
object_class->get_property = sysprof_callgraph_view_get_property;
object_class->set_property = sysprof_callgraph_view_set_property;
klass->go_previous = sp_callgraph_view_real_go_previous;
klass->go_previous = sysprof_callgraph_view_real_go_previous;
properties [PROP_PROFILE] =
g_param_spec_object ("profile",
"Profile",
"The callgraph profile to view",
SP_TYPE_CALLGRAPH_PROFILE,
SYSPROF_TYPE_CALLGRAPH_PROFILE,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
@ -748,27 +748,27 @@ sp_callgraph_view_class_init (SpCallgraphViewClass *klass)
g_signal_new ("go-previous",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (SpCallgraphViewClass, go_previous),
G_STRUCT_OFFSET (SysprofCallgraphViewClass, go_previous),
NULL, NULL, NULL, G_TYPE_NONE, 0);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/sysprof/ui/sp-callgraph-view.ui");
"/org/gnome/sysprof/ui/sysprof-callgraph-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpCallgraphView, callers_view);
gtk_widget_class_bind_template_child_private (widget_class, SpCallgraphView, functions_view);
gtk_widget_class_bind_template_child_private (widget_class, SpCallgraphView, descendants_view);
gtk_widget_class_bind_template_child_private (widget_class, SpCallgraphView, descendants_name_column);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, callers_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, functions_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofCallgraphView, descendants_name_column);
bindings = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (bindings, GDK_KEY_Left, GDK_MOD1_MASK, "go-previous", 0);
g_type_ensure (SP_TYPE_CELL_RENDERER_PERCENT);
g_type_ensure (SYSPROF_TYPE_CELL_RENDERER_PERCENT);
}
static void
sp_callgraph_view_init (SpCallgraphView *self)
sysprof_callgraph_view_init (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeSelection *selection;
GtkCellRenderer *cell;
@ -780,19 +780,19 @@ sp_callgraph_view_init (SpCallgraphView *self)
g_signal_connect_object (selection,
"changed",
G_CALLBACK (sp_callgraph_view_function_selection_changed),
G_CALLBACK (sysprof_callgraph_view_function_selection_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->descendants_view,
"row-activated",
G_CALLBACK (sp_callgraph_view_descendant_activated),
G_CALLBACK (sysprof_callgraph_view_descendant_activated),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->callers_view,
"row-activated",
G_CALLBACK (sp_callgraph_view_caller_activated),
G_CALLBACK (sysprof_callgraph_view_caller_activated),
self,
G_CONNECT_SWAPPED);
@ -815,7 +815,7 @@ sp_callgraph_view_init (SpCallgraphView *self)
NULL);
gtk_tree_view_column_pack_start (priv->descendants_name_column, cell, FALSE);
gtk_tree_view_column_set_cell_data_func (priv->descendants_name_column, cell,
sp_callgraph_view_tag_data_func,
sysprof_callgraph_view_tag_data_func,
self, NULL);
}
@ -916,7 +916,7 @@ build_tree (StackNode *node)
}
static void
append_to_tree_and_free (SpCallgraphView *self,
append_to_tree_and_free (SysprofCallgraphView *self,
StackStash *stash,
GtkTreeStore *store,
Descendant *item,
@ -929,7 +929,7 @@ append_to_tree_and_free (SpCallgraphView *self,
g_assert (GTK_IS_TREE_STORE (store));
g_assert (item != NULL);
profile_size = MAX (1, sp_callgraph_view_get_profile_size (self));
profile_size = MAX (1, sysprof_callgraph_view_get_profile_size (self));
gtk_tree_store_append (store, &iter, parent);
@ -952,13 +952,13 @@ append_to_tree_and_free (SpCallgraphView *self,
}
static void
sp_callgraph_view_update_descendants (SpCallgraphView *self,
sysprof_callgraph_view_update_descendants (SysprofCallgraphView *self,
StackNode *node)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeStore *store;
g_assert (SP_IS_CALLGRAPH_VIEW (self));
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
if (g_queue_peek_head (priv->history) != node)
g_queue_push_head (priv->history, node);
@ -973,7 +973,7 @@ sp_callgraph_view_update_descendants (SpCallgraphView *self,
{
StackStash *stash;
stash = sp_callgraph_profile_get_stash (priv->profile);
stash = sysprof_callgraph_profile_get_stash (priv->profile);
if (stash != NULL)
{
Descendant *tree;
@ -987,14 +987,14 @@ sp_callgraph_view_update_descendants (SpCallgraphView *self,
gtk_tree_view_set_model (priv->descendants_view, GTK_TREE_MODEL (store));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
COLUMN_TOTAL, GTK_SORT_DESCENDING);
sp_callgraph_view_expand_descendants (self);
sysprof_callgraph_view_expand_descendants (self);
g_clear_object (&store);
}
/**
* sp_callgraph_view_screenshot:
* @self: A #SpCallgraphView.
* sysprof_callgraph_view_screenshot:
* @self: A #SysprofCallgraphView.
*
* This function will generate a text representation of the descendants tree.
* This is useful if you want to include various profiling information in a
@ -1006,16 +1006,16 @@ sp_callgraph_view_update_descendants (SpCallgraphView *self,
* with g_free().
*/
gchar *
sp_callgraph_view_screenshot (SpCallgraphView *self)
sysprof_callgraph_view_screenshot (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeView *tree_view;
GtkTreeModel *model;
GtkTreePath *tree_path;
GString *str;
GtkTreeIter iter;
g_return_val_if_fail (SP_IS_CALLGRAPH_VIEW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), NULL);
tree_view = priv->descendants_view;
@ -1073,13 +1073,13 @@ sp_callgraph_view_screenshot (SpCallgraphView *self)
}
guint
sp_callgraph_view_get_n_functions (SpCallgraphView *self)
sysprof_callgraph_view_get_n_functions (SysprofCallgraphView *self)
{
SpCallgraphViewPrivate *priv = sp_callgraph_view_get_instance_private (self);
SysprofCallgraphViewPrivate *priv = sysprof_callgraph_view_get_instance_private (self);
GtkTreeModel *model;
guint ret = 0;
g_return_val_if_fail (SP_IS_CALLGRAPH_VIEW (self), 0);
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), 0);
if (NULL != (model = gtk_tree_view_get_model (priv->functions_view)))
ret = gtk_tree_model_iter_n_children (model, NULL);

View File

@ -1,4 +1,4 @@
/* sp-callgraph-view.h
/* sysprof-callgraph-view.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,36 +22,36 @@
#include <gtk/gtk.h>
#include "sp-callgraph-profile.h"
#include "sysprof-callgraph-profile.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_CALLGRAPH_VIEW (sp_callgraph_view_get_type())
#define SYSPROF_TYPE_CALLGRAPH_VIEW (sysprof_callgraph_view_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpCallgraphView, sp_callgraph_view, SP, CALLGRAPH_VIEW, GtkBin)
G_DECLARE_DERIVABLE_TYPE (SysprofCallgraphView, sysprof_callgraph_view, SYSPROF, CALLGRAPH_VIEW, GtkBin)
struct _SpCallgraphViewClass
struct _SysprofCallgraphViewClass
{
GtkBinClass parent_class;
void (*go_previous) (SpCallgraphView *self);
void (*go_previous) (SysprofCallgraphView *self);
gpointer padding[8];
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_callgraph_view_new (void);
GtkWidget *sysprof_callgraph_view_new (void);
SYSPROF_AVAILABLE_IN_ALL
SpCallgraphProfile *sp_callgraph_view_get_profile (SpCallgraphView *self);
SysprofCallgraphProfile *sysprof_callgraph_view_get_profile (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_callgraph_view_set_profile (SpCallgraphView *self,
SpCallgraphProfile *profile);
void sysprof_callgraph_view_set_profile (SysprofCallgraphView *self,
SysprofCallgraphProfile *profile);
SYSPROF_AVAILABLE_IN_ALL
gchar *sp_callgraph_view_screenshot (SpCallgraphView *self);
gchar *sysprof_callgraph_view_screenshot (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
guint sp_callgraph_view_get_n_functions (SpCallgraphView *self);
guint sysprof_callgraph_view_get_n_functions (SysprofCallgraphView *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-cell-renderer-percent.c
/* sysprof-cell-renderer-percent.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,12 +22,12 @@
#include <glib/gi18n.h>
#include "sp-cell-renderer-percent.h"
#include "sysprof-cell-renderer-percent.h"
typedef struct
{
gdouble percent;
} SpCellRendererPercentPrivate;
} SysprofCellRendererPercentPrivate;
enum {
PROP_0,
@ -35,22 +35,22 @@ enum {
N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE (SpCellRendererPercent, sp_cell_renderer_percent, GTK_TYPE_CELL_RENDERER_TEXT)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofCellRendererPercent, sysprof_cell_renderer_percent, GTK_TYPE_CELL_RENDERER_TEXT)
static GParamSpec *properties [N_PROPS];
static void
sp_cell_renderer_percent_get_property (GObject *object,
sysprof_cell_renderer_percent_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpCellRendererPercent *self = SP_CELL_RENDERER_PERCENT (object);
SysprofCellRendererPercent *self = SYSPROF_CELL_RENDERER_PERCENT (object);
switch (prop_id)
{
case PROP_PERCENT:
g_value_set_double (value, sp_cell_renderer_percent_get_percent (self));
g_value_set_double (value, sysprof_cell_renderer_percent_get_percent (self));
break;
default:
@ -59,17 +59,17 @@ sp_cell_renderer_percent_get_property (GObject *object,
}
static void
sp_cell_renderer_percent_set_property (GObject *object,
sysprof_cell_renderer_percent_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpCellRendererPercent *self = SP_CELL_RENDERER_PERCENT (object);
SysprofCellRendererPercent *self = SYSPROF_CELL_RENDERER_PERCENT (object);
switch (prop_id)
{
case PROP_PERCENT:
sp_cell_renderer_percent_set_percent (self, g_value_get_double (value));
sysprof_cell_renderer_percent_set_percent (self, g_value_get_double (value));
break;
default:
@ -78,12 +78,12 @@ sp_cell_renderer_percent_set_property (GObject *object,
}
static void
sp_cell_renderer_percent_class_init (SpCellRendererPercentClass *klass)
sysprof_cell_renderer_percent_class_init (SysprofCellRendererPercentClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = sp_cell_renderer_percent_get_property;
object_class->set_property = sp_cell_renderer_percent_set_property;
object_class->get_property = sysprof_cell_renderer_percent_get_property;
object_class->set_property = sysprof_cell_renderer_percent_set_property;
properties [PROP_PERCENT] =
g_param_spec_double ("percent",
@ -98,28 +98,28 @@ sp_cell_renderer_percent_class_init (SpCellRendererPercentClass *klass)
}
static void
sp_cell_renderer_percent_init (SpCellRendererPercent *self)
sysprof_cell_renderer_percent_init (SysprofCellRendererPercent *self)
{
g_object_set (self, "xalign", 1.0f, NULL);
}
gdouble
sp_cell_renderer_percent_get_percent (SpCellRendererPercent *self)
sysprof_cell_renderer_percent_get_percent (SysprofCellRendererPercent *self)
{
SpCellRendererPercentPrivate *priv = sp_cell_renderer_percent_get_instance_private (self);
SysprofCellRendererPercentPrivate *priv = sysprof_cell_renderer_percent_get_instance_private (self);
g_return_val_if_fail (SP_IS_CELL_RENDERER_PERCENT (self), 0.0);
g_return_val_if_fail (SYSPROF_IS_CELL_RENDERER_PERCENT (self), 0.0);
return priv->percent;
}
void
sp_cell_renderer_percent_set_percent (SpCellRendererPercent *self,
sysprof_cell_renderer_percent_set_percent (SysprofCellRendererPercent *self,
gdouble percent)
{
SpCellRendererPercentPrivate *priv = sp_cell_renderer_percent_get_instance_private (self);
SysprofCellRendererPercentPrivate *priv = sysprof_cell_renderer_percent_get_instance_private (self);
g_return_if_fail (SP_IS_CELL_RENDERER_PERCENT (self));
g_return_if_fail (SYSPROF_IS_CELL_RENDERER_PERCENT (self));
g_return_if_fail (percent >= 0.0);
g_return_if_fail (percent <= 100.0);

View File

@ -0,0 +1,62 @@
/* sysprof-cell-renderer-percent.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_CELL_RENDERER_PERCENT (sysprof_cell_renderer_percent_get_type())
#define SYSPROF_CELL_RENDERER_PERCENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYSPROF_TYPE_CELL_RENDERER_PERCENT, SysprofCellRendererPercent))
#define SYSPROF_CELL_RENDERER_PERCENT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYSPROF_TYPE_CELL_RENDERER_PERCENT, SysprofCellRendererPercent const))
#define SYSPROF_CELL_RENDERER_PERCENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYSPROF_TYPE_CELL_RENDERER_PERCENT, SysprofCellRendererPercentClass))
#define SYSPROF_IS_CELL_RENDERER_PERCENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYSPROF_TYPE_CELL_RENDERER_PERCENT))
#define SYSPROF_IS_CELL_RENDERER_PERCENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYSPROF_TYPE_CELL_RENDERER_PERCENT))
#define SYSPROF_CELL_RENDERER_PERCENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYSPROF_TYPE_CELL_RENDERER_PERCENT, SysprofCellRendererPercentClass))
typedef struct _SysprofCellRendererPercent SysprofCellRendererPercent;
typedef struct _SysprofCellRendererPercentClass SysprofCellRendererPercentClass;
struct _SysprofCellRendererPercent
{
GtkCellRendererText parent;
};
struct _SysprofCellRendererPercentClass
{
GtkCellRendererTextClass parent_class;
gpointer padding[4];
};
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_cell_renderer_percent_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
GtkCellRenderer *sysprof_cell_renderer_percent_new (void);
SYSPROF_AVAILABLE_IN_ALL
gdouble sysprof_cell_renderer_percent_get_percent (SysprofCellRendererPercent *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_cell_renderer_percent_set_percent (SysprofCellRendererPercent *self,
gdouble percent);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-color-cycle.c
/* sysprof-color-cycle.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,13 +18,13 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-color-cycle"
#define G_LOG_DOMAIN "sysprof-color-cycle"
#include "config.h"
#include "sp-color-cycle.h"
#include "sysprof-color-cycle.h"
G_DEFINE_BOXED_TYPE (SpColorCycle, sp_color_cycle, sp_color_cycle_ref, sp_color_cycle_unref)
G_DEFINE_BOXED_TYPE (SysprofColorCycle, sysprof_color_cycle, sysprof_color_cycle_ref, sysprof_color_cycle_unref)
static const gchar *default_colors[] = {
"#73d216",
@ -54,7 +54,7 @@ static const gchar *default_colors[] = {
NULL
};
struct _SpColorCycle
struct _SysprofColorCycle
{
volatile gint ref_count;
GdkRGBA *colors;
@ -63,18 +63,18 @@ struct _SpColorCycle
};
static void
sp_color_cycle_destroy (SpColorCycle *self)
sysprof_color_cycle_destroy (SysprofColorCycle *self)
{
g_free (self->colors);
g_slice_free (SpColorCycle, self);
g_slice_free (SysprofColorCycle, self);
}
SpColorCycle *
sp_color_cycle_new (void)
SysprofColorCycle *
sysprof_color_cycle_new (void)
{
SpColorCycle *self;
SysprofColorCycle *self;
self = g_slice_new0 (SpColorCycle);
self = g_slice_new0 (SysprofColorCycle);
self->ref_count = 1;
self->n_colors = g_strv_length ((gchar **)default_colors);
self->colors = g_new0 (GdkRGBA, self->n_colors);
@ -88,8 +88,8 @@ sp_color_cycle_new (void)
return self;
}
SpColorCycle *
sp_color_cycle_ref (SpColorCycle *self)
SysprofColorCycle *
sysprof_color_cycle_ref (SysprofColorCycle *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count > 0, NULL);
@ -98,16 +98,16 @@ sp_color_cycle_ref (SpColorCycle *self)
}
void
sp_color_cycle_unref (SpColorCycle *self)
sysprof_color_cycle_unref (SysprofColorCycle *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_color_cycle_destroy (self);
sysprof_color_cycle_destroy (self);
}
void
sp_color_cycle_next (SpColorCycle *self,
sysprof_color_cycle_next (SysprofColorCycle *self,
GdkRGBA *rgba)
{
g_return_if_fail (self != NULL);
@ -126,7 +126,7 @@ sp_color_cycle_next (SpColorCycle *self,
}
void
sp_color_cycle_reset (SpColorCycle *self)
sysprof_color_cycle_reset (SysprofColorCycle *self)
{
g_return_if_fail (self != NULL);

View File

@ -1,4 +1,4 @@
/* sp-color-cycle.h
/* sysprof-color-cycle.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -26,22 +26,22 @@
G_BEGIN_DECLS
#define SP_TYPE_COLOR_CYCLE (sp_color_cycle_get_type())
#define SYSPROF_TYPE_COLOR_CYCLE (sysprof_color_cycle_get_type())
typedef struct _SpColorCycle SpColorCycle;
typedef struct _SysprofColorCycle SysprofColorCycle;
SYSPROF_AVAILABLE_IN_ALL
GType sp_color_cycle_get_type (void);
GType sysprof_color_cycle_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
SpColorCycle *sp_color_cycle_ref (SpColorCycle *self);
SysprofColorCycle *sysprof_color_cycle_ref (SysprofColorCycle *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_color_cycle_unref (SpColorCycle *self);
void sysprof_color_cycle_unref (SysprofColorCycle *self);
SYSPROF_AVAILABLE_IN_ALL
SpColorCycle *sp_color_cycle_new (void);
SysprofColorCycle *sysprof_color_cycle_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sp_color_cycle_reset (SpColorCycle *self);
void sysprof_color_cycle_reset (SysprofColorCycle *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_color_cycle_next (SpColorCycle *self,
void sysprof_color_cycle_next (SysprofColorCycle *self,
GdkRGBA *rgba);
G_END_DECLS

View File

@ -0,0 +1,173 @@
/* sysprof-cpu-visualizer-row.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sysprof-cpu-visualizer-row"
#include "config.h"
#include "sysprof-capture-condition.h"
#include "sysprof-capture-cursor.h"
#include "sysprof-color-cycle.h"
#include "sysprof-cpu-visualizer-row.h"
struct _SysprofCpuVisualizerRow
{
SysprofLineVisualizerRow parent_instance;
SysprofColorCycle *colors;
};
G_DEFINE_TYPE (SysprofCpuVisualizerRow, sysprof_cpu_visualizer_row, SYSPROF_TYPE_LINE_VISUALIZER_ROW)
static gboolean
sysprof_cpu_visualizer_counter_found (const SysprofCaptureFrame *frame,
gpointer user_data)
{
const SysprofCaptureFrameCounterDefine *def = (SysprofCaptureFrameCounterDefine *)frame;
GArray *counters = user_data;
gboolean found = FALSE;
g_assert (frame->type == SYSPROF_CAPTURE_FRAME_CTRDEF);
/*
* In practice, all the CPU counters are defined at once, so we can avoid
* walking the rest of the capture by returning after we find our CTRDEF.
*/
for (guint i = 0; i < def->n_counters; i++)
{
if (g_str_equal (def->counters[i].category, "CPU Percent"))
{
guint id = def->counters[i].id;
g_array_append_val (counters, id);
found = TRUE;
}
}
return !found;
}
static void
sysprof_cpu_visualizer_row_discover_counters (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *canellable)
{
const SysprofCaptureFrameType types[] = { SYSPROF_CAPTURE_FRAME_CTRDEF };
SysprofCaptureReader *reader = task_data;
g_autoptr(SysprofCaptureCursor) cursor = NULL;
g_autoptr(GArray) counters = NULL;
g_assert (G_IS_TASK (task));
g_assert (SYSPROF_IS_CPU_VISUALIZER_ROW (source_object));
g_assert (reader != NULL);
counters = g_array_new (FALSE, FALSE, sizeof (guint));
cursor = sysprof_capture_cursor_new (reader);
sysprof_capture_cursor_add_condition (cursor, sysprof_capture_condition_new_where_type_in (G_N_ELEMENTS (types), types));
sysprof_capture_cursor_foreach (cursor, sysprof_cpu_visualizer_counter_found, counters);
g_task_return_pointer (task, g_steal_pointer (&counters), (GDestroyNotify)g_array_unref);
}
static void
complete_counters (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SysprofCpuVisualizerRow *self = (SysprofCpuVisualizerRow *)object;
g_autoptr(GArray) counters = NULL;
g_assert (SYSPROF_IS_CPU_VISUALIZER_ROW (self));
g_assert (G_IS_TASK (result));
counters = g_task_propagate_pointer (G_TASK (result), NULL);
if (counters != NULL)
{
for (guint i = 0; i < counters->len; i++)
{
guint counter_id = g_array_index (counters, guint, i);
GdkRGBA color;
sysprof_color_cycle_next (self->colors, &color);
sysprof_line_visualizer_row_add_counter (SYSPROF_LINE_VISUALIZER_ROW (self), counter_id, &color);
}
}
/* Hide ourself if we failed to locate counters */
gtk_widget_set_visible (GTK_WIDGET (self), counters != NULL && counters->len > 0);
}
static void
sysprof_cpu_visualizer_row_set_reader (SysprofVisualizerRow *row,
SysprofCaptureReader *reader)
{
SysprofCpuVisualizerRow *self = (SysprofCpuVisualizerRow *)row;
g_autoptr(GTask) task = NULL;
g_assert (SYSPROF_IS_CPU_VISUALIZER_ROW (row));
sysprof_color_cycle_reset (self->colors);
sysprof_line_visualizer_row_clear (SYSPROF_LINE_VISUALIZER_ROW (row));
SYSPROF_VISUALIZER_ROW_CLASS (sysprof_cpu_visualizer_row_parent_class)->set_reader (row, reader);
if (reader != NULL)
{
task = g_task_new (self, NULL, complete_counters, NULL);
g_task_set_source_tag (task, sysprof_cpu_visualizer_row_set_reader);
g_task_set_task_data (task, sysprof_capture_reader_copy (reader),
(GDestroyNotify)sysprof_capture_reader_unref);
g_task_run_in_thread (task, sysprof_cpu_visualizer_row_discover_counters);
}
}
static void
sysprof_cpu_visualizer_row_finalize (GObject *object)
{
SysprofCpuVisualizerRow *self = (SysprofCpuVisualizerRow *)object;
g_clear_pointer (&self->colors, sysprof_color_cycle_unref);
G_OBJECT_CLASS (sysprof_cpu_visualizer_row_parent_class)->finalize (object);
}
static void
sysprof_cpu_visualizer_row_class_init (SysprofCpuVisualizerRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
SysprofVisualizerRowClass *row_class = SYSPROF_VISUALIZER_ROW_CLASS (klass);
object_class->finalize = sysprof_cpu_visualizer_row_finalize;
row_class->set_reader = sysprof_cpu_visualizer_row_set_reader;
}
static void
sysprof_cpu_visualizer_row_init (SysprofCpuVisualizerRow *self)
{
self->colors = sysprof_color_cycle_new ();
}
GtkWidget *
sysprof_cpu_visualizer_row_new (void)
{
return g_object_new (SYSPROF_TYPE_CPU_VISUALIZER_ROW, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-cpu-visualizer-row.h
/* sysprof-cpu-visualizer-row.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,18 +20,18 @@
#pragma once
#include "sp-line-visualizer-row.h"
#include "sysprof-line-visualizer-row.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_CPU_VISUALIZER_ROW (sp_cpu_visualizer_row_get_type())
#define SYSPROF_TYPE_CPU_VISUALIZER_ROW (sysprof_cpu_visualizer_row_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpCpuVisualizerRow, sp_cpu_visualizer_row, SP, CPU_VISUALIZER_ROW, SpLineVisualizerRow)
G_DECLARE_FINAL_TYPE (SysprofCpuVisualizerRow, sysprof_cpu_visualizer_row, SYSPROF, CPU_VISUALIZER_ROW, SysprofLineVisualizerRow)
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_cpu_visualizer_row_new (void);
GtkWidget *sysprof_cpu_visualizer_row_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-empty-state-view.c
/* sysprof-empty-state-view.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,21 +18,21 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-empty-state-view"
#define G_LOG_DOMAIN "sysprof-empty-state-view"
#include "config.h"
#include <string.h>
#include "sp-empty-state-view.h"
#include "sysprof-empty-state-view.h"
typedef struct
{
GtkLabel *title;
GtkLabel *subtitle;
} SpEmptyStateViewPrivate;
} SysprofEmptyStateViewPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SpEmptyStateView, sp_empty_state_view, GTK_TYPE_BIN)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofEmptyStateView, sysprof_empty_state_view, GTK_TYPE_BIN)
enum {
PROP_0,
@ -44,13 +44,13 @@ enum {
static GParamSpec *properties [N_PROPS];
GtkWidget *
sp_empty_state_view_new (void)
sysprof_empty_state_view_new (void)
{
return g_object_new (SP_TYPE_EMPTY_STATE_VIEW, NULL);
return g_object_new (SYSPROF_TYPE_EMPTY_STATE_VIEW, NULL);
}
static gboolean
sp_empty_state_view_action (GtkWidget *widget,
sysprof_empty_state_view_action (GtkWidget *widget,
const gchar *prefix,
const gchar *action_name,
GVariant *parameter)
@ -96,11 +96,11 @@ sp_empty_state_view_action (GtkWidget *widget,
}
static gboolean
sp_empty_state_view_activate_link (SpEmptyStateView *self,
sysprof_empty_state_view_activate_link (SysprofEmptyStateView *self,
const gchar *uri,
GtkLabel *label)
{
g_assert (SP_IS_EMPTY_STATE_VIEW (self));
g_assert (SYSPROF_IS_EMPTY_STATE_VIEW (self));
g_assert (uri != NULL);
g_assert (GTK_IS_LABEL (label));
@ -127,7 +127,7 @@ sp_empty_state_view_activate_link (SpEmptyStateView *self,
group_name = g_strndup (full_name, dot - full_name);
action_name = g_strdup (++dot);
sp_empty_state_view_action (GTK_WIDGET (self),
sysprof_empty_state_view_action (GTK_WIDGET (self),
group_name,
action_name,
param);
@ -142,13 +142,13 @@ sp_empty_state_view_activate_link (SpEmptyStateView *self,
}
static void
sp_empty_state_view_set_property (GObject *object,
sysprof_empty_state_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpEmptyStateView *self = SP_EMPTY_STATE_VIEW (object);
SpEmptyStateViewPrivate *priv = sp_empty_state_view_get_instance_private (self);
SysprofEmptyStateView *self = SYSPROF_EMPTY_STATE_VIEW (object);
SysprofEmptyStateViewPrivate *priv = sysprof_empty_state_view_get_instance_private (self);
switch (prop_id)
{
@ -166,12 +166,12 @@ sp_empty_state_view_set_property (GObject *object,
}
static void
sp_empty_state_view_class_init (SpEmptyStateViewClass *klass)
sysprof_empty_state_view_class_init (SysprofEmptyStateViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->set_property = sp_empty_state_view_set_property;
object_class->set_property = sysprof_empty_state_view_set_property;
properties [PROP_TITLE] =
g_param_spec_string ("title",
@ -189,21 +189,21 @@ sp_empty_state_view_class_init (SpEmptyStateViewClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sp-empty-state-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpEmptyStateView, subtitle);
gtk_widget_class_bind_template_child_private (widget_class, SpEmptyStateView, title);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-empty-state-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SysprofEmptyStateView, subtitle);
gtk_widget_class_bind_template_child_private (widget_class, SysprofEmptyStateView, title);
}
static void
sp_empty_state_view_init (SpEmptyStateView *self)
sysprof_empty_state_view_init (SysprofEmptyStateView *self)
{
SpEmptyStateViewPrivate *priv = sp_empty_state_view_get_instance_private (self);
SysprofEmptyStateViewPrivate *priv = sysprof_empty_state_view_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (priv->subtitle,
"activate-link",
G_CALLBACK (sp_empty_state_view_activate_link),
G_CALLBACK (sysprof_empty_state_view_activate_link),
self,
G_CONNECT_SWAPPED);
}

View File

@ -1,4 +1,4 @@
/* sp-empty-state-view.h
/* sysprof-empty-state-view.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -26,12 +26,12 @@
G_BEGIN_DECLS
#define SP_TYPE_EMPTY_STATE_VIEW (sp_empty_state_view_get_type())
#define SYSPROF_TYPE_EMPTY_STATE_VIEW (sysprof_empty_state_view_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpEmptyStateView, sp_empty_state_view, SP, EMPTY_STATE_VIEW, GtkBin)
G_DECLARE_DERIVABLE_TYPE (SysprofEmptyStateView, sysprof_empty_state_view, SYSPROF, EMPTY_STATE_VIEW, GtkBin)
struct _SpEmptyStateViewClass
struct _SysprofEmptyStateViewClass
{
GtkBinClass parent;
@ -39,6 +39,6 @@ struct _SpEmptyStateViewClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_empty_state_view_new (void);
GtkWidget *sysprof_empty_state_view_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-failed-state-view.c
/* sysprof-failed-state-view.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,27 +20,27 @@
#include "config.h"
#include "sp-failed-state-view.h"
#include "sysprof-failed-state-view.h"
G_DEFINE_TYPE (SpFailedStateView, sp_failed_state_view, GTK_TYPE_BIN)
G_DEFINE_TYPE (SysprofFailedStateView, sysprof_failed_state_view, GTK_TYPE_BIN)
GtkWidget *
sp_failed_state_view_new (void)
sysprof_failed_state_view_new (void)
{
return g_object_new (SP_TYPE_FAILED_STATE_VIEW, NULL);
return g_object_new (SYSPROF_TYPE_FAILED_STATE_VIEW, NULL);
}
static void
sp_failed_state_view_class_init (SpFailedStateViewClass *klass)
sysprof_failed_state_view_class_init (SysprofFailedStateViewClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/sysprof/ui/sp-failed-state-view.ui");
"/org/gnome/sysprof/ui/sysprof-failed-state-view.ui");
}
static void
sp_failed_state_view_init (SpFailedStateView *self)
sysprof_failed_state_view_init (SysprofFailedStateView *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}

View File

@ -1,4 +1,4 @@
/* sp-failed-state-view.h
/* sysprof-failed-state-view.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,17 +22,17 @@
#include <gtk/gtk.h>
#include "sp-profiler.h"
#include "sysprof-profiler.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_FAILED_STATE_VIEW (sp_failed_state_view_get_type())
#define SYSPROF_TYPE_FAILED_STATE_VIEW (sysprof_failed_state_view_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpFailedStateView, sp_failed_state_view, SP, FAILED_STATE_VIEW, GtkBin)
G_DECLARE_DERIVABLE_TYPE (SysprofFailedStateView, sysprof_failed_state_view, SYSPROF, FAILED_STATE_VIEW, GtkBin)
struct _SpFailedStateViewClass
struct _SysprofFailedStateViewClass
{
GtkBinClass parent;
@ -40,9 +40,9 @@ struct _SpFailedStateViewClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_failed_state_view_new (void);
GtkWidget *sysprof_failed_state_view_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sp_failed_state_view_set_profiler (SpFailedStateView *self,
SpProfiler *profiler);
void sysprof_failed_state_view_set_profiler (SysprofFailedStateView *self,
SysprofProfiler *profiler);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-line-visualizer-row.c
/* sysprof-line-visualizer-row.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-line-visualizer-row"
#define G_LOG_DOMAIN "sysprof-line-visualizer-row"
#include "config.h"
@ -26,16 +26,16 @@
#include <string.h>
#include "pointcache.h"
#include "sp-capture-condition.h"
#include "sp-capture-cursor.h"
#include "sp-line-visualizer-row.h"
#include "sysprof-capture-condition.h"
#include "sysprof-capture-cursor.h"
#include "sysprof-line-visualizer-row.h"
typedef struct
{
/*
* Our reader as assigned by the visualizer system.
*/
SpCaptureReader *reader;
SysprofCaptureReader *reader;
/*
* An array of LineInfo which contains information about the counters
@ -70,7 +70,7 @@ typedef struct
guint y_lower_set : 1;
guint y_upper_set : 1;
} SpLineVisualizerRowPrivate;
} SysprofLineVisualizerRowPrivate;
typedef struct
{
@ -84,7 +84,7 @@ typedef struct
typedef struct
{
SpCaptureCursor *cursor;
SysprofCaptureCursor *cursor;
GArray *lines;
PointCache *cache;
gint64 begin_time;
@ -95,13 +95,13 @@ typedef struct
guint y_upper_set : 1;
} LoadData;
G_DEFINE_TYPE_WITH_PRIVATE (SpLineVisualizerRow, sp_line_visualizer_row, SP_TYPE_VISUALIZER_ROW)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofLineVisualizerRow, sysprof_line_visualizer_row, SYSPROF_TYPE_VISUALIZER_ROW)
static void sp_line_visualizer_row_load_data_async (SpLineVisualizerRow *self,
static void sysprof_line_visualizer_row_load_data_async (SysprofLineVisualizerRow *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
static PointCache *sp_line_visualizer_row_load_data_finish (SpLineVisualizerRow *self,
static PointCache *sysprof_line_visualizer_row_load_data_finish (SysprofLineVisualizerRow *self,
GAsyncResult *result,
GError **error);
@ -123,7 +123,7 @@ load_data_free (gpointer data)
if (load != NULL)
{
g_clear_pointer (&load->lines, g_array_unref);
g_clear_pointer (&load->cursor, sp_capture_cursor_unref);
g_clear_pointer (&load->cursor, sysprof_capture_cursor_unref);
g_clear_pointer (&load->cache, point_cache_unref);
g_slice_free (LoadData, load);
}
@ -142,23 +142,23 @@ copy_array (GArray *ar)
}
static gboolean
sp_line_visualizer_row_draw (GtkWidget *widget,
sysprof_line_visualizer_row_draw (GtkWidget *widget,
cairo_t *cr)
{
SpLineVisualizerRow *self = (SpLineVisualizerRow *)widget;
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = (SysprofLineVisualizerRow *)widget;
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
GtkStyleContext *style_context;
GtkStateFlags flags;
GtkAllocation alloc;
GdkRGBA foreground;
gboolean ret;
g_assert (SP_IS_LINE_VISUALIZER_ROW (widget));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (widget));
g_assert (cr != NULL);
gtk_widget_get_allocation (widget, &alloc);
ret = GTK_WIDGET_CLASS (sp_line_visualizer_row_parent_class)->draw (widget, cr);
ret = GTK_WIDGET_CLASS (sysprof_line_visualizer_row_parent_class)->draw (widget, cr);
if (priv->cache == NULL)
return ret;
@ -169,7 +169,7 @@ sp_line_visualizer_row_draw (GtkWidget *widget,
for (guint line = 0; line < priv->lines->len; line++)
{
g_autofree SpVisualizerRowAbsolutePoint *points = NULL;
g_autofree SysprofVisualizerRowAbsolutePoint *points = NULL;
const LineInfo *line_info = &g_array_index (priv->lines, LineInfo, line);
const Point *fpoints;
guint n_fpoints = 0;
@ -182,10 +182,10 @@ sp_line_visualizer_row_draw (GtkWidget *widget,
gdouble last_x;
gdouble last_y;
points = g_new0 (SpVisualizerRowAbsolutePoint, n_fpoints);
points = g_new0 (SysprofVisualizerRowAbsolutePoint, n_fpoints);
sp_visualizer_row_translate_points (SP_VISUALIZER_ROW (self),
(const SpVisualizerRowRelativePoint *)fpoints,
sysprof_visualizer_row_translate_points (SYSPROF_VISUALIZER_ROW (self),
(const SysprofVisualizerRowRelativePoint *)fpoints,
n_fpoints,
points,
n_fpoints);
@ -244,18 +244,18 @@ sp_line_visualizer_row_draw (GtkWidget *widget,
}
static void
sp_line_visualizer_row_load_data_cb (GObject *object,
sysprof_line_visualizer_row_load_data_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SpLineVisualizerRow *self = (SpLineVisualizerRow *)object;
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = (SysprofLineVisualizerRow *)object;
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_autoptr(GError) error = NULL;
g_autoptr(PointCache) cache = NULL;
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
cache = sp_line_visualizer_row_load_data_finish (self, result, &error);
cache = sysprof_line_visualizer_row_load_data_finish (self, result, &error);
if (cache == NULL)
{
@ -270,20 +270,20 @@ sp_line_visualizer_row_load_data_cb (GObject *object,
}
static gboolean
sp_line_visualizer_row_do_reload (gpointer data)
sysprof_line_visualizer_row_do_reload (gpointer data)
{
SpLineVisualizerRow *self = data;
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = data;
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
priv->queued_load = 0;
if (priv->reader != NULL)
{
sp_line_visualizer_row_load_data_async (self,
sysprof_line_visualizer_row_load_data_async (self,
NULL,
sp_line_visualizer_row_load_data_cb,
sysprof_line_visualizer_row_load_data_cb,
NULL);
}
@ -291,54 +291,54 @@ sp_line_visualizer_row_do_reload (gpointer data)
}
static void
sp_line_visualizer_row_queue_reload (SpLineVisualizerRow *self)
sysprof_line_visualizer_row_queue_reload (SysprofLineVisualizerRow *self)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
if (priv->queued_load == 0)
{
priv->queued_load = gdk_threads_add_idle_full (G_PRIORITY_LOW,
sp_line_visualizer_row_do_reload,
sysprof_line_visualizer_row_do_reload,
self,
NULL);
}
}
static void
sp_line_visualizer_row_set_reader (SpVisualizerRow *row,
SpCaptureReader *reader)
sysprof_line_visualizer_row_set_reader (SysprofVisualizerRow *row,
SysprofCaptureReader *reader)
{
SpLineVisualizerRow *self = (SpLineVisualizerRow *)row;
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = (SysprofLineVisualizerRow *)row;
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
if (priv->reader != reader)
{
if (priv->reader != NULL)
{
sp_capture_reader_unref (priv->reader);
sysprof_capture_reader_unref (priv->reader);
priv->reader = NULL;
}
if (reader != NULL)
priv->reader = sp_capture_reader_ref (reader);
priv->reader = sysprof_capture_reader_ref (reader);
sp_line_visualizer_row_queue_reload (self);
sysprof_line_visualizer_row_queue_reload (self);
}
}
static void
sp_line_visualizer_row_finalize (GObject *object)
sysprof_line_visualizer_row_finalize (GObject *object)
{
SpLineVisualizerRow *self = (SpLineVisualizerRow *)object;
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = (SysprofLineVisualizerRow *)object;
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_clear_pointer (&priv->lines, g_array_unref);
g_clear_pointer (&priv->cache, point_cache_unref);
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
if (priv->queued_load != 0)
{
@ -346,17 +346,17 @@ sp_line_visualizer_row_finalize (GObject *object)
priv->queued_load = 0;
}
G_OBJECT_CLASS (sp_line_visualizer_row_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_line_visualizer_row_parent_class)->finalize (object);
}
static void
sp_line_visualizer_row_get_property (GObject *object,
sysprof_line_visualizer_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpLineVisualizerRow *self = SP_LINE_VISUALIZER_ROW (object);
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = SYSPROF_LINE_VISUALIZER_ROW (object);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
switch (prop_id)
{
@ -378,13 +378,13 @@ sp_line_visualizer_row_get_property (GObject *object,
}
static void
sp_line_visualizer_row_set_property (GObject *object,
sysprof_line_visualizer_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpLineVisualizerRow *self = SP_LINE_VISUALIZER_ROW (object);
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRow *self = SYSPROF_LINE_VISUALIZER_ROW (object);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
switch (prop_id)
{
@ -410,19 +410,19 @@ sp_line_visualizer_row_set_property (GObject *object,
}
static void
sp_line_visualizer_row_class_init (SpLineVisualizerRowClass *klass)
sysprof_line_visualizer_row_class_init (SysprofLineVisualizerRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
SpVisualizerRowClass *visualizer_class = SP_VISUALIZER_ROW_CLASS (klass);
SysprofVisualizerRowClass *visualizer_class = SYSPROF_VISUALIZER_ROW_CLASS (klass);
object_class->finalize = sp_line_visualizer_row_finalize;
object_class->get_property = sp_line_visualizer_row_get_property;
object_class->set_property = sp_line_visualizer_row_set_property;
object_class->finalize = sysprof_line_visualizer_row_finalize;
object_class->get_property = sysprof_line_visualizer_row_get_property;
object_class->set_property = sysprof_line_visualizer_row_set_property;
widget_class->draw = sp_line_visualizer_row_draw;
widget_class->draw = sysprof_line_visualizer_row_draw;
visualizer_class->set_reader = sp_line_visualizer_row_set_reader;
visualizer_class->set_reader = sysprof_line_visualizer_row_set_reader;
properties [PROP_TITLE] =
g_param_spec_string ("title",
@ -453,9 +453,9 @@ sp_line_visualizer_row_class_init (SpLineVisualizerRowClass *klass)
}
static void
sp_line_visualizer_row_init (SpLineVisualizerRow *self)
sysprof_line_visualizer_row_init (SysprofLineVisualizerRow *self)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
PangoAttrList *attrs = pango_attr_list_new ();
priv->lines = g_array_new (FALSE, FALSE, sizeof (LineInfo));
@ -474,14 +474,14 @@ sp_line_visualizer_row_init (SpLineVisualizerRow *self)
}
void
sp_line_visualizer_row_add_counter (SpLineVisualizerRow *self,
sysprof_line_visualizer_row_add_counter (SysprofLineVisualizerRow *self,
guint counter_id,
const GdkRGBA *color)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
LineInfo line_info = { 0 };
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
g_assert (priv->lines != NULL);
line_info.id = counter_id;
@ -500,18 +500,18 @@ sp_line_visualizer_row_add_counter (SpLineVisualizerRow *self,
g_array_append_val (priv->lines, line_info);
if (SP_LINE_VISUALIZER_ROW_GET_CLASS (self)->counter_added)
SP_LINE_VISUALIZER_ROW_GET_CLASS (self)->counter_added (self, counter_id);
if (SYSPROF_LINE_VISUALIZER_ROW_GET_CLASS (self)->counter_added)
SYSPROF_LINE_VISUALIZER_ROW_GET_CLASS (self)->counter_added (self, counter_id);
sp_line_visualizer_row_queue_reload (self);
sysprof_line_visualizer_row_queue_reload (self);
}
void
sp_line_visualizer_row_clear (SpLineVisualizerRow *self)
sysprof_line_visualizer_row_clear (SysprofLineVisualizerRow *self)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_LINE_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
if (priv->lines->len > 0)
g_array_remove_range (priv->lines, 0, priv->lines->len);
@ -542,7 +542,7 @@ counter_type (LoadData *load,
* We need to keep some information on the counter (by id) so that we
* can track the counters type (which is a 1-byte type id).
*/
return SP_CAPTURE_COUNTER_DOUBLE;
return SYSPROF_CAPTURE_COUNTER_DOUBLE;
}
static inline gdouble
@ -570,24 +570,24 @@ calc_y_int64 (gint64 lower,
}
static gboolean
sp_line_visualizer_row_load_data_frame_cb (const SpCaptureFrame *frame,
sysprof_line_visualizer_row_load_data_frame_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
LoadData *load = user_data;
g_assert (frame != NULL);
g_assert (frame->type == SP_CAPTURE_FRAME_CTRSET ||
frame->type == SP_CAPTURE_FRAME_CTRDEF);
g_assert (frame->type == SYSPROF_CAPTURE_FRAME_CTRSET ||
frame->type == SYSPROF_CAPTURE_FRAME_CTRDEF);
g_assert (load != NULL);
if (frame->type == SP_CAPTURE_FRAME_CTRSET)
if (frame->type == SYSPROF_CAPTURE_FRAME_CTRSET)
{
const SpCaptureFrameCounterSet *set = (SpCaptureFrameCounterSet *)frame;
const SysprofCaptureFrameCounterSet *set = (SysprofCaptureFrameCounterSet *)frame;
gdouble x = calc_x (load->begin_time, load->end_time, frame->time);
for (guint i = 0; i < set->n_values; i++)
{
const SpCaptureCounterValues *group = &set->values[i];
const SysprofCaptureCounterValues *group = &set->values[i];
for (guint j = 0; j < G_N_ELEMENTS (group->ids); j++)
{
@ -597,7 +597,7 @@ sp_line_visualizer_row_load_data_frame_cb (const SpCaptureFrame *frame,
{
gdouble y;
if (counter_type (load, counter_id) == SP_CAPTURE_COUNTER_DOUBLE)
if (counter_type (load, counter_id) == SYSPROF_CAPTURE_COUNTER_DOUBLE)
y = calc_y_double (load->y_lower, load->y_upper, group->values[j].vdbl);
else
y = calc_y_int64 (load->y_lower, load->y_upper, group->values[j].v64);
@ -612,25 +612,25 @@ sp_line_visualizer_row_load_data_frame_cb (const SpCaptureFrame *frame,
}
static gboolean
sp_line_visualizer_row_load_data_range_cb (const SpCaptureFrame *frame,
sysprof_line_visualizer_row_load_data_range_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
LoadData *load = user_data;
g_assert (frame != NULL);
g_assert (frame->type == SP_CAPTURE_FRAME_CTRSET ||
frame->type == SP_CAPTURE_FRAME_CTRDEF);
g_assert (frame->type == SYSPROF_CAPTURE_FRAME_CTRSET ||
frame->type == SYSPROF_CAPTURE_FRAME_CTRDEF);
g_assert (load != NULL);
g_assert (load->y_upper_set == FALSE ||
load->y_lower_set == FALSE);
if (frame->type == SP_CAPTURE_FRAME_CTRSET)
if (frame->type == SYSPROF_CAPTURE_FRAME_CTRSET)
{
const SpCaptureFrameCounterSet *set = (SpCaptureFrameCounterSet *)frame;
const SysprofCaptureFrameCounterSet *set = (SysprofCaptureFrameCounterSet *)frame;
for (guint i = 0; i < set->n_values; i++)
{
const SpCaptureCounterValues *group = &set->values[i];
const SysprofCaptureCounterValues *group = &set->values[i];
for (guint j = 0; j < G_N_ELEMENTS (group->ids); j++)
{
@ -640,7 +640,7 @@ sp_line_visualizer_row_load_data_range_cb (const SpCaptureFrame *frame,
{
gdouble y;
if (counter_type (load, counter_id) == SP_CAPTURE_COUNTER_DOUBLE)
if (counter_type (load, counter_id) == SYSPROF_CAPTURE_COUNTER_DOUBLE)
y = group->values[j].vdbl;
else
y = group->values[j].v64;
@ -659,7 +659,7 @@ sp_line_visualizer_row_load_data_range_cb (const SpCaptureFrame *frame,
}
static void
sp_line_visualizer_row_load_data_worker (GTask *task,
sysprof_line_visualizer_row_load_data_worker (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@ -668,7 +668,7 @@ sp_line_visualizer_row_load_data_worker (GTask *task,
g_autoptr(GArray) counter_ids = NULL;
g_assert (G_IS_TASK (task));
g_assert (SP_IS_LINE_VISUALIZER_ROW (source_object));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (source_object));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
counter_ids = g_array_new (FALSE, FALSE, sizeof (guint));
@ -679,41 +679,41 @@ sp_line_visualizer_row_load_data_worker (GTask *task,
g_array_append_val (counter_ids, line_info->id);
}
sp_capture_cursor_add_condition (load->cursor,
sp_capture_condition_new_where_counter_in (counter_ids->len,
sysprof_capture_cursor_add_condition (load->cursor,
sysprof_capture_condition_new_where_counter_in (counter_ids->len,
(guint *)(gpointer)counter_ids->data));
/* If y boundaries are not set, we need to discover them by scaning the data. */
if (!load->y_lower_set || !load->y_upper_set)
{
sp_capture_cursor_foreach (load->cursor, sp_line_visualizer_row_load_data_range_cb, load);
sp_capture_cursor_reset (load->cursor);
sysprof_capture_cursor_foreach (load->cursor, sysprof_line_visualizer_row_load_data_range_cb, load);
sysprof_capture_cursor_reset (load->cursor);
/* Add extra boundary for some space above the graph line */
if (G_MAXDOUBLE - load->y_upper > (load->y_upper * .25))
load->y_upper *= 1.25;
}
sp_capture_cursor_foreach (load->cursor, sp_line_visualizer_row_load_data_frame_cb, load);
sysprof_capture_cursor_foreach (load->cursor, sysprof_line_visualizer_row_load_data_frame_cb, load);
g_task_return_pointer (task, g_steal_pointer (&load->cache), (GDestroyNotify)point_cache_unref);
}
static void
sp_line_visualizer_row_load_data_async (SpLineVisualizerRow *self,
sysprof_line_visualizer_row_load_data_async (SysprofLineVisualizerRow *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_autoptr(GTask) task = NULL;
LoadData *load;
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_source_tag (task, sp_line_visualizer_row_load_data_async);
g_task_set_source_tag (task, sysprof_line_visualizer_row_load_data_async);
if (priv->reader == NULL)
{
@ -730,9 +730,9 @@ sp_line_visualizer_row_load_data_async (SpLineVisualizerRow *self,
load->y_upper = priv->y_upper;
load->y_lower_set = priv->y_lower_set;
load->y_upper_set = priv->y_upper_set;
load->begin_time = sp_capture_reader_get_start_time (priv->reader);
load->end_time = sp_capture_reader_get_end_time (priv->reader);
load->cursor = sp_capture_cursor_new (priv->reader);
load->begin_time = sysprof_capture_reader_get_start_time (priv->reader);
load->end_time = sysprof_capture_reader_get_end_time (priv->reader);
load->cursor = sysprof_capture_cursor_new (priv->reader);
load->lines = copy_array (priv->lines);
for (guint i = 0; i < load->lines->len; i++)
@ -743,18 +743,18 @@ sp_line_visualizer_row_load_data_async (SpLineVisualizerRow *self,
}
g_task_set_task_data (task, load, load_data_free);
g_task_run_in_thread (task, sp_line_visualizer_row_load_data_worker);
g_task_run_in_thread (task, sysprof_line_visualizer_row_load_data_worker);
}
static PointCache *
sp_line_visualizer_row_load_data_finish (SpLineVisualizerRow *self,
sysprof_line_visualizer_row_load_data_finish (SysprofLineVisualizerRow *self,
GAsyncResult *result,
GError **error)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
LoadData *state;
g_assert (SP_IS_LINE_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
g_assert (G_IS_TASK (result));
state = g_task_get_task_data (G_TASK (result));
@ -775,13 +775,13 @@ sp_line_visualizer_row_load_data_finish (SpLineVisualizerRow *self,
}
void
sp_line_visualizer_row_set_line_width (SpLineVisualizerRow *self,
sysprof_line_visualizer_row_set_line_width (SysprofLineVisualizerRow *self,
guint counter_id,
gdouble width)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_LINE_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
for (guint i = 0; i < priv->lines->len; i++)
{
@ -790,20 +790,20 @@ sp_line_visualizer_row_set_line_width (SpLineVisualizerRow *self,
if (info->id == counter_id)
{
info->line_width = width;
sp_line_visualizer_row_queue_reload (self);
sysprof_line_visualizer_row_queue_reload (self);
break;
}
}
}
void
sp_line_visualizer_row_set_fill (SpLineVisualizerRow *self,
sysprof_line_visualizer_row_set_fill (SysprofLineVisualizerRow *self,
guint counter_id,
const GdkRGBA *color)
{
SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_LINE_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_LINE_VISUALIZER_ROW (self));
for (guint i = 0; i < priv->lines->len; i++)
{
@ -814,7 +814,7 @@ sp_line_visualizer_row_set_fill (SpLineVisualizerRow *self,
info->fill = !!color;
if (color != NULL)
info->background = *color;
sp_line_visualizer_row_queue_reload (self);
sysprof_line_visualizer_row_queue_reload (self);
break;
}
}

View File

@ -1,4 +1,4 @@
/* sp-line-visualizer-row.h
/* sysprof-line-visualizer-row.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -20,21 +20,21 @@
#pragma once
#include "sp-visualizer-row.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_LINE_VISUALIZER_ROW (sp_line_visualizer_row_get_type())
#define SYSPROF_TYPE_LINE_VISUALIZER_ROW (sysprof_line_visualizer_row_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpLineVisualizerRow, sp_line_visualizer_row, SP, LINE_VISUALIZER_ROW, SpVisualizerRow)
G_DECLARE_DERIVABLE_TYPE (SysprofLineVisualizerRow, sysprof_line_visualizer_row, SYSPROF, LINE_VISUALIZER_ROW, SysprofVisualizerRow)
struct _SpLineVisualizerRowClass
struct _SysprofLineVisualizerRowClass
{
SpVisualizerRowClass parent_class;
SysprofVisualizerRowClass parent_class;
void (*counter_added) (SpLineVisualizerRow *self,
void (*counter_added) (SysprofLineVisualizerRow *self,
guint counter_id);
/*< private >*/
@ -42,19 +42,19 @@ struct _SpLineVisualizerRowClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_line_visualizer_row_new (void);
GtkWidget *sysprof_line_visualizer_row_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sp_line_visualizer_row_clear (SpLineVisualizerRow *self);
void sysprof_line_visualizer_row_clear (SysprofLineVisualizerRow *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_line_visualizer_row_add_counter (SpLineVisualizerRow *self,
void sysprof_line_visualizer_row_add_counter (SysprofLineVisualizerRow *self,
guint counter_id,
const GdkRGBA *color);
SYSPROF_AVAILABLE_IN_ALL
void sp_line_visualizer_row_set_line_width (SpLineVisualizerRow *self,
void sysprof_line_visualizer_row_set_line_width (SysprofLineVisualizerRow *self,
guint counter_id,
gdouble width);
SYSPROF_AVAILABLE_IN_ALL
void sp_line_visualizer_row_set_fill (SpLineVisualizerRow *self,
void sysprof_line_visualizer_row_set_fill (SysprofLineVisualizerRow *self,
guint counter_id,
const GdkRGBA *color);

View File

@ -1,4 +1,4 @@
/* sp-mark-visualizer-row.c
/* sysprof-mark-visualizer-row.c
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,21 +18,21 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-mark-visualizer-row"
#define G_LOG_DOMAIN "sysprof-mark-visualizer-row"
#include "config.h"
#include "sp-capture-condition.h"
#include "sp-capture-cursor.h"
#include "sysprof-capture-condition.h"
#include "sysprof-capture-cursor.h"
#include "rectangles.h"
#include "sp-mark-visualizer-row.h"
#include "sysprof-mark-visualizer-row.h"
typedef struct
{
/*
* Our reader as assigned by the visualizer system.
*/
SpCaptureReader *reader;
SysprofCaptureReader *reader;
/*
* The group we care about for displaying marks. The idea is that we only
@ -51,12 +51,12 @@ typedef struct
* Child widget to display the label in the upper corner.
*/
GtkLabel *label;
} SpMarkVisualizerRowPrivate;
} SysprofMarkVisualizerRowPrivate;
typedef struct
{
gchar *group;
SpCaptureCursor *cursor;
SysprofCaptureCursor *cursor;
Rectangles *rects;
GHashTable *inferred_rects;
} BuildState;
@ -74,7 +74,7 @@ enum {
N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE (SpMarkVisualizerRow, sp_mark_visualizer_row, SP_TYPE_VISUALIZER_ROW)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofMarkVisualizerRow, sysprof_mark_visualizer_row, SYSPROF_TYPE_VISUALIZER_ROW)
static GParamSpec *properties [N_PROPS];
@ -116,7 +116,7 @@ build_state_free (BuildState *state)
*/
static gboolean
process_gpu_mark (BuildState *state,
const SpCaptureMark *mark)
const SysprofCaptureMark *mark)
{
InferredRect *rect = g_hash_table_lookup (state->inferred_rects,
mark->message);
@ -167,14 +167,14 @@ process_gpu_mark (BuildState *state,
static gboolean
sp_mark_visualizer_row_add_rect (const SpCaptureFrame *frame,
sysprof_mark_visualizer_row_add_rect (const SysprofCaptureFrame *frame,
gpointer user_data)
{
BuildState *state = user_data;
const SpCaptureMark *mark = (const SpCaptureMark *)frame;
const SysprofCaptureMark *mark = (const SysprofCaptureMark *)frame;
g_assert (frame != NULL);
g_assert (frame->type == SP_CAPTURE_FRAME_MARK);
g_assert (frame->type == SYSPROF_CAPTURE_FRAME_MARK);
g_assert (state != NULL);
g_assert (state->rects != NULL);
@ -195,7 +195,7 @@ sp_mark_visualizer_row_add_rect (const SpCaptureFrame *frame,
}
static void
sp_mark_visualizer_row_worker (GTask *task,
sysprof_mark_visualizer_row_worker (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@ -206,11 +206,11 @@ sp_mark_visualizer_row_worker (GTask *task,
gint64 end_time;
g_assert (G_IS_TASK (task));
g_assert (SP_IS_MARK_VISUALIZER_ROW (source_object));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (source_object));
g_assert (state != NULL);
g_assert (state->cursor != NULL);
sp_capture_cursor_foreach (state->cursor, sp_mark_visualizer_row_add_rect, state);
sysprof_capture_cursor_foreach (state->cursor, sysprof_mark_visualizer_row_add_rect, state);
/* If any inferred rects are left incomplete, just drop them in as
* point events for now.
@ -224,22 +224,22 @@ sp_mark_visualizer_row_worker (GTask *task,
}
g_hash_table_remove_all (state->inferred_rects);
end_time = sp_capture_reader_get_end_time (sp_capture_cursor_get_reader (state->cursor));
end_time = sysprof_capture_reader_get_end_time (sysprof_capture_cursor_get_reader (state->cursor));
rectangles_set_end_time (state->rects, end_time);
g_task_return_pointer (task, g_steal_pointer (&state->rects), (GDestroyNotify)rectangles_free);
}
static gboolean
sp_mark_visualizer_row_query_tooltip (GtkWidget *widget,
sysprof_mark_visualizer_row_query_tooltip (GtkWidget *widget,
gint x,
gint y,
gboolean keyboard_mode,
GtkTooltip *tooltip)
{
SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)widget;
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = (SysprofMarkVisualizerRow *)widget;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_assert (SP_IS_MARK_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (self));
if (priv->rectangles == NULL)
return FALSE;
@ -248,23 +248,23 @@ sp_mark_visualizer_row_query_tooltip (GtkWidget *widget,
}
static gboolean
sp_mark_visualizer_row_draw (GtkWidget *widget,
sysprof_mark_visualizer_row_draw (GtkWidget *widget,
cairo_t *cr)
{
SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)widget;
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = (SysprofMarkVisualizerRow *)widget;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
GtkStyleContext *style_context;
GtkStateFlags flags;
GdkRGBA foreground;
GtkAllocation alloc;
gboolean ret;
g_assert (SP_IS_MARK_VISUALIZER_ROW (widget));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (widget));
g_assert (cr != NULL);
gtk_widget_get_allocation (widget, &alloc);
ret = GTK_WIDGET_CLASS (sp_mark_visualizer_row_parent_class)->draw (widget, cr);
ret = GTK_WIDGET_CLASS (sysprof_mark_visualizer_row_parent_class)->draw (widget, cr);
if (priv->rectangles == NULL)
return ret;
@ -283,10 +283,10 @@ data_load_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)object;
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = (SysprofMarkVisualizerRow *)object;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_assert (SP_IS_MARK_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (self));
g_assert (G_IS_TASK (result));
g_clear_pointer (&priv->rectangles, rectangles_free);
@ -295,21 +295,21 @@ data_load_cb (GObject *object,
}
static void
sp_mark_visualizer_row_reload (SpMarkVisualizerRow *self)
sysprof_mark_visualizer_row_reload (SysprofMarkVisualizerRow *self)
{
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
g_autoptr(SpCaptureCursor) cursor = NULL;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_autoptr(SysprofCaptureCursor) cursor = NULL;
g_autoptr(GTask) task = NULL;
SpCaptureCondition *condition;
SysprofCaptureCondition *condition;
BuildState *state;
g_assert (SP_IS_MARK_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (self));
g_clear_pointer (&priv->rectangles, rectangles_free);
condition = sp_capture_condition_new_where_type_in (1, (SpCaptureFrameType[]) { SP_CAPTURE_FRAME_MARK });
cursor = sp_capture_cursor_new (priv->reader);
sp_capture_cursor_add_condition (cursor, g_steal_pointer (&condition));
condition = sysprof_capture_condition_new_where_type_in (1, (SysprofCaptureFrameType[]) { SYSPROF_CAPTURE_FRAME_MARK });
cursor = sysprof_capture_cursor_new (priv->reader);
sysprof_capture_cursor_add_condition (cursor, g_steal_pointer (&condition));
state = g_slice_new0 (BuildState);
state->inferred_rects = g_hash_table_new_full (g_str_hash, g_str_equal,
@ -317,57 +317,57 @@ sp_mark_visualizer_row_reload (SpMarkVisualizerRow *self)
(GDestroyNotify)free_inferred_rect);
state->group = g_strdup (priv->group);
state->cursor = g_steal_pointer (&cursor);
state->rects = rectangles_new (sp_capture_reader_get_start_time (priv->reader),
sp_capture_reader_get_end_time (priv->reader));
state->rects = rectangles_new (sysprof_capture_reader_get_start_time (priv->reader),
sysprof_capture_reader_get_end_time (priv->reader));
task = g_task_new (self, NULL, data_load_cb, NULL);
g_task_set_task_data (task, state, (GDestroyNotify)build_state_free);
g_task_run_in_thread (task, sp_mark_visualizer_row_worker);
g_task_run_in_thread (task, sysprof_mark_visualizer_row_worker);
}
static void
sp_mark_visualizer_row_set_reader (SpVisualizerRow *row,
SpCaptureReader *reader)
sysprof_mark_visualizer_row_set_reader (SysprofVisualizerRow *row,
SysprofCaptureReader *reader)
{
SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)row;
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = (SysprofMarkVisualizerRow *)row;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_assert (SP_IS_MARK_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_MARK_VISUALIZER_ROW (self));
if (reader != priv->reader)
{
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
if (reader != NULL)
priv->reader = sp_capture_reader_ref (reader);
sp_mark_visualizer_row_reload (self);
priv->reader = sysprof_capture_reader_ref (reader);
sysprof_mark_visualizer_row_reload (self);
}
}
static void
sp_mark_visualizer_row_finalize (GObject *object)
sysprof_mark_visualizer_row_finalize (GObject *object)
{
SpMarkVisualizerRow *self = (SpMarkVisualizerRow *)object;
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = (SysprofMarkVisualizerRow *)object;
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_clear_pointer (&priv->group, g_free);
g_clear_pointer (&priv->rectangles, rectangles_free);
G_OBJECT_CLASS (sp_mark_visualizer_row_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_mark_visualizer_row_parent_class)->finalize (object);
}
static void
sp_mark_visualizer_row_get_property (GObject *object,
sysprof_mark_visualizer_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpMarkVisualizerRow *self = SP_MARK_VISUALIZER_ROW (object);
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = SYSPROF_MARK_VISUALIZER_ROW (object);
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
switch (prop_id)
{
case PROP_GROUP:
g_value_set_string (value, sp_mark_visualizer_row_get_group (self));
g_value_set_string (value, sysprof_mark_visualizer_row_get_group (self));
break;
case PROP_TITLE:
@ -380,18 +380,18 @@ sp_mark_visualizer_row_get_property (GObject *object,
}
static void
sp_mark_visualizer_row_set_property (GObject *object,
sysprof_mark_visualizer_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpMarkVisualizerRow *self = SP_MARK_VISUALIZER_ROW (object);
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRow *self = SYSPROF_MARK_VISUALIZER_ROW (object);
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
switch (prop_id)
{
case PROP_GROUP:
sp_mark_visualizer_row_set_group (self, g_value_get_string (value));
sysprof_mark_visualizer_row_set_group (self, g_value_get_string (value));
break;
case PROP_TITLE:
@ -404,20 +404,20 @@ sp_mark_visualizer_row_set_property (GObject *object,
}
static void
sp_mark_visualizer_row_class_init (SpMarkVisualizerRowClass *klass)
sysprof_mark_visualizer_row_class_init (SysprofMarkVisualizerRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
SpVisualizerRowClass *visualizer_class = SP_VISUALIZER_ROW_CLASS (klass);
SysprofVisualizerRowClass *visualizer_class = SYSPROF_VISUALIZER_ROW_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = sp_mark_visualizer_row_finalize;
object_class->get_property = sp_mark_visualizer_row_get_property;
object_class->set_property = sp_mark_visualizer_row_set_property;
object_class->finalize = sysprof_mark_visualizer_row_finalize;
object_class->get_property = sysprof_mark_visualizer_row_get_property;
object_class->set_property = sysprof_mark_visualizer_row_set_property;
widget_class->draw = sp_mark_visualizer_row_draw;
widget_class->query_tooltip = sp_mark_visualizer_row_query_tooltip;
widget_class->draw = sysprof_mark_visualizer_row_draw;
widget_class->query_tooltip = sysprof_mark_visualizer_row_query_tooltip;
visualizer_class->set_reader = sp_mark_visualizer_row_set_reader;
visualizer_class->set_reader = sysprof_mark_visualizer_row_set_reader;
properties [PROP_GROUP] =
g_param_spec_string ("group",
@ -437,9 +437,9 @@ sp_mark_visualizer_row_class_init (SpMarkVisualizerRowClass *klass)
}
static void
sp_mark_visualizer_row_init (SpMarkVisualizerRow *self)
sysprof_mark_visualizer_row_init (SysprofMarkVisualizerRow *self)
{
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
PangoAttrList *attrs = pango_attr_list_new ();
gtk_widget_set_has_tooltip (GTK_WIDGET (self), TRUE);
@ -458,28 +458,28 @@ sp_mark_visualizer_row_init (SpMarkVisualizerRow *self)
}
GtkWidget *
sp_mark_visualizer_row_new (void)
sysprof_mark_visualizer_row_new (void)
{
return g_object_new (SP_TYPE_MARK_VISUALIZER_ROW, NULL);
return g_object_new (SYSPROF_TYPE_MARK_VISUALIZER_ROW, NULL);
}
const gchar *
sp_mark_visualizer_row_get_group (SpMarkVisualizerRow *self)
sysprof_mark_visualizer_row_get_group (SysprofMarkVisualizerRow *self)
{
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_return_val_if_fail (SP_IS_MARK_VISUALIZER_ROW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_MARK_VISUALIZER_ROW (self), NULL);
return priv->group;
}
void
sp_mark_visualizer_row_set_group (SpMarkVisualizerRow *self,
sysprof_mark_visualizer_row_set_group (SysprofMarkVisualizerRow *self,
const gchar *group)
{
SpMarkVisualizerRowPrivate *priv = sp_mark_visualizer_row_get_instance_private (self);
SysprofMarkVisualizerRowPrivate *priv = sysprof_mark_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_MARK_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_MARK_VISUALIZER_ROW (self));
if (g_strcmp0 (priv->group, group) != 0)
{

View File

@ -1,4 +1,4 @@
/* sp-mark-visualizer-row.h
/* sysprof-mark-visualizer-row.h
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,30 +20,30 @@
#pragma once
#include "sp-visualizer-row.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_MARK_VISUALIZER_ROW (sp_mark_visualizer_row_get_type())
#define SYSPROF_TYPE_MARK_VISUALIZER_ROW (sysprof_mark_visualizer_row_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpMarkVisualizerRow, sp_mark_visualizer_row, SP, MARK_VISUALIZER_ROW, SpVisualizerRow)
G_DECLARE_DERIVABLE_TYPE (SysprofMarkVisualizerRow, sysprof_mark_visualizer_row, SYSPROF, MARK_VISUALIZER_ROW, SysprofVisualizerRow)
struct _SpMarkVisualizerRowClass
struct _SysprofMarkVisualizerRowClass
{
SpVisualizerRowClass parent_class;
SysprofVisualizerRowClass parent_class;
/*< private >*/
gpointer _reserved[16];
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_mark_visualizer_row_new (void);
GtkWidget *sysprof_mark_visualizer_row_new (void);
SYSPROF_AVAILABLE_IN_ALL
const gchar *sp_mark_visualizer_row_get_group (SpMarkVisualizerRow *self);
const gchar *sysprof_mark_visualizer_row_get_group (SysprofMarkVisualizerRow *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_mark_visualizer_row_set_group (SpMarkVisualizerRow *self,
void sysprof_mark_visualizer_row_set_group (SysprofMarkVisualizerRow *self,
const gchar *group);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-model-filter.c
/* sysprof-model-filter.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -20,13 +20,13 @@
#include "config.h"
#include "sp-model-filter.h"
#include "sysprof-model-filter.h"
typedef struct
{
GSequenceIter *child_iter;
GSequenceIter *filter_iter;
} SpModelFilterItem;
} SysprofModelFilterItem;
typedef struct
{
@ -34,7 +34,7 @@ typedef struct
GListModel *child_model;
/*
* Both sequences point to the same SpModelFilterItem which
* Both sequences point to the same SysprofModelFilterItem which
* contains cross-referencing stable GSequenceIter pointers.
* The child_seq is considered the "owner" and used to release
* allocated resources.
@ -46,7 +46,7 @@ typedef struct
* Typical set of callback/closure/free function pointers and data.
* Called for child items to determine visibility state.
*/
SpModelFilterFunc filter_func;
SysprofModelFilterFunc filter_func;
gpointer filter_func_data;
GDestroyNotify filter_func_data_destroy;
@ -56,12 +56,12 @@ typedef struct
* that have changed.
*/
guint supress_items_changed : 1;
} SpModelFilterPrivate;
} SysprofModelFilterPrivate;
static void list_model_iface_init (GListModelInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpModelFilter, sp_model_filter, G_TYPE_OBJECT, 0,
G_ADD_PRIVATE (SpModelFilter)
G_DEFINE_TYPE_EXTENDED (SysprofModelFilter, sysprof_model_filter, G_TYPE_OBJECT, 0,
G_ADD_PRIVATE (SysprofModelFilter)
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL,
list_model_iface_init))
@ -75,17 +75,17 @@ static GParamSpec *properties [N_PROPS];
static guint signal_id;
static void
sp_model_filter_item_free (gpointer data)
sysprof_model_filter_item_free (gpointer data)
{
SpModelFilterItem *item = data;
SysprofModelFilterItem *item = data;
g_clear_pointer (&item->filter_iter, g_sequence_remove);
item->child_iter = NULL;
g_slice_free (SpModelFilterItem, item);
g_slice_free (SysprofModelFilterItem, item);
}
static gboolean
sp_model_filter_default_filter_func (GObject *item,
sysprof_model_filter_default_filter_func (GObject *item,
gpointer user_data)
{
return TRUE;
@ -101,17 +101,17 @@ sp_model_filter_default_filter_func (GObject *item,
* Returns: a #GSequenceIter from the filter sequence.
*/
static GSequenceIter *
find_next_visible_filter_iter (SpModelFilter *self,
find_next_visible_filter_iter (SysprofModelFilter *self,
GSequenceIter *iter)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_assert (SP_IS_MODEL_FILTER (self));
g_assert (SYSPROF_IS_MODEL_FILTER (self));
g_assert (iter != NULL);
for (; !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter))
{
SpModelFilterItem *item = g_sequence_get (iter);
SysprofModelFilterItem *item = g_sequence_get (iter);
g_assert (item->child_iter == iter);
g_assert (item->filter_iter == NULL ||
@ -125,16 +125,16 @@ find_next_visible_filter_iter (SpModelFilter *self,
}
static void
sp_model_filter_child_model_items_changed (SpModelFilter *self,
sysprof_model_filter_child_model_items_changed (SysprofModelFilter *self,
guint position,
guint n_removed,
guint n_added,
GListModel *child_model)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
gboolean unblocked;
g_assert (SP_IS_MODEL_FILTER (self));
g_assert (SYSPROF_IS_MODEL_FILTER (self));
g_assert (G_IS_LIST_MODEL (child_model));
g_assert (priv->child_model == child_model);
g_assert (position <= (guint)g_sequence_get_length (priv->child_seq));
@ -164,7 +164,7 @@ sp_model_filter_child_model_items_changed (SpModelFilter *self,
for (guint i = 0; i < n_removed; i++)
{
GSequenceIter *to_remove = iter;
SpModelFilterItem *item = g_sequence_get (iter);
SysprofModelFilterItem *item = g_sequence_get (iter);
g_assert (item != NULL);
g_assert (item->child_iter == iter);
@ -207,9 +207,9 @@ add_new_items:
for (guint i = position + n_added; i > position; i--)
{
g_autoptr(GObject) instance = NULL;
SpModelFilterItem *item;
SysprofModelFilterItem *item;
item = g_slice_new0 (SpModelFilterItem);
item = g_slice_new0 (SysprofModelFilterItem);
item->filter_iter = NULL;
item->child_iter = g_sequence_insert_before (iter, item);
@ -240,10 +240,10 @@ add_new_items:
}
static void
sp_model_filter_finalize (GObject *object)
sysprof_model_filter_finalize (GObject *object)
{
SpModelFilter *self = (SpModelFilter *)object;
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilter *self = (SysprofModelFilter *)object;
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_clear_pointer (&priv->child_seq, g_sequence_free);
g_clear_pointer (&priv->filter_seq, g_sequence_free);
@ -256,21 +256,21 @@ sp_model_filter_finalize (GObject *object)
g_clear_object (&priv->child_model);
G_OBJECT_CLASS (sp_model_filter_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_model_filter_parent_class)->finalize (object);
}
static void
sp_model_filter_get_property (GObject *object,
sysprof_model_filter_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpModelFilter *self = SP_MODEL_FILTER (object);
SysprofModelFilter *self = SYSPROF_MODEL_FILTER (object);
switch (prop_id)
{
case PROP_CHILD_MODEL:
g_value_set_object (value, sp_model_filter_get_child_model (self));
g_value_set_object (value, sysprof_model_filter_get_child_model (self));
break;
default:
@ -279,12 +279,12 @@ sp_model_filter_get_property (GObject *object,
}
static void
sp_model_filter_class_init (SpModelFilterClass *klass)
sysprof_model_filter_class_init (SysprofModelFilterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_model_filter_finalize;
object_class->get_property = sp_model_filter_get_property;
object_class->finalize = sysprof_model_filter_finalize;
object_class->get_property = sysprof_model_filter_get_property;
properties [PROP_CHILD_MODEL] =
g_param_spec_object ("child-model",
@ -295,53 +295,53 @@ sp_model_filter_class_init (SpModelFilterClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
signal_id = g_signal_lookup ("items-changed", SP_TYPE_MODEL_FILTER);
signal_id = g_signal_lookup ("items-changed", SYSPROF_TYPE_MODEL_FILTER);
}
static void
sp_model_filter_init (SpModelFilter *self)
sysprof_model_filter_init (SysprofModelFilter *self)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
priv->filter_func = sp_model_filter_default_filter_func;
priv->child_seq = g_sequence_new (sp_model_filter_item_free);
priv->filter_func = sysprof_model_filter_default_filter_func;
priv->child_seq = g_sequence_new (sysprof_model_filter_item_free);
priv->filter_seq = g_sequence_new (NULL);
}
static GType
sp_model_filter_get_item_type (GListModel *model)
sysprof_model_filter_get_item_type (GListModel *model)
{
SpModelFilter *self = (SpModelFilter *)model;
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilter *self = (SysprofModelFilter *)model;
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_assert (SP_IS_MODEL_FILTER (self));
g_assert (SYSPROF_IS_MODEL_FILTER (self));
return g_list_model_get_item_type (priv->child_model);
}
static guint
sp_model_filter_get_n_items (GListModel *model)
sysprof_model_filter_get_n_items (GListModel *model)
{
SpModelFilter *self = (SpModelFilter *)model;
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilter *self = (SysprofModelFilter *)model;
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_assert (SP_IS_MODEL_FILTER (self));
g_assert (SYSPROF_IS_MODEL_FILTER (self));
g_assert (priv->filter_seq != NULL);
return g_sequence_get_length (priv->filter_seq);
}
static gpointer
sp_model_filter_get_item (GListModel *model,
sysprof_model_filter_get_item (GListModel *model,
guint position)
{
SpModelFilter *self = (SpModelFilter *)model;
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SpModelFilterItem *item;
SysprofModelFilter *self = (SysprofModelFilter *)model;
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
SysprofModelFilterItem *item;
GSequenceIter *iter;
guint child_position;
g_assert (SP_IS_MODEL_FILTER (self));
g_assert (SYSPROF_IS_MODEL_FILTER (self));
g_assert (position < (guint)g_sequence_get_length (priv->filter_seq));
iter = g_sequence_get_iter_at_pos (priv->filter_seq, position);
@ -361,59 +361,59 @@ sp_model_filter_get_item (GListModel *model,
static void
list_model_iface_init (GListModelInterface *iface)
{
iface->get_item_type = sp_model_filter_get_item_type;
iface->get_n_items = sp_model_filter_get_n_items;
iface->get_item = sp_model_filter_get_item;
iface->get_item_type = sysprof_model_filter_get_item_type;
iface->get_n_items = sysprof_model_filter_get_n_items;
iface->get_item = sysprof_model_filter_get_item;
}
SpModelFilter *
sp_model_filter_new (GListModel *child_model)
SysprofModelFilter *
sysprof_model_filter_new (GListModel *child_model)
{
SpModelFilter *ret;
SpModelFilterPrivate *priv;
SysprofModelFilter *ret;
SysprofModelFilterPrivate *priv;
g_return_val_if_fail (G_IS_LIST_MODEL (child_model), NULL);
ret = g_object_new (SP_TYPE_MODEL_FILTER, NULL);
priv = sp_model_filter_get_instance_private (ret);
ret = g_object_new (SYSPROF_TYPE_MODEL_FILTER, NULL);
priv = sysprof_model_filter_get_instance_private (ret);
priv->child_model = g_object_ref (child_model);
g_signal_connect_object (child_model,
"items-changed",
G_CALLBACK (sp_model_filter_child_model_items_changed),
G_CALLBACK (sysprof_model_filter_child_model_items_changed),
ret,
G_CONNECT_SWAPPED);
sp_model_filter_invalidate (ret);
sysprof_model_filter_invalidate (ret);
return ret;
}
/**
* sp_model_filter_get_child_model:
* @self: A #SpModelFilter
* sysprof_model_filter_get_child_model:
* @self: A #SysprofModelFilter
*
* Gets the child model that is being filtered.
*
* Returns: (transfer none): A #GListModel.
*/
GListModel *
sp_model_filter_get_child_model (SpModelFilter *self)
sysprof_model_filter_get_child_model (SysprofModelFilter *self)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_return_val_if_fail (SP_IS_MODEL_FILTER (self), NULL);
g_return_val_if_fail (SYSPROF_IS_MODEL_FILTER (self), NULL);
return priv->child_model;
}
void
sp_model_filter_invalidate (SpModelFilter *self)
sysprof_model_filter_invalidate (SysprofModelFilter *self)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
guint n_items;
g_return_if_fail (SP_IS_MODEL_FILTER (self));
g_return_if_fail (SYSPROF_IS_MODEL_FILTER (self));
/* We block emission while in invalidate so that we can use
* a single larger items-changed rather lots of small emissions.
@ -448,7 +448,7 @@ sp_model_filter_invalidate (SpModelFilter *self)
* we get populate our sequence and filter sequence.
*/
child_n_items = g_list_model_get_n_items (priv->child_model);
sp_model_filter_child_model_items_changed (self, 0, 0, child_n_items, priv->child_model);
sysprof_model_filter_child_model_items_changed (self, 0, 0, child_n_items, priv->child_model);
g_assert ((guint)g_sequence_get_length (priv->child_seq) == child_n_items);
g_assert ((guint)g_sequence_get_length (priv->filter_seq) <= child_n_items);
@ -467,14 +467,14 @@ sp_model_filter_invalidate (SpModelFilter *self)
}
void
sp_model_filter_set_filter_func (SpModelFilter *self,
SpModelFilterFunc filter_func,
sysprof_model_filter_set_filter_func (SysprofModelFilter *self,
SysprofModelFilterFunc filter_func,
gpointer filter_func_data,
GDestroyNotify filter_func_data_destroy)
{
SpModelFilterPrivate *priv = sp_model_filter_get_instance_private (self);
SysprofModelFilterPrivate *priv = sysprof_model_filter_get_instance_private (self);
g_return_if_fail (SP_IS_MODEL_FILTER (self));
g_return_if_fail (SYSPROF_IS_MODEL_FILTER (self));
g_return_if_fail (filter_func || (!filter_func_data && !filter_func_data_destroy));
if (priv->filter_func_data_destroy != NULL)
@ -488,10 +488,10 @@ sp_model_filter_set_filter_func (SpModelFilter *self,
}
else
{
priv->filter_func = sp_model_filter_default_filter_func;
priv->filter_func = sysprof_model_filter_default_filter_func;
priv->filter_func_data = NULL;
priv->filter_func_data_destroy = NULL;
}
sp_model_filter_invalidate (self);
sysprof_model_filter_invalidate (self);
}

View File

@ -1,4 +1,4 @@
/* sp-model-filter.h
/* sysprof-model-filter.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -26,15 +26,15 @@
G_BEGIN_DECLS
#define SP_TYPE_MODEL_FILTER (sp_model_filter_get_type())
#define SYSPROF_TYPE_MODEL_FILTER (sysprof_model_filter_get_type())
typedef gboolean (*SpModelFilterFunc) (GObject *object,
typedef gboolean (*SysprofModelFilterFunc) (GObject *object,
gpointer user_data);
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpModelFilter, sp_model_filter, SP, MODEL_FILTER, GObject)
G_DECLARE_DERIVABLE_TYPE (SysprofModelFilter, sysprof_model_filter, SYSPROF, MODEL_FILTER, GObject)
struct _SpModelFilterClass
struct _SysprofModelFilterClass
{
GObjectClass parent_class;
@ -42,14 +42,14 @@ struct _SpModelFilterClass
};
SYSPROF_AVAILABLE_IN_ALL
SpModelFilter *sp_model_filter_new (GListModel *child_model);
SysprofModelFilter *sysprof_model_filter_new (GListModel *child_model);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sp_model_filter_get_child_model (SpModelFilter *self);
GListModel *sysprof_model_filter_get_child_model (SysprofModelFilter *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_model_filter_invalidate (SpModelFilter *self);
void sysprof_model_filter_invalidate (SysprofModelFilter *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_model_filter_set_filter_func (SpModelFilter *self,
SpModelFilterFunc filter_func,
void sysprof_model_filter_set_filter_func (SysprofModelFilter *self,
SysprofModelFilterFunc filter_func,
gpointer filter_func_data,
GDestroyNotify filter_func_data_destroy);

View File

@ -1,4 +1,4 @@
/* sp-multi-paned.h
/* sysprof-multi-paned.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -27,18 +27,18 @@
G_BEGIN_DECLS
#define SP_TYPE_MULTI_PANED (sp_multi_paned_get_type())
#define SYSPROF_TYPE_MULTI_PANED (sysprof_multi_paned_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpMultiPaned, sp_multi_paned, SP, MULTI_PANED, GtkContainer)
G_DECLARE_DERIVABLE_TYPE (SysprofMultiPaned, sysprof_multi_paned, SYSPROF, MULTI_PANED, GtkContainer)
struct _SpMultiPanedClass
struct _SysprofMultiPanedClass
{
GtkContainerClass parent;
void (*resize_drag_begin) (SpMultiPaned *self,
void (*resize_drag_begin) (SysprofMultiPaned *self,
GtkWidget *child);
void (*resize_drag_end) (SpMultiPaned *self,
void (*resize_drag_end) (SysprofMultiPaned *self,
GtkWidget *child);
gpointer _reserved1;
@ -52,8 +52,8 @@ struct _SpMultiPanedClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_multi_paned_new (void);
GtkWidget *sysprof_multi_paned_new (void);
SYSPROF_AVAILABLE_IN_ALL
guint sp_multi_paned_get_n_children (SpMultiPaned *self);
guint sysprof_multi_paned_get_n_children (SysprofMultiPaned *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-process-model-row.c
/* sysprof-process-model-row.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -20,20 +20,20 @@
#include "config.h"
#include "sp-process-model-row.h"
#include "sysprof-process-model-row.h"
typedef struct
{
SpProcessModelItem *item;
SysprofProcessModelItem *item;
GtkLabel *args_label;
GtkLabel *label;
GtkLabel *pid;
GtkImage *image;
GtkImage *check;
} SpProcessModelRowPrivate;
} SysprofProcessModelRowPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SpProcessModelRow, sp_process_model_row, GTK_TYPE_LIST_BOX_ROW)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofProcessModelRow, sysprof_process_model_row, GTK_TYPE_LIST_BOX_ROW)
enum {
PROP_0,
@ -45,31 +45,31 @@ enum {
static GParamSpec *properties [N_PROPS];
GtkWidget *
sp_process_model_row_new (SpProcessModelItem *item)
sysprof_process_model_row_new (SysprofProcessModelItem *item)
{
return g_object_new (SP_TYPE_PROCESS_MODEL_ROW,
return g_object_new (SYSPROF_TYPE_PROCESS_MODEL_ROW,
"item", item,
NULL);
}
SpProcessModelItem *
sp_process_model_row_get_item (SpProcessModelRow *self)
SysprofProcessModelItem *
sysprof_process_model_row_get_item (SysprofProcessModelRow *self)
{
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ROW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ROW (self), NULL);
return priv->item;
}
static void
sp_process_model_row_set_item (SpProcessModelRow *self,
SpProcessModelItem *item)
sysprof_process_model_row_set_item (SysprofProcessModelRow *self,
SysprofProcessModelItem *item)
{
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_assert (SP_IS_PROCESS_MODEL_ROW (self));
g_assert (SP_IS_PROCESS_MODEL_ITEM (item));
g_assert (SYSPROF_IS_PROCESS_MODEL_ROW (self));
g_assert (SYSPROF_IS_PROCESS_MODEL_ITEM (item));
if (g_set_object (&priv->item, item))
{
@ -79,11 +79,11 @@ sp_process_model_row_set_item (SpProcessModelRow *self,
const gchar * const *argv;
GPid pid;
command_line = sp_process_model_item_get_command_line (item);
command_line = sysprof_process_model_item_get_command_line (item);
parts = g_strsplit (command_line ?: "", "\n", 0);
gtk_label_set_label (priv->label, parts [0]);
if ((NULL != (argv = sp_process_model_item_get_argv (item))) && (argv[0] != NULL))
if ((NULL != (argv = sysprof_process_model_item_get_argv (item))) && (argv[0] != NULL))
{
g_autofree gchar *argvstr = g_strjoinv (" ", (gchar **)&argv[1]);
g_autofree gchar *escaped = g_markup_escape_text (argvstr, -1);
@ -91,7 +91,7 @@ sp_process_model_row_set_item (SpProcessModelRow *self,
gtk_label_set_label (priv->args_label, escaped);
}
pid = sp_process_model_item_get_pid (item);
pid = sysprof_process_model_item_get_pid (item);
pidstr = g_strdup_printf ("<small>%u</small>", pid);
gtk_label_set_label (priv->pid, pidstr);
gtk_label_set_use_markup (priv->pid, TRUE);
@ -99,26 +99,26 @@ sp_process_model_row_set_item (SpProcessModelRow *self,
}
gboolean
sp_process_model_row_get_selected (SpProcessModelRow *self)
sysprof_process_model_row_get_selected (SysprofProcessModelRow *self)
{
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ROW (self), FALSE);
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ROW (self), FALSE);
return gtk_widget_get_visible (GTK_WIDGET (priv->check));
}
void
sp_process_model_row_set_selected (SpProcessModelRow *self,
sysprof_process_model_row_set_selected (SysprofProcessModelRow *self,
gboolean selected)
{
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_return_if_fail (SP_IS_PROCESS_MODEL_ROW (self));
g_return_if_fail (SYSPROF_IS_PROCESS_MODEL_ROW (self));
selected = !!selected;
if (selected != sp_process_model_row_get_selected (self))
if (selected != sysprof_process_model_row_get_selected (self))
{
gtk_widget_set_visible (GTK_WIDGET (priv->check), selected);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SELECTED]);
@ -126,21 +126,21 @@ sp_process_model_row_set_selected (SpProcessModelRow *self,
}
static gboolean
sp_process_model_row_query_tooltip (GtkWidget *widget,
sysprof_process_model_row_query_tooltip (GtkWidget *widget,
gint x,
gint y,
gboolean keyboard_mode,
GtkTooltip *tooltip)
{
SpProcessModelRow *self = (SpProcessModelRow *)widget;
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRow *self = (SysprofProcessModelRow *)widget;
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_assert (SP_IS_PROCESS_MODEL_ROW (self));
g_assert (SYSPROF_IS_PROCESS_MODEL_ROW (self));
g_assert (GTK_IS_TOOLTIP (tooltip));
if (priv->item != NULL)
{
const gchar * const *argv = sp_process_model_item_get_argv (priv->item);
const gchar * const *argv = sysprof_process_model_item_get_argv (priv->item);
if (argv != NULL)
{
@ -154,32 +154,32 @@ sp_process_model_row_query_tooltip (GtkWidget *widget,
}
static void
sp_process_model_row_finalize (GObject *object)
sysprof_process_model_row_finalize (GObject *object)
{
SpProcessModelRow *self = (SpProcessModelRow *)object;
SpProcessModelRowPrivate *priv = sp_process_model_row_get_instance_private (self);
SysprofProcessModelRow *self = (SysprofProcessModelRow *)object;
SysprofProcessModelRowPrivate *priv = sysprof_process_model_row_get_instance_private (self);
g_clear_object (&priv->item);
G_OBJECT_CLASS (sp_process_model_row_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_process_model_row_parent_class)->finalize (object);
}
static void
sp_process_model_row_get_property (GObject *object,
sysprof_process_model_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpProcessModelRow *self = SP_PROCESS_MODEL_ROW (object);
SysprofProcessModelRow *self = SYSPROF_PROCESS_MODEL_ROW (object);
switch (prop_id)
{
case PROP_ITEM:
g_value_set_object (value, sp_process_model_row_get_item (self));
g_value_set_object (value, sysprof_process_model_row_get_item (self));
break;
case PROP_SELECTED:
g_value_set_boolean (value, sp_process_model_row_get_selected (self));
g_value_set_boolean (value, sysprof_process_model_row_get_selected (self));
break;
default:
@ -188,21 +188,21 @@ sp_process_model_row_get_property (GObject *object,
}
static void
sp_process_model_row_set_property (GObject *object,
sysprof_process_model_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpProcessModelRow *self = SP_PROCESS_MODEL_ROW (object);
SysprofProcessModelRow *self = SYSPROF_PROCESS_MODEL_ROW (object);
switch (prop_id)
{
case PROP_ITEM:
sp_process_model_row_set_item (self, g_value_get_object (value));
sysprof_process_model_row_set_item (self, g_value_get_object (value));
break;
case PROP_SELECTED:
sp_process_model_row_set_selected (self, g_value_get_boolean (value));
sysprof_process_model_row_set_selected (self, g_value_get_boolean (value));
break;
default:
@ -211,22 +211,22 @@ sp_process_model_row_set_property (GObject *object,
}
static void
sp_process_model_row_class_init (SpProcessModelRowClass *klass)
sysprof_process_model_row_class_init (SysprofProcessModelRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = sp_process_model_row_finalize;
object_class->get_property = sp_process_model_row_get_property;
object_class->set_property = sp_process_model_row_set_property;
object_class->finalize = sysprof_process_model_row_finalize;
object_class->get_property = sysprof_process_model_row_get_property;
object_class->set_property = sysprof_process_model_row_set_property;
widget_class->query_tooltip = sp_process_model_row_query_tooltip;
widget_class->query_tooltip = sysprof_process_model_row_query_tooltip;
properties [PROP_ITEM] =
g_param_spec_object ("item",
"Item",
"Item",
SP_TYPE_PROCESS_MODEL_ITEM,
SYSPROF_TYPE_PROCESS_MODEL_ITEM,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_SELECTED] =
@ -239,16 +239,16 @@ sp_process_model_row_class_init (SpProcessModelRowClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/sysprof/ui/sp-process-model-row.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpProcessModelRow, args_label);
gtk_widget_class_bind_template_child_private (widget_class, SpProcessModelRow, image);
gtk_widget_class_bind_template_child_private (widget_class, SpProcessModelRow, label);
gtk_widget_class_bind_template_child_private (widget_class, SpProcessModelRow, pid);
gtk_widget_class_bind_template_child_private (widget_class, SpProcessModelRow, check);
"/org/gnome/sysprof/ui/sysprof-process-model-row.ui");
gtk_widget_class_bind_template_child_private (widget_class, SysprofProcessModelRow, args_label);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProcessModelRow, image);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProcessModelRow, label);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProcessModelRow, pid);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProcessModelRow, check);
}
static void
sp_process_model_row_init (SpProcessModelRow *self)
sysprof_process_model_row_init (SysprofProcessModelRow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));

View File

@ -1,4 +1,4 @@
/* sp-process-model-row.h
/* sysprof-process-model-row.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,17 +22,17 @@
#include <gtk/gtk.h>
#include "sp-process-model-item.h"
#include "sysprof-process-model-item.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_PROCESS_MODEL_ROW (sp_process_model_row_get_type())
#define SYSPROF_TYPE_PROCESS_MODEL_ROW (sysprof_process_model_row_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpProcessModelRow, sp_process_model_row, SP, PROCESS_MODEL_ROW, GtkListBoxRow)
G_DECLARE_DERIVABLE_TYPE (SysprofProcessModelRow, sysprof_process_model_row, SYSPROF, PROCESS_MODEL_ROW, GtkListBoxRow)
struct _SpProcessModelRowClass
struct _SysprofProcessModelRowClass
{
GtkListBoxRowClass parent;
@ -40,13 +40,13 @@ struct _SpProcessModelRowClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_process_model_row_new (SpProcessModelItem *item);
GtkWidget *sysprof_process_model_row_new (SysprofProcessModelItem *item);
SYSPROF_AVAILABLE_IN_ALL
SpProcessModelItem *sp_process_model_row_get_item (SpProcessModelRow *self);
SysprofProcessModelItem *sysprof_process_model_row_get_item (SysprofProcessModelRow *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_process_model_row_get_selected (SpProcessModelRow *self);
gboolean sysprof_process_model_row_get_selected (SysprofProcessModelRow *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_process_model_row_set_selected (SpProcessModelRow *self,
void sysprof_process_model_row_set_selected (SysprofProcessModelRow *self,
gboolean selected);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-profiler-menu-button.c
/* sysprof-profiler-menu-button.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -23,16 +23,16 @@
#include <glib/gi18n.h>
#include <string.h>
#include "sp-model-filter.h"
#include "sp-process-model.h"
#include "sp-process-model-item.h"
#include "sp-process-model-row.h"
#include "sp-profiler-menu-button.h"
#include "sysprof-model-filter.h"
#include "sysprof-process-model.h"
#include "sysprof-process-model-item.h"
#include "sysprof-process-model-row.h"
#include "sysprof-profiler-menu-button.h"
typedef struct
{
SpProfiler *profiler;
SpModelFilter *process_filter;
SysprofProfiler *profiler;
SysprofModelFilter *process_filter;
/* Gtk template widgets */
GtkTreeModel *environment_model;
@ -40,7 +40,7 @@ typedef struct
GtkPopover *popover;
GtkEntry *process_filter_entry;
GtkListBox *process_list_box;
SpProcessModel *process_model;
SysprofProcessModel *process_model;
GtkBox *processes_box;
GtkEntry *spawn_entry;
GtkStack *stack;
@ -63,9 +63,9 @@ typedef struct
/* GSources */
guint save_env_source;
} SpProfilerMenuButtonPrivate;
} SysprofProfilerMenuButtonPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SpProfilerMenuButton, sp_profiler_menu_button, GTK_TYPE_MENU_BUTTON)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofProfilerMenuButton, sysprof_profiler_menu_button, GTK_TYPE_MENU_BUTTON)
enum {
PROP_0,
@ -73,32 +73,32 @@ enum {
N_PROPS
};
static void sp_profiler_menu_button_env_row_changed (SpProfilerMenuButton *self,
static void sysprof_profiler_menu_button_env_row_changed (SysprofProfilerMenuButton *self,
GtkTreePath *tree_path,
GtkTreeIter *tree_iter,
gpointer user_data);
static void sp_profiler_menu_button_validate_spawn (SpProfilerMenuButton *self,
static void sysprof_profiler_menu_button_validate_spawn (SysprofProfilerMenuButton *self,
GtkEntry *entry);
static gboolean save_environ_to_gsettings (gpointer data);
static GParamSpec *properties [N_PROPS];
GtkWidget *
sp_profiler_menu_button_new (void)
sysprof_profiler_menu_button_new (void)
{
return g_object_new (SP_TYPE_PROFILER_MENU_BUTTON, NULL);
return g_object_new (SYSPROF_TYPE_PROFILER_MENU_BUTTON, NULL);
}
static void
sp_profiler_menu_button_update_label (SpProfilerMenuButton *self)
sysprof_profiler_menu_button_update_label (SysprofProfilerMenuButton *self)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_autofree gchar *str = NULL;
const gchar *visible_child;
const GPid *pids;
guint n_pids = 0;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
if (priv->profiler == NULL)
{
@ -116,21 +116,21 @@ sp_profiler_menu_button_update_label (SpProfilerMenuButton *self)
if (text && *text)
gtk_label_set_label (priv->label, text);
else if (sp_profiler_get_whole_system (priv->profiler))
else if (sysprof_profiler_get_whole_system (priv->profiler))
gtk_label_set_label (priv->label, _("All Processes"));
else
gtk_label_set_label (priv->label, _("New Process"));
sp_profiler_set_spawn (priv->profiler, text && *text);
sysprof_profiler_set_spawn (priv->profiler, text && *text);
return;
}
sp_profiler_set_spawn (priv->profiler, FALSE);
sysprof_profiler_set_spawn (priv->profiler, FALSE);
pids = sp_profiler_get_pids (priv->profiler, &n_pids);
pids = sysprof_profiler_get_pids (priv->profiler, &n_pids);
if (n_pids == 0 || sp_profiler_get_whole_system (priv->profiler))
if (n_pids == 0 || sysprof_profiler_get_whole_system (priv->profiler))
{
gtk_label_set_label (priv->label, _("All Processes"));
return;
@ -153,7 +153,7 @@ static void
clear_selected_flags (GtkWidget *widget,
gpointer user_data)
{
sp_process_model_row_set_selected (SP_PROCESS_MODEL_ROW (widget), FALSE);
sysprof_process_model_row_set_selected (SYSPROF_PROCESS_MODEL_ROW (widget), FALSE);
}
static void
@ -192,12 +192,12 @@ clear_binding (GBinding **binding)
}
static void
sp_profiler_menu_button_connect (SpProfilerMenuButton *self)
sysprof_profiler_menu_button_connect (SysprofProfilerMenuButton *self)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SP_IS_PROFILER (priv->profiler));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER (priv->profiler));
add_binding (&priv->mutable_binding,
priv->profiler, "is-mutable",
@ -222,23 +222,23 @@ sp_profiler_menu_button_connect (SpProfilerMenuButton *self)
priv->notify_whole_system_handler =
g_signal_connect_object (priv->profiler,
"notify::whole-system",
G_CALLBACK (sp_profiler_menu_button_update_label),
G_CALLBACK (sysprof_profiler_menu_button_update_label),
self,
G_CONNECT_SWAPPED);
sp_profiler_menu_button_update_label (self);
sysprof_profiler_menu_button_update_label (self);
sp_profiler_menu_button_validate_spawn (self, priv->spawn_entry);
sp_profiler_menu_button_env_row_changed (self, NULL, NULL, NULL);
sysprof_profiler_menu_button_validate_spawn (self, priv->spawn_entry);
sysprof_profiler_menu_button_env_row_changed (self, NULL, NULL, NULL);
}
static void
sp_profiler_menu_button_disconnect (SpProfilerMenuButton *self)
sysprof_profiler_menu_button_disconnect (SysprofProfilerMenuButton *self)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SP_IS_PROFILER (priv->profiler));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER (priv->profiler));
clear_binding (&priv->mutable_binding);
clear_binding (&priv->whole_system_binding);
@ -259,45 +259,45 @@ sp_profiler_menu_button_disconnect (SpProfilerMenuButton *self)
clear_selected_flags,
NULL);
sp_profiler_menu_button_update_label (self);
sysprof_profiler_menu_button_update_label (self);
}
/**
* sp_profiler_menu_button_get_profiler:
* @self: An #SpProfilerMenuButton
* sysprof_profiler_menu_button_get_profiler:
* @self: An #SysprofProfilerMenuButton
*
* Gets the profiler instance that is being configured.
*
* Returns: (nullable) (transfer none): An #SpProfiler or %NULL.
* Returns: (nullable) (transfer none): An #SysprofProfiler or %NULL.
*/
SpProfiler *
sp_profiler_menu_button_get_profiler (SpProfilerMenuButton *self)
SysprofProfiler *
sysprof_profiler_menu_button_get_profiler (SysprofProfilerMenuButton *self)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_return_val_if_fail (SP_IS_PROFILER_MENU_BUTTON (self), NULL);
g_return_val_if_fail (SYSPROF_IS_PROFILER_MENU_BUTTON (self), NULL);
return priv->profiler;
}
void
sp_profiler_menu_button_set_profiler (SpProfilerMenuButton *self,
SpProfiler *profiler)
sysprof_profiler_menu_button_set_profiler (SysprofProfilerMenuButton *self,
SysprofProfiler *profiler)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_return_if_fail (SP_IS_PROFILER_MENU_BUTTON (self));
g_return_if_fail (!profiler || SP_IS_PROFILER (profiler));
g_return_if_fail (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_return_if_fail (!profiler || SYSPROF_IS_PROFILER (profiler));
if (priv->profiler != profiler)
{
if (priv->profiler != NULL)
sp_profiler_menu_button_disconnect (self);
sysprof_profiler_menu_button_disconnect (self);
if (profiler != NULL)
{
priv->profiler = g_object_ref (profiler);
sp_profiler_menu_button_connect (self);
sysprof_profiler_menu_button_connect (self);
}
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PROFILER]);
@ -305,75 +305,75 @@ sp_profiler_menu_button_set_profiler (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_row_activated (SpProfilerMenuButton *self,
SpProcessModelRow *row,
sysprof_profiler_menu_button_row_activated (SysprofProfilerMenuButton *self,
SysprofProcessModelRow *row,
GtkListBox *list_box)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
gboolean selected;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SP_IS_PROCESS_MODEL_ROW (row));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROCESS_MODEL_ROW (row));
g_assert (GTK_IS_LIST_BOX (list_box));
selected = !sp_process_model_row_get_selected (row);
sp_process_model_row_set_selected (row, selected);
selected = !sysprof_process_model_row_get_selected (row);
sysprof_process_model_row_set_selected (row, selected);
if (priv->profiler != NULL)
{
SpProcessModelItem *item = sp_process_model_row_get_item (row);
GPid pid = sp_process_model_item_get_pid (item);
SysprofProcessModelItem *item = sysprof_process_model_row_get_item (row);
GPid pid = sysprof_process_model_item_get_pid (item);
if (selected)
sp_profiler_add_pid (priv->profiler, pid);
sysprof_profiler_add_pid (priv->profiler, pid);
else
sp_profiler_remove_pid (priv->profiler, pid);
sysprof_profiler_remove_pid (priv->profiler, pid);
}
sp_profiler_menu_button_update_label (self);
sysprof_profiler_menu_button_update_label (self);
}
static GtkWidget *
sp_profiler_menu_button_create_row (gpointer itemptr,
sysprof_profiler_menu_button_create_row (gpointer itemptr,
gpointer user_data)
{
SpProcessModelItem *item = itemptr;
SysprofProcessModelItem *item = itemptr;
g_assert (SP_IS_PROCESS_MODEL_ITEM (item));
g_assert (SP_IS_PROFILER_MENU_BUTTON (user_data));
g_assert (SYSPROF_IS_PROCESS_MODEL_ITEM (item));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (user_data));
return g_object_new (SP_TYPE_PROCESS_MODEL_ROW,
return g_object_new (SYSPROF_TYPE_PROCESS_MODEL_ROW,
"item", item,
"visible", TRUE,
NULL);
}
static void
sp_profiler_menu_button_clicked (GtkButton *button)
sysprof_profiler_menu_button_clicked (GtkButton *button)
{
SpProfilerMenuButton *self = (SpProfilerMenuButton *)button;
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButton *self = (SysprofProfilerMenuButton *)button;
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
sp_process_model_queue_reload (priv->process_model);
sysprof_process_model_queue_reload (priv->process_model);
GTK_BUTTON_CLASS (sp_profiler_menu_button_parent_class)->clicked (button);
GTK_BUTTON_CLASS (sysprof_profiler_menu_button_parent_class)->clicked (button);
}
static gboolean
sp_profiler_menu_button_filter_func (GObject *object,
sysprof_profiler_menu_button_filter_func (GObject *object,
gpointer user_data)
{
const gchar *needle = user_data;
const gchar *haystack;
g_assert (SP_IS_PROCESS_MODEL_ITEM (object));
g_assert (SYSPROF_IS_PROCESS_MODEL_ITEM (object));
if (needle == NULL)
return TRUE;
haystack = sp_process_model_item_get_command_line (SP_PROCESS_MODEL_ITEM (object));
haystack = sysprof_process_model_item_get_command_line (SYSPROF_PROCESS_MODEL_ITEM (object));
if (haystack == NULL)
return FALSE;
@ -382,52 +382,52 @@ sp_profiler_menu_button_filter_func (GObject *object,
}
static void
sp_profiler_menu_button_filter_changed (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_filter_changed (SysprofProfilerMenuButton *self,
GtkEntry *entry)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
const gchar *text;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (GTK_IS_ENTRY (entry));
text = gtk_entry_get_text (entry);
if (text && *text == 0)
text = NULL;
sp_model_filter_set_filter_func (priv->process_filter,
sp_profiler_menu_button_filter_func,
sysprof_model_filter_set_filter_func (priv->process_filter,
sysprof_profiler_menu_button_filter_func,
g_strdup (text),
g_free);
}
static void
sp_profiler_menu_button_constructed (GObject *object)
sysprof_profiler_menu_button_constructed (GObject *object)
{
SpProfilerMenuButton *self = (SpProfilerMenuButton *)object;
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButton *self = (SysprofProfilerMenuButton *)object;
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
priv->process_filter = sp_model_filter_new (G_LIST_MODEL (priv->process_model));
priv->process_filter = sysprof_model_filter_new (G_LIST_MODEL (priv->process_model));
gtk_list_box_bind_model (priv->process_list_box,
G_LIST_MODEL (priv->process_filter),
sp_profiler_menu_button_create_row,
sysprof_profiler_menu_button_create_row,
self, NULL);
G_OBJECT_CLASS (sp_profiler_menu_button_parent_class)->constructed (object);
G_OBJECT_CLASS (sysprof_profiler_menu_button_parent_class)->constructed (object);
}
static void
sp_profiler_menu_button_realize (GtkWidget *widget)
sysprof_profiler_menu_button_realize (GtkWidget *widget)
{
SpProfilerMenuButton *self = (SpProfilerMenuButton *)widget;
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButton *self = (SysprofProfilerMenuButton *)widget;
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_autoptr(GSettings) settings = NULL;
g_auto(GStrv) env = NULL;
GTK_WIDGET_CLASS (sp_profiler_menu_button_parent_class)->realize (widget);
GTK_WIDGET_CLASS (sysprof_profiler_menu_button_parent_class)->realize (widget);
settings = g_settings_new ("org.gnome.sysprof2");
@ -475,13 +475,13 @@ sp_profiler_menu_button_realize (GtkWidget *widget)
static gboolean
save_environ_to_gsettings (gpointer data)
{
SpProfilerMenuButton *self = data;
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButton *self = data;
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_autoptr(GPtrArray) ar = NULL;
g_autoptr(GSettings) settings = NULL;
GtkTreeIter iter;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
priv->save_env_source = 0;
@ -521,14 +521,14 @@ save_environ_to_gsettings (gpointer data)
static void
sp_profiler_menu_button_destroy (GtkWidget *widget)
sysprof_profiler_menu_button_destroy (GtkWidget *widget)
{
SpProfilerMenuButton *self = (SpProfilerMenuButton *)widget;
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButton *self = (SysprofProfilerMenuButton *)widget;
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
if (priv->profiler != NULL)
{
sp_profiler_menu_button_disconnect (self);
sysprof_profiler_menu_button_disconnect (self);
g_clear_object (&priv->profiler);
}
@ -540,21 +540,21 @@ sp_profiler_menu_button_destroy (GtkWidget *widget)
priv->save_env_source = 0;
}
GTK_WIDGET_CLASS (sp_profiler_menu_button_parent_class)->destroy (widget);
GTK_WIDGET_CLASS (sysprof_profiler_menu_button_parent_class)->destroy (widget);
}
static void
sp_profiler_menu_button_get_property (GObject *object,
sysprof_profiler_menu_button_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpProfilerMenuButton *self = SP_PROFILER_MENU_BUTTON (object);
SysprofProfilerMenuButton *self = SYSPROF_PROFILER_MENU_BUTTON (object);
switch (prop_id)
{
case PROP_PROFILER:
g_value_set_object (value, sp_profiler_menu_button_get_profiler (self));
g_value_set_object (value, sysprof_profiler_menu_button_get_profiler (self));
break;
default:
@ -563,17 +563,17 @@ sp_profiler_menu_button_get_property (GObject *object,
}
static void
sp_profiler_menu_button_set_property (GObject *object,
sysprof_profiler_menu_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpProfilerMenuButton *self = SP_PROFILER_MENU_BUTTON (object);
SysprofProfilerMenuButton *self = SYSPROF_PROFILER_MENU_BUTTON (object);
switch (prop_id)
{
case PROP_PROFILER:
sp_profiler_menu_button_set_profiler (self, g_value_get_object (value));
sysprof_profiler_menu_button_set_profiler (self, g_value_get_object (value));
break;
default:
@ -582,61 +582,61 @@ sp_profiler_menu_button_set_property (GObject *object,
}
static void
sp_profiler_menu_button_class_init (SpProfilerMenuButtonClass *klass)
sysprof_profiler_menu_button_class_init (SysprofProfilerMenuButtonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
object_class->constructed = sp_profiler_menu_button_constructed;
object_class->get_property = sp_profiler_menu_button_get_property;
object_class->set_property = sp_profiler_menu_button_set_property;
object_class->constructed = sysprof_profiler_menu_button_constructed;
object_class->get_property = sysprof_profiler_menu_button_get_property;
object_class->set_property = sysprof_profiler_menu_button_set_property;
widget_class->destroy = sp_profiler_menu_button_destroy;
widget_class->realize = sp_profiler_menu_button_realize;
widget_class->destroy = sysprof_profiler_menu_button_destroy;
widget_class->realize = sysprof_profiler_menu_button_realize;
button_class->clicked = sp_profiler_menu_button_clicked;
button_class->clicked = sysprof_profiler_menu_button_clicked;
properties [PROP_PROFILER] =
g_param_spec_object ("profiler",
"Profiler",
"Profiler",
SP_TYPE_PROFILER,
SYSPROF_TYPE_PROFILER,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sp-profiler-menu-button.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, env_key_column);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, env_tree_view);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, env_value_column);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, environment_model);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, inherit_environ);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, key_cell);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, label);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, popover);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, process_filter_entry);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, process_list_box);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, process_model);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, processes_box);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, spawn_entry);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, stack);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, value_cell);
gtk_widget_class_bind_template_child_private (widget_class, SpProfilerMenuButton, whole_system_switch);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-profiler-menu-button.ui");
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, env_key_column);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, env_tree_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, env_value_column);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, environment_model);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, inherit_environ);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, key_cell);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, label);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, popover);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, process_filter_entry);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, process_list_box);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, process_model);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, processes_box);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, spawn_entry);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, stack);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, value_cell);
gtk_widget_class_bind_template_child_private (widget_class, SysprofProfilerMenuButton, whole_system_switch);
}
static void
sp_profiler_menu_button_env_row_changed (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_env_row_changed (SysprofProfilerMenuButton *self,
GtkTreePath *tree_path,
GtkTreeIter *tree_iter,
gpointer user_data)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_autoptr(GPtrArray) env = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (GTK_IS_TREE_MODEL (priv->environment_model));
/* queue saving settings to gsettings */
@ -673,14 +673,14 @@ sp_profiler_menu_button_env_row_changed (SpProfilerMenuButton *self,
while (gtk_tree_model_iter_next (model, &iter));
}
g_ptr_array_add (env, NULL);
sp_profiler_set_spawn_env (priv->profiler, (const gchar * const *)env->pdata);
sysprof_profiler_set_spawn_env (priv->profiler, (const gchar * const *)env->pdata);
}
static void
on_backspace (SpProfilerMenuButton *self,
on_backspace (SysprofProfilerMenuButton *self,
GtkEntry *entry)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
if (g_object_get_data (G_OBJECT (entry), "CELL_WAS_EMPTY"))
{
@ -703,7 +703,7 @@ on_backspace (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_env_key_editing_started (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_env_key_editing_started (SysprofProfilerMenuButton *self,
GtkCellEditable *editable,
const gchar *path,
GtkCellRenderer *cell)
@ -716,17 +716,17 @@ sp_profiler_menu_button_env_key_editing_started (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_env_key_edited (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_env_key_edited (SysprofProfilerMenuButton *self,
const gchar *path,
const gchar *new_text,
GtkCellRendererText *cell)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
GtkTreeModel *model;
GtkTreePath *tree_path;
GtkTreeIter iter;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (path != NULL);
g_assert (new_text != NULL);
g_assert (GTK_IS_CELL_RENDERER_TEXT (cell));
@ -755,18 +755,18 @@ sp_profiler_menu_button_env_key_edited (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_env_value_edited (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_env_value_edited (SysprofProfilerMenuButton *self,
const gchar *path,
const gchar *new_text,
GtkCellRendererText *cell)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
GtkTreeModel *model;
GtkTreePath *tree_path;
GtkTreeIter iter;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (path != NULL);
g_assert (new_text != NULL);
g_assert (GTK_IS_CELL_RENDERER_TEXT (cell));
@ -797,23 +797,23 @@ sp_profiler_menu_button_env_value_edited (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_validate_spawn (SpProfilerMenuButton *self,
sysprof_profiler_menu_button_validate_spawn (SysprofProfilerMenuButton *self,
GtkEntry *entry)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
g_auto(GStrv) argv = NULL;
g_autoptr(GError) error = NULL;
const gchar *text;
gint argc;
g_assert (SP_IS_PROFILER_MENU_BUTTON (self));
g_assert (SYSPROF_IS_PROFILER_MENU_BUTTON (self));
g_assert (GTK_IS_ENTRY (entry));
text = gtk_entry_get_text (entry);
if (text && *text && !g_shell_parse_argv (text, &argc, &argv, &error))
{
sp_profiler_set_spawn_argv (priv->profiler, NULL);
sysprof_profiler_set_spawn_argv (priv->profiler, NULL);
g_object_set (entry,
"secondary-icon-name", "dialog-warning-symbolic",
"secondary-icon-tooltip-text", _("The command line arguments provided are invalid"),
@ -821,7 +821,7 @@ sp_profiler_menu_button_validate_spawn (SpProfilerMenuButton *self,
}
else
{
sp_profiler_set_spawn_argv (priv->profiler, (const gchar * const *)argv);
sysprof_profiler_set_spawn_argv (priv->profiler, (const gchar * const *)argv);
g_object_set (entry,
"secondary-icon-name", NULL,
"secondary-icon-tooltip-text", NULL,
@ -830,63 +830,63 @@ sp_profiler_menu_button_validate_spawn (SpProfilerMenuButton *self,
}
static void
sp_profiler_menu_button_init (SpProfilerMenuButton *self)
sysprof_profiler_menu_button_init (SysprofProfilerMenuButton *self)
{
SpProfilerMenuButtonPrivate *priv = sp_profiler_menu_button_get_instance_private (self);
SysprofProfilerMenuButtonPrivate *priv = sysprof_profiler_menu_button_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (priv->process_filter_entry,
"changed",
G_CALLBACK (sp_profiler_menu_button_filter_changed),
G_CALLBACK (sysprof_profiler_menu_button_filter_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->spawn_entry,
"changed",
G_CALLBACK (sp_profiler_menu_button_update_label),
G_CALLBACK (sysprof_profiler_menu_button_update_label),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->spawn_entry,
"changed",
G_CALLBACK (sp_profiler_menu_button_validate_spawn),
G_CALLBACK (sysprof_profiler_menu_button_validate_spawn),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->stack,
"notify::visible-child",
G_CALLBACK (sp_profiler_menu_button_update_label),
G_CALLBACK (sysprof_profiler_menu_button_update_label),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->process_list_box,
"row-activated",
G_CALLBACK (sp_profiler_menu_button_row_activated),
G_CALLBACK (sysprof_profiler_menu_button_row_activated),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->key_cell,
"edited",
G_CALLBACK (sp_profiler_menu_button_env_key_edited),
G_CALLBACK (sysprof_profiler_menu_button_env_key_edited),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->value_cell,
"edited",
G_CALLBACK (sp_profiler_menu_button_env_value_edited),
G_CALLBACK (sysprof_profiler_menu_button_env_value_edited),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (gtk_tree_view_get_model (priv->env_tree_view),
"row-changed",
G_CALLBACK (sp_profiler_menu_button_env_row_changed),
G_CALLBACK (sysprof_profiler_menu_button_env_row_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->key_cell,
"editing-started",
G_CALLBACK (sp_profiler_menu_button_env_key_editing_started),
G_CALLBACK (sysprof_profiler_menu_button_env_key_editing_started),
self,
G_CONNECT_SWAPPED);

View File

@ -1,4 +1,4 @@
/* sp-profiler-menu-button.h
/* sysprof-profiler-menu-button.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,17 +22,17 @@
#include <gtk/gtk.h>
#include "sp-profiler.h"
#include "sysprof-profiler.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_PROFILER_MENU_BUTTON (sp_profiler_menu_button_get_type())
#define SYSPROF_TYPE_PROFILER_MENU_BUTTON (sysprof_profiler_menu_button_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpProfilerMenuButton, sp_profiler_menu_button, SP, PROFILER_MENU_BUTTON, GtkMenuButton)
G_DECLARE_DERIVABLE_TYPE (SysprofProfilerMenuButton, sysprof_profiler_menu_button, SYSPROF, PROFILER_MENU_BUTTON, GtkMenuButton)
struct _SpProfilerMenuButtonClass
struct _SysprofProfilerMenuButtonClass
{
GtkMenuButtonClass parent_class;
@ -40,11 +40,11 @@ struct _SpProfilerMenuButtonClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_profiler_menu_button_new (void);
GtkWidget *sysprof_profiler_menu_button_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_menu_button_set_profiler (SpProfilerMenuButton *self,
SpProfiler *profiler);
void sysprof_profiler_menu_button_set_profiler (SysprofProfilerMenuButton *self,
SysprofProfiler *profiler);
SYSPROF_AVAILABLE_IN_ALL
SpProfiler *sp_profiler_menu_button_get_profiler (SpProfilerMenuButton *self);
SysprofProfiler *sysprof_profiler_menu_button_get_profiler (SysprofProfilerMenuButton *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-recording-state-view.c
/* sysprof-recording-state-view.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,16 +20,16 @@
#include "config.h"
#include "sp-recording-state-view.h"
#include "sysprof-recording-state-view.h"
typedef struct
{
SpProfiler *profiler;
SysprofProfiler *profiler;
gulong notify_elapsed_handler;
GtkLabel *elapsed;
} SpRecordingStateViewPrivate;
} SysprofRecordingStateViewPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SpRecordingStateView, sp_recording_state_view, GTK_TYPE_BIN)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofRecordingStateView, sysprof_recording_state_view, GTK_TYPE_BIN)
enum {
PROP_0,
@ -40,27 +40,27 @@ enum {
static GParamSpec *properties [N_PROPS];
GtkWidget *
sp_recording_state_view_new (void)
sysprof_recording_state_view_new (void)
{
return g_object_new (SP_TYPE_RECORDING_STATE_VIEW, NULL);
return g_object_new (SYSPROF_TYPE_RECORDING_STATE_VIEW, NULL);
}
static void
sp_recording_state_view_notify_elapsed (SpRecordingStateView *self,
sysprof_recording_state_view_notify_elapsed (SysprofRecordingStateView *self,
GParamSpec *pspec,
SpProfiler *profiler)
SysprofProfiler *profiler)
{
SpRecordingStateViewPrivate *priv = sp_recording_state_view_get_instance_private (self);
SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
g_autofree gchar *str = NULL;
gint64 elapsed;
guint hours;
guint minutes;
guint seconds;
g_assert (SP_IS_RECORDING_STATE_VIEW (self));
g_assert (SP_IS_PROFILER (profiler));
g_assert (SYSPROF_IS_RECORDING_STATE_VIEW (self));
g_assert (SYSPROF_IS_PROFILER (profiler));
elapsed = (gint64)sp_profiler_get_elapsed (profiler);
elapsed = (gint64)sysprof_profiler_get_elapsed (profiler);
hours = elapsed / (60 * 60);
if (hours > 0)
@ -78,10 +78,10 @@ sp_recording_state_view_notify_elapsed (SpRecordingStateView *self,
}
static void
sp_recording_state_view_destroy (GtkWidget *widget)
sysprof_recording_state_view_destroy (GtkWidget *widget)
{
SpRecordingStateView *self = (SpRecordingStateView *)widget;
SpRecordingStateViewPrivate *priv = sp_recording_state_view_get_instance_private (self);
SysprofRecordingStateView *self = (SysprofRecordingStateView *)widget;
SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
if (priv->profiler != NULL)
{
@ -89,17 +89,17 @@ sp_recording_state_view_destroy (GtkWidget *widget)
g_clear_object (&priv->profiler);
}
GTK_WIDGET_CLASS (sp_recording_state_view_parent_class)->destroy (widget);
GTK_WIDGET_CLASS (sysprof_recording_state_view_parent_class)->destroy (widget);
}
static void
sp_recording_state_view_get_property (GObject *object,
sysprof_recording_state_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpRecordingStateView *self = SP_RECORDING_STATE_VIEW (object);
SpRecordingStateViewPrivate *priv = sp_recording_state_view_get_instance_private (self);
SysprofRecordingStateView *self = SYSPROF_RECORDING_STATE_VIEW (object);
SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
switch (prop_id)
{
@ -113,17 +113,17 @@ sp_recording_state_view_get_property (GObject *object,
}
static void
sp_recording_state_view_set_property (GObject *object,
sysprof_recording_state_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpRecordingStateView *self = SP_RECORDING_STATE_VIEW (object);
SysprofRecordingStateView *self = SYSPROF_RECORDING_STATE_VIEW (object);
switch (prop_id)
{
case PROP_PROFILER:
sp_recording_state_view_set_profiler (self, g_value_get_object (value));
sysprof_recording_state_view_set_profiler (self, g_value_get_object (value));
break;
default:
@ -132,44 +132,44 @@ sp_recording_state_view_set_property (GObject *object,
}
static void
sp_recording_state_view_class_init (SpRecordingStateViewClass *klass)
sysprof_recording_state_view_class_init (SysprofRecordingStateViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = sp_recording_state_view_get_property;
object_class->set_property = sp_recording_state_view_set_property;
object_class->get_property = sysprof_recording_state_view_get_property;
object_class->set_property = sysprof_recording_state_view_set_property;
widget_class->destroy = sp_recording_state_view_destroy;
widget_class->destroy = sysprof_recording_state_view_destroy;
properties [PROP_PROFILER] =
g_param_spec_object ("profiler",
"Profiler",
"Profiler",
SP_TYPE_PROFILER,
SYSPROF_TYPE_PROFILER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/sysprof/ui/sp-recording-state-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpRecordingStateView, elapsed);
"/org/gnome/sysprof/ui/sysprof-recording-state-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SysprofRecordingStateView, elapsed);
}
static void
sp_recording_state_view_init (SpRecordingStateView *self)
sysprof_recording_state_view_init (SysprofRecordingStateView *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
void
sp_recording_state_view_set_profiler (SpRecordingStateView *self,
SpProfiler *profiler)
sysprof_recording_state_view_set_profiler (SysprofRecordingStateView *self,
SysprofProfiler *profiler)
{
SpRecordingStateViewPrivate *priv = sp_recording_state_view_get_instance_private (self);
SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
g_assert (SP_IS_RECORDING_STATE_VIEW (self));
g_assert (!profiler || SP_IS_PROFILER (profiler));
g_assert (SYSPROF_IS_RECORDING_STATE_VIEW (self));
g_assert (!profiler || SYSPROF_IS_PROFILER (profiler));
gtk_label_set_label (priv->elapsed, "00:00");
@ -189,7 +189,7 @@ sp_recording_state_view_set_profiler (SpRecordingStateView *self,
priv->notify_elapsed_handler =
g_signal_connect_object (profiler,
"notify::elapsed",
G_CALLBACK (sp_recording_state_view_notify_elapsed),
G_CALLBACK (sysprof_recording_state_view_notify_elapsed),
self,
G_CONNECT_SWAPPED);
}

View File

@ -1,4 +1,4 @@
/* sp-recording-state-view.h
/* sysprof-recording-state-view.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,17 +22,17 @@
#include <gtk/gtk.h>
#include "sp-profiler.h"
#include "sysprof-profiler.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_RECORDING_STATE_VIEW (sp_recording_state_view_get_type())
#define SYSPROF_TYPE_RECORDING_STATE_VIEW (sysprof_recording_state_view_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpRecordingStateView, sp_recording_state_view, SP, RECORDING_STATE_VIEW, GtkBin)
G_DECLARE_DERIVABLE_TYPE (SysprofRecordingStateView, sysprof_recording_state_view, SYSPROF, RECORDING_STATE_VIEW, GtkBin)
struct _SpRecordingStateViewClass
struct _SysprofRecordingStateViewClass
{
GtkBinClass parent;
@ -40,9 +40,9 @@ struct _SpRecordingStateViewClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_recording_state_view_new (void);
GtkWidget *sysprof_recording_state_view_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sp_recording_state_view_set_profiler (SpRecordingStateView *self,
SpProfiler *profiler);
void sysprof_recording_state_view_set_profiler (SysprofRecordingStateView *self,
SysprofProfiler *profiler);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-theme-manager.c
/* sysprof-theme-manager.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,13 +18,13 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-theme-manager"
#define G_LOG_DOMAIN "sysprof-theme-manager"
#include "config.h"
#include "sp-theme-manager.h"
#include "sysprof-theme-manager.h"
struct _SpThemeManager
struct _SysprofThemeManager
{
GObject parent_instance;
GHashTable *theme_resources;
@ -42,7 +42,7 @@ typedef struct
GtkCssProvider *provider;
} ThemeResource;
G_DEFINE_TYPE (SpThemeManager, sp_theme_manager, G_TYPE_OBJECT)
G_DEFINE_TYPE (SysprofThemeManager, sysprof_theme_manager, G_TYPE_OBJECT)
static void
theme_resource_free (gpointer data)
@ -98,14 +98,14 @@ theme_resource_matches (ThemeResource *theme_resource,
}
static gboolean
sp_theme_manager_do_reload (gpointer data)
sysprof_theme_manager_do_reload (gpointer data)
{
SpThemeManager *self = data;
SysprofThemeManager *self = data;
ThemeResource *theme_resource;
GHashTableIter iter;
GtkSettings *settings;
g_assert (SP_IS_THEME_MANAGER (self));
g_assert (SYSPROF_IS_THEME_MANAGER (self));
self->reload_source = 0;
@ -141,21 +141,21 @@ sp_theme_manager_do_reload (gpointer data)
}
static void
sp_theme_manager_queue_reload (SpThemeManager *self)
sysprof_theme_manager_queue_reload (SysprofThemeManager *self)
{
g_assert (SP_IS_THEME_MANAGER (self));
g_assert (SYSPROF_IS_THEME_MANAGER (self));
if (self->reload_source == 0)
self->reload_source = gdk_threads_add_idle_full (G_PRIORITY_LOW,
sp_theme_manager_do_reload,
sysprof_theme_manager_do_reload,
self,
NULL);
}
static void
sp_theme_manager_finalize (GObject *object)
sysprof_theme_manager_finalize (GObject *object)
{
SpThemeManager *self = (SpThemeManager *)object;
SysprofThemeManager *self = (SysprofThemeManager *)object;
if (self->reload_source != 0)
{
@ -165,19 +165,19 @@ sp_theme_manager_finalize (GObject *object)
g_clear_pointer (&self->theme_resources, g_hash_table_unref);
G_OBJECT_CLASS (sp_theme_manager_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_theme_manager_parent_class)->finalize (object);
}
static void
sp_theme_manager_class_init (SpThemeManagerClass *klass)
sysprof_theme_manager_class_init (SysprofThemeManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_theme_manager_finalize;
object_class->finalize = sysprof_theme_manager_finalize;
}
static void
sp_theme_manager_init (SpThemeManager *self)
sysprof_theme_manager_init (SysprofThemeManager *self)
{
self->theme_resources = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, theme_resource_free);
@ -185,23 +185,23 @@ sp_theme_manager_init (SpThemeManager *self)
}
/**
* sp_theme_manager_get_default:
* sysprof_theme_manager_get_default:
*
* Returns: (transfer none): An #SpThemeManager
* Returns: (transfer none): An #SysprofThemeManager
*/
SpThemeManager *
sp_theme_manager_get_default (void)
SysprofThemeManager *
sysprof_theme_manager_get_default (void)
{
static SpThemeManager *instance;
static SysprofThemeManager *instance;
if (instance == NULL)
instance = g_object_new (SP_TYPE_THEME_MANAGER, NULL);
instance = g_object_new (SYSPROF_TYPE_THEME_MANAGER, NULL);
return instance;
}
guint
sp_theme_manager_register_resource (SpThemeManager *self,
sysprof_theme_manager_register_resource (SysprofThemeManager *self,
const gchar *theme_name,
const gchar *variant,
const gchar *resource)
@ -210,7 +210,7 @@ sp_theme_manager_register_resource (SpThemeManager *self,
static guint counter;
guint id;
g_return_val_if_fail (SP_IS_THEME_MANAGER (self), 0);
g_return_val_if_fail (SYSPROF_IS_THEME_MANAGER (self), 0);
theme_resource = g_slice_new0 (ThemeResource);
theme_resource->id = id = ++counter;
@ -230,29 +230,29 @@ sp_theme_manager_register_resource (SpThemeManager *self,
self->registered_signals = TRUE;
g_signal_connect_object (gtk_settings_get_default (),
"notify::gtk-application-prefer-dark-theme",
G_CALLBACK (sp_theme_manager_queue_reload),
G_CALLBACK (sysprof_theme_manager_queue_reload),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (gtk_settings_get_default (),
"notify::gtk-theme-name",
G_CALLBACK (sp_theme_manager_queue_reload),
G_CALLBACK (sysprof_theme_manager_queue_reload),
self,
G_CONNECT_SWAPPED);
}
sp_theme_manager_queue_reload (self);
sysprof_theme_manager_queue_reload (self);
return id;
}
void
sp_theme_manager_unregister (SpThemeManager *self,
sysprof_theme_manager_unregister (SysprofThemeManager *self,
guint registration_id)
{
GHashTableIter iter;
ThemeResource *theme_resource;
g_return_if_fail (SP_IS_THEME_MANAGER (self));
g_return_if_fail (SYSPROF_IS_THEME_MANAGER (self));
g_hash_table_iter_init (&iter, self->theme_resources);

View File

@ -1,4 +1,4 @@
/* sp-theme-manager.h
/* sysprof-theme-manager.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -24,18 +24,18 @@
G_BEGIN_DECLS
#define SP_TYPE_THEME_MANAGER (sp_theme_manager_get_type())
#define SYSPROF_TYPE_THEME_MANAGER (sysprof_theme_manager_get_type())
G_GNUC_INTERNAL
G_DECLARE_FINAL_TYPE (SpThemeManager, sp_theme_manager, SP, THEME_MANAGER, GObject)
G_DECLARE_FINAL_TYPE (SysprofThemeManager, sysprof_theme_manager, SYSPROF, THEME_MANAGER, GObject)
G_GNUC_INTERNAL
SpThemeManager *sp_theme_manager_get_default (void);
SysprofThemeManager *sysprof_theme_manager_get_default (void);
G_GNUC_INTERNAL
void sp_theme_manager_unregister (SpThemeManager *self,
void sysprof_theme_manager_unregister (SysprofThemeManager *self,
guint registration_id);
G_GNUC_INTERNAL
guint sp_theme_manager_register_resource (SpThemeManager *self,
guint sysprof_theme_manager_register_resource (SysprofThemeManager *self,
const gchar *theme_name,
const gchar *variant,
const gchar *resource);

View File

@ -26,22 +26,22 @@ G_BEGIN_DECLS
#define SYSPROF_UI_INSIDE
# include "sp-callgraph-view.h"
# include "sp-cell-renderer-percent.h"
# include "sp-cpu-visualizer-row.h"
# include "sp-failed-state-view.h"
# include "sp-line-visualizer-row.h"
# include "sp-empty-state-view.h"
# include "sp-model-filter.h"
# include "sp-multi-paned.h"
# include "sp-recording-state-view.h"
# include "sp-process-model.h"
# include "sp-process-model-item.h"
# include "sp-process-model-row.h"
# include "sp-profiler-menu-button.h"
# include "sp-visualizer-row.h"
# include "sp-visualizer-view.h"
# include "sp-zoom-manager.h"
# include "sysprof-callgraph-view.h"
# include "sysprof-cell-renderer-percent.h"
# include "sysprof-cpu-visualizer-row.h"
# include "sysprof-failed-state-view.h"
# include "sysprof-line-visualizer-row.h"
# include "sysprof-empty-state-view.h"
# include "sysprof-model-filter.h"
# include "sysprof-multi-paned.h"
# include "sysprof-recording-state-view.h"
# include "sysprof-process-model.h"
# include "sysprof-process-model-item.h"
# include "sysprof-process-model-row.h"
# include "sysprof-profiler-menu-button.h"
# include "sysprof-visualizer-row.h"
# include "sysprof-visualizer-view.h"
# include "sysprof-zoom-manager.h"
#undef SYSPROF_UI_INSIDE

View File

@ -1,4 +1,4 @@
/* sp-visualizer-list.c
/* sysprof-visualizer-list.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,33 +18,33 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-visualizer-list"
#define G_LOG_DOMAIN "sysprof-visualizer-list"
#include "config.h"
#include <glib/gi18n.h>
#include <sysprof.h>
#include "sp-cpu-visualizer-row.h"
#include "sp-visualizer-list.h"
#include "sp-visualizer-row.h"
#include "sp-mark-visualizer-row.h"
#include "sp-zoom-manager.h"
#include "sysprof-cpu-visualizer-row.h"
#include "sysprof-visualizer-list.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-mark-visualizer-row.h"
#include "sysprof-zoom-manager.h"
#define NSEC_PER_SEC G_GUINT64_CONSTANT(1000000000)
#define DEFAULT_PIXELS_PER_SECOND 20
typedef struct
{
SpCaptureReader *reader;
SpZoomManager *zoom_manager;
SysprofCaptureReader *reader;
SysprofZoomManager *zoom_manager;
gint64 begin_time;
gint64 end_time;
} SpVisualizerListPrivate;
} SysprofVisualizerListPrivate;
typedef struct
{
SpCaptureCursor *cursor;
SysprofCaptureCursor *cursor;
GHashTable *mark_groups;
guint fps_counter;
GArray *memory;
@ -58,7 +58,7 @@ enum {
N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE (SpVisualizerList, sp_visualizer_list, GTK_TYPE_LIST_BOX)
G_DEFINE_TYPE_WITH_PRIVATE (SysprofVisualizerList, sysprof_visualizer_list, GTK_TYPE_LIST_BOX)
static GParamSpec *properties [N_PROPS];
@ -67,53 +67,53 @@ discovery_free (Discovery *state)
{
g_clear_pointer (&state->mark_groups, g_hash_table_unref);
g_clear_pointer (&state->memory, g_array_unref);
g_clear_pointer (&state->cursor, sp_capture_cursor_unref);
g_clear_pointer (&state->cursor, sysprof_capture_cursor_unref);
g_slice_free (Discovery, state);
}
static void
sp_visualizer_list_add (GtkContainer *container,
sysprof_visualizer_list_add (GtkContainer *container,
GtkWidget *widget)
{
SpVisualizerList *self = (SpVisualizerList *)container;
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerList *self = (SysprofVisualizerList *)container;
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
GTK_CONTAINER_CLASS (sp_visualizer_list_parent_class)->add (container, widget);
GTK_CONTAINER_CLASS (sysprof_visualizer_list_parent_class)->add (container, widget);
if (SP_IS_VISUALIZER_ROW (widget))
if (SYSPROF_IS_VISUALIZER_ROW (widget))
{
sp_visualizer_row_set_reader (SP_VISUALIZER_ROW (widget), priv->reader);
sp_visualizer_row_set_zoom_manager (SP_VISUALIZER_ROW (widget), priv->zoom_manager);
sysprof_visualizer_row_set_reader (SYSPROF_VISUALIZER_ROW (widget), priv->reader);
sysprof_visualizer_row_set_zoom_manager (SYSPROF_VISUALIZER_ROW (widget), priv->zoom_manager);
}
}
static void
sp_visualizer_list_finalize (GObject *object)
sysprof_visualizer_list_finalize (GObject *object)
{
SpVisualizerList *self = (SpVisualizerList *)object;
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerList *self = (SysprofVisualizerList *)object;
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
G_OBJECT_CLASS (sp_visualizer_list_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_visualizer_list_parent_class)->finalize (object);
}
static void
sp_visualizer_list_get_property (GObject *object,
sysprof_visualizer_list_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpVisualizerList *self = SP_VISUALIZER_LIST (object);
SysprofVisualizerList *self = SYSPROF_VISUALIZER_LIST (object);
switch (prop_id)
{
case PROP_READER:
g_value_set_boxed (value, sp_visualizer_list_get_reader (self));
g_value_set_boxed (value, sysprof_visualizer_list_get_reader (self));
break;
case PROP_ZOOM_MANAGER:
g_value_set_object (value, sp_visualizer_list_get_zoom_manager (self));
g_value_set_object (value, sysprof_visualizer_list_get_zoom_manager (self));
break;
default:
@ -122,21 +122,21 @@ sp_visualizer_list_get_property (GObject *object,
}
static void
sp_visualizer_list_set_property (GObject *object,
sysprof_visualizer_list_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpVisualizerList *self = SP_VISUALIZER_LIST (object);
SysprofVisualizerList *self = SYSPROF_VISUALIZER_LIST (object);
switch (prop_id)
{
case PROP_READER:
sp_visualizer_list_set_reader (self, g_value_get_boxed (value));
sysprof_visualizer_list_set_reader (self, g_value_get_boxed (value));
break;
case PROP_ZOOM_MANAGER:
sp_visualizer_list_set_zoom_manager (self, g_value_get_object (value));
sysprof_visualizer_list_set_zoom_manager (self, g_value_get_object (value));
break;
default:
@ -145,64 +145,64 @@ sp_visualizer_list_set_property (GObject *object,
}
static void
sp_visualizer_list_class_init (SpVisualizerListClass *klass)
sysprof_visualizer_list_class_init (SysprofVisualizerListClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->finalize = sp_visualizer_list_finalize;
object_class->get_property = sp_visualizer_list_get_property;
object_class->set_property = sp_visualizer_list_set_property;
object_class->finalize = sysprof_visualizer_list_finalize;
object_class->get_property = sysprof_visualizer_list_get_property;
object_class->set_property = sysprof_visualizer_list_set_property;
container_class->add = sp_visualizer_list_add;
container_class->add = sysprof_visualizer_list_add;
properties [PROP_READER] =
g_param_spec_boxed ("reader",
"Reader",
"The capture reader",
SP_TYPE_CAPTURE_READER,
SYSPROF_TYPE_CAPTURE_READER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_ZOOM_MANAGER] =
g_param_spec_object ("zoom-manager",
"Zoom Manager",
"The zoom manager",
SP_TYPE_ZOOM_MANAGER,
SYSPROF_TYPE_ZOOM_MANAGER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
sp_visualizer_list_init (SpVisualizerList *self)
sysprof_visualizer_list_init (SysprofVisualizerList *self)
{
}
GtkWidget *
sp_visualizer_list_new (void)
sysprof_visualizer_list_new (void)
{
return g_object_new (SP_TYPE_VISUALIZER_ROW, NULL);
return g_object_new (SYSPROF_TYPE_VISUALIZER_ROW, NULL);
}
/**
* sp_visualizer_list_get_reader:
* sysprof_visualizer_list_get_reader:
*
* Gets the reader that is being used for the #SpVisualizerList.
* Gets the reader that is being used for the #SysprofVisualizerList.
*
* Returns: (transfer none): An #SpCaptureReader
* Returns: (transfer none): An #SysprofCaptureReader
*/
SpCaptureReader *
sp_visualizer_list_get_reader (SpVisualizerList *self)
SysprofCaptureReader *
sysprof_visualizer_list_get_reader (SysprofVisualizerList *self)
{
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_LIST (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_LIST (self), NULL);
return priv->reader;
}
static gboolean
discover_new_rows_frame_cb (const SpCaptureFrame *frame,
discover_new_rows_frame_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
Discovery *state = user_data;
@ -218,21 +218,21 @@ discover_new_rows_frame_cb (const SpCaptureFrame *frame,
* and widget views to be displayed.
*/
if (frame->type == SP_CAPTURE_FRAME_MARK)
if (frame->type == SYSPROF_CAPTURE_FRAME_MARK)
{
const SpCaptureMark *mark = (const SpCaptureMark *)frame;
const SysprofCaptureMark *mark = (const SysprofCaptureMark *)frame;
if (!g_hash_table_contains (state->mark_groups, mark->group))
g_hash_table_add (state->mark_groups, g_strdup (mark->group));
}
if (frame->type == SP_CAPTURE_FRAME_CTRDEF)
if (frame->type == SYSPROF_CAPTURE_FRAME_CTRDEF)
{
const SpCaptureFrameCounterDefine *def = (const SpCaptureFrameCounterDefine *)frame;
const SysprofCaptureFrameCounterDefine *def = (const SysprofCaptureFrameCounterDefine *)frame;
for (guint i = 0; i < def->n_counters; i++)
{
const SpCaptureCounter *ctr = &def->counters[i];
const SysprofCaptureCounter *ctr = &def->counters[i];
if (!state->has_cpu &&
strstr (ctr->category, "CPU Percent") != NULL)
@ -263,7 +263,7 @@ discover_new_rows_worker (GTask *task,
g_assert (state != NULL);
g_assert (state->cursor != NULL);
sp_capture_cursor_foreach (state->cursor, discover_new_rows_frame_cb, state);
sysprof_capture_cursor_foreach (state->cursor, discover_new_rows_frame_cb, state);
g_task_return_boolean (task, TRUE);
}
@ -272,11 +272,11 @@ handle_capture_results (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
SpVisualizerList *self = (SpVisualizerList *)object;
SysprofVisualizerList *self = (SysprofVisualizerList *)object;
Discovery *state;
const gchar *key;
g_assert (SP_IS_VISUALIZER_LIST (self));
g_assert (SYSPROF_IS_VISUALIZER_LIST (self));
g_assert (G_IS_TASK (result));
g_assert (user_data == NULL);
@ -292,7 +292,7 @@ handle_capture_results (GObject *object,
if (state->has_cpu)
{
GtkWidget *row = g_object_new (SP_TYPE_CPU_VISUALIZER_ROW,
GtkWidget *row = g_object_new (SYSPROF_TYPE_CPU_VISUALIZER_ROW,
/* Translators: CPU is the processor. */
"title", _("CPU"),
"height-request", 50,
@ -308,7 +308,7 @@ handle_capture_results (GObject *object,
{
guint counter_id = g_array_index (state->memory, guint, i);
GdkRGBA rgba;
GtkWidget *row = g_object_new (SP_TYPE_LINE_VISUALIZER_ROW,
GtkWidget *row = g_object_new (SYSPROF_TYPE_LINE_VISUALIZER_ROW,
"title", _("Memory Used"),
"height-request", 35,
"selectable", FALSE,
@ -316,16 +316,16 @@ handle_capture_results (GObject *object,
"y-lower", 0.0,
NULL);
gdk_rgba_parse (&rgba, "#204a87");
sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (row), counter_id, &rgba);
sysprof_line_visualizer_row_add_counter (SYSPROF_LINE_VISUALIZER_ROW (row), counter_id, &rgba);
rgba.alpha = 0.3;
sp_line_visualizer_row_set_fill (SP_LINE_VISUALIZER_ROW (row), counter_id, &rgba);
sysprof_line_visualizer_row_set_fill (SYSPROF_LINE_VISUALIZER_ROW (row), counter_id, &rgba);
gtk_container_add (GTK_CONTAINER (self), row);
}
if (state->fps_counter)
{
GdkRGBA rgba;
GtkWidget *row = g_object_new (SP_TYPE_LINE_VISUALIZER_ROW,
GtkWidget *row = g_object_new (SYSPROF_TYPE_LINE_VISUALIZER_ROW,
/* Translators: FPS is frames per second. */
"title", _("FPS"),
"height-request", 35,
@ -335,9 +335,9 @@ handle_capture_results (GObject *object,
"y-upper", 150.0,
NULL);
gdk_rgba_parse (&rgba, "#204a87");
sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
sysprof_line_visualizer_row_add_counter (SYSPROF_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
rgba.alpha = 0.3;
sp_line_visualizer_row_set_fill (SP_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
sysprof_line_visualizer_row_set_fill (SYSPROF_LINE_VISUALIZER_ROW (row), state->fps_counter, &rgba);
gtk_container_add (GTK_CONTAINER (self), row);
}
@ -349,7 +349,7 @@ handle_capture_results (GObject *object,
while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
{
GtkWidget *row = g_object_new (SP_TYPE_MARK_VISUALIZER_ROW,
GtkWidget *row = g_object_new (SYSPROF_TYPE_MARK_VISUALIZER_ROW,
"group", key,
"title", key,
"height-request", 50,
@ -362,16 +362,16 @@ handle_capture_results (GObject *object,
}
static void
discover_new_rows (SpVisualizerList *self,
SpCaptureReader *reader)
discover_new_rows (SysprofVisualizerList *self,
SysprofCaptureReader *reader)
{
static const SpCaptureFrameType types[] = { SP_CAPTURE_FRAME_CTRDEF, SP_CAPTURE_FRAME_MARK };
g_autoptr(SpCaptureCursor) cursor = NULL;
static const SysprofCaptureFrameType types[] = { SYSPROF_CAPTURE_FRAME_CTRDEF, SYSPROF_CAPTURE_FRAME_MARK };
g_autoptr(SysprofCaptureCursor) cursor = NULL;
g_autoptr(GTask) task = NULL;
SpCaptureCondition *condition;
SysprofCaptureCondition *condition;
Discovery *state;
g_assert (SP_IS_VISUALIZER_LIST (self));
g_assert (SYSPROF_IS_VISUALIZER_LIST (self));
g_assert (reader != NULL);
/*
@ -381,9 +381,9 @@ discover_new_rows (SpVisualizerList *self,
* denote capabilities at the beginning of the capture stream.
*/
cursor = sp_capture_cursor_new (reader);
condition = sp_capture_condition_new_where_type_in (G_N_ELEMENTS (types), types);
sp_capture_cursor_add_condition (cursor, g_steal_pointer (&condition));
cursor = sysprof_capture_cursor_new (reader);
condition = sysprof_capture_condition_new_where_type_in (G_N_ELEMENTS (types), types);
sysprof_capture_cursor_add_condition (cursor, g_steal_pointer (&condition));
state = g_slice_new0 (Discovery);
state->mark_groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@ -396,25 +396,25 @@ discover_new_rows (SpVisualizerList *self,
}
void
sp_visualizer_list_set_reader (SpVisualizerList *self,
SpCaptureReader *reader)
sysprof_visualizer_list_set_reader (SysprofVisualizerList *self,
SysprofCaptureReader *reader)
{
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_LIST (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_LIST (self));
if (reader != priv->reader)
{
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
if (reader != NULL)
{
priv->reader = sp_capture_reader_ref (reader);
priv->reader = sysprof_capture_reader_ref (reader);
discover_new_rows (self, reader);
}
gtk_container_foreach (GTK_CONTAINER (self),
(GtkCallback)sp_visualizer_row_set_reader,
(GtkCallback)sysprof_visualizer_row_set_reader,
reader);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_READER]);
@ -422,34 +422,34 @@ sp_visualizer_list_set_reader (SpVisualizerList *self,
}
void
sp_visualizer_list_set_zoom_manager (SpVisualizerList *self,
SpZoomManager *zoom_manager)
sysprof_visualizer_list_set_zoom_manager (SysprofVisualizerList *self,
SysprofZoomManager *zoom_manager)
{
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_LIST (self));
g_return_if_fail (SP_IS_ZOOM_MANAGER (zoom_manager));
g_return_if_fail (SYSPROF_IS_VISUALIZER_LIST (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (zoom_manager));
if (g_set_object (&priv->zoom_manager, zoom_manager))
{
gtk_container_foreach (GTK_CONTAINER (self),
(GtkCallback)sp_visualizer_row_set_zoom_manager,
(GtkCallback)sysprof_visualizer_row_set_zoom_manager,
zoom_manager);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ZOOM_MANAGER]);
}
}
/**
* sp_visualizer_list_get_zoom_manager:
* sysprof_visualizer_list_get_zoom_manager:
*
* Returns: (nullable) (transfer): A #SpZoomManager or %NULL.
* Returns: (nullable) (transfer): A #SysprofZoomManager or %NULL.
*/
SpZoomManager *
sp_visualizer_list_get_zoom_manager (SpVisualizerList *self)
SysprofZoomManager *
sysprof_visualizer_list_get_zoom_manager (SysprofVisualizerList *self)
{
SpVisualizerListPrivate *priv = sp_visualizer_list_get_instance_private (self);
SysprofVisualizerListPrivate *priv = sysprof_visualizer_list_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_LIST (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_LIST (self), NULL);
return priv->zoom_manager;
}

View File

@ -1,4 +1,4 @@
/* sp-visualizer-list.h
/* sysprof-visualizer-list.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,16 +22,16 @@
#include <gtk/gtk.h>
#include "sp-capture-reader.h"
#include "sp-zoom-manager.h"
#include "sysprof-capture-reader.h"
#include "sysprof-zoom-manager.h"
G_BEGIN_DECLS
#define SP_TYPE_VISUALIZER_LIST (sp_visualizer_list_get_type())
#define SYSPROF_TYPE_VISUALIZER_LIST (sysprof_visualizer_list_get_type())
G_DECLARE_DERIVABLE_TYPE (SpVisualizerList, sp_visualizer_list, SP, VISUALIZER_LIST, GtkListBox)
G_DECLARE_DERIVABLE_TYPE (SysprofVisualizerList, sysprof_visualizer_list, SYSPROF, VISUALIZER_LIST, GtkListBox)
struct _SpVisualizerListClass
struct _SysprofVisualizerListClass
{
GtkListBoxClass parent_class;
@ -45,12 +45,12 @@ struct _SpVisualizerListClass
gpointer _reserved8;
};
GtkWidget *sp_visualizer_list_new (void);
void sp_visualizer_list_set_reader (SpVisualizerList *self,
SpCaptureReader *reader);
SpCaptureReader *sp_visualizer_list_get_reader (SpVisualizerList *self);
SpZoomManager *sp_visualizer_list_get_zoom_manager (SpVisualizerList *self);
void sp_visualizer_list_set_zoom_manager (SpVisualizerList *self,
SpZoomManager *zoom_manager);
GtkWidget *sysprof_visualizer_list_new (void);
void sysprof_visualizer_list_set_reader (SysprofVisualizerList *self,
SysprofCaptureReader *reader);
SysprofCaptureReader *sysprof_visualizer_list_get_reader (SysprofVisualizerList *self);
SysprofZoomManager *sysprof_visualizer_list_get_zoom_manager (SysprofVisualizerList *self);
void sysprof_visualizer_list_set_zoom_manager (SysprofVisualizerList *self,
SysprofZoomManager *zoom_manager);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-visualizer-row-private.h
/* sysprof-visualizer-row-private.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,10 +20,10 @@
#pragma once
#include "sp-visualizer-row.h"
#include "sysprof-visualizer-row.h"
G_BEGIN_DECLS
gint _sp_visualizer_row_get_graph_width (SpVisualizerRow *self);
gint _sysprof_visualizer_row_get_graph_width (SysprofVisualizerRow *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-visualizer-row.c
/* sysprof-visualizer-row.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -18,21 +18,21 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-visualizer-row"
#define G_LOG_DOMAIN "sysprof-visualizer-row"
#include "config.h"
#include "sp-visualizer-row.h"
#include "sp-visualizer-row-private.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-visualizer-row-private.h"
#define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000)
#define DEFAULT_PIXELS_PER_SECOND 20
typedef struct
{
SpCaptureReader *reader;
SpZoomManager *zoom_manager;
} SpVisualizerRowPrivate;
SysprofCaptureReader *reader;
SysprofZoomManager *zoom_manager;
} SysprofVisualizerRowPrivate;
enum {
PROP_0,
@ -42,26 +42,26 @@ enum {
static GParamSpec *properties [N_PROPS];
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SpVisualizerRow, sp_visualizer_row, GTK_TYPE_LIST_BOX_ROW)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (SysprofVisualizerRow, sysprof_visualizer_row, GTK_TYPE_LIST_BOX_ROW)
gint
_sp_visualizer_row_get_graph_width (SpVisualizerRow *self)
_sysprof_visualizer_row_get_graph_width (SysprofVisualizerRow *self)
{
SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
SysprofVisualizerRowPrivate *priv = sysprof_visualizer_row_get_instance_private (self);
gdouble zoom_level = 1.0;
gint64 begin_time;
gint64 end_time;
g_assert (SP_IS_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_VISUALIZER_ROW (self));
if (priv->reader == NULL)
return 0;
if (priv->zoom_manager != NULL)
zoom_level = sp_zoom_manager_get_zoom (priv->zoom_manager);
zoom_level = sysprof_zoom_manager_get_zoom (priv->zoom_manager);
begin_time = sp_capture_reader_get_start_time (priv->reader);
end_time = sp_capture_reader_get_end_time (priv->reader);
begin_time = sysprof_capture_reader_get_start_time (priv->reader);
end_time = sysprof_capture_reader_get_end_time (priv->reader);
return (end_time - begin_time)
/ (gdouble)NSEC_PER_SEC
@ -70,36 +70,36 @@ _sp_visualizer_row_get_graph_width (SpVisualizerRow *self)
}
static void
sp_visualizer_row_get_preferred_width (GtkWidget *widget,
sysprof_visualizer_row_get_preferred_width (GtkWidget *widget,
gint *min_width,
gint *nat_width)
{
SpVisualizerRow *self = (SpVisualizerRow *)widget;
SysprofVisualizerRow *self = (SysprofVisualizerRow *)widget;
gint graph_width;
gint real_min_width = 0;
gint real_nat_width = 0;
g_assert (SP_IS_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_VISUALIZER_ROW (self));
GTK_WIDGET_CLASS (sp_visualizer_row_parent_class)->get_preferred_width (widget, &real_min_width, &real_nat_width);
GTK_WIDGET_CLASS (sysprof_visualizer_row_parent_class)->get_preferred_width (widget, &real_min_width, &real_nat_width);
graph_width = _sp_visualizer_row_get_graph_width (self);
graph_width = _sysprof_visualizer_row_get_graph_width (self);
*min_width = *nat_width = real_min_width + graph_width;
}
static void
sp_visualizer_row_get_property (GObject *object,
sysprof_visualizer_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpVisualizerRow *self = SP_VISUALIZER_ROW (object);
SysprofVisualizerRow *self = SYSPROF_VISUALIZER_ROW (object);
switch (prop_id)
{
case PROP_ZOOM_MANAGER:
g_value_set_object (value, sp_visualizer_row_get_zoom_manager (self));
g_value_set_object (value, sysprof_visualizer_row_get_zoom_manager (self));
break;
default:
@ -108,17 +108,17 @@ sp_visualizer_row_get_property (GObject *object,
}
static void
sp_visualizer_row_set_property (GObject *object,
sysprof_visualizer_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpVisualizerRow *self = SP_VISUALIZER_ROW (object);
SysprofVisualizerRow *self = SYSPROF_VISUALIZER_ROW (object);
switch (prop_id)
{
case PROP_ZOOM_MANAGER:
sp_visualizer_row_set_zoom_manager (self, g_value_get_object (value));
sysprof_visualizer_row_set_zoom_manager (self, g_value_get_object (value));
break;
default:
@ -127,87 +127,87 @@ sp_visualizer_row_set_property (GObject *object,
}
static void
sp_visualizer_row_finalize (GObject *object)
sysprof_visualizer_row_finalize (GObject *object)
{
SpVisualizerRow *self = (SpVisualizerRow *)object;
SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
SysprofVisualizerRow *self = (SysprofVisualizerRow *)object;
SysprofVisualizerRowPrivate *priv = sysprof_visualizer_row_get_instance_private (self);
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
g_clear_object (&priv->zoom_manager);
G_OBJECT_CLASS (sp_visualizer_row_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_visualizer_row_parent_class)->finalize (object);
}
static void
sp_visualizer_row_class_init (SpVisualizerRowClass *klass)
sysprof_visualizer_row_class_init (SysprofVisualizerRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = sp_visualizer_row_finalize;
object_class->get_property = sp_visualizer_row_get_property;
object_class->set_property = sp_visualizer_row_set_property;
object_class->finalize = sysprof_visualizer_row_finalize;
object_class->get_property = sysprof_visualizer_row_get_property;
object_class->set_property = sysprof_visualizer_row_set_property;
widget_class->get_preferred_width = sp_visualizer_row_get_preferred_width;
widget_class->get_preferred_width = sysprof_visualizer_row_get_preferred_width;
properties [PROP_ZOOM_MANAGER] =
g_param_spec_object ("zoom-manager",
"Zoom Manager",
"Zoom Manager",
SP_TYPE_ZOOM_MANAGER,
SYSPROF_TYPE_ZOOM_MANAGER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
sp_visualizer_row_init (SpVisualizerRow *self)
sysprof_visualizer_row_init (SysprofVisualizerRow *self)
{
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (self), FALSE);
gtk_list_box_row_set_selectable (GTK_LIST_BOX_ROW (self), FALSE);
}
static void
sp_visualizer_row_zoom_manager_notify_zoom (SpVisualizerRow *self,
sysprof_visualizer_row_zoom_manager_notify_zoom (SysprofVisualizerRow *self,
GParamSpec *pspec,
SpZoomManager *zoom_manager)
SysprofZoomManager *zoom_manager)
{
g_assert (SP_IS_VISUALIZER_ROW (self));
g_assert (SP_IS_ZOOM_MANAGER (zoom_manager));
g_assert (SYSPROF_IS_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (zoom_manager));
gtk_widget_queue_resize (GTK_WIDGET (self));
}
/**
* sp_visualizer_row_get_zoom_manager:
* sysprof_visualizer_row_get_zoom_manager:
*
* Returns: (transfer none) (nullable): A #SpZoomManager or %NULL.
* Returns: (transfer none) (nullable): A #SysprofZoomManager or %NULL.
*/
SpZoomManager *
sp_visualizer_row_get_zoom_manager (SpVisualizerRow *self)
SysprofZoomManager *
sysprof_visualizer_row_get_zoom_manager (SysprofVisualizerRow *self)
{
SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
SysprofVisualizerRowPrivate *priv = sysprof_visualizer_row_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_ROW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_ROW (self), NULL);
return priv->zoom_manager;
}
void
sp_visualizer_row_set_zoom_manager (SpVisualizerRow *self,
SpZoomManager *zoom_manager)
sysprof_visualizer_row_set_zoom_manager (SysprofVisualizerRow *self,
SysprofZoomManager *zoom_manager)
{
SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
SysprofVisualizerRowPrivate *priv = sysprof_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_ROW (self));
g_return_if_fail (!zoom_manager || SP_IS_ZOOM_MANAGER (zoom_manager));
g_return_if_fail (SYSPROF_IS_VISUALIZER_ROW (self));
g_return_if_fail (!zoom_manager || SYSPROF_IS_ZOOM_MANAGER (zoom_manager));
if (priv->zoom_manager != zoom_manager)
{
if (priv->zoom_manager != NULL)
{
g_signal_handlers_disconnect_by_func (priv->zoom_manager,
G_CALLBACK (sp_visualizer_row_zoom_manager_notify_zoom),
G_CALLBACK (sysprof_visualizer_row_zoom_manager_notify_zoom),
self);
g_clear_object (&priv->zoom_manager);
}
@ -217,7 +217,7 @@ sp_visualizer_row_set_zoom_manager (SpVisualizerRow *self,
priv->zoom_manager = g_object_ref (zoom_manager);
g_signal_connect_object (priv->zoom_manager,
"notify::zoom",
G_CALLBACK (sp_visualizer_row_zoom_manager_notify_zoom),
G_CALLBACK (sysprof_visualizer_row_zoom_manager_notify_zoom),
self,
G_CONNECT_SWAPPED);
}
@ -228,22 +228,22 @@ sp_visualizer_row_set_zoom_manager (SpVisualizerRow *self,
}
void
sp_visualizer_row_set_reader (SpVisualizerRow *self,
SpCaptureReader *reader)
sysprof_visualizer_row_set_reader (SysprofVisualizerRow *self,
SysprofCaptureReader *reader)
{
SpVisualizerRowPrivate *priv = sp_visualizer_row_get_instance_private (self);
SysprofVisualizerRowPrivate *priv = sysprof_visualizer_row_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_ROW (self));
if (priv->reader != reader)
{
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
if (reader != NULL)
priv->reader = sp_capture_reader_ref (reader);
priv->reader = sysprof_capture_reader_ref (reader);
if (SP_VISUALIZER_ROW_GET_CLASS (self)->set_reader)
SP_VISUALIZER_ROW_GET_CLASS (self)->set_reader (self, reader);
if (SYSPROF_VISUALIZER_ROW_GET_CLASS (self)->set_reader)
SYSPROF_VISUALIZER_ROW_GET_CLASS (self)->set_reader (self, reader);
gtk_widget_queue_resize (GTK_WIDGET (self));
}
@ -264,14 +264,14 @@ subtract_border (GtkAllocation *alloc,
}
static void
adjust_alloc_for_borders (SpVisualizerRow *self,
adjust_alloc_for_borders (SysprofVisualizerRow *self,
GtkAllocation *alloc)
{
GtkStyleContext *style_context;
GtkBorder border;
GtkStateFlags state;
g_assert (SP_IS_VISUALIZER_ROW (self));
g_assert (SYSPROF_IS_VISUALIZER_ROW (self));
g_assert (alloc != NULL);
state = gtk_widget_get_state_flags (GTK_WIDGET (self));
@ -282,16 +282,16 @@ adjust_alloc_for_borders (SpVisualizerRow *self,
}
void
sp_visualizer_row_translate_points (SpVisualizerRow *self,
const SpVisualizerRowRelativePoint *in_points,
sysprof_visualizer_row_translate_points (SysprofVisualizerRow *self,
const SysprofVisualizerRowRelativePoint *in_points,
guint n_in_points,
SpVisualizerRowAbsolutePoint *out_points,
SysprofVisualizerRowAbsolutePoint *out_points,
guint n_out_points)
{
GtkAllocation alloc;
gint graph_width;
g_return_if_fail (SP_IS_VISUALIZER_ROW (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_ROW (self));
g_return_if_fail (in_points != NULL);
g_return_if_fail (out_points != NULL);
g_return_if_fail (n_in_points == n_out_points);
@ -299,7 +299,7 @@ sp_visualizer_row_translate_points (SpVisualizerRow *self,
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
adjust_alloc_for_borders (self, &alloc);
graph_width = _sp_visualizer_row_get_graph_width (self);
graph_width = _sysprof_visualizer_row_get_graph_width (self);
for (guint i = 0; i < n_in_points; i++)
{

View File

@ -1,4 +1,4 @@
/* sp-visualizer-row.h
/* sysprof-visualizer-row.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,54 +22,54 @@
#include <gtk/gtk.h>
#include "sp-capture-reader.h"
#include "sp-zoom-manager.h"
#include "sysprof-capture-reader.h"
#include "sysprof-zoom-manager.h"
G_BEGIN_DECLS
#define SP_TYPE_VISUALIZER_ROW (sp_visualizer_row_get_type())
#define SYSPROF_TYPE_VISUALIZER_ROW (sysprof_visualizer_row_get_type())
G_DECLARE_DERIVABLE_TYPE (SpVisualizerRow, sp_visualizer_row, SP, VISUALIZER_ROW, GtkListBoxRow)
G_DECLARE_DERIVABLE_TYPE (SysprofVisualizerRow, sysprof_visualizer_row, SYSPROF, VISUALIZER_ROW, GtkListBoxRow)
typedef struct
{
gdouble x;
gdouble y;
} SpVisualizerRowRelativePoint;
} SysprofVisualizerRowRelativePoint;
typedef struct
{
gint x;
gint y;
} SpVisualizerRowAbsolutePoint;
} SysprofVisualizerRowAbsolutePoint;
struct _SpVisualizerRowClass
struct _SysprofVisualizerRowClass
{
GtkListBoxRowClass parent_class;
/**
* SpVisualizerRow::set_reader:
* SysprofVisualizerRow::set_reader:
*
* Sets the reader that the row should use to extract counters.
* This reader is private to the row and should be freed when
* no longer in use with sp_capture_reader_unref().
* no longer in use with sysprof_capture_reader_unref().
*/
void (*set_reader) (SpVisualizerRow *self,
SpCaptureReader *reader);
void (*set_reader) (SysprofVisualizerRow *self,
SysprofCaptureReader *reader);
/*< private >*/
gpointer _reserved[16];
};
void sp_visualizer_row_set_reader (SpVisualizerRow *self,
SpCaptureReader *reader);
SpZoomManager *sp_visualizer_row_get_zoom_manager (SpVisualizerRow *self);
void sp_visualizer_row_set_zoom_manager (SpVisualizerRow *self,
SpZoomManager *zoom_manager);
void sp_visualizer_row_translate_points (SpVisualizerRow *self,
const SpVisualizerRowRelativePoint *in_points,
void sysprof_visualizer_row_set_reader (SysprofVisualizerRow *self,
SysprofCaptureReader *reader);
SysprofZoomManager *sysprof_visualizer_row_get_zoom_manager (SysprofVisualizerRow *self);
void sysprof_visualizer_row_set_zoom_manager (SysprofVisualizerRow *self,
SysprofZoomManager *zoom_manager);
void sysprof_visualizer_row_translate_points (SysprofVisualizerRow *self,
const SysprofVisualizerRowRelativePoint *in_points,
guint n_in_points,
SpVisualizerRowAbsolutePoint *out_points,
SysprofVisualizerRowAbsolutePoint *out_points,
guint n_out_points);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-visualizer-ticks.c
/* sysprof-visualizer-ticks.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,7 +22,7 @@
#include <glib/gi18n.h>
#include "sp-visualizer-ticks.h"
#include "sysprof-visualizer-ticks.h"
#define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000)
#define NSEC_PER_HOUR (NSEC_PER_SEC * 60 * 60)
@ -31,7 +31,7 @@
#define MIN_TICK_DISTANCE 20
#define LABEL_HEIGHT_PX 8
struct _SpVisualizerTicks
struct _SysprofVisualizerTicks
{
GtkDrawingArea parent_instance;
@ -69,7 +69,7 @@ struct {
{ 1, 3, NSEC_PER_SEC / 1000 },
};
G_DEFINE_TYPE (SpVisualizerTicks, sp_visualizer_ticks, GTK_TYPE_DRAWING_AREA)
G_DEFINE_TYPE (SysprofVisualizerTicks, sysprof_visualizer_ticks, GTK_TYPE_DRAWING_AREA)
static void
update_label_text (PangoLayout *layout,
@ -126,7 +126,7 @@ update_label_text (PangoLayout *layout,
}
static inline gdouble
get_x_for_time (SpVisualizerTicks *self,
get_x_for_time (SysprofVisualizerTicks *self,
const GtkAllocation *alloc,
gint64 t)
{
@ -137,7 +137,7 @@ get_x_for_time (SpVisualizerTicks *self,
#if 0
static inline gint64
get_time_at_x (SpVisualizerTicks *self,
get_time_at_x (SysprofVisualizerTicks *self,
const GtkAllocation *alloc,
gdouble x)
{
@ -148,7 +148,7 @@ get_time_at_x (SpVisualizerTicks *self,
#endif
static gboolean
draw_ticks (SpVisualizerTicks *self,
draw_ticks (SysprofVisualizerTicks *self,
cairo_t *cr,
GtkAllocation *area,
gint ticks,
@ -159,7 +159,7 @@ draw_ticks (SpVisualizerTicks *self,
gint64 x_offset;
gint count = 0;
g_assert (SP_IS_VISUALIZER_TICKS (self));
g_assert (SYSPROF_IS_VISUALIZER_TICKS (self));
g_assert (cr != NULL);
g_assert (area != NULL);
g_assert (ticks >= 0);
@ -234,17 +234,17 @@ draw_ticks (SpVisualizerTicks *self,
}
static gboolean
sp_visualizer_ticks_draw (GtkWidget *widget,
sysprof_visualizer_ticks_draw (GtkWidget *widget,
cairo_t *cr)
{
SpVisualizerTicks *self = SP_VISUALIZER_TICKS (widget);
SysprofVisualizerTicks *self = SYSPROF_VISUALIZER_TICKS (widget);
GtkStyleContext *style;
GtkAllocation alloc;
GtkStateFlags state;
gint64 timespan;
GdkRGBA color;
g_assert (SP_IS_VISUALIZER_TICKS (self));
g_assert (SYSPROF_IS_VISUALIZER_TICKS (self));
g_assert (cr != NULL);
if (0 == (timespan = self->end_time - self->begin_time))
@ -289,28 +289,28 @@ sp_visualizer_ticks_draw (GtkWidget *widget,
}
static void
sp_visualizer_ticks_get_preferred_height (GtkWidget *widget,
sysprof_visualizer_ticks_get_preferred_height (GtkWidget *widget,
gint *min_height,
gint *nat_height)
{
g_assert (SP_IS_VISUALIZER_TICKS (widget));
g_assert (SYSPROF_IS_VISUALIZER_TICKS (widget));
*min_height = *nat_height = tick_sizing[0].height + LABEL_HEIGHT_PX;
}
static void
sp_visualizer_ticks_class_init (SpVisualizerTicksClass *klass)
sysprof_visualizer_ticks_class_init (SysprofVisualizerTicksClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->draw = sp_visualizer_ticks_draw;
widget_class->get_preferred_height = sp_visualizer_ticks_get_preferred_height;
widget_class->draw = sysprof_visualizer_ticks_draw;
widget_class->get_preferred_height = sysprof_visualizer_ticks_get_preferred_height;
gtk_widget_class_set_css_name (widget_class, "ticks");
}
static void
sp_visualizer_ticks_init (SpVisualizerTicks *self)
sysprof_visualizer_ticks_init (SysprofVisualizerTicks *self)
{
self->end_time = G_GINT64_CONSTANT (1000000000) * 60;
@ -318,17 +318,17 @@ sp_visualizer_ticks_init (SpVisualizerTicks *self)
}
GtkWidget *
sp_visualizer_ticks_new (void)
sysprof_visualizer_ticks_new (void)
{
return g_object_new (SP_TYPE_VISUALIZER_TICKS, NULL);
return g_object_new (SYSPROF_TYPE_VISUALIZER_TICKS, NULL);
}
void
sp_visualizer_ticks_get_time_range (SpVisualizerTicks *self,
sysprof_visualizer_ticks_get_time_range (SysprofVisualizerTicks *self,
gint64 *begin_time,
gint64 *end_time)
{
g_return_if_fail (SP_IS_VISUALIZER_TICKS (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_TICKS (self));
g_return_if_fail (begin_time != NULL || end_time != NULL);
if (begin_time != NULL)
@ -339,11 +339,11 @@ sp_visualizer_ticks_get_time_range (SpVisualizerTicks *self,
}
void
sp_visualizer_ticks_set_time_range (SpVisualizerTicks *self,
sysprof_visualizer_ticks_set_time_range (SysprofVisualizerTicks *self,
gint64 begin_time,
gint64 end_time)
{
g_return_if_fail (SP_IS_VISUALIZER_TICKS (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_TICKS (self));
if (begin_time > end_time)
{
@ -359,9 +359,9 @@ sp_visualizer_ticks_set_time_range (SpVisualizerTicks *self,
}
gint64
sp_visualizer_ticks_get_epoch (SpVisualizerTicks *self)
sysprof_visualizer_ticks_get_epoch (SysprofVisualizerTicks *self)
{
g_return_val_if_fail (SP_IS_VISUALIZER_TICKS (self), 0);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_TICKS (self), 0);
return self->epoch;
}
@ -370,7 +370,7 @@ sp_visualizer_ticks_get_epoch (SpVisualizerTicks *self)
* Sets the epoch for the visualizer ticks.
*
* The epoch is the "real" starting time of the capture, where as the
* sp_visualizer_ticks_set_time_range() function sets the visible range
* sysprof_visualizer_ticks_set_time_range() function sets the visible range
* of the capture.
*
* This is used to calculate the offset of the beginning of the capture
@ -379,10 +379,10 @@ sp_visualizer_ticks_get_epoch (SpVisualizerTicks *self)
* This function should only need to be called when the reader is changed.
*/
void
sp_visualizer_ticks_set_epoch (SpVisualizerTicks *self,
sysprof_visualizer_ticks_set_epoch (SysprofVisualizerTicks *self,
gint64 epoch)
{
g_return_if_fail (SP_IS_VISUALIZER_TICKS (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_TICKS (self));
if (self->epoch != epoch)
{

View File

@ -1,4 +1,4 @@
/* sp-visualizer-ticks.h
/* sysprof-visualizer-ticks.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -24,18 +24,18 @@
G_BEGIN_DECLS
#define SP_TYPE_VISUALIZER_TICKS (sp_visualizer_ticks_get_type())
#define SYSPROF_TYPE_VISUALIZER_TICKS (sysprof_visualizer_ticks_get_type())
G_DECLARE_FINAL_TYPE (SpVisualizerTicks, sp_visualizer_ticks, SP, VISUALIZER_TICKS, GtkDrawingArea)
G_DECLARE_FINAL_TYPE (SysprofVisualizerTicks, sysprof_visualizer_ticks, SYSPROF, VISUALIZER_TICKS, GtkDrawingArea)
GtkWidget *sp_visualizer_ticks_new (void);
void sp_visualizer_ticks_set_epoch (SpVisualizerTicks *self,
GtkWidget *sysprof_visualizer_ticks_new (void);
void sysprof_visualizer_ticks_set_epoch (SysprofVisualizerTicks *self,
gint64 epoch);
gint64 sp_visualizer_ticks_get_epoch (SpVisualizerTicks *self);
void sp_visualizer_ticks_get_time_range (SpVisualizerTicks *self,
gint64 sysprof_visualizer_ticks_get_epoch (SysprofVisualizerTicks *self);
void sysprof_visualizer_ticks_get_time_range (SysprofVisualizerTicks *self,
gint64 *begin_time,
gint64 *end_time);
void sp_visualizer_ticks_set_time_range (SpVisualizerTicks *self,
void sysprof_visualizer_ticks_set_time_range (SysprofVisualizerTicks *self,
gint64 begin_time,
gint64 end_time);

View File

@ -1,4 +1,4 @@
/* sp-visualizer-view.c
/* sysprof-visualizer-view.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,42 +18,42 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-visualizer-view"
#define G_LOG_DOMAIN "sysprof-visualizer-view"
#include "config.h"
#include <glib/gi18n.h>
#include "sp-theme-manager.h"
#include "sp-visualizer-list.h"
#include "sp-visualizer-row.h"
#include "sp-visualizer-row-private.h"
#include "sp-selection.h"
#include "sp-visualizer-ticks.h"
#include "sp-visualizer-view.h"
#include "sysprof-theme-manager.h"
#include "sysprof-visualizer-list.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-visualizer-row-private.h"
#include "sysprof-selection.h"
#include "sysprof-visualizer-ticks.h"
#include "sysprof-visualizer-view.h"
#define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000)
#define DEFAULT_PIXELS_PER_SECOND 20
typedef struct
{
SpCaptureReader *reader;
SpZoomManager *zoom_manager;
SpSelection *selection;
SysprofCaptureReader *reader;
SysprofZoomManager *zoom_manager;
SysprofSelection *selection;
SpVisualizerList *list;
SysprofVisualizerList *list;
GtkScrolledWindow *scroller;
SpVisualizerTicks *ticks;
SysprofVisualizerTicks *ticks;
gint64 drag_begin_at;
gint64 drag_selection_at;
guint button_pressed : 1;
} SpVisualizerViewPrivate;
} SysprofVisualizerViewPrivate;
typedef struct
{
SpVisualizerView *self;
SysprofVisualizerView *self;
GtkStyleContext *style_context;
cairo_t *cr;
GtkAllocation alloc;
@ -74,8 +74,8 @@ enum {
static void buildable_iface_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_EXTENDED (SpVisualizerView, sp_visualizer_view, GTK_TYPE_BIN, 0,
G_ADD_PRIVATE (SpVisualizerView)
G_DEFINE_TYPE_EXTENDED (SysprofVisualizerView, sysprof_visualizer_view, GTK_TYPE_BIN, 0,
G_ADD_PRIVATE (SysprofVisualizerView)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
static GParamSpec *properties [N_PROPS];
@ -88,23 +88,23 @@ find_row1 (GtkWidget *widget,
{
GtkWidget **row1 = data;
if (*row1 == NULL && SP_IS_VISUALIZER_ROW (widget))
if (*row1 == NULL && SYSPROF_IS_VISUALIZER_ROW (widget))
*row1 = widget;
}
static gint64
get_time_from_coordinates (SpVisualizerView *self,
get_time_from_coordinates (SysprofVisualizerView *self,
gint x,
gint y)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SpVisualizerRow *row1 = NULL;
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
SysprofVisualizerRow *row1 = NULL;
GtkAllocation alloc;
gint64 begin_time;
gint64 end_time;
gint graph_width;
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
if (priv->reader == NULL)
return 0;
@ -119,23 +119,23 @@ get_time_from_coordinates (SpVisualizerView *self,
* (ignoring spacing caused by the widget being wider than the data points.
*/
gtk_container_foreach (GTK_CONTAINER (priv->list), find_row1, &row1);
if (!SP_IS_VISUALIZER_ROW (row1))
if (!SYSPROF_IS_VISUALIZER_ROW (row1))
return 0;
begin_time = sp_capture_reader_get_start_time (priv->reader);
end_time = sp_capture_reader_get_end_time (priv->reader);
graph_width = _sp_visualizer_row_get_graph_width (row1);
begin_time = sysprof_capture_reader_get_start_time (priv->reader);
end_time = sysprof_capture_reader_get_end_time (priv->reader);
graph_width = _sysprof_visualizer_row_get_graph_width (row1);
return begin_time + ((end_time - begin_time) * (x / (gdouble)graph_width));
}
static gint
get_x_for_time_at (SpVisualizerView *self,
get_x_for_time_at (SysprofVisualizerView *self,
const GtkAllocation *alloc,
gint64 time_at)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SpVisualizerRow *row1 = NULL;
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
SysprofVisualizerRow *row1 = NULL;
GtkAdjustment *hadjustment;
gdouble nsec_per_pixel;
gdouble value;
@ -143,7 +143,7 @@ get_x_for_time_at (SpVisualizerView *self,
gint64 end_time;
gint graph_width;
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (alloc != NULL);
/*
@ -151,16 +151,16 @@ get_x_for_time_at (SpVisualizerView *self,
* (ignoring spacing caused by the widget being wider than the data points.
*/
gtk_container_foreach (GTK_CONTAINER (priv->list), find_row1, &row1);
if (!SP_IS_VISUALIZER_ROW (row1))
if (!SYSPROF_IS_VISUALIZER_ROW (row1))
return 0;
hadjustment = gtk_scrolled_window_get_hadjustment (priv->scroller);
value = gtk_adjustment_get_value (hadjustment);
begin_time = sp_capture_reader_get_start_time (priv->reader);
end_time = sp_capture_reader_get_end_time (priv->reader);
begin_time = sysprof_capture_reader_get_start_time (priv->reader);
end_time = sysprof_capture_reader_get_end_time (priv->reader);
graph_width = _sp_visualizer_row_get_graph_width (row1);
graph_width = _sysprof_visualizer_row_get_graph_width (row1);
nsec_per_pixel = (end_time - begin_time) / (gdouble)graph_width;
begin_time += value * nsec_per_pixel;
@ -168,42 +168,42 @@ get_x_for_time_at (SpVisualizerView *self,
}
static void
sp_visualizer_view_row_added (SpVisualizerView *self,
sysprof_visualizer_view_row_added (SysprofVisualizerView *self,
GtkWidget *widget,
SpVisualizerList *list)
SysprofVisualizerList *list)
{
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (GTK_IS_WIDGET (widget));
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
if (SP_IS_VISUALIZER_ROW (widget))
if (SYSPROF_IS_VISUALIZER_ROW (widget))
g_signal_emit (self, signals [VISUALIZER_ADDED], 0, widget);
}
static void
sp_visualizer_view_row_removed (SpVisualizerView *self,
sysprof_visualizer_view_row_removed (SysprofVisualizerView *self,
GtkWidget *widget,
SpVisualizerList *list)
SysprofVisualizerList *list)
{
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (GTK_IS_WIDGET (widget));
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
if (SP_IS_VISUALIZER_ROW (widget))
if (SYSPROF_IS_VISUALIZER_ROW (widget))
g_signal_emit (self, signals [VISUALIZER_REMOVED], 0, widget);
}
static void
sp_visualizer_view_update_ticks (SpVisualizerView *self)
sysprof_visualizer_view_update_ticks (SysprofVisualizerView *self)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
GtkAdjustment *hadjustment;
GtkAllocation alloc;
gdouble value;
gint64 begin_time;
gint64 end_time;
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
hadjustment = gtk_scrolled_window_get_hadjustment (priv->scroller);
value = gtk_adjustment_get_value (hadjustment);
@ -213,35 +213,35 @@ sp_visualizer_view_update_ticks (SpVisualizerView *self)
begin_time = get_time_from_coordinates (self, alloc.x + value, alloc.y);
end_time = get_time_from_coordinates (self, alloc.x + value + alloc.width, alloc.y);
sp_visualizer_ticks_set_time_range (priv->ticks, begin_time, end_time);
sysprof_visualizer_ticks_set_time_range (priv->ticks, begin_time, end_time);
}
static void
sp_visualizer_view_hadjustment_value_changed (SpVisualizerView *self,
sysprof_visualizer_view_hadjustment_value_changed (SysprofVisualizerView *self,
GtkAdjustment *adjustment)
{
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (GTK_IS_ADJUSTMENT (adjustment));
sp_visualizer_view_update_ticks (self);
sysprof_visualizer_view_update_ticks (self);
}
static void
sp_visualizer_view_size_allocate (GtkWidget *widget,
sysprof_visualizer_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
SpVisualizerView *self = (SpVisualizerView *)widget;
SysprofVisualizerView *self = (SysprofVisualizerView *)widget;
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (allocation != NULL);
GTK_WIDGET_CLASS (sp_visualizer_view_parent_class)->size_allocate (widget, allocation);
GTK_WIDGET_CLASS (sysprof_visualizer_view_parent_class)->size_allocate (widget, allocation);
sp_visualizer_view_update_ticks (self);
sysprof_visualizer_view_update_ticks (self);
}
static void
draw_selection_cb (SpSelection *selection,
draw_selection_cb (SysprofSelection *selection,
gint64 range_begin,
gint64 range_end,
gpointer user_data)
@ -249,10 +249,10 @@ draw_selection_cb (SpSelection *selection,
SelectionDraw *draw = user_data;
GdkRectangle area;
g_assert (SP_IS_SELECTION (selection));
g_assert (SYSPROF_IS_SELECTION (selection));
g_assert (draw != NULL);
g_assert (draw->cr != NULL);
g_assert (SP_IS_VISUALIZER_VIEW (draw->self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (draw->self));
area.x = get_x_for_time_at (draw->self, &draw->alloc, range_begin);
area.width = get_x_for_time_at (draw->self, &draw->alloc, range_end) - area.x;
@ -269,11 +269,11 @@ draw_selection_cb (SpSelection *selection,
}
static gboolean
sp_visualizer_view_draw (GtkWidget *widget,
sysprof_visualizer_view_draw (GtkWidget *widget,
cairo_t *cr)
{
SpVisualizerView *self = (SpVisualizerView *)widget;
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerView *self = (SysprofVisualizerView *)widget;
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
SelectionDraw draw = { 0 };
gboolean ret;
@ -286,12 +286,12 @@ sp_visualizer_view_draw (GtkWidget *widget,
gtk_widget_get_allocation (widget, &draw.alloc);
ret = GTK_WIDGET_CLASS (sp_visualizer_view_parent_class)->draw (widget, cr);
ret = GTK_WIDGET_CLASS (sysprof_visualizer_view_parent_class)->draw (widget, cr);
if (sp_selection_get_has_selection (priv->selection) || priv->button_pressed)
if (sysprof_selection_get_has_selection (priv->selection) || priv->button_pressed)
{
gtk_style_context_add_class (draw.style_context, "selection");
sp_selection_foreach (priv->selection, draw_selection_cb, &draw);
sysprof_selection_foreach (priv->selection, draw_selection_cb, &draw);
if (priv->button_pressed)
draw_selection_cb (priv->selection, priv->drag_begin_at, priv->drag_selection_at, &draw);
gtk_style_context_remove_class (draw.style_context, "selection");
@ -301,31 +301,31 @@ sp_visualizer_view_draw (GtkWidget *widget,
}
static gboolean
sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
sysprof_visualizer_view_list_button_press_event (SysprofVisualizerView *self,
GdkEventButton *ev,
SpVisualizerList *list)
SysprofVisualizerList *list)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (ev != NULL);
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
if (priv->reader == NULL)
return GDK_EVENT_PROPAGATE;
if (ev->button != GDK_BUTTON_PRIMARY)
{
if (sp_selection_get_has_selection (priv->selection))
if (sysprof_selection_get_has_selection (priv->selection))
{
sp_selection_unselect_all (priv->selection);
sysprof_selection_unselect_all (priv->selection);
return GDK_EVENT_STOP;
}
return GDK_EVENT_PROPAGATE;
}
if ((ev->state & GDK_SHIFT_MASK) == 0)
sp_selection_unselect_all (priv->selection);
sysprof_selection_unselect_all (priv->selection);
priv->button_pressed = TRUE;
@ -338,15 +338,15 @@ sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
}
static gboolean
sp_visualizer_view_list_button_release_event (SpVisualizerView *self,
sysprof_visualizer_view_list_button_release_event (SysprofVisualizerView *self,
GdkEventButton *ev,
SpVisualizerList *list)
SysprofVisualizerList *list)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (ev != NULL);
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
if (!priv->button_pressed || ev->button != GDK_BUTTON_PRIMARY)
return GDK_EVENT_PROPAGATE;
@ -355,7 +355,7 @@ sp_visualizer_view_list_button_release_event (SpVisualizerView *self,
if (priv->drag_begin_at != priv->drag_selection_at)
{
sp_selection_select_range (priv->selection,
sysprof_selection_select_range (priv->selection,
priv->drag_begin_at,
priv->drag_selection_at);
priv->drag_begin_at = -1;
@ -368,15 +368,15 @@ sp_visualizer_view_list_button_release_event (SpVisualizerView *self,
}
static gboolean
sp_visualizer_view_list_motion_notify_event (SpVisualizerView *self,
sysprof_visualizer_view_list_motion_notify_event (SysprofVisualizerView *self,
GdkEventMotion *ev,
SpVisualizerList *list)
SysprofVisualizerList *list)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (ev != NULL);
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
if (!priv->button_pressed)
return GDK_EVENT_PROPAGATE;
@ -389,15 +389,15 @@ sp_visualizer_view_list_motion_notify_event (SpVisualizerView *self,
}
static void
sp_visualizer_view_list_realize_after (SpVisualizerView *self,
SpVisualizerList *list)
sysprof_visualizer_view_list_realize_after (SysprofVisualizerView *self,
SysprofVisualizerList *list)
{
GdkDisplay *display;
GdkWindow *window;
GdkCursor *cursor;
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SP_IS_VISUALIZER_LIST (list));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_LIST (list));
window = gtk_widget_get_window (GTK_WIDGET (list));
display = gdk_window_get_display (window);
@ -407,44 +407,44 @@ sp_visualizer_view_list_realize_after (SpVisualizerView *self,
}
static void
sp_visualizer_view_selection_changed (SpVisualizerView *self,
SpSelection *selection)
sysprof_visualizer_view_selection_changed (SysprofVisualizerView *self,
SysprofSelection *selection)
{
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SP_IS_SELECTION (selection));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_SELECTION (selection));
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
sp_visualizer_view_finalize (GObject *object)
sysprof_visualizer_view_finalize (GObject *object)
{
SpVisualizerView *self = (SpVisualizerView *)object;
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerView *self = (SysprofVisualizerView *)object;
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
g_clear_object (&priv->zoom_manager);
g_clear_object (&priv->selection);
G_OBJECT_CLASS (sp_visualizer_view_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_visualizer_view_parent_class)->finalize (object);
}
static void
sp_visualizer_view_get_property (GObject *object,
sysprof_visualizer_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpVisualizerView *self = SP_VISUALIZER_VIEW (object);
SysprofVisualizerView *self = SYSPROF_VISUALIZER_VIEW (object);
switch (prop_id)
{
case PROP_READER:
g_value_set_boxed (value, sp_visualizer_view_get_reader (self));
g_value_set_boxed (value, sysprof_visualizer_view_get_reader (self));
break;
case PROP_ZOOM_MANAGER:
g_value_set_object (value, sp_visualizer_view_get_zoom_manager (self));
g_value_set_object (value, sysprof_visualizer_view_get_zoom_manager (self));
break;
default:
@ -453,21 +453,21 @@ sp_visualizer_view_get_property (GObject *object,
}
static void
sp_visualizer_view_set_property (GObject *object,
sysprof_visualizer_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpVisualizerView *self = SP_VISUALIZER_VIEW (object);
SysprofVisualizerView *self = SYSPROF_VISUALIZER_VIEW (object);
switch (prop_id)
{
case PROP_READER:
sp_visualizer_view_set_reader (self, g_value_get_boxed (value));
sysprof_visualizer_view_set_reader (self, g_value_get_boxed (value));
break;
case PROP_ZOOM_MANAGER:
sp_visualizer_view_set_zoom_manager (self, g_value_get_object (value));
sysprof_visualizer_view_set_zoom_manager (self, g_value_get_object (value));
break;
default:
@ -476,31 +476,31 @@ sp_visualizer_view_set_property (GObject *object,
}
static void
sp_visualizer_view_class_init (SpVisualizerViewClass *klass)
sysprof_visualizer_view_class_init (SysprofVisualizerViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
SpThemeManager *theme_manager = sp_theme_manager_get_default ();
SysprofThemeManager *theme_manager = sysprof_theme_manager_get_default ();
object_class->finalize = sp_visualizer_view_finalize;
object_class->get_property = sp_visualizer_view_get_property;
object_class->set_property = sp_visualizer_view_set_property;
object_class->finalize = sysprof_visualizer_view_finalize;
object_class->get_property = sysprof_visualizer_view_get_property;
object_class->set_property = sysprof_visualizer_view_set_property;
widget_class->draw = sp_visualizer_view_draw;
widget_class->size_allocate = sp_visualizer_view_size_allocate;
widget_class->draw = sysprof_visualizer_view_draw;
widget_class->size_allocate = sysprof_visualizer_view_size_allocate;
properties [PROP_READER] =
g_param_spec_boxed ("reader",
"Reader",
"The reader for the visualizers",
SP_TYPE_CAPTURE_READER,
SYSPROF_TYPE_CAPTURE_READER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_ZOOM_MANAGER] =
g_param_spec_object ("zoom-manager",
"Zoom Manager",
"The zoom manager for the view",
SP_TYPE_ZOOM_MANAGER,
SYSPROF_TYPE_ZOOM_MANAGER,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
@ -509,37 +509,37 @@ sp_visualizer_view_class_init (SpVisualizerViewClass *klass)
g_signal_new ("visualizer-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (SpVisualizerViewClass, visualizer_added),
G_STRUCT_OFFSET (SysprofVisualizerViewClass, visualizer_added),
NULL, NULL, NULL,
G_TYPE_NONE, 1, SP_TYPE_VISUALIZER_ROW);
G_TYPE_NONE, 1, SYSPROF_TYPE_VISUALIZER_ROW);
signals [VISUALIZER_REMOVED] =
g_signal_new ("visualizer-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (SpVisualizerViewClass, visualizer_removed),
G_STRUCT_OFFSET (SysprofVisualizerViewClass, visualizer_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 1, SP_TYPE_VISUALIZER_ROW);
G_TYPE_NONE, 1, SYSPROF_TYPE_VISUALIZER_ROW);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sp-visualizer-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpVisualizerView, list);
gtk_widget_class_bind_template_child_private (widget_class, SpVisualizerView, scroller);
gtk_widget_class_bind_template_child_private (widget_class, SpVisualizerView, ticks);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-visualizer-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SysprofVisualizerView, list);
gtk_widget_class_bind_template_child_private (widget_class, SysprofVisualizerView, scroller);
gtk_widget_class_bind_template_child_private (widget_class, SysprofVisualizerView, ticks);
gtk_widget_class_set_css_name (widget_class, "visualizers");
sp_theme_manager_register_resource (theme_manager, NULL, NULL, "/org/gnome/sysprof/css/SpVisualizerView-shared.css");
sp_theme_manager_register_resource (theme_manager, "Adwaita", NULL, "/org/gnome/sysprof/css/SpVisualizerView-Adwaita.css");
sp_theme_manager_register_resource (theme_manager, "Adwaita", "dark", "/org/gnome/sysprof/css/SpVisualizerView-Adwaita-dark.css");
sysprof_theme_manager_register_resource (theme_manager, NULL, NULL, "/org/gnome/sysprof/css/SysprofVisualizerView-shared.css");
sysprof_theme_manager_register_resource (theme_manager, "Adwaita", NULL, "/org/gnome/sysprof/css/SysprofVisualizerView-Adwaita.css");
sysprof_theme_manager_register_resource (theme_manager, "Adwaita", "dark", "/org/gnome/sysprof/css/SysprofVisualizerView-Adwaita-dark.css");
g_type_ensure (SP_TYPE_VISUALIZER_LIST);
g_type_ensure (SP_TYPE_VISUALIZER_TICKS);
g_type_ensure (SYSPROF_TYPE_VISUALIZER_LIST);
g_type_ensure (SYSPROF_TYPE_VISUALIZER_TICKS);
}
static void
sp_visualizer_view_init (SpVisualizerView *self)
sysprof_visualizer_view_init (SysprofVisualizerView *self)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
GtkAdjustment *hadjustment;
priv->drag_begin_at = -1;
@ -547,47 +547,47 @@ sp_visualizer_view_init (SpVisualizerView *self)
gtk_widget_init_template (GTK_WIDGET (self));
priv->selection = g_object_new (SP_TYPE_SELECTION, NULL);
priv->selection = g_object_new (SYSPROF_TYPE_SELECTION, NULL);
g_signal_connect_object (priv->selection,
"changed",
G_CALLBACK (sp_visualizer_view_selection_changed),
G_CALLBACK (sysprof_visualizer_view_selection_changed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->list,
"button-press-event",
G_CALLBACK (sp_visualizer_view_list_button_press_event),
G_CALLBACK (sysprof_visualizer_view_list_button_press_event),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->list,
"button-release-event",
G_CALLBACK (sp_visualizer_view_list_button_release_event),
G_CALLBACK (sysprof_visualizer_view_list_button_release_event),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->list,
"motion-notify-event",
G_CALLBACK (sp_visualizer_view_list_motion_notify_event),
G_CALLBACK (sysprof_visualizer_view_list_motion_notify_event),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->list,
"realize",
G_CALLBACK (sp_visualizer_view_list_realize_after),
G_CALLBACK (sysprof_visualizer_view_list_realize_after),
self,
G_CONNECT_SWAPPED | G_CONNECT_AFTER);
g_signal_connect_object (priv->list,
"add",
G_CALLBACK (sp_visualizer_view_row_added),
G_CALLBACK (sysprof_visualizer_view_row_added),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (priv->list,
"remove",
G_CALLBACK (sp_visualizer_view_row_removed),
G_CALLBACK (sysprof_visualizer_view_row_removed),
self,
G_CONNECT_SWAPPED);
@ -595,69 +595,69 @@ sp_visualizer_view_init (SpVisualizerView *self)
g_signal_connect_object (hadjustment,
"value-changed",
G_CALLBACK (sp_visualizer_view_hadjustment_value_changed),
G_CALLBACK (sysprof_visualizer_view_hadjustment_value_changed),
self,
G_CONNECT_SWAPPED);
}
/**
* sp_visualizer_view_get_reader:
* sysprof_visualizer_view_get_reader:
*
* Returns: (transfer none): An #SpCaptureReader
* Returns: (transfer none): An #SysprofCaptureReader
*/
SpCaptureReader *
sp_visualizer_view_get_reader (SpVisualizerView *self)
SysprofCaptureReader *
sysprof_visualizer_view_get_reader (SysprofVisualizerView *self)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_VIEW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_VIEW (self), NULL);
return priv->reader;
}
void
sp_visualizer_view_set_reader (SpVisualizerView *self,
SpCaptureReader *reader)
sysprof_visualizer_view_set_reader (SysprofVisualizerView *self,
SysprofCaptureReader *reader)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_VIEW (self));
g_return_if_fail (SYSPROF_IS_VISUALIZER_VIEW (self));
if (priv->reader != reader)
{
g_clear_pointer (&priv->reader, sp_capture_reader_unref);
g_clear_pointer (&priv->reader, sysprof_capture_reader_unref);
if (reader != NULL)
{
gint64 begin_time;
priv->reader = sp_capture_reader_ref (reader);
priv->reader = sysprof_capture_reader_ref (reader);
begin_time = sp_capture_reader_get_start_time (priv->reader);
begin_time = sysprof_capture_reader_get_start_time (priv->reader);
sp_visualizer_ticks_set_epoch (priv->ticks, begin_time);
sp_visualizer_ticks_set_time_range (priv->ticks, begin_time, begin_time);
sysprof_visualizer_ticks_set_epoch (priv->ticks, begin_time);
sysprof_visualizer_ticks_set_time_range (priv->ticks, begin_time, begin_time);
sp_selection_unselect_all (priv->selection);
sysprof_selection_unselect_all (priv->selection);
}
sp_visualizer_list_set_reader (priv->list, reader);
sp_visualizer_view_update_ticks (self);
sysprof_visualizer_list_set_reader (priv->list, reader);
sysprof_visualizer_view_update_ticks (self);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_READER]);
}
}
static void
sp_visualizer_view_add_child (GtkBuildable *buildable,
sysprof_visualizer_view_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *type)
{
SpVisualizerView *self = (SpVisualizerView *)buildable;
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerView *self = (SysprofVisualizerView *)buildable;
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (GTK_IS_BUILDER (builder));
g_assert (G_IS_OBJECT (child));
@ -674,50 +674,50 @@ static void
buildable_iface_init (GtkBuildableIface *iface)
{
parent_buildable = g_type_interface_peek_parent (iface);
iface->add_child = sp_visualizer_view_add_child;
iface->add_child = sysprof_visualizer_view_add_child;
}
static void
sp_visualizer_view_zoom_manager_notify_zoom (SpVisualizerView *self,
sysprof_visualizer_view_zoom_manager_notify_zoom (SysprofVisualizerView *self,
GParamSpec *pspec,
SpZoomManager *zoom_manager)
SysprofZoomManager *zoom_manager)
{
g_assert (SP_IS_VISUALIZER_VIEW (self));
g_assert (SP_IS_ZOOM_MANAGER (zoom_manager));
g_assert (SYSPROF_IS_VISUALIZER_VIEW (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (zoom_manager));
sp_visualizer_view_update_ticks (self);
sysprof_visualizer_view_update_ticks (self);
}
/**
* sp_visualizer_view_get_zoom_manager:
* sysprof_visualizer_view_get_zoom_manager:
*
* Returns: (transfer none) (nullable): An #SpZoomManager or %NULL
* Returns: (transfer none) (nullable): An #SysprofZoomManager or %NULL
*/
SpZoomManager *
sp_visualizer_view_get_zoom_manager (SpVisualizerView *self)
SysprofZoomManager *
sysprof_visualizer_view_get_zoom_manager (SysprofVisualizerView *self)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_VIEW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_VIEW (self), NULL);
return priv->zoom_manager;
}
void
sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
SpZoomManager *zoom_manager)
sysprof_visualizer_view_set_zoom_manager (SysprofVisualizerView *self,
SysprofZoomManager *zoom_manager)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_return_if_fail (SP_IS_VISUALIZER_VIEW (self));
g_return_if_fail (!zoom_manager || SP_IS_ZOOM_MANAGER (zoom_manager));
g_return_if_fail (SYSPROF_IS_VISUALIZER_VIEW (self));
g_return_if_fail (!zoom_manager || SYSPROF_IS_ZOOM_MANAGER (zoom_manager));
if (priv->zoom_manager != zoom_manager)
{
if (priv->zoom_manager != NULL)
{
g_signal_handlers_disconnect_by_func (priv->zoom_manager,
G_CALLBACK (sp_visualizer_view_zoom_manager_notify_zoom),
G_CALLBACK (sysprof_visualizer_view_zoom_manager_notify_zoom),
self);
g_clear_object (&priv->zoom_manager);
}
@ -727,12 +727,12 @@ sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
priv->zoom_manager = g_object_ref (zoom_manager);
g_signal_connect_object (priv->zoom_manager,
"notify::zoom",
G_CALLBACK (sp_visualizer_view_zoom_manager_notify_zoom),
G_CALLBACK (sysprof_visualizer_view_zoom_manager_notify_zoom),
self,
G_CONNECT_SWAPPED);
}
sp_visualizer_list_set_zoom_manager (priv->list, zoom_manager);
sysprof_visualizer_list_set_zoom_manager (priv->list, zoom_manager);
gtk_widget_queue_resize (GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ZOOM_MANAGER]);
@ -740,19 +740,19 @@ sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
}
/**
* sp_visualizer_view_get_selection:
* sysprof_visualizer_view_get_selection:
*
* Gets the #SpSelection instance for the visualizer view.
* Gets the #SysprofSelection instance for the visualizer view.
* This can be used to alter the selection or selections of the visualizers.
*
* Returns: (transfer none): An #SpSelection.
* Returns: (transfer none): An #SysprofSelection.
*/
SpSelection *
sp_visualizer_view_get_selection (SpVisualizerView *self)
SysprofSelection *
sysprof_visualizer_view_get_selection (SysprofVisualizerView *self)
{
SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
SysprofVisualizerViewPrivate *priv = sysprof_visualizer_view_get_instance_private (self);
g_return_val_if_fail (SP_IS_VISUALIZER_VIEW (self), NULL);
g_return_val_if_fail (SYSPROF_IS_VISUALIZER_VIEW (self), NULL);
return priv->selection;
}

View File

@ -1,4 +1,4 @@
/* sp-visualizer-view.h
/* sysprof-visualizer-view.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -23,26 +23,26 @@
#include <gtk/gtk.h>
#include <sysprof.h>
#include "sp-visualizer-row.h"
#include "sp-selection.h"
#include "sp-zoom-manager.h"
#include "sysprof-visualizer-row.h"
#include "sysprof-selection.h"
#include "sysprof-zoom-manager.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_VISUALIZER_VIEW (sp_visualizer_view_get_type())
#define SYSPROF_TYPE_VISUALIZER_VIEW (sysprof_visualizer_view_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpVisualizerView, sp_visualizer_view, SP, VISUALIZER_VIEW, GtkBin)
G_DECLARE_DERIVABLE_TYPE (SysprofVisualizerView, sysprof_visualizer_view, SYSPROF, VISUALIZER_VIEW, GtkBin)
struct _SpVisualizerViewClass
struct _SysprofVisualizerViewClass
{
GtkBinClass parent_class;
void (*visualizer_added) (SpVisualizerView *self,
SpVisualizerRow *visualizer);
void (*visualizer_removed) (SpVisualizerView *self,
SpVisualizerRow *visualizer);
void (*visualizer_added) (SysprofVisualizerView *self,
SysprofVisualizerRow *visualizer);
void (*visualizer_removed) (SysprofVisualizerView *self,
SysprofVisualizerRow *visualizer);
gpointer _reserved1;
gpointer _reserved2;
@ -63,18 +63,18 @@ struct _SpVisualizerViewClass
};
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sp_visualizer_view_new (void);
GtkWidget *sysprof_visualizer_view_new (void);
SYSPROF_AVAILABLE_IN_ALL
SpCaptureReader *sp_visualizer_view_get_reader (SpVisualizerView *self);
SysprofCaptureReader *sysprof_visualizer_view_get_reader (SysprofVisualizerView *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_visualizer_view_set_reader (SpVisualizerView *self,
SpCaptureReader *reader);
void sysprof_visualizer_view_set_reader (SysprofVisualizerView *self,
SysprofCaptureReader *reader);
SYSPROF_AVAILABLE_IN_ALL
SpZoomManager *sp_visualizer_view_get_zoom_manager (SpVisualizerView *self);
SysprofZoomManager *sysprof_visualizer_view_get_zoom_manager (SysprofVisualizerView *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_visualizer_view_set_zoom_manager (SpVisualizerView *self,
SpZoomManager *zoom_manager);
void sysprof_visualizer_view_set_zoom_manager (SysprofVisualizerView *self,
SysprofZoomManager *zoom_manager);
SYSPROF_AVAILABLE_IN_ALL
SpSelection *sp_visualizer_view_get_selection (SpVisualizerView *self);
SysprofSelection *sysprof_visualizer_view_get_selection (SysprofVisualizerView *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-zoom-manager.c
/* sysprof-zoom-manager.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-zoom-manager"
#define G_LOG_DOMAIN "sysprof-zoom-manager"
#include "config.h"
#include <glib/gi18n.h>
#include <gio/gio.h>
#include "sp-zoom-manager.h"
#include "sysprof-zoom-manager.h"
struct _SpZoomManager
struct _SysprofZoomManager
{
GObject parent_instance;
@ -50,7 +50,7 @@ enum {
static void action_group_iface_init (GActionGroupInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpZoomManager, sp_zoom_manager, G_TYPE_OBJECT, 0,
G_DEFINE_TYPE_EXTENDED (SysprofZoomManager, sysprof_zoom_manager, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, action_group_iface_init))
static GParamSpec *properties [N_PROPS];
@ -77,63 +77,63 @@ static gdouble zoom_levels[] = {
};
static void
sp_zoom_manager_zoom_in_action (GSimpleAction *action,
sysprof_zoom_manager_zoom_in_action (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
SpZoomManager *self = user_data;
g_assert (SP_IS_ZOOM_MANAGER (self));
sp_zoom_manager_zoom_in (self);
SysprofZoomManager *self = user_data;
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
sysprof_zoom_manager_zoom_in (self);
}
static void
sp_zoom_manager_zoom_out_action (GSimpleAction *action,
sysprof_zoom_manager_zoom_out_action (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
SpZoomManager *self = user_data;
g_assert (SP_IS_ZOOM_MANAGER (self));
sp_zoom_manager_zoom_out (self);
SysprofZoomManager *self = user_data;
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
sysprof_zoom_manager_zoom_out (self);
}
static void
sp_zoom_manager_zoom_one_action (GSimpleAction *action,
sysprof_zoom_manager_zoom_one_action (GSimpleAction *action,
GVariant *param,
gpointer user_data)
{
SpZoomManager *self = user_data;
g_assert (SP_IS_ZOOM_MANAGER (self));
sp_zoom_manager_reset (self);
SysprofZoomManager *self = user_data;
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
sysprof_zoom_manager_reset (self);
}
static void
sp_zoom_manager_get_property (GObject *object,
sysprof_zoom_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpZoomManager *self = SP_ZOOM_MANAGER (object);
SysprofZoomManager *self = SYSPROF_ZOOM_MANAGER (object);
switch (prop_id)
{
case PROP_MIN_ZOOM:
g_value_set_double (value, sp_zoom_manager_get_min_zoom (self));
g_value_set_double (value, sysprof_zoom_manager_get_min_zoom (self));
break;
case PROP_MAX_ZOOM:
g_value_set_double (value, sp_zoom_manager_get_max_zoom (self));
g_value_set_double (value, sysprof_zoom_manager_get_max_zoom (self));
break;
case PROP_ZOOM:
g_value_set_double (value, sp_zoom_manager_get_zoom (self));
g_value_set_double (value, sysprof_zoom_manager_get_zoom (self));
break;
case PROP_CAN_ZOOM_IN:
g_value_set_boolean (value, sp_zoom_manager_get_can_zoom_in (self));
g_value_set_boolean (value, sysprof_zoom_manager_get_can_zoom_in (self));
break;
case PROP_CAN_ZOOM_OUT:
g_value_set_boolean (value, sp_zoom_manager_get_can_zoom_out (self));
g_value_set_boolean (value, sysprof_zoom_manager_get_can_zoom_out (self));
break;
default:
@ -142,25 +142,25 @@ sp_zoom_manager_get_property (GObject *object,
}
static void
sp_zoom_manager_set_property (GObject *object,
sysprof_zoom_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpZoomManager *self = SP_ZOOM_MANAGER (object);
SysprofZoomManager *self = SYSPROF_ZOOM_MANAGER (object);
switch (prop_id)
{
case PROP_MIN_ZOOM:
sp_zoom_manager_set_min_zoom (self, g_value_get_double (value));
sysprof_zoom_manager_set_min_zoom (self, g_value_get_double (value));
break;
case PROP_MAX_ZOOM:
sp_zoom_manager_set_max_zoom (self, g_value_get_double (value));
sysprof_zoom_manager_set_max_zoom (self, g_value_get_double (value));
break;
case PROP_ZOOM:
sp_zoom_manager_set_zoom (self, g_value_get_double (value));
sysprof_zoom_manager_set_zoom (self, g_value_get_double (value));
break;
default:
@ -169,12 +169,12 @@ sp_zoom_manager_set_property (GObject *object,
}
static void
sp_zoom_manager_class_init (SpZoomManagerClass *klass)
sysprof_zoom_manager_class_init (SysprofZoomManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = sp_zoom_manager_get_property;
object_class->set_property = sp_zoom_manager_set_property;
object_class->get_property = sysprof_zoom_manager_get_property;
object_class->set_property = sysprof_zoom_manager_set_property;
properties [PROP_CAN_ZOOM_IN] =
g_param_spec_boolean ("can-zoom-in",
@ -221,12 +221,12 @@ sp_zoom_manager_class_init (SpZoomManagerClass *klass)
}
static void
sp_zoom_manager_init (SpZoomManager *self)
sysprof_zoom_manager_init (SysprofZoomManager *self)
{
static const GActionEntry entries[] = {
{ "zoom-in", sp_zoom_manager_zoom_in_action },
{ "zoom-out", sp_zoom_manager_zoom_out_action },
{ "zoom-one", sp_zoom_manager_zoom_one_action },
{ "zoom-in", sysprof_zoom_manager_zoom_in_action },
{ "zoom-out", sysprof_zoom_manager_zoom_out_action },
{ "zoom-one", sysprof_zoom_manager_zoom_one_action },
};
GAction *action;
@ -247,49 +247,49 @@ sp_zoom_manager_init (SpZoomManager *self)
g_object_bind_property (self, "can-zoom-out", action, "enabled", G_BINDING_SYNC_CREATE);
}
SpZoomManager *
sp_zoom_manager_new (void)
SysprofZoomManager *
sysprof_zoom_manager_new (void)
{
return g_object_new (SP_TYPE_ZOOM_MANAGER, NULL);
return g_object_new (SYSPROF_TYPE_ZOOM_MANAGER, NULL);
}
gboolean
sp_zoom_manager_get_can_zoom_in (SpZoomManager *self)
sysprof_zoom_manager_get_can_zoom_in (SysprofZoomManager *self)
{
g_return_val_if_fail (SP_IS_ZOOM_MANAGER (self), FALSE);
g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), FALSE);
return self->max_zoom == 0.0 || self->zoom < self->max_zoom;
}
gboolean
sp_zoom_manager_get_can_zoom_out (SpZoomManager *self)
sysprof_zoom_manager_get_can_zoom_out (SysprofZoomManager *self)
{
g_return_val_if_fail (SP_IS_ZOOM_MANAGER (self), FALSE);
g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), FALSE);
return self->min_zoom == 0.0 || self->zoom > self->min_zoom;
}
gboolean
sp_zoom_manager_get_min_zoom (SpZoomManager *self)
sysprof_zoom_manager_get_min_zoom (SysprofZoomManager *self)
{
g_return_val_if_fail (SP_IS_ZOOM_MANAGER (self), FALSE);
g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), FALSE);
return self->min_zoom;
}
gboolean
sp_zoom_manager_get_max_zoom (SpZoomManager *self)
sysprof_zoom_manager_get_max_zoom (SysprofZoomManager *self)
{
g_return_val_if_fail (SP_IS_ZOOM_MANAGER (self), FALSE);
g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), FALSE);
return self->max_zoom;
}
void
sp_zoom_manager_set_min_zoom (SpZoomManager *self,
sysprof_zoom_manager_set_min_zoom (SysprofZoomManager *self,
gdouble min_zoom)
{
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
if (min_zoom != self->min_zoom)
{
@ -300,10 +300,10 @@ sp_zoom_manager_set_min_zoom (SpZoomManager *self,
}
void
sp_zoom_manager_set_max_zoom (SpZoomManager *self,
sysprof_zoom_manager_set_max_zoom (SysprofZoomManager *self,
gdouble max_zoom)
{
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
if (max_zoom != self->max_zoom)
{
@ -314,13 +314,13 @@ sp_zoom_manager_set_max_zoom (SpZoomManager *self,
}
void
sp_zoom_manager_zoom_in (SpZoomManager *self)
sysprof_zoom_manager_zoom_in (SysprofZoomManager *self)
{
gdouble zoom;
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
if (!sp_zoom_manager_get_can_zoom_in (self))
if (!sysprof_zoom_manager_get_can_zoom_in (self))
return;
zoom = self->zoom;
@ -337,17 +337,17 @@ sp_zoom_manager_zoom_in (SpZoomManager *self)
if (zoom == self->zoom)
zoom *= 2;
sp_zoom_manager_set_zoom (self, zoom);
sysprof_zoom_manager_set_zoom (self, zoom);
}
void
sp_zoom_manager_zoom_out (SpZoomManager *self)
sysprof_zoom_manager_zoom_out (SysprofZoomManager *self)
{
gdouble zoom;
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
if (!sp_zoom_manager_get_can_zoom_out (self))
if (!sysprof_zoom_manager_get_can_zoom_out (self))
return;
zoom = self->zoom;
@ -364,33 +364,33 @@ sp_zoom_manager_zoom_out (SpZoomManager *self)
if (zoom == self->zoom)
zoom /= 2.0;
sp_zoom_manager_set_zoom (self, zoom);
sysprof_zoom_manager_set_zoom (self, zoom);
}
void
sp_zoom_manager_reset (SpZoomManager *self)
sysprof_zoom_manager_reset (SysprofZoomManager *self)
{
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
sp_zoom_manager_set_zoom (self, 1.0);
sysprof_zoom_manager_set_zoom (self, 1.0);
}
gdouble
sp_zoom_manager_get_zoom (SpZoomManager *self)
sysprof_zoom_manager_get_zoom (SysprofZoomManager *self)
{
g_return_val_if_fail (SP_IS_ZOOM_MANAGER (self), 0.0);
g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), 0.0);
return self->zoom;
}
void
sp_zoom_manager_set_zoom (SpZoomManager *self,
sysprof_zoom_manager_set_zoom (SysprofZoomManager *self,
gdouble zoom)
{
gdouble min_zoom;
gdouble max_zoom;
g_return_if_fail (SP_IS_ZOOM_MANAGER (self));
g_return_if_fail (SYSPROF_IS_ZOOM_MANAGER (self));
min_zoom = (self->min_zoom == 0.0) ? -G_MAXDOUBLE : self->min_zoom;
max_zoom = (self->max_zoom == 0.0) ? G_MAXDOUBLE : self->max_zoom;
@ -410,17 +410,17 @@ sp_zoom_manager_set_zoom (SpZoomManager *self,
}
static gchar **
sp_zoom_manager_list_actions (GActionGroup *action_group)
sysprof_zoom_manager_list_actions (GActionGroup *action_group)
{
SpZoomManager *self = (SpZoomManager *)action_group;
SysprofZoomManager *self = (SysprofZoomManager *)action_group;
g_assert (SP_IS_ZOOM_MANAGER (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
return g_action_group_list_actions (G_ACTION_GROUP (self->actions));
}
static gboolean
sp_zoom_manager_query_action (GActionGroup *action_group,
sysprof_zoom_manager_query_action (GActionGroup *action_group,
const gchar *action_name,
gboolean *enabled,
const GVariantType **parameter_type,
@ -428,9 +428,9 @@ sp_zoom_manager_query_action (GActionGroup *action_group,
GVariant **state_hint,
GVariant **state)
{
SpZoomManager *self = (SpZoomManager *)action_group;
SysprofZoomManager *self = (SysprofZoomManager *)action_group;
g_assert (SP_IS_ZOOM_MANAGER (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
g_assert (action_name != NULL);
return g_action_group_query_action (G_ACTION_GROUP (self->actions),
@ -443,26 +443,26 @@ sp_zoom_manager_query_action (GActionGroup *action_group,
}
static void
sp_zoom_manager_change_action_state (GActionGroup *action_group,
sysprof_zoom_manager_change_action_state (GActionGroup *action_group,
const gchar *action_name,
GVariant *value)
{
SpZoomManager *self = (SpZoomManager *)action_group;
SysprofZoomManager *self = (SysprofZoomManager *)action_group;
g_assert (SP_IS_ZOOM_MANAGER (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
g_assert (action_name != NULL);
g_action_group_change_action_state (G_ACTION_GROUP (self->actions), action_name, value);
}
static void
sp_zoom_manager_activate_action (GActionGroup *action_group,
sysprof_zoom_manager_activate_action (GActionGroup *action_group,
const gchar *action_name,
GVariant *parameter)
{
SpZoomManager *self = (SpZoomManager *)action_group;
SysprofZoomManager *self = (SysprofZoomManager *)action_group;
g_assert (SP_IS_ZOOM_MANAGER (self));
g_assert (SYSPROF_IS_ZOOM_MANAGER (self));
g_assert (action_name != NULL);
g_action_group_activate_action (G_ACTION_GROUP (self->actions), action_name, parameter);
@ -471,8 +471,8 @@ sp_zoom_manager_activate_action (GActionGroup *action_group,
static void
action_group_iface_init (GActionGroupInterface *iface)
{
iface->list_actions = sp_zoom_manager_list_actions;
iface->query_action = sp_zoom_manager_query_action;
iface->change_action_state = sp_zoom_manager_change_action_state;
iface->activate_action = sp_zoom_manager_activate_action;
iface->list_actions = sysprof_zoom_manager_list_actions;
iface->query_action = sysprof_zoom_manager_query_action;
iface->change_action_state = sysprof_zoom_manager_change_action_state;
iface->activate_action = sysprof_zoom_manager_activate_action;
}

View File

@ -1,4 +1,4 @@
/* sp-zoom-manager.h
/* sysprof-zoom-manager.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -26,37 +26,37 @@
G_BEGIN_DECLS
#define SP_TYPE_ZOOM_MANAGER (sp_zoom_manager_get_type())
#define SYSPROF_TYPE_ZOOM_MANAGER (sysprof_zoom_manager_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpZoomManager, sp_zoom_manager, SP, ZOOM_MANAGER, GObject)
G_DECLARE_FINAL_TYPE (SysprofZoomManager, sysprof_zoom_manager, SYSPROF, ZOOM_MANAGER, GObject)
SYSPROF_AVAILABLE_IN_ALL
SpZoomManager *sp_zoom_manager_new (void);
SysprofZoomManager *sysprof_zoom_manager_new (void);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_zoom_manager_get_can_zoom_in (SpZoomManager *self);
gboolean sysprof_zoom_manager_get_can_zoom_in (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_zoom_manager_get_can_zoom_out (SpZoomManager *self);
gboolean sysprof_zoom_manager_get_can_zoom_out (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_zoom_manager_get_min_zoom (SpZoomManager *self);
gboolean sysprof_zoom_manager_get_min_zoom (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_zoom_manager_get_max_zoom (SpZoomManager *self);
gboolean sysprof_zoom_manager_get_max_zoom (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_set_min_zoom (SpZoomManager *self,
void sysprof_zoom_manager_set_min_zoom (SysprofZoomManager *self,
gdouble min_zoom);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_set_max_zoom (SpZoomManager *self,
void sysprof_zoom_manager_set_max_zoom (SysprofZoomManager *self,
gdouble max_zoom);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_zoom_in (SpZoomManager *self);
void sysprof_zoom_manager_zoom_in (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_zoom_out (SpZoomManager *self);
void sysprof_zoom_manager_zoom_out (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_reset (SpZoomManager *self);
void sysprof_zoom_manager_reset (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
gdouble sp_zoom_manager_get_zoom (SpZoomManager *self);
gdouble sysprof_zoom_manager_get_zoom (SysprofZoomManager *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_zoom_manager_set_zoom (SpZoomManager *self,
void sysprof_zoom_manager_set_zoom (SysprofZoomManager *self,
gdouble zoom);
G_END_DECLS

View File

@ -37,7 +37,7 @@
#include "binfile.h"
#include "elfparser.h"
#include "sp-symbol-dirs.h"
#include "sysprof-symbol-dirs.h"
struct bin_file_t
{
@ -173,7 +173,7 @@ get_debuglink_file (ElfParser *elf,
dir = g_path_get_dirname (filename);
tries = sp_symbol_dirs_get_paths (dir, basename);
tries = sysprof_symbol_dirs_get_paths (dir, basename);
for (i = 0; tries[i]; i++)
{

View File

@ -1,45 +1,45 @@
libsysprof_c_args = [ '-DSYSPROF_COMPILATION' ]
libsysprof_public_sources = [
'sp-callgraph-profile.c',
'sp-capture-gobject.c',
'sp-elf-symbol-resolver.c',
'sp-hostinfo-source.c',
'sp-jitmap-symbol-resolver.c',
'sp-kallsyms.c',
'sp-kernel-symbol.c',
'sp-kernel-symbol-resolver.c',
'sp-local-profiler.c',
'sp-map-lookaside.c',
'sp-process-model.c',
'sp-process-model-item.c',
'sp-profile.c',
'sp-profiler.c',
'sp-selection.c',
'sp-source.c',
'sp-symbol-dirs.c',
'sp-symbol-resolver.c',
'sysprof-callgraph-profile.c',
'sysprof-capture-gobject.c',
'sysprof-elf-symbol-resolver.c',
'sysprof-hostinfo-source.c',
'sysprof-jitmap-symbol-resolver.c',
'sysprof-kallsyms.c',
'sysprof-kernel-symbol.c',
'sysprof-kernel-symbol-resolver.c',
'sysprof-local-profiler.c',
'sysprof-map-lookaside.c',
'sysprof-process-model.c',
'sysprof-process-model-item.c',
'sysprof-profile.c',
'sysprof-profiler.c',
'sysprof-selection.c',
'sysprof-source.c',
'sysprof-symbol-dirs.c',
'sysprof-symbol-resolver.c',
]
libsysprof_public_headers = [
'sp-callgraph-profile.h',
'sp-capture-gobject.h',
'sp-elf-symbol-resolver.h',
'sp-hostinfo-source.h',
'sp-jitmap-symbol-resolver.h',
'sp-kallsyms.h',
'sp-kernel-symbol.h',
'sp-kernel-symbol-resolver.h',
'sp-local-profiler.h',
'sp-map-lookaside.h',
'sp-process-model.h',
'sp-process-model-item.h',
'sp-profile.h',
'sp-profiler.h',
'sp-selection.h',
'sp-source.h',
'sp-symbol-dirs.h',
'sp-symbol-resolver.h',
'sysprof-callgraph-profile.h',
'sysprof-capture-gobject.h',
'sysprof-elf-symbol-resolver.h',
'sysprof-hostinfo-source.h',
'sysprof-jitmap-symbol-resolver.h',
'sysprof-kallsyms.h',
'sysprof-kernel-symbol.h',
'sysprof-kernel-symbol-resolver.h',
'sysprof-local-profiler.h',
'sysprof-map-lookaside.h',
'sysprof-process-model.h',
'sysprof-process-model-item.h',
'sysprof-profile.h',
'sysprof-profiler.h',
'sysprof-selection.h',
'sysprof-source.h',
'sysprof-symbol-dirs.h',
'sysprof-symbol-resolver.h',
'sysprof.h',
]
@ -48,8 +48,8 @@ libsysprof_private_sources = [
'binfile.c',
'demangle.cpp',
'elfparser.c',
'sp-source-util.c',
'sp-line-reader.c',
'sysprof-source-util.c',
'sysprof-line-reader.c',
]
libsysprof_public_sources += libsysprof_capture_sources
@ -62,19 +62,19 @@ libsysprof_deps = [
if host_machine.system() == 'linux'
libsysprof_public_sources += [
'sp-gjs-source.c',
'sp-memory-source.c',
'sp-perf-counter.c',
'sp-perf-source.c',
'sp-proc-source.c',
'sysprof-gjs-source.c',
'sysprof-memory-source.c',
'sysprof-perf-counter.c',
'sysprof-perf-source.c',
'sysprof-proc-source.c',
]
libsysprof_public_headers += [
'sp-gjs-source.h',
'sp-memory-source.h',
'sp-perf-counter.h',
'sp-perf-source.h',
'sp-proc-source.h',
'sysprof-gjs-source.h',
'sysprof-memory-source.h',
'sysprof-perf-counter.h',
'sysprof-perf-source.h',
'sysprof-proc-source.h',
]
endif

View File

@ -1,125 +0,0 @@
/* sp-jitmap-symbol-resolver.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "sp-kernel-symbol.h"
#include "sp-jitmap-symbol-resolver.h"
struct _SpJitmapSymbolResolver
{
GObject parent_instance;
GHashTable *jitmap;
};
static void symbol_resolver_iface_init (SpSymbolResolverInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpJitmapSymbolResolver,
sp_jitmap_symbol_resolver,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (SP_TYPE_SYMBOL_RESOLVER,
symbol_resolver_iface_init))
static void
sp_jitmap_symbol_resolver_finalize (GObject *object)
{
SpJitmapSymbolResolver *self = (SpJitmapSymbolResolver *)object;
g_clear_pointer (&self->jitmap, g_hash_table_unref);
G_OBJECT_CLASS (sp_jitmap_symbol_resolver_parent_class)->finalize (object);
}
static void
sp_jitmap_symbol_resolver_class_init (SpJitmapSymbolResolverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_jitmap_symbol_resolver_finalize;
}
static void
sp_jitmap_symbol_resolver_init (SpJitmapSymbolResolver *self)
{
self->jitmap = g_hash_table_new_full (NULL, NULL, NULL, g_free);
}
static void
sp_jitmap_symbol_resolver_load (SpSymbolResolver *resolver,
SpCaptureReader *reader)
{
SpJitmapSymbolResolver *self = (SpJitmapSymbolResolver *)resolver;
SpCaptureFrameType type;
g_assert (SP_IS_JITMAP_SYMBOL_RESOLVER (self));
g_assert (reader != NULL);
while (sp_capture_reader_peek_type (reader, &type))
{
g_autoptr(GHashTable) jitmap = NULL;
GHashTableIter iter;
SpCaptureAddress addr;
const gchar *str;
if (type != SP_CAPTURE_FRAME_JITMAP)
{
if (!sp_capture_reader_skip (reader))
return;
continue;
}
if (!(jitmap = sp_capture_reader_read_jitmap (reader)))
return;
g_hash_table_iter_init (&iter, jitmap);
while (g_hash_table_iter_next (&iter, (gpointer *)&addr, (gpointer *)&str))
g_hash_table_insert (self->jitmap, GSIZE_TO_POINTER (addr), g_strdup (str));
}
}
static gchar *
sp_jitmap_symbol_resolver_resolve (SpSymbolResolver *resolver,
guint64 time,
GPid pid,
SpCaptureAddress address,
GQuark *tag)
{
SpJitmapSymbolResolver *self = (SpJitmapSymbolResolver *)resolver;
g_assert (SP_IS_JITMAP_SYMBOL_RESOLVER (self));
*tag = 0;
return g_strdup (g_hash_table_lookup (self->jitmap, GSIZE_TO_POINTER (address)));
}
static void
symbol_resolver_iface_init (SpSymbolResolverInterface *iface)
{
iface->load = sp_jitmap_symbol_resolver_load;
iface->resolve = sp_jitmap_symbol_resolver_resolve;
}
SpSymbolResolver *
sp_jitmap_symbol_resolver_new (void)
{
return g_object_new (SP_TYPE_JITMAP_SYMBOL_RESOLVER, NULL);
}

View File

@ -1,184 +0,0 @@
/* sp-profiler.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include "sysprof-version-macros.h"
#include "sp-capture-writer.h"
#include "sp-source.h"
G_BEGIN_DECLS
#define SP_TYPE_PROFILER (sp_profiler_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (SpProfiler, sp_profiler, SP, PROFILER, GObject)
struct _SpProfilerInterface
{
GTypeInterface parent_interface;
/**
* SpProfiler::failed:
* @self: A #SpProfiler
* @reason: A #GError representing the reason for the failure
*
* This signal is emitted if the profiler failed. Note that
* #SpProfiler::stopped will also be emitted, but does not allow for
* receiving the error condition.
*/
void (*failed) (SpProfiler *self,
const GError *error);
/**
* SpProfiler::stopped:
* @self: A #SpProfiler
*
* This signal is emitted when a profiler is stopped. It will always be
* emitted after a sp_profiler_start() has been called, either after
* completion of sp_profiler_stop() or after a failure or after asynchronous
* completion of stopping.
*/
void (*stopped) (SpProfiler *self);
/**
* SpProfiler::add_source:
*
* Adds a source to the profiler.
*/
void (*add_source) (SpProfiler *profiler,
SpSource *source);
/**
* SpProfiler::set_writer:
*
* Sets the writer to use for the profiler.
*/
void (*set_writer) (SpProfiler *self,
SpCaptureWriter *writer);
/**
* SpProfiler::get_writer:
*
* Gets the writer that is being used to capture.
*
* Returns: (nullable) (transfer none): A #SpCaptureWriter.
*/
SpCaptureWriter *(*get_writer) (SpProfiler *self);
/**
* SpProfiler::start:
*
* Starts the profiler.
*/
void (*start) (SpProfiler *self);
/**
* SpProfiler::stop:
*
* Stops the profiler.
*/
void (*stop) (SpProfiler *self);
/**
* SpProfiler::add_pid:
*
* Add a pid to be profiled.
*/
void (*add_pid) (SpProfiler *self,
GPid pid);
/**
* SpProfiler::remove_pid:
*
* Remove a pid from the profiler. This will not be called after
* SpProfiler::start has been called.
*/
void (*remove_pid) (SpProfiler *self,
GPid pid);
/**
* SpProfiler::get_pids:
*
* Gets the pids that are part of this profiling session. If no pids
* have been specified, %NULL is returned.
*
* Returns: (nullable) (transfer none): An array of #GPid, or %NULL.
*/
const GPid *(*get_pids) (SpProfiler *self,
guint *n_pids);
};
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_emit_failed (SpProfiler *self,
const GError *error);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_emit_stopped (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
gdouble sp_profiler_get_elapsed (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_profiler_get_is_mutable (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_profiler_get_spawn_inherit_environ (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_spawn_inherit_environ (SpProfiler *self,
gboolean spawn_inherit_environ);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_profiler_get_whole_system (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_whole_system (SpProfiler *self,
gboolean whole_system);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_profiler_get_spawn (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_spawn (SpProfiler *self,
gboolean spawn);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_spawn_argv (SpProfiler *self,
const gchar * const *spawn_argv);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_spawn_env (SpProfiler *self,
const gchar * const *spawn_env);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_add_source (SpProfiler *self,
SpSource *source);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_set_writer (SpProfiler *self,
SpCaptureWriter *writer);
SYSPROF_AVAILABLE_IN_ALL
SpCaptureWriter *sp_profiler_get_writer (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_profiler_get_is_running (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_start (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_stop (SpProfiler *self);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_add_pid (SpProfiler *self,
GPid pid);
SYSPROF_AVAILABLE_IN_ALL
void sp_profiler_remove_pid (SpProfiler *self,
GPid pid);
SYSPROF_AVAILABLE_IN_ALL
const GPid *sp_profiler_get_pids (SpProfiler *self,
guint *n_pids);
G_END_DECLS

View File

@ -1,132 +0,0 @@
/* sp-source.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <glib-object.h>
#include "sp-capture-writer.h"
G_BEGIN_DECLS
#define SP_TYPE_SOURCE (sp_source_get_type())
G_DECLARE_INTERFACE (SpSource, sp_source, SP, SOURCE, GObject)
struct _SpSourceInterface
{
GTypeInterface parent_iface;
/**
* SpSource::get_is_ready:
* @self: A SpSource.
*
* This function should return %TRUE if the source is ready to start
* profiling. If the source is not ready until after sp_source_start() has
* been called, use sp_source_emit_ready() to notify the profiler that the
* source is ready for profiling.
*
* Returns: %TRUE if the source is ready to start profiling.
*/
gboolean (*get_is_ready) (SpSource *self);
/**
* SpSource::set_writer:
* @self: A #SpSource.
* @writer: A #SpCaptureWriter
*
* Sets the #SpCaptureWriter to use when profiling. @writer is only safe to
* use from the main thread. If you need to capture from a thread, you should
* create a memory-based #SpCaptureWriter and then splice that into this
* writer from the main thread when profiling completes.
*
* See sp_capture_writer_splice() for information on splicing writers.
*/
void (*set_writer) (SpSource *self,
SpCaptureWriter *writer);
/**
* SpSource::prepare:
*
* This function is called before profiling has started. The source should
* prepare any pre-profiling setup here. It may perform this work
* asynchronously, but must g_object_notify() the SpSource::is-ready
* property once that asynchronous work has been performed. Until it
* is ready, #SpSource::is-ready must return FALSE.
*/
void (*prepare) (SpSource *self);
/**
* SpSource::add_pid:
* @self: A #SpSource
* @pid: A pid_t > -1
*
* This function is used to notify the #SpSource that a new process,
* identified by @pid, should be profiled. By default, sources should
* assume all processes, and only restrict to a given set of pids if
* this function is called.
*/
void (*add_pid) (SpSource *self,
GPid pid);
/**
* SpSource::start:
* @self: A #SpSource.
*
* Start profiling as configured.
*
* If a failure occurs while processing, the source should notify the
* profiling session via sp_source_emit_failed() from the main thread.
*/
void (*start) (SpSource *self);
/**
* SpSource::stop:
* @self: A #SpSource.
*
* Stop capturing a profile. The source should immediately stop
* profiling and perform any cleanup tasks required. If doing
* off-main-thread capturing, this is a good time to splice your
* capture into the capture file set with sp_source_set_writer().
*
* If you need to perform asynchronous cleanup, call
* sp_source_emit_finished() once that work has completed. If you do
* not need to perform asynchronous cleanup, call
* sp_source_emit_finished() from this function.
*
* sp_source_emit_finished() must be called from the main-thread.
*/
void (*stop) (SpSource *self);
};
void sp_source_add_pid (SpSource *self,
GPid pid);
void sp_source_emit_ready (SpSource *self);
void sp_source_emit_finished (SpSource *self);
void sp_source_emit_failed (SpSource *self,
const GError *error);
gboolean sp_source_get_is_ready (SpSource *self);
void sp_source_prepare (SpSource *self);
void sp_source_set_writer (SpSource *self,
SpCaptureWriter *writer);
void sp_source_start (SpSource *self);
void sp_source_stop (SpSource *self);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-callgraph-profile.c
/* sysprof-callgraph-profile.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -45,22 +45,22 @@
#include "../stackstash.h"
#include "sp-callgraph-profile.h"
#include "sp-capture-reader.h"
#include "sp-elf-symbol-resolver.h"
#include "sp-jitmap-symbol-resolver.h"
#include "sp-kernel-symbol-resolver.h"
#include "sp-map-lookaside.h"
#include "sp-selection.h"
#include "sysprof-callgraph-profile.h"
#include "sysprof-capture-reader.h"
#include "sysprof-elf-symbol-resolver.h"
#include "sysprof-jitmap-symbol-resolver.h"
#include "sysprof-kernel-symbol-resolver.h"
#include "sysprof-map-lookaside.h"
#include "sysprof-selection.h"
#define CHECK_CANCELLABLE_INTERVAL 100
struct _SpCallgraphProfile
struct _SysprofCallgraphProfile
{
GObject parent_instance;
SpCaptureReader *reader;
SpSelection *selection;
SysprofCaptureReader *reader;
SysprofSelection *selection;
StackStash *stash;
GStringChunk *symbols;
GHashTable *tags;
@ -68,14 +68,14 @@ struct _SpCallgraphProfile
typedef struct
{
SpCaptureReader *reader;
SpSelection *selection;
SysprofCaptureReader *reader;
SysprofSelection *selection;
} Generate;
static void profile_iface_init (SpProfileInterface *iface);
static void profile_iface_init (SysprofProfileInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpCallgraphProfile, sp_callgraph_profile, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SP_TYPE_PROFILE, profile_iface_init))
G_DEFINE_TYPE_EXTENDED (SysprofCallgraphProfile, sysprof_callgraph_profile, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_PROFILE, profile_iface_init))
enum {
PROP_0,
@ -85,41 +85,41 @@ enum {
static GParamSpec *properties [N_PROPS];
SpProfile *
sp_callgraph_profile_new (void)
SysprofProfile *
sysprof_callgraph_profile_new (void)
{
return g_object_new (SP_TYPE_CALLGRAPH_PROFILE, NULL);
return g_object_new (SYSPROF_TYPE_CALLGRAPH_PROFILE, NULL);
}
SpProfile *
sp_callgraph_profile_new_with_selection (SpSelection *selection)
SysprofProfile *
sysprof_callgraph_profile_new_with_selection (SysprofSelection *selection)
{
return g_object_new (SP_TYPE_CALLGRAPH_PROFILE,
return g_object_new (SYSPROF_TYPE_CALLGRAPH_PROFILE,
"selection", selection,
NULL);
}
static void
sp_callgraph_profile_finalize (GObject *object)
sysprof_callgraph_profile_finalize (GObject *object)
{
SpCallgraphProfile *self = (SpCallgraphProfile *)object;
SysprofCallgraphProfile *self = (SysprofCallgraphProfile *)object;
g_clear_pointer (&self->symbols, g_string_chunk_free);
g_clear_pointer (&self->stash, stack_stash_unref);
g_clear_pointer (&self->reader, sp_capture_reader_unref);
g_clear_pointer (&self->reader, sysprof_capture_reader_unref);
g_clear_pointer (&self->tags, g_hash_table_unref);
g_clear_object (&self->selection);
G_OBJECT_CLASS (sp_callgraph_profile_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_callgraph_profile_parent_class)->finalize (object);
}
static void
sp_callgraph_profile_get_property (GObject *object,
sysprof_callgraph_profile_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpCallgraphProfile *self = SP_CALLGRAPH_PROFILE (object);
SysprofCallgraphProfile *self = SYSPROF_CALLGRAPH_PROFILE (object);
switch (prop_id)
{
@ -133,12 +133,12 @@ sp_callgraph_profile_get_property (GObject *object,
}
static void
sp_callgraph_profile_set_property (GObject *object,
sysprof_callgraph_profile_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpCallgraphProfile *self = SP_CALLGRAPH_PROFILE (object);
SysprofCallgraphProfile *self = SYSPROF_CALLGRAPH_PROFILE (object);
switch (prop_id)
{
@ -152,51 +152,51 @@ sp_callgraph_profile_set_property (GObject *object,
}
static void
sp_callgraph_profile_class_init (SpCallgraphProfileClass *klass)
sysprof_callgraph_profile_class_init (SysprofCallgraphProfileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_callgraph_profile_finalize;
object_class->get_property = sp_callgraph_profile_get_property;
object_class->set_property = sp_callgraph_profile_set_property;
object_class->finalize = sysprof_callgraph_profile_finalize;
object_class->get_property = sysprof_callgraph_profile_get_property;
object_class->set_property = sysprof_callgraph_profile_set_property;
properties [PROP_SELECTION] =
g_param_spec_object ("selection",
"Selection",
"The selection for filtering the callgraph",
SP_TYPE_SELECTION,
SYSPROF_TYPE_SELECTION,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
sp_callgraph_profile_init (SpCallgraphProfile *self)
sysprof_callgraph_profile_init (SysprofCallgraphProfile *self)
{
self->symbols = g_string_chunk_new (getpagesize ());
self->tags = g_hash_table_new (g_str_hash, g_str_equal);
}
static void
sp_callgraph_profile_set_reader (SpProfile *profile,
SpCaptureReader *reader)
sysprof_callgraph_profile_set_reader (SysprofProfile *profile,
SysprofCaptureReader *reader)
{
SpCallgraphProfile *self = (SpCallgraphProfile *)profile;
SysprofCallgraphProfile *self = (SysprofCallgraphProfile *)profile;
g_assert (SP_IS_CALLGRAPH_PROFILE (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (self));
g_assert (reader != NULL);
g_clear_pointer (&self->reader, sp_capture_reader_unref);
self->reader = sp_capture_reader_ref (reader);
g_clear_pointer (&self->reader, sysprof_capture_reader_unref);
self->reader = sysprof_capture_reader_ref (reader);
}
static const gchar *
sp_callgraph_profile_intern_string_take (SpCallgraphProfile *self,
sysprof_callgraph_profile_intern_string_take (SysprofCallgraphProfile *self,
gchar *str)
{
const gchar *ret;
g_assert (SP_IS_CALLGRAPH_PROFILE (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (self));
g_assert (str != NULL);
ret = g_string_chunk_insert_const (self->symbols, str);
@ -205,30 +205,30 @@ sp_callgraph_profile_intern_string_take (SpCallgraphProfile *self,
}
static const gchar *
sp_callgraph_profile_intern_string (SpCallgraphProfile *self,
sysprof_callgraph_profile_intern_string (SysprofCallgraphProfile *self,
const gchar *str)
{
g_assert (SP_IS_CALLGRAPH_PROFILE (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (self));
g_assert (str != NULL);
return g_string_chunk_insert_const (self->symbols, str);
}
static void
sp_callgraph_profile_generate_worker (GTask *task,
sysprof_callgraph_profile_generate_worker (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
{
SpCallgraphProfile *self = source_object;
SysprofCallgraphProfile *self = source_object;
Generate *gen = task_data;
SpCaptureReader *reader;
SpSelection *selection;
SysprofCaptureReader *reader;
SysprofSelection *selection;
g_autoptr(GArray) resolved = NULL;
g_autoptr(GHashTable) maps_by_pid = NULL;
g_autoptr(GHashTable) cmdlines = NULL;
g_autoptr(GPtrArray) resolvers = NULL;
SpCaptureFrameType type;
SysprofCaptureFrameType type;
StackStash *stash = NULL;
StackStash *resolved_stash = NULL;
guint count = 0;
@ -241,26 +241,26 @@ sp_callgraph_profile_generate_worker (GTask *task,
reader = gen->reader;
selection = gen->selection;
maps_by_pid = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)sp_map_lookaside_free);
maps_by_pid = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)sysprof_map_lookaside_free);
cmdlines = g_hash_table_new (NULL, NULL);
stash = stack_stash_new (NULL);
resolved_stash = stack_stash_new (NULL);
resolvers = g_ptr_array_new_with_free_func (g_object_unref);
g_ptr_array_add (resolvers, sp_kernel_symbol_resolver_new ());
g_ptr_array_add (resolvers, sp_elf_symbol_resolver_new ());
g_ptr_array_add (resolvers, sp_jitmap_symbol_resolver_new ());
g_ptr_array_add (resolvers, sysprof_kernel_symbol_resolver_new ());
g_ptr_array_add (resolvers, sysprof_elf_symbol_resolver_new ());
g_ptr_array_add (resolvers, sysprof_jitmap_symbol_resolver_new ());
for (guint j = 0; j < resolvers->len; j++)
{
SpSymbolResolver *resolver = g_ptr_array_index (resolvers, j);
SysprofSymbolResolver *resolver = g_ptr_array_index (resolvers, j);
sp_capture_reader_reset (reader);
sp_symbol_resolver_load (resolver, reader);
sysprof_capture_reader_reset (reader);
sysprof_symbol_resolver_load (resolver, reader);
}
sp_capture_reader_reset (reader);
sysprof_capture_reader_reset (reader);
/*
* The resolved pointer array is where we stash the names for the
@ -270,31 +270,31 @@ sp_callgraph_profile_generate_worker (GTask *task,
*/
resolved = g_array_new (FALSE, TRUE, sizeof (guint64));
while (sp_capture_reader_peek_type (reader, &type))
while (sysprof_capture_reader_peek_type (reader, &type))
{
const SpCaptureProcess *pr;
const SysprofCaptureProcess *pr;
const gchar *cmdline;
if (type != SP_CAPTURE_FRAME_PROCESS)
if (type != SYSPROF_CAPTURE_FRAME_PROCESS)
{
if (!sp_capture_reader_skip (reader))
if (!sysprof_capture_reader_skip (reader))
goto failure;
continue;
}
if (NULL == (pr = sp_capture_reader_read_process (reader)))
if (NULL == (pr = sysprof_capture_reader_read_process (reader)))
goto failure;
cmdline = g_strdup_printf ("[%s]", pr->cmdline);
g_hash_table_insert (cmdlines,
GINT_TO_POINTER (pr->frame.pid),
(gchar *)sp_callgraph_profile_intern_string (self, cmdline));
(gchar *)sysprof_callgraph_profile_intern_string (self, cmdline));
}
if (g_task_return_error_if_cancelled (task))
goto cleanup;
sp_capture_reader_reset (reader);
sysprof_capture_reader_reset (reader);
/*
* Walk through all of the sample events and resolve instruction-pointers
@ -302,18 +302,18 @@ sp_callgraph_profile_generate_worker (GTask *task,
* name. If we wanted to support dynamic systems, we'd want to extend this
* to parse information from captured data about the languages jit'd code.
*/
while (sp_capture_reader_peek_type (reader, &type))
while (sysprof_capture_reader_peek_type (reader, &type))
{
SpAddressContext last_context = SP_ADDRESS_CONTEXT_NONE;
const SpCaptureSample *sample;
SysprofAddressContext last_context = SYSPROF_ADDRESS_CONTEXT_NONE;
const SysprofCaptureSample *sample;
StackNode *node;
StackNode *iter;
const gchar *cmdline;
guint len = 5;
if (type != SP_CAPTURE_FRAME_SAMPLE)
if (type != SYSPROF_CAPTURE_FRAME_SAMPLE)
{
if (!sp_capture_reader_skip (reader))
if (!sysprof_capture_reader_skip (reader))
goto failure;
continue;
}
@ -324,10 +324,10 @@ sp_callgraph_profile_generate_worker (GTask *task,
goto cleanup;
}
if (NULL == (sample = sp_capture_reader_read_sample (reader)))
if (NULL == (sample = sysprof_capture_reader_read_sample (reader)))
goto failure;
if (!sp_selection_contains (selection, sample->frame.time))
if (!sysprof_selection_contains (selection, sample->frame.time))
continue;
if (sample->n_addrs == 0)
@ -340,8 +340,8 @@ sp_callgraph_profile_generate_worker (GTask *task,
* untrusted data from capture files, it's not safe to assume. But in
* practice it is.
*/
g_assert (sp_address_is_context_switch (sample->addrs[0], &last_context));
last_context = SP_ADDRESS_CONTEXT_NONE;
g_assert (sysprof_address_is_context_switch (sample->addrs[0], &last_context));
last_context = SYSPROF_ADDRESS_CONTEXT_NONE;
#endif
node = stack_stash_add_trace (stash, (gpointer)sample->addrs, sample->n_addrs, 1);
@ -356,14 +356,14 @@ sp_callgraph_profile_generate_worker (GTask *task,
for (iter = node; iter != NULL; iter = iter->parent)
{
SpAddressContext context = SP_ADDRESS_CONTEXT_NONE;
SpAddress address = iter->data;
SysprofAddressContext context = SYSPROF_ADDRESS_CONTEXT_NONE;
SysprofAddress address = iter->data;
const gchar *symbol = NULL;
if (sp_address_is_context_switch (address, &context))
if (sysprof_address_is_context_switch (address, &context))
{
if (last_context)
symbol = sp_address_context_to_string (last_context);
symbol = sysprof_address_context_to_string (last_context);
else
symbol = NULL;
@ -373,11 +373,11 @@ sp_callgraph_profile_generate_worker (GTask *task,
{
for (guint j = 0; j < resolvers->len; j++)
{
SpSymbolResolver *resolver = g_ptr_array_index (resolvers, j);
SysprofSymbolResolver *resolver = g_ptr_array_index (resolvers, j);
GQuark tag = 0;
gchar *str;
str = sp_symbol_resolver_resolve_with_context (resolver,
str = sysprof_symbol_resolver_resolve_with_context (resolver,
sample->frame.time,
sample->frame.pid,
last_context,
@ -386,7 +386,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
if (str != NULL)
{
symbol = sp_callgraph_profile_intern_string_take (self, str);
symbol = sysprof_callgraph_profile_intern_string_take (self, str);
if (tag != 0)
g_hash_table_insert (self->tags, (gchar *)symbol, GSIZE_TO_POINTER (tag));
break;
@ -395,18 +395,18 @@ sp_callgraph_profile_generate_worker (GTask *task,
}
if (symbol != NULL)
g_array_index (resolved, SpAddress, len++) = POINTER_TO_U64 (symbol);
g_array_index (resolved, SysprofAddress, len++) = POINTER_TO_U64 (symbol);
}
if (last_context && last_context != SP_ADDRESS_CONTEXT_USER)
if (last_context && last_context != SYSPROF_ADDRESS_CONTEXT_USER)
{
/* Kernel threads do not have a user part, so we end up here
* without ever getting a user context. If this happens,
* add the '- - kernel - - ' name, so that kernel threads
* are properly blamed on the kernel
*/
const gchar *name = sp_address_context_to_string (last_context);
g_array_index (resolved, SpAddress, len++) = POINTER_TO_U64 (name);
const gchar *name = sysprof_address_context_to_string (last_context);
g_array_index (resolved, SysprofAddress, len++) = POINTER_TO_U64 (name);
}
if (cmdline != NULL)
@ -438,43 +438,43 @@ cleanup:
static void
generate_free (Generate *generate)
{
sp_capture_reader_unref (generate->reader);
sysprof_capture_reader_unref (generate->reader);
g_clear_object (&generate->selection);
g_slice_free (Generate, generate);
}
static void
sp_callgraph_profile_generate (SpProfile *profile,
sysprof_callgraph_profile_generate (SysprofProfile *profile,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
SpCallgraphProfile *self = (SpCallgraphProfile *)profile;
SysprofCallgraphProfile *self = (SysprofCallgraphProfile *)profile;
Generate *gen;
g_autoptr(GTask) task = NULL;
g_assert (SP_IS_CALLGRAPH_PROFILE (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
gen = g_slice_new0 (Generate);
gen->reader = sp_capture_reader_copy (self->reader);
gen->selection = sp_selection_copy (self->selection);
gen->reader = sysprof_capture_reader_copy (self->reader);
gen->selection = sysprof_selection_copy (self->selection);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_task_data (task, gen, (GDestroyNotify)generate_free);
g_task_run_in_thread (task, sp_callgraph_profile_generate_worker);
g_task_run_in_thread (task, sysprof_callgraph_profile_generate_worker);
}
static gboolean
sp_callgraph_profile_generate_finish (SpProfile *profile,
sysprof_callgraph_profile_generate_finish (SysprofProfile *profile,
GAsyncResult *result,
GError **error)
{
SpCallgraphProfile *self = (SpCallgraphProfile *)profile;
SysprofCallgraphProfile *self = (SysprofCallgraphProfile *)profile;
StackStash *stash;
g_assert (SP_IS_CALLGRAPH_PROFILE (self));
g_assert (SYSPROF_IS_CALLGRAPH_PROFILE (self));
g_assert (G_IS_TASK (result));
stash = g_task_propagate_pointer (G_TASK (result), error);
@ -496,26 +496,26 @@ sp_callgraph_profile_generate_finish (SpProfile *profile,
}
static void
profile_iface_init (SpProfileInterface *iface)
profile_iface_init (SysprofProfileInterface *iface)
{
iface->generate = sp_callgraph_profile_generate;
iface->generate_finish = sp_callgraph_profile_generate_finish;
iface->set_reader = sp_callgraph_profile_set_reader;
iface->generate = sysprof_callgraph_profile_generate;
iface->generate_finish = sysprof_callgraph_profile_generate_finish;
iface->set_reader = sysprof_callgraph_profile_set_reader;
}
gpointer
sp_callgraph_profile_get_stash (SpCallgraphProfile *self)
sysprof_callgraph_profile_get_stash (SysprofCallgraphProfile *self)
{
g_return_val_if_fail (SP_IS_CALLGRAPH_PROFILE (self), NULL);
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_PROFILE (self), NULL);
return self->stash;
}
GQuark
sp_callgraph_profile_get_tag (SpCallgraphProfile *self,
sysprof_callgraph_profile_get_tag (SysprofCallgraphProfile *self,
const gchar *symbol)
{
g_return_val_if_fail (SP_IS_CALLGRAPH_PROFILE (self), 0);
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_PROFILE (self), 0);
return GPOINTER_TO_SIZE (g_hash_table_lookup (self->tags, symbol));
}

View File

@ -1,4 +1,4 @@
/* sp-callgraph-profile.h
/* sysprof-callgraph-profile.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,24 +22,24 @@
#include "sysprof-version-macros.h"
#include "sp-profile.h"
#include "sp-selection.h"
#include "sysprof-profile.h"
#include "sysprof-selection.h"
G_BEGIN_DECLS
#define SP_TYPE_CALLGRAPH_PROFILE (sp_callgraph_profile_get_type())
#define SYSPROF_TYPE_CALLGRAPH_PROFILE (sysprof_callgraph_profile_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpCallgraphProfile, sp_callgraph_profile, SP, CALLGRAPH_PROFILE, GObject)
G_DECLARE_FINAL_TYPE (SysprofCallgraphProfile, sysprof_callgraph_profile, SYSPROF, CALLGRAPH_PROFILE, GObject)
SYSPROF_AVAILABLE_IN_ALL
SpProfile *sp_callgraph_profile_new (void);
SysprofProfile *sysprof_callgraph_profile_new (void);
SYSPROF_AVAILABLE_IN_ALL
SpProfile *sp_callgraph_profile_new_with_selection (SpSelection *selection);
SysprofProfile *sysprof_callgraph_profile_new_with_selection (SysprofSelection *selection);
SYSPROF_AVAILABLE_IN_ALL
gpointer sp_callgraph_profile_get_stash (SpCallgraphProfile *self);
gpointer sysprof_callgraph_profile_get_stash (SysprofCallgraphProfile *self);
SYSPROF_AVAILABLE_IN_ALL
GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self,
GQuark sysprof_callgraph_profile_get_tag (SysprofCallgraphProfile *self,
const gchar *symbol);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-capture-gobject.c
/* sysprof-capture-gobject.c
*
* Copyright 2019 Christian Hergert <chergert@redhat.com>
*
@ -20,10 +20,10 @@
#include "config.h"
#include "sp-capture-gobject.h"
#include "sysprof-capture-gobject.h"
#include <sysprof-capture.h>
G_DEFINE_BOXED_TYPE (SpCaptureReader, sp_capture_reader, (GBoxedCopyFunc)sp_capture_reader_ref, (GBoxedFreeFunc)sp_capture_reader_unref)
G_DEFINE_BOXED_TYPE (SpCaptureWriter, sp_capture_writer, (GBoxedCopyFunc)sp_capture_writer_ref, (GBoxedFreeFunc)sp_capture_writer_unref)
G_DEFINE_BOXED_TYPE (SpCaptureCursor, sp_capture_cursor, (GBoxedCopyFunc)sp_capture_cursor_ref, (GBoxedFreeFunc)sp_capture_cursor_unref)
G_DEFINE_BOXED_TYPE (SysprofCaptureReader, sysprof_capture_reader, (GBoxedCopyFunc)sysprof_capture_reader_ref, (GBoxedFreeFunc)sysprof_capture_reader_unref)
G_DEFINE_BOXED_TYPE (SysprofCaptureWriter, sysprof_capture_writer, (GBoxedCopyFunc)sysprof_capture_writer_ref, (GBoxedFreeFunc)sysprof_capture_writer_unref)
G_DEFINE_BOXED_TYPE (SysprofCaptureCursor, sysprof_capture_cursor, (GBoxedCopyFunc)sysprof_capture_cursor_ref, (GBoxedFreeFunc)sysprof_capture_cursor_unref)

View File

@ -1,4 +1,4 @@
/* sp-capture-gobject.h
/* sysprof-capture-gobject.h
*
* Copyright 2019 Christian Hergert <chergert@redhat.com>
*
@ -26,15 +26,15 @@
G_BEGIN_DECLS
#define SP_TYPE_CAPTURE_READER (sp_capture_reader_get_type())
#define SP_TYPE_CAPTURE_WRITER (sp_capture_writer_get_type())
#define SP_TYPE_CAPTURE_CURSOR (sp_capture_cursor_get_type())
#define SYSPROF_TYPE_CAPTURE_READER (sysprof_capture_reader_get_type())
#define SYSPROF_TYPE_CAPTURE_WRITER (sysprof_capture_writer_get_type())
#define SYSPROF_TYPE_CAPTURE_CURSOR (sysprof_capture_cursor_get_type())
SYSPROF_AVAILABLE_IN_ALL
GType sp_capture_reader_get_type (void);
GType sysprof_capture_reader_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
GType sp_capture_writer_get_type (void);
GType sysprof_capture_writer_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
GType sp_capture_cursor_get_type (void);
GType sysprof_capture_cursor_get_type (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-elf-symbol-resolver.c
/* sysprof-elf-symbol-resolver.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -24,10 +24,10 @@
#include "binfile.h"
#include "elfparser.h"
#include "sp-elf-symbol-resolver.h"
#include "sp-map-lookaside.h"
#include "sysprof-elf-symbol-resolver.h"
#include "sysprof-map-lookaside.h"
struct _SpElfSymbolResolver
struct _SysprofElfSymbolResolver
{
GObject parent_instance;
@ -36,42 +36,42 @@ struct _SpElfSymbolResolver
GHashTable *tag_cache;
};
static void symbol_resolver_iface_init (SpSymbolResolverInterface *iface);
static void symbol_resolver_iface_init (SysprofSymbolResolverInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpElfSymbolResolver,
sp_elf_symbol_resolver,
G_DEFINE_TYPE_EXTENDED (SysprofElfSymbolResolver,
sysprof_elf_symbol_resolver,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (SP_TYPE_SYMBOL_RESOLVER,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SYMBOL_RESOLVER,
symbol_resolver_iface_init))
static void
sp_elf_symbol_resolver_finalize (GObject *object)
sysprof_elf_symbol_resolver_finalize (GObject *object)
{
SpElfSymbolResolver *self = (SpElfSymbolResolver *)object;
SysprofElfSymbolResolver *self = (SysprofElfSymbolResolver *)object;
g_clear_pointer (&self->bin_files, g_hash_table_unref);
g_clear_pointer (&self->lookasides, g_hash_table_unref);
g_clear_pointer (&self->tag_cache, g_hash_table_unref);
G_OBJECT_CLASS (sp_elf_symbol_resolver_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_elf_symbol_resolver_parent_class)->finalize (object);
}
static void
sp_elf_symbol_resolver_class_init (SpElfSymbolResolverClass *klass)
sysprof_elf_symbol_resolver_class_init (SysprofElfSymbolResolverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_elf_symbol_resolver_finalize;
object_class->finalize = sysprof_elf_symbol_resolver_finalize;
}
static void
sp_elf_symbol_resolver_init (SpElfSymbolResolver *self)
sysprof_elf_symbol_resolver_init (SysprofElfSymbolResolver *self)
{
self->lookasides = g_hash_table_new_full (NULL,
NULL,
NULL,
(GDestroyNotify)sp_map_lookaside_free);
(GDestroyNotify)sysprof_map_lookaside_free);
self->bin_files = g_hash_table_new_full (g_str_hash,
g_str_equal,
@ -82,31 +82,31 @@ sp_elf_symbol_resolver_init (SpElfSymbolResolver *self)
}
static void
sp_elf_symbol_resolver_load (SpSymbolResolver *resolver,
SpCaptureReader *reader)
sysprof_elf_symbol_resolver_load (SysprofSymbolResolver *resolver,
SysprofCaptureReader *reader)
{
SpElfSymbolResolver *self = (SpElfSymbolResolver *)resolver;
SpCaptureFrameType type;
SysprofElfSymbolResolver *self = (SysprofElfSymbolResolver *)resolver;
SysprofCaptureFrameType type;
g_assert (SP_IS_SYMBOL_RESOLVER (resolver));
g_assert (SYSPROF_IS_SYMBOL_RESOLVER (resolver));
g_assert (reader != NULL);
sp_capture_reader_reset (reader);
sysprof_capture_reader_reset (reader);
while (sp_capture_reader_peek_type (reader, &type))
while (sysprof_capture_reader_peek_type (reader, &type))
{
const SpCaptureMap *ev;
SpMapLookaside *lookaside;
SpMap map;
const SysprofCaptureMap *ev;
SysprofMapLookaside *lookaside;
SysprofMap map;
if (type != SP_CAPTURE_FRAME_MAP)
if (type != SYSPROF_CAPTURE_FRAME_MAP)
{
if (!sp_capture_reader_skip (reader))
if (!sysprof_capture_reader_skip (reader))
return;
continue;
}
ev = sp_capture_reader_read_map (reader);
ev = sysprof_capture_reader_read_map (reader);
map.start = ev->start;
map.end = ev->end;
@ -118,21 +118,21 @@ sp_elf_symbol_resolver_load (SpSymbolResolver *resolver,
if (lookaside == NULL)
{
lookaside = sp_map_lookaside_new ();
lookaside = sysprof_map_lookaside_new ();
g_hash_table_insert (self->lookasides, GINT_TO_POINTER (ev->frame.pid), lookaside);
}
sp_map_lookaside_insert (lookaside, &map);
sysprof_map_lookaside_insert (lookaside, &map);
}
}
static bin_file_t *
sp_elf_symbol_resolver_get_bin_file (SpElfSymbolResolver *self,
sysprof_elf_symbol_resolver_get_bin_file (SysprofElfSymbolResolver *self,
const gchar *filename)
{
bin_file_t *bin_file;
g_assert (SP_IS_ELF_SYMBOL_RESOLVER (self));
g_assert (SYSPROF_IS_ELF_SYMBOL_RESOLVER (self));
bin_file = g_hash_table_lookup (self->bin_files, filename);
@ -141,7 +141,7 @@ sp_elf_symbol_resolver_get_bin_file (SpElfSymbolResolver *self,
const gchar *alternate = filename;
/*
* If we are in a new mount namespace, then rely on the sp_symbol_dirs
* If we are in a new mount namespace, then rely on the sysprof_symbol_dirs
* to find us a locate to resolve the file where the CRC will match.
*
* TODO: We need to translate the path here so that we can locate the
@ -159,8 +159,8 @@ sp_elf_symbol_resolver_get_bin_file (SpElfSymbolResolver *self,
}
static GQuark
guess_tag (SpElfSymbolResolver *self,
const SpMap *map)
guess_tag (SysprofElfSymbolResolver *self,
const SysprofMap *map)
{
g_assert (map != NULL);
g_assert (map->filename != NULL);
@ -254,37 +254,37 @@ guess_tag (SpElfSymbolResolver *self,
}
static gchar *
sp_elf_symbol_resolver_resolve_with_context (SpSymbolResolver *resolver,
sysprof_elf_symbol_resolver_resolve_with_context (SysprofSymbolResolver *resolver,
guint64 time,
GPid pid,
SpAddressContext context,
SpCaptureAddress address,
SysprofAddressContext context,
SysprofCaptureAddress address,
GQuark *tag)
{
SpElfSymbolResolver *self = (SpElfSymbolResolver *)resolver;
SysprofElfSymbolResolver *self = (SysprofElfSymbolResolver *)resolver;
const bin_symbol_t *bin_sym;
SpMapLookaside *lookaside;
SysprofMapLookaside *lookaside;
const gchar *bin_sym_name;
const SpMap *map;
const SysprofMap *map;
bin_file_t *bin_file;
g_assert (SP_IS_ELF_SYMBOL_RESOLVER (self));
g_assert (SYSPROF_IS_ELF_SYMBOL_RESOLVER (self));
if (context != SP_ADDRESS_CONTEXT_USER)
if (context != SYSPROF_ADDRESS_CONTEXT_USER)
return NULL;
lookaside = g_hash_table_lookup (self->lookasides, GINT_TO_POINTER (pid));
if (lookaside == NULL)
return NULL;
map = sp_map_lookaside_lookup (lookaside, address);
map = sysprof_map_lookaside_lookup (lookaside, address);
if (map == NULL)
return NULL;
address -= map->start;
address += map->offset;
bin_file = sp_elf_symbol_resolver_get_bin_file (self, map->filename);
bin_file = sysprof_elf_symbol_resolver_get_bin_file (self, map->filename);
g_assert (bin_file != NULL);
@ -301,14 +301,14 @@ sp_elf_symbol_resolver_resolve_with_context (SpSymbolResolver *resolver,
}
static void
symbol_resolver_iface_init (SpSymbolResolverInterface *iface)
symbol_resolver_iface_init (SysprofSymbolResolverInterface *iface)
{
iface->load = sp_elf_symbol_resolver_load;
iface->resolve_with_context = sp_elf_symbol_resolver_resolve_with_context;
iface->load = sysprof_elf_symbol_resolver_load;
iface->resolve_with_context = sysprof_elf_symbol_resolver_resolve_with_context;
}
SpSymbolResolver *
sp_elf_symbol_resolver_new (void)
SysprofSymbolResolver *
sysprof_elf_symbol_resolver_new (void)
{
return g_object_new (SP_TYPE_ELF_SYMBOL_RESOLVER, NULL);
return g_object_new (SYSPROF_TYPE_ELF_SYMBOL_RESOLVER, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-elf-symbol-resolver.h
/* sysprof-elf-symbol-resolver.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,16 +22,16 @@
#include "sysprof-version-macros.h"
#include "sp-symbol-resolver.h"
#include "sysprof-symbol-resolver.h"
G_BEGIN_DECLS
#define SP_TYPE_ELF_SYMBOL_RESOLVER (sp_elf_symbol_resolver_get_type())
#define SYSPROF_TYPE_ELF_SYMBOL_RESOLVER (sysprof_elf_symbol_resolver_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpElfSymbolResolver, sp_elf_symbol_resolver, SP, ELF_SYMBOL_RESOLVER, GObject)
G_DECLARE_FINAL_TYPE (SysprofElfSymbolResolver, sysprof_elf_symbol_resolver, SYSPROF, ELF_SYMBOL_RESOLVER, GObject)
SYSPROF_AVAILABLE_IN_ALL
SpSymbolResolver *sp_elf_symbol_resolver_new (void);
SysprofSymbolResolver *sysprof_elf_symbol_resolver_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-gjs-source.c
/* sysprof-gjs-source.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -23,14 +23,14 @@
#include <signal.h>
#include <string.h>
#include "sp-capture-reader.h"
#include "sp-gjs-source.h"
#include "sysprof-capture-reader.h"
#include "sysprof-gjs-source.h"
struct _SpGjsSource
struct _SysprofGjsSource
{
GObject parent_instance;
SpCaptureWriter *writer;
SysprofCaptureWriter *writer;
GArray *pids;
GArray *enabled;
};
@ -38,57 +38,57 @@ struct _SpGjsSource
#define ENABLE_PROFILER 0x1
#define DISABLE_PROFILER 0x0
static void source_iface_init (SpSourceInterface *iface);
static void source_iface_init (SysprofSourceInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpGjsSource, sp_gjs_source, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SP_TYPE_SOURCE, source_iface_init))
G_DEFINE_TYPE_EXTENDED (SysprofGjsSource, sysprof_gjs_source, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
static void
sp_gjs_source_finalize (GObject *object)
sysprof_gjs_source_finalize (GObject *object)
{
SpGjsSource *self = (SpGjsSource *)object;
SysprofGjsSource *self = (SysprofGjsSource *)object;
g_clear_pointer (&self->pids, g_array_unref);
g_clear_pointer (&self->enabled, g_array_unref);
g_clear_pointer (&self->writer, sp_capture_writer_unref);
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
G_OBJECT_CLASS (sp_gjs_source_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_gjs_source_parent_class)->finalize (object);
}
static void
sp_gjs_source_class_init (SpGjsSourceClass *klass)
sysprof_gjs_source_class_init (SysprofGjsSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_gjs_source_finalize;
object_class->finalize = sysprof_gjs_source_finalize;
}
static void
sp_gjs_source_init (SpGjsSource *self)
sysprof_gjs_source_init (SysprofGjsSource *self)
{
self->pids = g_array_new (FALSE, FALSE, sizeof (GPid));
self->enabled = g_array_new (FALSE, FALSE, sizeof (GPid));
}
static void
sp_gjs_source_process_capture (SpGjsSource *self,
sysprof_gjs_source_process_capture (SysprofGjsSource *self,
GPid pid,
const gchar *path)
{
g_autoptr(GError) error = NULL;
g_autoptr(SpCaptureReader) reader = NULL;
g_autoptr(SysprofCaptureReader) reader = NULL;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (self->writer != NULL);
g_assert (path != NULL);
if (!(reader = sp_capture_reader_new (path, &error)))
if (!(reader = sysprof_capture_reader_new (path, &error)))
{
g_warning ("Failed to load capture: %s", error->message);
return;
}
if (!sp_capture_reader_splice (reader, self->writer, &error))
if (!sysprof_capture_reader_splice (reader, self->writer, &error))
{
g_warning ("Failed to load capture: %s", error->message);
return;
@ -96,11 +96,11 @@ sp_gjs_source_process_capture (SpGjsSource *self,
}
static void
sp_gjs_source_process_captures (SpGjsSource *self)
sysprof_gjs_source_process_captures (SysprofGjsSource *self)
{
guint i;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (self->writer != NULL);
for (i = 0; i < self->enabled->len; i++)
@ -112,20 +112,20 @@ sp_gjs_source_process_captures (SpGjsSource *self)
filename = g_strdup_printf ("gjs-profile-%u", (guint)pid);
path = g_build_filename (g_get_tmp_dir (), filename, NULL);
sp_gjs_source_process_capture (self, pid, path);
sysprof_gjs_source_process_capture (self, pid, path);
}
}
static void
sp_gjs_source_set_writer (SpSource *source,
SpCaptureWriter *writer)
sysprof_gjs_source_set_writer (SysprofSource *source,
SysprofCaptureWriter *writer)
{
SpGjsSource *self = (SpGjsSource *)source;
SysprofGjsSource *self = (SysprofGjsSource *)source;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (writer != NULL);
self->writer = sp_capture_writer_ref (writer);
self->writer = sysprof_capture_writer_ref (writer);
}
static gboolean
@ -154,12 +154,12 @@ pid_is_profileable (GPid pid)
}
static void
sp_gjs_source_enable_pid (SpGjsSource *self,
sysprof_gjs_source_enable_pid (SysprofGjsSource *self,
GPid pid)
{
union sigval si;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (pid != -1);
si.sival_int = ENABLE_PROFILER;
@ -171,12 +171,12 @@ sp_gjs_source_enable_pid (SpGjsSource *self,
}
static void
sp_gjs_source_disable_pid (SpGjsSource *self,
sysprof_gjs_source_disable_pid (SysprofGjsSource *self,
GPid pid)
{
union sigval si;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (pid != -1);
si.sival_int = DISABLE_PROFILER;
@ -186,64 +186,64 @@ sp_gjs_source_disable_pid (SpGjsSource *self,
}
static void
sp_gjs_source_start (SpSource *source)
sysprof_gjs_source_start (SysprofSource *source)
{
SpGjsSource *self = (SpGjsSource *)source;
SysprofGjsSource *self = (SysprofGjsSource *)source;
guint i;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
for (i = 0; i < self->pids->len; i++)
{
GPid pid = g_array_index (self->pids, GPid, i);
if (pid_is_profileable (pid))
sp_gjs_source_enable_pid (self, pid);
sysprof_gjs_source_enable_pid (self, pid);
}
}
static void
sp_gjs_source_stop (SpSource *source)
sysprof_gjs_source_stop (SysprofSource *source)
{
SpGjsSource *self = (SpGjsSource *)source;
SysprofGjsSource *self = (SysprofGjsSource *)source;
guint i;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
for (i = 0; i < self->pids->len; i++)
{
GPid pid = g_array_index (self->pids, GPid, i);
if (pid_is_profileable (pid))
sp_gjs_source_disable_pid (self, pid);
sysprof_gjs_source_disable_pid (self, pid);
}
sp_gjs_source_process_captures (self);
sysprof_gjs_source_process_captures (self);
}
static void
sp_gjs_source_add_pid (SpSource *source,
sysprof_gjs_source_add_pid (SysprofSource *source,
GPid pid)
{
SpGjsSource *self = (SpGjsSource *)source;
SysprofGjsSource *self = (SysprofGjsSource *)source;
g_assert (SP_IS_GJS_SOURCE (self));
g_assert (SYSPROF_IS_GJS_SOURCE (self));
g_assert (pid > -1);
g_array_append_val (self->pids, pid);
}
static void
source_iface_init (SpSourceInterface *iface)
source_iface_init (SysprofSourceInterface *iface)
{
iface->set_writer = sp_gjs_source_set_writer;
iface->start = sp_gjs_source_start;
iface->stop = sp_gjs_source_stop;
iface->add_pid = sp_gjs_source_add_pid;
iface->set_writer = sysprof_gjs_source_set_writer;
iface->start = sysprof_gjs_source_start;
iface->stop = sysprof_gjs_source_stop;
iface->add_pid = sysprof_gjs_source_add_pid;
}
SpSource *
sp_gjs_source_new (void)
SysprofSource *
sysprof_gjs_source_new (void)
{
return g_object_new (SP_TYPE_GJS_SOURCE, NULL);
return g_object_new (SYSPROF_TYPE_GJS_SOURCE, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-gjs-source.h
/* sysprof-gjs-source.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,14 +20,14 @@
#pragma once
#include "sp-source.h"
#include "sysprof-source.h"
G_BEGIN_DECLS
#define SP_TYPE_GJS_SOURCE (sp_gjs_source_get_type())
#define SYSPROF_TYPE_GJS_SOURCE (sysprof_gjs_source_get_type())
G_DECLARE_FINAL_TYPE (SpGjsSource, sp_gjs_source, SP, GJS_SOURCE, GObject)
G_DECLARE_FINAL_TYPE (SysprofGjsSource, sysprof_gjs_source, SYSPROF, GJS_SOURCE, GObject)
SpSource *sp_gjs_source_new (void);
SysprofSource *sysprof_gjs_source_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-hostinfo-source.c
/* sysprof-hostinfo-source.c
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -27,11 +27,11 @@
#include <sys/stat.h>
#include <unistd.h>
#include "sp-hostinfo-source.h"
#include "sysprof-hostinfo-source.h"
#define PROC_STAT_BUF_SIZE 4096
struct _SpHostinfoSource
struct _SysprofHostinfoSource
{
GObject parent_instance;
@ -39,7 +39,7 @@ struct _SpHostinfoSource
gint n_cpu;
gint stat_fd;
SpCaptureWriter *writer;
SysprofCaptureWriter *writer;
GArray *cpu_info;
gchar *stat_buf;
};
@ -61,19 +61,19 @@ typedef struct
glong last_guest_nice;
} CpuInfo;
static void source_iface_init (SpSourceInterface *iface);
static void source_iface_init (SysprofSourceInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpHostinfoSource, sp_hostinfo_source, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SP_TYPE_SOURCE, source_iface_init))
G_DEFINE_TYPE_EXTENDED (SysprofHostinfoSource, sysprof_hostinfo_source, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
SpSource *
sp_hostinfo_source_new (void)
SysprofSource *
sysprof_hostinfo_source_new (void)
{
return g_object_new (SP_TYPE_HOSTINFO_SOURCE, NULL);
return g_object_new (SYSPROF_TYPE_HOSTINFO_SOURCE, NULL);
}
static gboolean
read_stat (SpHostinfoSource *self)
read_stat (SysprofHostinfoSource *self)
{
gssize len;
@ -97,7 +97,7 @@ read_stat (SpHostinfoSource *self)
}
static void
poll_cpu (SpHostinfoSource *self)
poll_cpu (SysprofHostinfoSource *self)
{
gchar cpu[64] = { 0 };
glong user;
@ -195,9 +195,9 @@ poll_cpu (SpHostinfoSource *self)
}
static void
publish_cpu (SpHostinfoSource *self)
publish_cpu (SysprofHostinfoSource *self)
{
SpCaptureCounterValue *counter_values;
SysprofCaptureCounterValue *counter_values;
guint *counter_ids;
counter_ids = alloca (sizeof *counter_ids * self->n_cpu * 2);
@ -206,7 +206,7 @@ publish_cpu (SpHostinfoSource *self)
for (guint i = 0; i < self->n_cpu; i++)
{
CpuInfo *info = &g_array_index (self->cpu_info, CpuInfo, i);
SpCaptureCounterValue *value = &counter_values[i*2];
SysprofCaptureCounterValue *value = &counter_values[i*2];
guint *id = &counter_ids[i*2];
*id = info->counter_base;
@ -219,8 +219,8 @@ publish_cpu (SpHostinfoSource *self)
value->vdbl = info->freq;
}
sp_capture_writer_set_counters (self->writer,
SP_CAPTURE_CURRENT_TIME,
sysprof_capture_writer_set_counters (self->writer,
SYSPROF_CAPTURE_CURRENT_TIME,
-1,
getpid (),
counter_ids,
@ -231,9 +231,9 @@ publish_cpu (SpHostinfoSource *self)
static gboolean
collect_hostinfo_cb (gpointer data)
{
SpHostinfoSource *self = data;
SysprofHostinfoSource *self = data;
g_assert (SP_IS_HOSTINFO_SOURCE (self));
g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
poll_cpu (self);
publish_cpu (self);
@ -242,9 +242,9 @@ collect_hostinfo_cb (gpointer data)
}
static void
sp_hostinfo_source_finalize (GObject *object)
sysprof_hostinfo_source_finalize (GObject *object)
{
SpHostinfoSource *self = (SpHostinfoSource *)object;
SysprofHostinfoSource *self = (SysprofHostinfoSource *)object;
if (self->handler)
{
@ -252,23 +252,23 @@ sp_hostinfo_source_finalize (GObject *object)
self->handler = 0;
}
g_clear_pointer (&self->writer, sp_capture_writer_unref);
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
g_clear_pointer (&self->cpu_info, g_array_unref);
g_clear_pointer (&self->stat_buf, g_free);
G_OBJECT_CLASS (sp_hostinfo_source_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_hostinfo_source_parent_class)->finalize (object);
}
static void
sp_hostinfo_source_class_init (SpHostinfoSourceClass *klass)
sysprof_hostinfo_source_class_init (SysprofHostinfoSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_hostinfo_source_finalize;
object_class->finalize = sysprof_hostinfo_source_finalize;
}
static void
sp_hostinfo_source_init (SpHostinfoSource *self)
sysprof_hostinfo_source_init (SysprofHostinfoSource *self)
{
self->stat_fd = -1;
self->cpu_info = g_array_new (FALSE, TRUE, sizeof (CpuInfo));
@ -276,35 +276,35 @@ sp_hostinfo_source_init (SpHostinfoSource *self)
}
static void
sp_hostinfo_source_set_writer (SpSource *source,
SpCaptureWriter *writer)
sysprof_hostinfo_source_set_writer (SysprofSource *source,
SysprofCaptureWriter *writer)
{
SpHostinfoSource *self = (SpHostinfoSource *)source;
SysprofHostinfoSource *self = (SysprofHostinfoSource *)source;
g_assert (SP_IS_HOSTINFO_SOURCE (self));
g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
g_assert (writer != NULL);
g_clear_pointer (&self->writer, sp_capture_writer_unref);
self->writer = sp_capture_writer_ref (writer);
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
self->writer = sysprof_capture_writer_ref (writer);
}
static void
sp_hostinfo_source_start (SpSource *source)
sysprof_hostinfo_source_start (SysprofSource *source)
{
SpHostinfoSource *self = (SpHostinfoSource *)source;
SysprofHostinfoSource *self = (SysprofHostinfoSource *)source;
g_assert (SP_IS_HOSTINFO_SOURCE (self));
g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
/* 20 samples per second */
self->handler = g_timeout_add (1000/20, collect_hostinfo_cb, self);
}
static void
sp_hostinfo_source_stop (SpSource *source)
sysprof_hostinfo_source_stop (SysprofSource *source)
{
SpHostinfoSource *self = (SpHostinfoSource *)source;
SysprofHostinfoSource *self = (SysprofHostinfoSource *)source;
g_assert (SP_IS_HOSTINFO_SOURCE (self));
g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
g_source_remove (self->handler);
self->handler = 0;
@ -315,16 +315,16 @@ sp_hostinfo_source_stop (SpSource *source)
self->stat_fd = -1;
}
sp_source_emit_finished (SP_SOURCE (self));
sysprof_source_emit_finished (SYSPROF_SOURCE (self));
}
static void
sp_hostinfo_source_prepare (SpSource *source)
sysprof_hostinfo_source_prepare (SysprofSource *source)
{
SpHostinfoSource *self = (SpHostinfoSource *)source;
SpCaptureCounter *counters;
SysprofHostinfoSource *self = (SysprofHostinfoSource *)source;
SysprofCaptureCounter *counters;
g_assert (SP_IS_HOSTINFO_SOURCE (self));
g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
self->stat_fd = open ("/proc/stat", O_RDONLY);
self->n_cpu = g_get_num_processors ();
@ -335,20 +335,20 @@ sp_hostinfo_source_prepare (SpSource *source)
for (guint i = 0; i < self->n_cpu; i++)
{
SpCaptureCounter *ctr = &counters[i*2];
SysprofCaptureCounter *ctr = &counters[i*2];
CpuInfo info = { 0 };
/*
* Request 2 counter values.
* One for CPU and one for Frequency.
*/
info.counter_base = sp_capture_writer_request_counter (self->writer, 2);
info.counter_base = sysprof_capture_writer_request_counter (self->writer, 2);
/*
* Define counters for capture file.
*/
ctr->id = info.counter_base;
ctr->type = SP_CAPTURE_COUNTER_DOUBLE;
ctr->type = SYSPROF_CAPTURE_COUNTER_DOUBLE;
ctr->value.vdbl = 0;
g_strlcpy (ctr->category, "CPU Percent", sizeof ctr->category);
g_snprintf (ctr->name, sizeof ctr->name, "Total CPU %d", i);
@ -358,7 +358,7 @@ sp_hostinfo_source_prepare (SpSource *source)
ctr++;
ctr->id = info.counter_base + 1;
ctr->type = SP_CAPTURE_COUNTER_DOUBLE;
ctr->type = SYSPROF_CAPTURE_COUNTER_DOUBLE;
ctr->value.vdbl = 0;
g_strlcpy (ctr->category, "CPU Frequency", sizeof ctr->category);
g_snprintf (ctr->name, sizeof ctr->name, "CPU %d", i);
@ -368,21 +368,21 @@ sp_hostinfo_source_prepare (SpSource *source)
g_array_append_val (self->cpu_info, info);
}
sp_capture_writer_define_counters (self->writer,
SP_CAPTURE_CURRENT_TIME,
sysprof_capture_writer_define_counters (self->writer,
SYSPROF_CAPTURE_CURRENT_TIME,
-1,
getpid (),
counters,
self->n_cpu * 2);
sp_source_emit_ready (SP_SOURCE (self));
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
}
static void
source_iface_init (SpSourceInterface *iface)
source_iface_init (SysprofSourceInterface *iface)
{
iface->set_writer = sp_hostinfo_source_set_writer;
iface->prepare = sp_hostinfo_source_prepare;
iface->start = sp_hostinfo_source_start;
iface->stop = sp_hostinfo_source_stop;
iface->set_writer = sysprof_hostinfo_source_set_writer;
iface->prepare = sysprof_hostinfo_source_prepare;
iface->start = sysprof_hostinfo_source_start;
iface->stop = sysprof_hostinfo_source_stop;
}

View File

@ -1,4 +1,4 @@
/* sp-hostinfo-source.h
/* sysprof-hostinfo-source.h
*
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
*
@ -22,16 +22,16 @@
#include "sysprof-version-macros.h"
#include "sp-source.h"
#include "sysprof-source.h"
G_BEGIN_DECLS
#define SP_TYPE_HOSTINFO_SOURCE (sp_hostinfo_source_get_type())
#define SYSPROF_TYPE_HOSTINFO_SOURCE (sysprof_hostinfo_source_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpHostinfoSource, sp_hostinfo_source, SP, HOSTINFO_SOURCE, GObject)
G_DECLARE_FINAL_TYPE (SysprofHostinfoSource, sysprof_hostinfo_source, SYSPROF, HOSTINFO_SOURCE, GObject)
SYSPROF_AVAILABLE_IN_ALL
SpSource *sp_hostinfo_source_new (void);
SysprofSource *sysprof_hostinfo_source_new (void);
G_END_DECLS

View File

@ -0,0 +1,125 @@
/* sysprof-jitmap-symbol-resolver.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "sysprof-kernel-symbol.h"
#include "sysprof-jitmap-symbol-resolver.h"
struct _SysprofJitmapSymbolResolver
{
GObject parent_instance;
GHashTable *jitmap;
};
static void symbol_resolver_iface_init (SysprofSymbolResolverInterface *iface);
G_DEFINE_TYPE_EXTENDED (SysprofJitmapSymbolResolver,
sysprof_jitmap_symbol_resolver,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SYMBOL_RESOLVER,
symbol_resolver_iface_init))
static void
sysprof_jitmap_symbol_resolver_finalize (GObject *object)
{
SysprofJitmapSymbolResolver *self = (SysprofJitmapSymbolResolver *)object;
g_clear_pointer (&self->jitmap, g_hash_table_unref);
G_OBJECT_CLASS (sysprof_jitmap_symbol_resolver_parent_class)->finalize (object);
}
static void
sysprof_jitmap_symbol_resolver_class_init (SysprofJitmapSymbolResolverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sysprof_jitmap_symbol_resolver_finalize;
}
static void
sysprof_jitmap_symbol_resolver_init (SysprofJitmapSymbolResolver *self)
{
self->jitmap = g_hash_table_new_full (NULL, NULL, NULL, g_free);
}
static void
sysprof_jitmap_symbol_resolver_load (SysprofSymbolResolver *resolver,
SysprofCaptureReader *reader)
{
SysprofJitmapSymbolResolver *self = (SysprofJitmapSymbolResolver *)resolver;
SysprofCaptureFrameType type;
g_assert (SYSPROF_IS_JITMAP_SYMBOL_RESOLVER (self));
g_assert (reader != NULL);
while (sysprof_capture_reader_peek_type (reader, &type))
{
g_autoptr(GHashTable) jitmap = NULL;
GHashTableIter iter;
SysprofCaptureAddress addr;
const gchar *str;
if (type != SYSPROF_CAPTURE_FRAME_JITMAP)
{
if (!sysprof_capture_reader_skip (reader))
return;
continue;
}
if (!(jitmap = sysprof_capture_reader_read_jitmap (reader)))
return;
g_hash_table_iter_init (&iter, jitmap);
while (g_hash_table_iter_next (&iter, (gpointer *)&addr, (gpointer *)&str))
g_hash_table_insert (self->jitmap, GSIZE_TO_POINTER (addr), g_strdup (str));
}
}
static gchar *
sysprof_jitmap_symbol_resolver_resolve (SysprofSymbolResolver *resolver,
guint64 time,
GPid pid,
SysprofCaptureAddress address,
GQuark *tag)
{
SysprofJitmapSymbolResolver *self = (SysprofJitmapSymbolResolver *)resolver;
g_assert (SYSPROF_IS_JITMAP_SYMBOL_RESOLVER (self));
*tag = 0;
return g_strdup (g_hash_table_lookup (self->jitmap, GSIZE_TO_POINTER (address)));
}
static void
symbol_resolver_iface_init (SysprofSymbolResolverInterface *iface)
{
iface->load = sysprof_jitmap_symbol_resolver_load;
iface->resolve = sysprof_jitmap_symbol_resolver_resolve;
}
SysprofSymbolResolver *
sysprof_jitmap_symbol_resolver_new (void)
{
return g_object_new (SYSPROF_TYPE_JITMAP_SYMBOL_RESOLVER, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-jitmap-symbol-resolver.h
/* sysprof-jitmap-symbol-resolver.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,14 +20,14 @@
#pragma once
#include "sp-symbol-resolver.h"
#include "sysprof-symbol-resolver.h"
G_BEGIN_DECLS
#define SP_TYPE_JITMAP_SYMBOL_RESOLVER (sp_jitmap_symbol_resolver_get_type())
#define SYSPROF_TYPE_JITMAP_SYMBOL_RESOLVER (sysprof_jitmap_symbol_resolver_get_type())
G_DECLARE_FINAL_TYPE (SpJitmapSymbolResolver, sp_jitmap_symbol_resolver, SP, JITMAP_SYMBOL_RESOLVER, GObject)
G_DECLARE_FINAL_TYPE (SysprofJitmapSymbolResolver, sysprof_jitmap_symbol_resolver, SYSPROF, JITMAP_SYMBOL_RESOLVER, GObject)
SpSymbolResolver *sp_jitmap_symbol_resolver_new (void);
SysprofSymbolResolver *sysprof_jitmap_symbol_resolver_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-kallsyms.c
/* sysprof-kallsyms.c
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,7 +18,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-kallsyms"
#define G_LOG_DOMAIN "sysprof-kallsyms"
#include "config.h"
@ -30,9 +30,9 @@
#include <string.h>
#include <stdio.h>
#include "sp-kallsyms.h"
#include "sysprof-kallsyms.h"
struct _SpKallsyms
struct _SysprofKallsyms
{
gchar *buf;
gsize buflen;
@ -41,24 +41,24 @@ struct _SpKallsyms
};
void
sp_kallsyms_free (SpKallsyms *self)
sysprof_kallsyms_free (SysprofKallsyms *self)
{
if (self != NULL)
{
g_clear_pointer (&self->buf, g_free);
g_slice_free (SpKallsyms, self);
g_slice_free (SysprofKallsyms, self);
}
}
SpKallsyms *
sp_kallsyms_new (const gchar *path)
SysprofKallsyms *
sysprof_kallsyms_new (const gchar *path)
{
g_autoptr(SpKallsyms) self = NULL;
g_autoptr(SysprofKallsyms) self = NULL;
if (path == NULL)
path = "/proc/kallsyms";
self = g_slice_new0 (SpKallsyms);
self = g_slice_new0 (SysprofKallsyms);
if (!g_file_get_contents (path, &self->buf, &self->buflen, NULL))
return NULL;
@ -70,7 +70,7 @@ sp_kallsyms_new (const gchar *path)
}
gboolean
sp_kallsyms_next (SpKallsyms *self,
sysprof_kallsyms_next (SysprofKallsyms *self,
const gchar **name,
guint64 *address,
guint8 *type)

View File

@ -1,4 +1,4 @@
/* sp-kallsyms.h
/* sysprof-kallsyms.h
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -24,18 +24,18 @@
G_BEGIN_DECLS
typedef struct _SpKallsyms SpKallsyms;
typedef struct _SysprofKallsyms SysprofKallsyms;
SYSPROF_AVAILABLE_IN_ALL
SpKallsyms *sp_kallsyms_new (const gchar *path);
SysprofKallsyms *sysprof_kallsyms_new (const gchar *path);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_kallsyms_next (SpKallsyms *self,
gboolean sysprof_kallsyms_next (SysprofKallsyms *self,
const gchar **name,
guint64 *address,
guint8 *type);
SYSPROF_AVAILABLE_IN_ALL
void sp_kallsyms_free (SpKallsyms *self);
void sysprof_kallsyms_free (SysprofKallsyms *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpKallsyms, sp_kallsyms_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofKallsyms, sysprof_kallsyms_free)
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-kernel-symbol-resolver.c
/* sysprof-kernel-symbol-resolver.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,10 +20,10 @@
#include "config.h"
#include "sp-kernel-symbol.h"
#include "sp-kernel-symbol-resolver.h"
#include "sysprof-kernel-symbol.h"
#include "sysprof-kernel-symbol-resolver.h"
struct _SpKernelSymbolResolver
struct _SysprofKernelSymbolResolver
{
GObject parent_instance;
};
@ -31,21 +31,21 @@ struct _SpKernelSymbolResolver
static GQuark linux_quark;
static gchar *
sp_kernel_symbol_resolver_resolve_with_context (SpSymbolResolver *resolver,
sysprof_kernel_symbol_resolver_resolve_with_context (SysprofSymbolResolver *resolver,
guint64 time,
GPid pid,
SpAddressContext context,
SpCaptureAddress address,
SysprofAddressContext context,
SysprofCaptureAddress address,
GQuark *tag)
{
const SpKernelSymbol *sym;
const SysprofKernelSymbol *sym;
g_assert (SP_IS_SYMBOL_RESOLVER (resolver));
g_assert (SYSPROF_IS_SYMBOL_RESOLVER (resolver));
if (context != SP_ADDRESS_CONTEXT_KERNEL)
if (context != SYSPROF_ADDRESS_CONTEXT_KERNEL)
return NULL;
sym = sp_kernel_symbol_from_address (address);
sym = sysprof_kernel_symbol_from_address (address);
if (sym != NULL)
{
@ -57,30 +57,30 @@ sp_kernel_symbol_resolver_resolve_with_context (SpSymbolResolver *resolver,
}
static void
symbol_resolver_iface_init (SpSymbolResolverInterface *iface)
symbol_resolver_iface_init (SysprofSymbolResolverInterface *iface)
{
iface->resolve_with_context = sp_kernel_symbol_resolver_resolve_with_context;
iface->resolve_with_context = sysprof_kernel_symbol_resolver_resolve_with_context;
}
G_DEFINE_TYPE_WITH_CODE (SpKernelSymbolResolver,
sp_kernel_symbol_resolver,
G_DEFINE_TYPE_WITH_CODE (SysprofKernelSymbolResolver,
sysprof_kernel_symbol_resolver,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SP_TYPE_SYMBOL_RESOLVER,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SYMBOL_RESOLVER,
symbol_resolver_iface_init))
static void
sp_kernel_symbol_resolver_class_init (SpKernelSymbolResolverClass *klass)
sysprof_kernel_symbol_resolver_class_init (SysprofKernelSymbolResolverClass *klass)
{
linux_quark = g_quark_from_static_string ("Kernel");
}
static void
sp_kernel_symbol_resolver_init (SpKernelSymbolResolver *skernel)
sysprof_kernel_symbol_resolver_init (SysprofKernelSymbolResolver *skernel)
{
}
SpSymbolResolver *
sp_kernel_symbol_resolver_new (void)
SysprofSymbolResolver *
sysprof_kernel_symbol_resolver_new (void)
{
return g_object_new (SP_TYPE_KERNEL_SYMBOL_RESOLVER, NULL);
return g_object_new (SYSPROF_TYPE_KERNEL_SYMBOL_RESOLVER, NULL);
}

View File

@ -1,4 +1,4 @@
/* sp-kernel-symbol-resolver.h
/* sysprof-kernel-symbol-resolver.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,14 +20,14 @@
#pragma once
#include "sp-symbol-resolver.h"
#include "sysprof-symbol-resolver.h"
G_BEGIN_DECLS
#define SP_TYPE_KERNEL_SYMBOL_RESOLVER (sp_kernel_symbol_resolver_get_type())
#define SYSPROF_TYPE_KERNEL_SYMBOL_RESOLVER (sysprof_kernel_symbol_resolver_get_type())
G_DECLARE_FINAL_TYPE (SpKernelSymbolResolver, sp_kernel_symbol_resolver, SP, KERNEL_SYMBOL_RESOLVER, GObject)
G_DECLARE_FINAL_TYPE (SysprofKernelSymbolResolver, sysprof_kernel_symbol_resolver, SYSPROF, KERNEL_SYMBOL_RESOLVER, GObject)
SpSymbolResolver *sp_kernel_symbol_resolver_new (void);
SysprofSymbolResolver *sysprof_kernel_symbol_resolver_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-kernel-symbol.c
/* sysprof-kernel-symbol.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-kernel-symbol"
#define G_LOG_DOMAIN "sysprof-kernel-symbol"
#include "config.h"
@ -28,8 +28,8 @@
#endif
#include <sysprof-capture.h>
#include "sp-kallsyms.h"
#include "sp-kernel-symbol.h"
#include "sysprof-kallsyms.h"
#include "sysprof-kernel-symbol.h"
static GArray *kernel_symbols;
static GStringChunk *kernel_symbol_strs;
@ -68,11 +68,11 @@ static const gchar *kernel_symbols_skip[] = {
};
static gint
sp_kernel_symbol_compare (gconstpointer a,
sysprof_kernel_symbol_compare (gconstpointer a,
gconstpointer b)
{
const SpKernelSymbol *syma = a;
const SpKernelSymbol *symb = b;
const SysprofKernelSymbol *syma = a;
const SysprofKernelSymbol *symb = b;
if (syma->address > symb->address)
return 1;
@ -125,7 +125,7 @@ failure:
}
static gboolean
sp_kernel_symbol_load_from_sysprofd (void)
sysprof_kernel_symbol_load_from_sysprofd (void)
{
g_autoptr(GDBusConnection) conn = NULL;
g_autoptr(GVariant) ret = NULL;
@ -164,13 +164,13 @@ sp_kernel_symbol_load_from_sysprofd (void)
return FALSE;
}
ar = g_array_new (FALSE, TRUE, sizeof (SpKernelSymbol));
ar = g_array_new (FALSE, TRUE, sizeof (SysprofKernelSymbol));
results = g_variant_get_child_value (ret, 0);
g_variant_iter_init (&iter, results);
while (g_variant_iter_loop (&iter, "(ty&s)", &addr, &type, &name))
{
SpKernelSymbol sym;
SysprofKernelSymbol sym;
if (type_is_ignored (type))
continue;
@ -181,12 +181,12 @@ sp_kernel_symbol_load_from_sysprofd (void)
g_array_append_val (ar, sym);
}
g_array_sort (ar, sp_kernel_symbol_compare);
g_array_sort (ar, sysprof_kernel_symbol_compare);
#if 0
g_print ("First: 0x%lx Last: 0x%lx\n",
g_array_index (ar, SpKernelSymbol, 0).address,
g_array_index (ar, SpKernelSymbol, ar->len - 1).address);
g_array_index (ar, SysprofKernelSymbol, 0).address,
g_array_index (ar, SysprofKernelSymbol, ar->len - 1).address);
#endif
kernel_symbols = g_steal_pointer (&ar);
@ -195,10 +195,10 @@ sp_kernel_symbol_load_from_sysprofd (void)
}
static gboolean
sp_kernel_symbol_load (void)
sysprof_kernel_symbol_load (void)
{
g_autoptr(GHashTable) skip = NULL;
g_autoptr(SpKallsyms) kallsyms = NULL;
g_autoptr(SysprofKallsyms) kallsyms = NULL;
g_autoptr(GArray) ar = NULL;
const gchar *name;
guint64 addr;
@ -210,14 +210,14 @@ sp_kernel_symbol_load (void)
kernel_symbols_skip_hash = g_steal_pointer (&skip);
kernel_symbol_strs = g_string_chunk_new (4096);
ar = g_array_new (FALSE, TRUE, sizeof (SpKernelSymbol));
ar = g_array_new (FALSE, TRUE, sizeof (SysprofKernelSymbol));
if (!(kallsyms = sp_kallsyms_new (NULL)))
if (!(kallsyms = sysprof_kallsyms_new (NULL)))
goto query_daemon;
while (sp_kallsyms_next (kallsyms, &name, &addr, &type))
while (sysprof_kallsyms_next (kallsyms, &name, &addr, &type))
{
SpKernelSymbol sym;
SysprofKernelSymbol sym;
if (type_is_ignored (type))
continue;
@ -231,13 +231,13 @@ sp_kernel_symbol_load (void)
if (ar->len == 0)
goto query_daemon;
g_array_sort (ar, sp_kernel_symbol_compare);
g_array_sort (ar, sysprof_kernel_symbol_compare);
kernel_symbols = g_steal_pointer (&ar);
return TRUE;
query_daemon:
if (sp_kernel_symbol_load_from_sysprofd ())
if (sysprof_kernel_symbol_load_from_sysprofd ())
return TRUE;
g_warning ("Kernel symbols will not be available.");
@ -245,9 +245,9 @@ query_daemon:
return FALSE;
}
static const SpKernelSymbol *
sp_kernel_symbol_lookup (SpKernelSymbol *symbols,
SpCaptureAddress address,
static const SysprofKernelSymbol *
sysprof_kernel_symbol_lookup (SysprofKernelSymbol *symbols,
SysprofCaptureAddress address,
guint first,
guint last)
{
@ -272,25 +272,25 @@ sp_kernel_symbol_lookup (SpKernelSymbol *symbols,
int mid = (first + last) / 2;
if (symbols [mid].address > address)
return sp_kernel_symbol_lookup (symbols, address, first, mid);
return sysprof_kernel_symbol_lookup (symbols, address, first, mid);
else
return sp_kernel_symbol_lookup (symbols, address, mid, last);
return sysprof_kernel_symbol_lookup (symbols, address, mid, last);
}
}
/**
* sp_kernel_symbol_from_address:
* sysprof_kernel_symbol_from_address:
* @address: the address of the instruction pointer
*
* Locates the kernel symbol that contains @address.
*
* Returns: (transfer none): An #SpKernelSymbol or %NULL.
* Returns: (transfer none): An #SysprofKernelSymbol or %NULL.
*/
const SpKernelSymbol *
sp_kernel_symbol_from_address (SpCaptureAddress address)
const SysprofKernelSymbol *
sysprof_kernel_symbol_from_address (SysprofCaptureAddress address)
{
const SpKernelSymbol *first;
const SpKernelSymbol *ret;
const SysprofKernelSymbol *first;
const SysprofKernelSymbol *ret;
if G_UNLIKELY (kernel_symbols == NULL)
{
@ -299,7 +299,7 @@ sp_kernel_symbol_from_address (SpCaptureAddress address)
if (failed)
return NULL;
if (!sp_kernel_symbol_load ())
if (!sysprof_kernel_symbol_load ())
{
failed = TRUE;
return NULL;
@ -310,11 +310,11 @@ sp_kernel_symbol_from_address (SpCaptureAddress address)
g_assert (kernel_symbols->len > 0);
/* Short circuit if this is out of range */
first = &g_array_index (kernel_symbols, SpKernelSymbol, 0);
first = &g_array_index (kernel_symbols, SysprofKernelSymbol, 0);
if (address < first->address)
return NULL;
ret = sp_kernel_symbol_lookup ((SpKernelSymbol *)(gpointer)kernel_symbols->data,
ret = sysprof_kernel_symbol_lookup ((SysprofKernelSymbol *)(gpointer)kernel_symbols->data,
address,
0,
kernel_symbols->len - 1);

View File

@ -1,4 +1,4 @@
/* sp-kernel-symbol.h
/* sysprof-kernel-symbol.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,16 +20,16 @@
#pragma once
#include "sp-capture-types.h"
#include "sysprof-capture-types.h"
G_BEGIN_DECLS
typedef struct
{
SpCaptureAddress address;
SysprofCaptureAddress address;
const gchar *name;
} SpKernelSymbol;
} SysprofKernelSymbol;
const SpKernelSymbol *sp_kernel_symbol_from_address (SpCaptureAddress address);
const SysprofKernelSymbol *sysprof_kernel_symbol_from_address (SysprofCaptureAddress address);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-line-reader.c
/* sysprof-line-reader.c
*
* Copyright 2015-2019 Christian Hergert <christian@hergert.me>
*
@ -22,9 +22,9 @@
#include <string.h>
#include "sp-line-reader.h"
#include "sysprof-line-reader.h"
struct _SpLineReader
struct _SysprofLineReader
{
const gchar *contents;
gsize length;
@ -32,30 +32,30 @@ struct _SpLineReader
};
void
sp_line_reader_free (SpLineReader *self)
sysprof_line_reader_free (SysprofLineReader *self)
{
g_slice_free (SpLineReader, self);
g_slice_free (SysprofLineReader, self);
}
/**
* sp_line_reader_new:
* sysprof_line_reader_new:
* @contents: The buffer to read lines from
* @length: the length of @buffer in bytes
*
* Creates a new #SpLineReader for the contents provided. @contents are not
* Creates a new #SysprofLineReader for the contents provided. @contents are not
* copied and therefore it is a programming error to free contents before
* freeing the #SpLineReader structure.
* freeing the #SysprofLineReader structure.
*
* Use sp_line_reader_next() to read through the lines of the buffer.
* Use sysprof_line_reader_next() to read through the lines of the buffer.
*
* Returns: (transfer full): A new #SpLineReader that should be freed with
* sp_line_reader_free() when no longer in use.
* Returns: (transfer full): A new #SysprofLineReader that should be freed with
* sysprof_line_reader_free() when no longer in use.
*/
SpLineReader *
sp_line_reader_new (const gchar *contents,
SysprofLineReader *
sysprof_line_reader_new (const gchar *contents,
gssize length)
{
SpLineReader *self = g_slice_new (SpLineReader);
SysprofLineReader *self = g_slice_new (SysprofLineReader);
if (contents == NULL)
{
@ -75,13 +75,13 @@ sp_line_reader_new (const gchar *contents,
}
/**
* sp_line_reader_next:
* @self: the #SpLineReader
* sysprof_line_reader_next:
* @self: the #SysprofLineReader
* @length: a location for the length of the line in bytes
*
* Moves forward to the beginning of the next line in the buffer. No changes to
* the buffer are made, and the result is a pointer within the string passed as
* @contents in sp_line_reader_init(). Since the line most likely will not be
* @contents in sysprof_line_reader_init(). Since the line most likely will not be
* terminated with a NULL byte, you must provide @length to determine the
* length of the line.
*
@ -94,7 +94,7 @@ sp_line_reader_new (const gchar *contents,
* Returns: (nullable) (transfer none): The beginning of the line within the buffer
*/
const gchar *
sp_line_reader_next (SpLineReader *self,
sysprof_line_reader_next (SysprofLineReader *self,
gsize *length)
{
const gchar *ret;

View File

@ -1,4 +1,4 @@
/* sp-line-reader.h
/* sysprof-line-reader.h
*
* Copyright 2015-2019 Christian Hergert <christian@hergert.me>
*
@ -24,17 +24,17 @@
G_BEGIN_DECLS
typedef struct _SpLineReader SpLineReader;
typedef struct _SysprofLineReader SysprofLineReader;
G_GNUC_INTERNAL
SpLineReader *sp_line_reader_new (const gchar *contents,
SysprofLineReader *sysprof_line_reader_new (const gchar *contents,
gssize length);
G_GNUC_INTERNAL
void sp_line_reader_free (SpLineReader *self);
void sysprof_line_reader_free (SysprofLineReader *self);
G_GNUC_INTERNAL
const gchar *sp_line_reader_next (SpLineReader *self,
const gchar *sysprof_line_reader_next (SysprofLineReader *self,
gsize *length);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpLineReader, sp_line_reader_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofLineReader, sysprof_line_reader_free)
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-local-profiler.c
/* sysprof-local-profiler.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -25,12 +25,12 @@
#include <errno.h>
#include <unistd.h>
#include "sp-local-profiler.h"
#include "sp-platform.h"
#include "sysprof-local-profiler.h"
#include "sysprof-platform.h"
typedef struct
{
SpCaptureWriter *writer;
SysprofCaptureWriter *writer;
/* All sources added */
GPtrArray *sources;
@ -85,13 +85,13 @@ typedef struct
* We do this to avoid a more complex state machine (for now).
*/
guint stop_after_starting : 1;
} SpLocalProfilerPrivate;
} SysprofLocalProfilerPrivate;
static void profiler_iface_init (SpProfilerInterface *iface);
static void profiler_iface_init (SysprofProfilerInterface *iface);
G_DEFINE_TYPE_EXTENDED (SpLocalProfiler, sp_local_profiler, G_TYPE_OBJECT, 0,
G_ADD_PRIVATE (SpLocalProfiler)
G_IMPLEMENT_INTERFACE (SP_TYPE_PROFILER, profiler_iface_init))
G_DEFINE_TYPE_EXTENDED (SysprofLocalProfiler, sysprof_local_profiler, G_TYPE_OBJECT, 0,
G_ADD_PRIVATE (SysprofLocalProfiler)
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_PROFILER, profiler_iface_init))
enum {
PROP_0,
@ -130,11 +130,11 @@ _g_ptr_array_contains (GPtrArray *ar,
}
static void
sp_local_profiler_clear_timer (SpLocalProfiler *self)
sysprof_local_profiler_clear_timer (SysprofLocalProfiler *self)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_clear_pointer (&priv->timer, g_timer_destroy);
@ -146,21 +146,21 @@ sp_local_profiler_clear_timer (SpLocalProfiler *self)
}
static void
sp_local_profiler_real_stopped (SpProfiler *profiler)
sysprof_local_profiler_real_stopped (SysprofProfiler *profiler)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
sp_local_profiler_clear_timer (self);
sysprof_local_profiler_clear_timer (self);
}
static gboolean
sp_local_profiler_notify_elapsed_cb (gpointer data)
sysprof_local_profiler_notify_elapsed_cb (gpointer data)
{
SpLocalProfiler *self = data;
SysprofLocalProfiler *self = data;
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_object_notify (G_OBJECT (self), "elapsed");
@ -168,11 +168,11 @@ sp_local_profiler_notify_elapsed_cb (gpointer data)
}
static void
sp_local_profiler_finish_stopping (SpLocalProfiler *self)
sysprof_local_profiler_finish_stopping (SysprofLocalProfiler *self)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (priv->is_starting == FALSE);
g_assert (priv->is_stopping == TRUE);
g_assert (priv->stopping->len == 0);
@ -181,26 +181,26 @@ sp_local_profiler_finish_stopping (SpLocalProfiler *self)
{
const GError *error = g_ptr_array_index (priv->failures, 0);
sp_profiler_emit_failed (SP_PROFILER (self), error);
sysprof_profiler_emit_failed (SYSPROF_PROFILER (self), error);
}
priv->is_running = FALSE;
priv->is_stopping = FALSE;
sp_profiler_emit_stopped (SP_PROFILER (self));
sysprof_profiler_emit_stopped (SYSPROF_PROFILER (self));
g_object_notify (G_OBJECT (self), "is-mutable");
g_object_notify (G_OBJECT (self), "is-running");
}
static void
sp_local_profiler_stop (SpProfiler *profiler)
sysprof_local_profiler_stop (SysprofProfiler *profiler)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
guint i;
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
if (priv->is_starting)
{
@ -217,13 +217,13 @@ sp_local_profiler_stop (SpProfiler *profiler)
* First we add everything to the stopping list, so that we can
* be notified of when they have completed. If everything stopped
* synchronously, the stopping list will be empty after calling
* sp_source_stop() for every source. Otherwise, we need to delay
* sysprof_source_stop() for every source. Otherwise, we need to delay
* stopping for a little bit.
*/
for (i = 0; i < priv->sources->len; i++)
{
SpSource *source = g_ptr_array_index (priv->sources, i);
SysprofSource *source = g_ptr_array_index (priv->sources, i);
if (!_g_ptr_array_contains (priv->finished_or_failed, source))
g_ptr_array_add (priv->stopping, g_object_ref (source));
@ -231,40 +231,40 @@ sp_local_profiler_stop (SpProfiler *profiler)
for (i = 0; i < priv->sources->len; i++)
{
SpSource *source = g_ptr_array_index (priv->sources, i);
SysprofSource *source = g_ptr_array_index (priv->sources, i);
sp_source_stop (source);
sysprof_source_stop (source);
}
if (priv->is_stopping && priv->stopping->len == 0)
sp_local_profiler_finish_stopping (self);
sysprof_local_profiler_finish_stopping (self);
}
static void
sp_local_profiler_dispose (GObject *object)
sysprof_local_profiler_dispose (GObject *object)
{
SpLocalProfiler *self = (SpLocalProfiler *)object;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)object;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
if (priv->is_running || priv->is_starting)
{
sp_local_profiler_stop (SP_PROFILER (self));
sysprof_local_profiler_stop (SYSPROF_PROFILER (self));
return;
}
sp_local_profiler_clear_timer (self);
sysprof_local_profiler_clear_timer (self);
G_OBJECT_CLASS (sp_local_profiler_parent_class)->dispose (object);
G_OBJECT_CLASS (sysprof_local_profiler_parent_class)->dispose (object);
}
static void
sp_local_profiler_finalize (GObject *object)
sysprof_local_profiler_finalize (GObject *object)
{
SpLocalProfiler *self = (SpLocalProfiler *)object;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)object;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_clear_pointer (&priv->writer, sp_capture_writer_unref);
g_clear_pointer (&priv->writer, sysprof_capture_writer_unref);
g_clear_pointer (&priv->sources, g_ptr_array_unref);
g_clear_pointer (&priv->starting, g_ptr_array_unref);
g_clear_pointer (&priv->stopping, g_ptr_array_unref);
@ -272,17 +272,17 @@ sp_local_profiler_finalize (GObject *object)
g_clear_pointer (&priv->finished_or_failed, g_ptr_array_unref);
g_clear_pointer (&priv->pids, g_array_unref);
G_OBJECT_CLASS (sp_local_profiler_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_local_profiler_parent_class)->finalize (object);
}
static void
sp_local_profiler_get_property (GObject *object,
sysprof_local_profiler_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SpLocalProfiler *self = SP_LOCAL_PROFILER (object);
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = SYSPROF_LOCAL_PROFILER (object);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
switch (prop_id)
{
@ -324,13 +324,13 @@ sp_local_profiler_get_property (GObject *object,
}
static void
sp_local_profiler_set_property (GObject *object,
sysprof_local_profiler_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SpLocalProfiler *self = SP_LOCAL_PROFILER (object);
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = SYSPROF_LOCAL_PROFILER (object);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
switch (prop_id)
{
@ -362,14 +362,14 @@ sp_local_profiler_set_property (GObject *object,
}
static void
sp_local_profiler_class_init (SpLocalProfilerClass *klass)
sysprof_local_profiler_class_init (SysprofLocalProfilerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = sp_local_profiler_dispose;
object_class->finalize = sp_local_profiler_finalize;
object_class->get_property = sp_local_profiler_get_property;
object_class->set_property = sp_local_profiler_set_property;
object_class->dispose = sysprof_local_profiler_dispose;
object_class->finalize = sysprof_local_profiler_finalize;
object_class->get_property = sysprof_local_profiler_get_property;
object_class->set_property = sysprof_local_profiler_set_property;
g_object_class_override_property (object_class, PROP_ELAPSED, "elapsed");
g_object_class_override_property (object_class, PROP_IS_MUTABLE, "is-mutable");
@ -382,9 +382,9 @@ sp_local_profiler_class_init (SpLocalProfilerClass *klass)
}
static void
sp_local_profiler_init (SpLocalProfiler *self)
sysprof_local_profiler_init (SysprofLocalProfiler *self)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
priv->whole_system = TRUE;
@ -396,23 +396,23 @@ sp_local_profiler_init (SpLocalProfiler *self)
priv->pids = g_array_new (FALSE, FALSE, sizeof (GPid));
}
SpProfiler *
sp_local_profiler_new (void)
SysprofProfiler *
sysprof_local_profiler_new (void)
{
return g_object_new (SP_TYPE_LOCAL_PROFILER, NULL);
return g_object_new (SYSPROF_TYPE_LOCAL_PROFILER, NULL);
}
static void
sp_local_profiler_finish_startup (SpLocalProfiler *self)
sysprof_local_profiler_finish_startup (SysprofLocalProfiler *self)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
guint i;
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (priv->is_starting == TRUE);
g_assert (priv->starting->len == 0);
sp_local_profiler_clear_timer (self);
sysprof_local_profiler_clear_timer (self);
priv->timer = g_timer_new ();
@ -423,14 +423,14 @@ sp_local_profiler_finish_startup (SpLocalProfiler *self)
*/
priv->timer_notify_source =
g_timeout_add (1000,
sp_local_profiler_notify_elapsed_cb,
sysprof_local_profiler_notify_elapsed_cb,
self);
for (i = 0; i < priv->sources->len; i++)
{
SpSource *source = g_ptr_array_index (priv->sources, i);
SysprofSource *source = g_ptr_array_index (priv->sources, i);
sp_source_start (source);
sysprof_source_start (source);
}
priv->is_starting = FALSE;
@ -444,8 +444,8 @@ sp_local_profiler_finish_startup (SpLocalProfiler *self)
const GError *error = g_ptr_array_index (priv->failures, 0);
g_object_ref (self);
sp_profiler_emit_failed (SP_PROFILER (self), error);
sp_local_profiler_stop (SP_PROFILER (self));
sysprof_profiler_emit_failed (SYSPROF_PROFILER (self), error);
sysprof_local_profiler_stop (SYSPROF_PROFILER (self));
g_object_unref (self);
return;
}
@ -462,17 +462,17 @@ sp_local_profiler_finish_startup (SpLocalProfiler *self)
* If we detect this, we stop immediately.
*/
if (priv->finished_or_failed->len == priv->sources->len || priv->stop_after_starting)
sp_local_profiler_stop (SP_PROFILER (self));
sysprof_local_profiler_stop (SYSPROF_PROFILER (self));
}
static void
sp_local_profiler_start (SpProfiler *profiler)
sysprof_local_profiler_start (SysprofProfiler *profiler)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
guint i;
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (priv->is_running == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
g_return_if_fail (priv->is_starting == FALSE);
@ -482,11 +482,11 @@ sp_local_profiler_start (SpProfiler *profiler)
if (priv->writer == NULL)
{
SpCaptureWriter *writer;
SysprofCaptureWriter *writer;
int fd;
if ((-1 == (fd = sp_memfd_create ("[sysprof]"))) ||
(NULL == (writer = sp_capture_writer_new_from_fd (fd, 0))))
if ((-1 == (fd = sysprof_memfd_create ("[sysprof]"))) ||
(NULL == (writer = sysprof_capture_writer_new_from_fd (fd, 0))))
{
const GError error = {
G_FILE_ERROR,
@ -497,13 +497,13 @@ sp_local_profiler_start (SpProfiler *profiler)
if (fd != -1)
close (fd);
sp_profiler_emit_failed (SP_PROFILER (self), &error);
sysprof_profiler_emit_failed (SYSPROF_PROFILER (self), &error);
return;
}
sp_profiler_set_writer (SP_PROFILER (self), writer);
g_clear_pointer (&writer, sp_capture_writer_unref);
sysprof_profiler_set_writer (SYSPROF_PROFILER (self), writer);
g_clear_pointer (&writer, sysprof_capture_writer_unref);
}
priv->is_running = TRUE;
@ -552,7 +552,7 @@ sp_local_profiler_start (SpProfiler *profiler)
for (i = 0; i < priv->sources->len; i++)
{
SpSource *source = g_ptr_array_index (priv->sources, i);
SysprofSource *source = g_ptr_array_index (priv->sources, i);
guint j;
if (priv->whole_system == FALSE)
@ -561,56 +561,56 @@ sp_local_profiler_start (SpProfiler *profiler)
{
GPid pid = g_array_index (priv->pids, GPid, j);
sp_source_add_pid (source, pid);
sysprof_source_add_pid (source, pid);
}
}
sp_source_set_writer (source, priv->writer);
sp_source_prepare (source);
sysprof_source_set_writer (source, priv->writer);
sysprof_source_prepare (source);
}
for (i = 0; i < priv->sources->len; i++)
{
SpSource *source = g_ptr_array_index (priv->sources, i);
SysprofSource *source = g_ptr_array_index (priv->sources, i);
if (!sp_source_get_is_ready (source))
if (!sysprof_source_get_is_ready (source))
g_ptr_array_add (priv->starting, g_object_ref (source));
}
if (priv->starting->len == 0)
sp_local_profiler_finish_startup (self);
sysprof_local_profiler_finish_startup (self);
}
static void
sp_local_profiler_set_writer (SpProfiler *profiler,
SpCaptureWriter *writer)
sysprof_local_profiler_set_writer (SysprofProfiler *profiler,
SysprofCaptureWriter *writer)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (priv->is_running == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
g_return_if_fail (writer != NULL);
if (priv->writer != writer)
{
g_clear_pointer (&priv->writer, sp_capture_writer_unref);
g_clear_pointer (&priv->writer, sysprof_capture_writer_unref);
if (writer != NULL)
priv->writer = sp_capture_writer_ref (writer);
priv->writer = sysprof_capture_writer_ref (writer);
}
}
static void
sp_local_profiler_track_completed (SpLocalProfiler *self,
SpSource *source)
sysprof_local_profiler_track_completed (SysprofLocalProfiler *self,
SysprofSource *source)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
gint i;
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SP_IS_SOURCE (source));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_SOURCE (source));
if (!_g_ptr_array_contains (priv->finished_or_failed, source))
g_ptr_array_add (priv->finished_or_failed, g_object_ref (source));
@ -623,7 +623,7 @@ sp_local_profiler_track_completed (SpLocalProfiler *self,
{
g_ptr_array_remove_index (priv->starting, i);
if (priv->starting->len == 0)
sp_local_profiler_finish_startup (self);
sysprof_local_profiler_finish_startup (self);
}
}
@ -636,47 +636,47 @@ sp_local_profiler_track_completed (SpLocalProfiler *self,
g_ptr_array_remove_index_fast (priv->stopping, i);
if ((priv->is_stopping == TRUE) && (priv->stopping->len == 0))
sp_local_profiler_finish_stopping (self);
sysprof_local_profiler_finish_stopping (self);
}
}
if (!priv->is_starting)
{
if (priv->finished_or_failed->len == priv->sources->len)
sp_local_profiler_stop (SP_PROFILER (self));
sysprof_local_profiler_stop (SYSPROF_PROFILER (self));
}
}
static void
sp_local_profiler_source_finished (SpLocalProfiler *self,
SpSource *source)
sysprof_local_profiler_source_finished (SysprofLocalProfiler *self,
SysprofSource *source)
{
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SP_IS_SOURCE (source));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_SOURCE (source));
sp_local_profiler_track_completed (self, source);
sysprof_local_profiler_track_completed (self, source);
}
static void
sp_local_profiler_source_ready (SpLocalProfiler *self,
SpSource *source)
sysprof_local_profiler_source_ready (SysprofLocalProfiler *self,
SysprofSource *source)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
guint i;
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SP_IS_SOURCE (source));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_SOURCE (source));
for (i = 0; i < priv->starting->len; i++)
{
SpSource *ele = g_ptr_array_index (priv->starting, i);
SysprofSource *ele = g_ptr_array_index (priv->starting, i);
if (ele == source)
{
g_ptr_array_remove_index_fast (priv->starting, i);
if ((priv->is_starting == TRUE) && (priv->starting->len == 0))
sp_local_profiler_finish_startup (self);
sysprof_local_profiler_finish_startup (self);
break;
}
@ -684,17 +684,17 @@ sp_local_profiler_source_ready (SpLocalProfiler *self,
}
static void
sp_local_profiler_source_failed (SpLocalProfiler *self,
sysprof_local_profiler_source_failed (SysprofLocalProfiler *self,
const GError *reason,
SpSource *source)
SysprofSource *source)
{
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_assert (SP_IS_LOCAL_PROFILER (self));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_assert (reason != NULL);
g_assert (SP_IS_SOURCE (source));
g_assert (SYSPROF_IS_SOURCE (source));
sp_local_profiler_track_completed (self, source);
sysprof_local_profiler_track_completed (self, source);
/* Failure emitted out of band */
if (!priv->is_starting && !priv->is_stopping && !priv->is_running)
@ -707,37 +707,37 @@ sp_local_profiler_source_failed (SpLocalProfiler *self,
return;
if (priv->is_running)
sp_local_profiler_stop (SP_PROFILER (self));
sysprof_local_profiler_stop (SYSPROF_PROFILER (self));
}
static void
sp_local_profiler_add_source (SpProfiler *profiler,
SpSource *source)
sysprof_local_profiler_add_source (SysprofProfiler *profiler,
SysprofSource *source)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SP_IS_SOURCE (source));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_SOURCE (source));
g_return_if_fail (priv->is_running == FALSE);
g_return_if_fail (priv->is_starting == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
g_signal_connect_object (source,
"failed",
G_CALLBACK (sp_local_profiler_source_failed),
G_CALLBACK (sysprof_local_profiler_source_failed),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (source,
"finished",
G_CALLBACK (sp_local_profiler_source_finished),
G_CALLBACK (sysprof_local_profiler_source_finished),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (source,
"ready",
G_CALLBACK (sp_local_profiler_source_ready),
G_CALLBACK (sysprof_local_profiler_source_ready),
self,
G_CONNECT_SWAPPED);
@ -746,13 +746,13 @@ sp_local_profiler_add_source (SpProfiler *profiler,
}
static void
sp_local_profiler_add_pid (SpProfiler *profiler,
sysprof_local_profiler_add_pid (SysprofProfiler *profiler,
GPid pid)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (pid > -1);
g_return_if_fail (priv->is_starting == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
@ -762,14 +762,14 @@ sp_local_profiler_add_pid (SpProfiler *profiler,
}
static void
sp_local_profiler_remove_pid (SpProfiler *profiler,
sysprof_local_profiler_remove_pid (SysprofProfiler *profiler,
GPid pid)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
guint i;
g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (pid > -1);
g_return_if_fail (priv->is_starting == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
@ -788,13 +788,13 @@ sp_local_profiler_remove_pid (SpProfiler *profiler,
}
static const GPid *
sp_local_profiler_get_pids (SpProfiler *profiler,
sysprof_local_profiler_get_pids (SysprofProfiler *profiler,
guint *n_pids)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_return_val_if_fail (SP_IS_LOCAL_PROFILER (self), NULL);
g_return_val_if_fail (SYSPROF_IS_LOCAL_PROFILER (self), NULL);
g_return_val_if_fail (n_pids != NULL, NULL);
*n_pids = priv->pids->len;
@ -802,27 +802,27 @@ sp_local_profiler_get_pids (SpProfiler *profiler,
return (GPid *)(gpointer)priv->pids->data;
}
static SpCaptureWriter *
sp_local_profiler_get_writer (SpProfiler *profiler)
static SysprofCaptureWriter *
sysprof_local_profiler_get_writer (SysprofProfiler *profiler)
{
SpLocalProfiler *self = (SpLocalProfiler *)profiler;
SpLocalProfilerPrivate *priv = sp_local_profiler_get_instance_private (self);
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_return_val_if_fail (SP_IS_LOCAL_PROFILER (self), NULL);
g_return_val_if_fail (SYSPROF_IS_LOCAL_PROFILER (self), NULL);
return priv->writer;
}
static void
profiler_iface_init (SpProfilerInterface *iface)
profiler_iface_init (SysprofProfilerInterface *iface)
{
iface->add_pid = sp_local_profiler_add_pid;
iface->add_source = sp_local_profiler_add_source;
iface->get_pids = sp_local_profiler_get_pids;
iface->get_writer = sp_local_profiler_get_writer;
iface->remove_pid = sp_local_profiler_remove_pid;
iface->set_writer = sp_local_profiler_set_writer;
iface->start = sp_local_profiler_start;
iface->stop = sp_local_profiler_stop;
iface->stopped = sp_local_profiler_real_stopped;
iface->add_pid = sysprof_local_profiler_add_pid;
iface->add_source = sysprof_local_profiler_add_source;
iface->get_pids = sysprof_local_profiler_get_pids;
iface->get_writer = sysprof_local_profiler_get_writer;
iface->remove_pid = sysprof_local_profiler_remove_pid;
iface->set_writer = sysprof_local_profiler_set_writer;
iface->start = sysprof_local_profiler_start;
iface->stop = sysprof_local_profiler_stop;
iface->stopped = sysprof_local_profiler_real_stopped;
}

View File

@ -1,4 +1,4 @@
/* sp-local-profiler.h
/* sysprof-local-profiler.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,24 +20,24 @@
#pragma once
#include "sp-profiler.h"
#include "sysprof-profiler.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
#define SP_TYPE_LOCAL_PROFILER (sp_local_profiler_get_type())
#define SYSPROF_TYPE_LOCAL_PROFILER (sysprof_local_profiler_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (SpLocalProfiler, sp_local_profiler, SP, LOCAL_PROFILER, GObject)
G_DECLARE_DERIVABLE_TYPE (SysprofLocalProfiler, sysprof_local_profiler, SYSPROF, LOCAL_PROFILER, GObject)
struct _SpLocalProfilerClass
struct _SysprofLocalProfilerClass
{
GObjectClass parent_class;
gpointer padding[8];
};
SYSPROF_AVAILABLE_IN_ALL
SpProfiler *sp_local_profiler_new (void);
SysprofProfiler *sysprof_local_profiler_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-map-lookaside.c
/* sysprof-map-lookaside.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -20,32 +20,32 @@
#include "config.h"
#include "sp-map-lookaside.h"
#include "sysprof-map-lookaside.h"
struct _SpMapLookaside
struct _SysprofMapLookaside
{
GSequence *seq;
GStringChunk *chunk;
};
static gint
sp_map_compare (gconstpointer a,
sysprof_map_compare (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
const SpMap *map_a = a;
const SpMap *map_b = b;
const SysprofMap *map_a = a;
const SysprofMap *map_b = b;
return sp_capture_address_compare (map_a->start, map_b->start);
return sysprof_capture_address_compare (map_a->start, map_b->start);
}
static gint
sp_map_compare_in_range (gconstpointer a,
sysprof_map_compare_in_range (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
const SpMap *map_a = a;
const SpMap *map_b = b;
const SysprofMap *map_a = a;
const SysprofMap *map_b = b;
/*
* map_b is the needle for the search.
@ -55,66 +55,66 @@ sp_map_compare_in_range (gconstpointer a,
if ((map_b->start >= map_a->start) && (map_b->start < map_a->end))
return 0;
return sp_capture_address_compare (map_a->start, map_b->start);
return sysprof_capture_address_compare (map_a->start, map_b->start);
}
static void
sp_map_free (gpointer data)
sysprof_map_free (gpointer data)
{
SpMap *map = data;
SysprofMap *map = data;
g_slice_free (SpMap, map);
g_slice_free (SysprofMap, map);
}
SpMapLookaside *
sp_map_lookaside_new (void)
SysprofMapLookaside *
sysprof_map_lookaside_new (void)
{
SpMapLookaside *ret;
SysprofMapLookaside *ret;
ret = g_slice_new (SpMapLookaside);
ret->seq = g_sequence_new (sp_map_free);
ret = g_slice_new (SysprofMapLookaside);
ret->seq = g_sequence_new (sysprof_map_free);
ret->chunk = g_string_chunk_new (4096);
return ret;
}
void
sp_map_lookaside_free (SpMapLookaside *self)
sysprof_map_lookaside_free (SysprofMapLookaside *self)
{
g_sequence_free (self->seq);
g_string_chunk_free (self->chunk);
g_slice_free (SpMapLookaside, self);
g_slice_free (SysprofMapLookaside, self);
}
void
sp_map_lookaside_insert (SpMapLookaside *self,
const SpMap *map)
sysprof_map_lookaside_insert (SysprofMapLookaside *self,
const SysprofMap *map)
{
SpMap *copy;
SysprofMap *copy;
g_assert (self != NULL);
g_assert (map != NULL);
copy = g_slice_new (SpMap);
copy = g_slice_new (SysprofMap);
copy->start = map->start;
copy->end = map->end;
copy->offset = map->offset;
copy->inode = map->inode;
copy->filename = g_string_chunk_insert_const (self->chunk, map->filename);
g_sequence_insert_sorted (self->seq, copy, sp_map_compare, NULL);
g_sequence_insert_sorted (self->seq, copy, sysprof_map_compare, NULL);
}
const SpMap *
sp_map_lookaside_lookup (SpMapLookaside *self,
SpCaptureAddress address)
const SysprofMap *
sysprof_map_lookaside_lookup (SysprofMapLookaside *self,
SysprofCaptureAddress address)
{
SpMap map = { address };
SysprofMap map = { address };
GSequenceIter *iter;
g_assert (self != NULL);
iter = g_sequence_lookup (self->seq, &map, sp_map_compare_in_range, NULL);
iter = g_sequence_lookup (self->seq, &map, sysprof_map_compare_in_range, NULL);
if (iter != NULL)
return g_sequence_get (iter);

View File

@ -1,4 +1,4 @@
/* sp-map-lookaside.h
/* sysprof-map-lookaside.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,28 +22,28 @@
#include <glib.h>
#include "sp-capture-types.h"
#include "sysprof-capture-types.h"
G_BEGIN_DECLS
typedef struct _SpMapLookaside SpMapLookaside;
typedef struct _SysprofMapLookaside SysprofMapLookaside;
typedef struct
{
SpCaptureAddress start;
SpCaptureAddress end;
SysprofCaptureAddress start;
SysprofCaptureAddress end;
off_t offset;
ino_t inode;
const gchar *filename;
} SpMap;
} SysprofMap;
SpMapLookaside *sp_map_lookaside_new (void);
void sp_map_lookaside_insert (SpMapLookaside *self,
const SpMap *map);
const SpMap *sp_map_lookaside_lookup (SpMapLookaside *self,
SpCaptureAddress address);
void sp_map_lookaside_free (SpMapLookaside *self);
SysprofMapLookaside *sysprof_map_lookaside_new (void);
void sysprof_map_lookaside_insert (SysprofMapLookaside *self,
const SysprofMap *map);
const SysprofMap *sysprof_map_lookaside_lookup (SysprofMapLookaside *self,
SysprofCaptureAddress address);
void sysprof_map_lookaside_free (SysprofMapLookaside *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpMapLookaside, sp_map_lookaside_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMapLookaside, sysprof_map_lookaside_free)
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-memory-source.c
/* sysprof-memory-source.c
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -18,7 +18,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#define G_LOG_DOMAIN "sp-memory-source"
#define G_LOG_DOMAIN "sysprof-memory-source"
#include "config.h"
@ -28,16 +28,16 @@
#include <sysprof-capture.h>
#include <unistd.h>
#include "sp-memory-source.h"
#include "sysprof-memory-source.h"
#define BUF_SIZE 4096
struct _SpMemorySource
struct _SysprofMemorySource
{
GObject parent_instance;
/* Capture writer to deliver samples */
SpCaptureWriter *writer;
SysprofCaptureWriter *writer;
/* 4k stat buffer for reading proc */
gchar *stat_buf;
@ -56,13 +56,13 @@ typedef struct
union {
struct {
SpCaptureCounterValue used;
SysprofCaptureCounterValue used;
gint64 total;
gint64 avail;
gint64 free;
} sys;
struct {
SpCaptureCounterValue used;
SysprofCaptureCounterValue used;
gint64 size;
gint64 resident;
gint64 shared;
@ -74,10 +74,10 @@ typedef struct
guint counter_ids[1];
} MemStat;
static void source_iface_init (SpSourceInterface *iface);
static void source_iface_init (SysprofSourceInterface *iface);
G_DEFINE_TYPE_WITH_CODE (SpMemorySource, sp_memory_source, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SP_TYPE_SOURCE, source_iface_init))
G_DEFINE_TYPE_WITH_CODE (SysprofMemorySource, sysprof_memory_source, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
static GHashTable *keys;
@ -221,13 +221,13 @@ mem_stat_poll (MemStat *st,
static void
mem_stat_publish (MemStat *st,
SpCaptureWriter *writer,
SysprofCaptureWriter *writer,
gint64 current_time)
{
g_assert (st != NULL);
g_assert (writer != NULL);
sp_capture_writer_set_counters (writer,
sysprof_capture_writer_set_counters (writer,
current_time,
-1,
st->pid,
@ -237,27 +237,27 @@ mem_stat_publish (MemStat *st,
}
/**
* sp_memory_source_new:
* sysprof_memory_source_new:
*
* Create a new #SpMemorySource.
* Create a new #SysprofMemorySource.
*
* Use this source to record basic memory statistics about the system
* such as Available, Free, and Total Memory.
*
* Returns: (transfer full): a newly created #SpMemorySource
* Returns: (transfer full): a newly created #SysprofMemorySource
* Since: 3.32
*/
SpSource *
sp_memory_source_new (void)
SysprofSource *
sysprof_memory_source_new (void)
{
return g_object_new (SP_TYPE_MEMORY_SOURCE, NULL);
return g_object_new (SYSPROF_TYPE_MEMORY_SOURCE, NULL);
}
static void
sp_memory_source_finalize (GObject *object)
sysprof_memory_source_finalize (GObject *object)
{
SpMemorySource *self = (SpMemorySource *)object;
SysprofMemorySource *self = (SysprofMemorySource *)object;
if (self->timer_source != 0)
{
@ -266,18 +266,18 @@ sp_memory_source_finalize (GObject *object)
}
g_clear_pointer (&self->stat_buf, g_free);
g_clear_pointer (&self->writer, sp_capture_writer_unref);
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
g_clear_pointer (&self->mem_stats, g_array_unref);
G_OBJECT_CLASS (sp_memory_source_parent_class)->finalize (object);
G_OBJECT_CLASS (sysprof_memory_source_parent_class)->finalize (object);
}
static void
sp_memory_source_class_init (SpMemorySourceClass *klass)
sysprof_memory_source_class_init (SysprofMemorySourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sp_memory_source_finalize;
object_class->finalize = sysprof_memory_source_finalize;
keys = g_hash_table_new (g_str_hash, g_str_equal);
@ -290,31 +290,31 @@ sp_memory_source_class_init (SpMemorySourceClass *klass)
}
static void
sp_memory_source_init (SpMemorySource *self)
sysprof_memory_source_init (SysprofMemorySource *self)
{
self->stat_buf = g_malloc (BUF_SIZE);
self->mem_stats = g_array_new (FALSE, FALSE, sizeof (MemStat));
}
static void
sp_memory_source_set_writer (SpSource *source,
SpCaptureWriter *writer)
sysprof_memory_source_set_writer (SysprofSource *source,
SysprofCaptureWriter *writer)
{
SpMemorySource *self = (SpMemorySource *)source;
SysprofMemorySource *self = (SysprofMemorySource *)source;
g_assert (SP_IS_SOURCE (self));
g_assert (SYSPROF_IS_SOURCE (self));
g_assert (writer != NULL);
g_assert (self->writer == NULL);
self->writer = sp_capture_writer_ref (writer);
self->writer = sysprof_capture_writer_ref (writer);
}
static void
sp_memory_source_prepare (SpSource *source)
sysprof_memory_source_prepare (SysprofSource *source)
{
SpMemorySource *self = (SpMemorySource *)source;
SysprofMemorySource *self = (SysprofMemorySource *)source;
g_assert (SP_IS_MEMORY_SOURCE (self));
g_assert (SYSPROF_IS_MEMORY_SOURCE (self));
g_assert (self->writer != NULL);
/* If no pids are registered, setup a system memory stat */
@ -334,25 +334,25 @@ sp_memory_source_prepare (SpSource *source)
for (guint i = 0; i < self->mem_stats->len; i++)
{
MemStat *st = &g_array_index (self->mem_stats, MemStat, i);
SpCaptureCounter counters[5];
SysprofCaptureCounter counters[5];
guint base;
mem_stat_open (st);
if (st->pid == -1)
{
base = sp_capture_writer_request_counter (self->writer, 1);
base = sysprof_capture_writer_request_counter (self->writer, 1);
g_strlcpy (counters[0].category, "Memory", sizeof counters[0].category);
g_strlcpy (counters[0].name, "Used", sizeof counters[0].name);
g_strlcpy (counters[0].description, "Memory used by system", sizeof counters[0].description);
counters[0].id = st->counter_ids[0] = base;
counters[0].type = SP_CAPTURE_COUNTER_DOUBLE;
counters[0].type = SYSPROF_CAPTURE_COUNTER_DOUBLE;
counters[0].value.vdbl = 0;
sp_capture_writer_define_counters (self->writer,
SP_CAPTURE_CURRENT_TIME,
sysprof_capture_writer_define_counters (self->writer,
SYSPROF_CAPTURE_CURRENT_TIME,
-1,
-1,
counters,
@ -360,18 +360,18 @@ sp_memory_source_prepare (SpSource *source)
}
else
{
base = sp_capture_writer_request_counter (self->writer, 1);
base = sysprof_capture_writer_request_counter (self->writer, 1);
g_strlcpy (counters[0].category, "Memory", sizeof counters[0].category);
g_strlcpy (counters[0].name, "Used", sizeof counters[0].name);
g_strlcpy (counters[0].description, "Memory used by process", sizeof counters[0].description);
counters[0].id = st->counter_ids[0] = base;
counters[0].type = SP_CAPTURE_COUNTER_DOUBLE;
counters[0].type = SYSPROF_CAPTURE_COUNTER_DOUBLE;
counters[0].value.vdbl = 0;
sp_capture_writer_define_counters (self->writer,
SP_CAPTURE_CURRENT_TIME,
sysprof_capture_writer_define_counters (self->writer,
SYSPROF_CAPTURE_CURRENT_TIME,
-1,
st->pid,
counters,
@ -379,18 +379,18 @@ sp_memory_source_prepare (SpSource *source)
}
}
sp_source_emit_ready (SP_SOURCE (self));
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
}
static gboolean
sp_memory_source_timer_cb (SpMemorySource *self)
sysprof_memory_source_timer_cb (SysprofMemorySource *self)
{
gint64 current_time;
g_assert (SP_IS_MEMORY_SOURCE (self));
g_assert (SYSPROF_IS_MEMORY_SOURCE (self));
g_assert (self->writer != NULL);
current_time = sp_clock_get_current_time ();
current_time = sysprof_clock_get_current_time ();
for (guint i = 0; i < self->mem_stats->len; i++)
{
@ -404,26 +404,26 @@ sp_memory_source_timer_cb (SpMemorySource *self)
}
static void
sp_memory_source_start (SpSource *source)
sysprof_memory_source_start (SysprofSource *source)
{
SpMemorySource *self = (SpMemorySource *)source;
SysprofMemorySource *self = (SysprofMemorySource *)source;
g_assert (SP_IS_MEMORY_SOURCE (self));
g_assert (SYSPROF_IS_MEMORY_SOURCE (self));
/* Poll 4x/sec for memory stats */
self->timer_source = g_timeout_add_full (G_PRIORITY_HIGH,
1000 / 4,
(GSourceFunc)sp_memory_source_timer_cb,
(GSourceFunc)sysprof_memory_source_timer_cb,
self,
NULL);
}
static void
sp_memory_source_stop (SpSource *source)
sysprof_memory_source_stop (SysprofSource *source)
{
SpMemorySource *self = (SpMemorySource *)source;
SysprofMemorySource *self = (SysprofMemorySource *)source;
g_assert (SP_IS_MEMORY_SOURCE (self));
g_assert (SYSPROF_IS_MEMORY_SOURCE (self));
if (self->timer_source != 0)
{
@ -438,17 +438,17 @@ sp_memory_source_stop (SpSource *source)
mem_stat_close (st);
}
sp_source_emit_finished (source);
sysprof_source_emit_finished (source);
}
static void
sp_memory_source_add_pid (SpSource *source,
sysprof_memory_source_add_pid (SysprofSource *source,
GPid pid)
{
SpMemorySource *self = (SpMemorySource *)source;
SysprofMemorySource *self = (SysprofMemorySource *)source;
MemStat st = {0};
g_assert (SP_IS_MEMORY_SOURCE (self));
g_assert (SYSPROF_IS_MEMORY_SOURCE (self));
st.pid = pid;
st.stat_fd = -1;
@ -457,11 +457,11 @@ sp_memory_source_add_pid (SpSource *source,
}
static void
source_iface_init (SpSourceInterface *iface)
source_iface_init (SysprofSourceInterface *iface)
{
iface->set_writer = sp_memory_source_set_writer;
iface->prepare = sp_memory_source_prepare;
iface->start = sp_memory_source_start;
iface->stop = sp_memory_source_stop;
iface->add_pid = sp_memory_source_add_pid;
iface->set_writer = sysprof_memory_source_set_writer;
iface->prepare = sysprof_memory_source_prepare;
iface->start = sysprof_memory_source_start;
iface->stop = sysprof_memory_source_stop;
iface->add_pid = sysprof_memory_source_add_pid;
}

View File

@ -1,4 +1,4 @@
/* sp-memory-source.h
/* sysprof-memory-source.h
*
* Copyright 2018-2019 Christian Hergert <chergert@redhat.com>
*
@ -22,16 +22,16 @@
#include "sysprof-version-macros.h"
#include "sp-source.h"
#include "sysprof-source.h"
G_BEGIN_DECLS
#define SP_TYPE_MEMORY_SOURCE (sp_memory_source_get_type())
#define SYSPROF_TYPE_MEMORY_SOURCE (sysprof_memory_source_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SpMemorySource, sp_memory_source, SP, MEMORY_SOURCE, GObject)
G_DECLARE_FINAL_TYPE (SysprofMemorySource, sysprof_memory_source, SYSPROF, MEMORY_SOURCE, GObject)
SYSPROF_AVAILABLE_IN_ALL
SpSource *sp_memory_source_new (void);
SysprofSource *sysprof_memory_source_new (void);
G_END_DECLS

View File

@ -1,4 +1,4 @@
/* sp-perf-counter.c
/* sysprof-perf-counter.c
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -52,7 +52,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include "sp-perf-counter.h"
#include "sysprof-perf-counter.h"
/*
* Number of pages to map for the ring buffer. We map one additional buffer
@ -61,7 +61,7 @@
#define N_PAGES 32
/*
* This represents a stream coming to us from perf. All SpPerfCounterInfo
* This represents a stream coming to us from perf. All SysprofPerfCounterInfo
* share a single GSource used for watching incoming G_IO_IN requests.
* The map is the mmap() zone we are using as a ring buffer for communicating
* with perf. The rest is for managing the ring buffer.
@ -75,9 +75,9 @@ typedef struct
guint64 tail;
gint cpu;
guint in_callback : 1;
} SpPerfCounterInfo;
} SysprofPerfCounterInfo;
struct _SpPerfCounter
struct _SysprofPerfCounter
{
volatile gint ref_count;
@ -94,7 +94,7 @@ struct _SpPerfCounter
GSource *source;
/*
* An array of SpPerfCounterInfo, indicating all of our open
* An array of SysprofPerfCounterInfo, indicating all of our open
* perf stream.s
*/
GPtrArray *info;
@ -102,7 +102,7 @@ struct _SpPerfCounter
/*
* The callback to execute for every discovered perf event.
*/
SpPerfCounterCallback callback;
SysprofPerfCounterCallback callback;
gpointer callback_data;
GDestroyNotify callback_data_destroy;
@ -115,13 +115,13 @@ struct _SpPerfCounter
typedef struct
{
GSource source;
SpPerfCounter *counter;
SysprofPerfCounter *counter;
} PerfGSource;
G_DEFINE_BOXED_TYPE (SpPerfCounter,
sp_perf_counter,
(GBoxedCopyFunc)sp_perf_counter_ref,
(GBoxedFreeFunc)sp_perf_counter_unref)
G_DEFINE_BOXED_TYPE (SysprofPerfCounter,
sysprof_perf_counter,
(GBoxedCopyFunc)sysprof_perf_counter_ref,
(GBoxedFreeFunc)sysprof_perf_counter_unref)
#ifdef ENABLE_POLKIT
static GDBusConnection *shared_conn;
@ -140,7 +140,7 @@ static GSourceFuncs source_funcs = {
};
static void
sp_perf_counter_info_free (SpPerfCounterInfo *info)
sysprof_perf_counter_info_free (SysprofPerfCounterInfo *info)
{
if (info->map)
{
@ -159,11 +159,11 @@ sp_perf_counter_info_free (SpPerfCounterInfo *info)
info->fd = 0;
}
g_slice_free (SpPerfCounterInfo, info);
g_slice_free (SysprofPerfCounterInfo, info);
}
static void
sp_perf_counter_finalize (SpPerfCounter *self)
sysprof_perf_counter_finalize (SysprofPerfCounter *self)
{
guint i;
@ -172,12 +172,12 @@ sp_perf_counter_finalize (SpPerfCounter *self)
for (i = 0; i < self->info->len; i++)
{
SpPerfCounterInfo *info = g_ptr_array_index (self->info, i);
SysprofPerfCounterInfo *info = g_ptr_array_index (self->info, i);
if (info->fdtag)
g_source_remove_unix_fd (self->source, info->fdtag);
sp_perf_counter_info_free (info);
sysprof_perf_counter_info_free (info);
}
if (self->callback_data_destroy)
@ -186,21 +186,21 @@ sp_perf_counter_finalize (SpPerfCounter *self)
g_clear_pointer (&self->source, g_source_destroy);
g_clear_pointer (&self->info, g_ptr_array_unref);
g_clear_pointer (&self->context, g_main_context_unref);
g_slice_free (SpPerfCounter, self);
g_slice_free (SysprofPerfCounter, self);
}
void
sp_perf_counter_unref (SpPerfCounter *self)
sysprof_perf_counter_unref (SysprofPerfCounter *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_perf_counter_finalize (self);
sysprof_perf_counter_finalize (self);
}
SpPerfCounter *
sp_perf_counter_ref (SpPerfCounter *self)
SysprofPerfCounter *
sysprof_perf_counter_ref (SysprofPerfCounter *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->ref_count > 0, NULL);
@ -211,8 +211,8 @@ sp_perf_counter_ref (SpPerfCounter *self)
}
static void
sp_perf_counter_flush (SpPerfCounter *self,
SpPerfCounterInfo *info)
sysprof_perf_counter_flush (SysprofPerfCounter *self,
SysprofPerfCounterInfo *info)
{
guint64 head;
guint64 tail;
@ -282,7 +282,7 @@ sp_perf_counter_flush (SpPerfCounter *self,
if (self->callback != NULL)
{
info->in_callback = TRUE;
self->callback ((SpPerfCounterEvent *)header, info->cpu, self->callback_data);
self->callback ((SysprofPerfCounterEvent *)header, info->cpu, self->callback_data);
info->in_callback = FALSE;
}
@ -296,9 +296,9 @@ sp_perf_counter_flush (SpPerfCounter *self,
}
static gboolean
sp_perf_counter_dispatch (gpointer user_data)
sysprof_perf_counter_dispatch (gpointer user_data)
{
SpPerfCounter *self = user_data;
SysprofPerfCounter *self = user_data;
guint i;
g_assert (self != NULL);
@ -306,17 +306,17 @@ sp_perf_counter_dispatch (gpointer user_data)
for (i = 0; i < self->info->len; i++)
{
SpPerfCounterInfo *info = g_ptr_array_index (self->info, i);
SysprofPerfCounterInfo *info = g_ptr_array_index (self->info, i);
sp_perf_counter_flush (self, info);
sysprof_perf_counter_flush (self, info);
}
return G_SOURCE_CONTINUE;
}
static void
sp_perf_counter_enable_info (SpPerfCounter *self,
SpPerfCounterInfo *info)
sysprof_perf_counter_enable_info (SysprofPerfCounter *self,
SysprofPerfCounterInfo *info)
{
g_assert (self != NULL);
g_assert (info != NULL);
@ -327,22 +327,22 @@ sp_perf_counter_enable_info (SpPerfCounter *self,
g_source_modify_unix_fd (self->source, info->fdtag, G_IO_IN);
}
SpPerfCounter *
sp_perf_counter_new (GMainContext *context)
SysprofPerfCounter *
sysprof_perf_counter_new (GMainContext *context)
{
SpPerfCounter *ret;
SysprofPerfCounter *ret;
if (context == NULL)
context = g_main_context_default ();
ret = g_slice_new0 (SpPerfCounter);
ret = g_slice_new0 (SysprofPerfCounter);
ret->ref_count = 1;
ret->info = g_ptr_array_new ();
ret->context = g_main_context_ref (context);
ret->source = g_source_new (&source_funcs, sizeof (PerfGSource));
((PerfGSource *)ret->source)->counter = ret;
g_source_set_callback (ret->source, sp_perf_counter_dispatch, ret, NULL);
g_source_set_callback (ret->source, sysprof_perf_counter_dispatch, ret, NULL);
g_source_set_name (ret->source, "[perf]");
g_source_attach (ret->source, context);
@ -350,7 +350,7 @@ sp_perf_counter_new (GMainContext *context)
}
void
sp_perf_counter_close (SpPerfCounter *self,
sysprof_perf_counter_close (SysprofPerfCounter *self,
gint fd)
{
guint i;
@ -360,25 +360,25 @@ sp_perf_counter_close (SpPerfCounter *self,
for (i = 0; i < self->info->len; i++)
{
SpPerfCounterInfo *info = g_ptr_array_index (self->info, i);
SysprofPerfCounterInfo *info = g_ptr_array_index (self->info, i);
if (info->fd == fd)
{
g_ptr_array_remove_index (self->info, i);
if (self->source)
g_source_remove_unix_fd (self->source, info->fdtag);
sp_perf_counter_info_free (info);
sysprof_perf_counter_info_free (info);
return;
}
}
}
static void
sp_perf_counter_add_info (SpPerfCounter *self,
sysprof_perf_counter_add_info (SysprofPerfCounter *self,
int fd,
int cpu)
{
SpPerfCounterInfo *info;
SysprofPerfCounterInfo *info;
guint8 *map;
gsize map_size;
@ -394,7 +394,7 @@ sp_perf_counter_add_info (SpPerfCounter *self,
return;
}
info = g_slice_new0 (SpPerfCounterInfo);
info = g_slice_new0 (SysprofPerfCounterInfo);
info->fd = fd;
info->map = (gpointer)map;
info->data = map + getpagesize ();
@ -406,17 +406,17 @@ sp_perf_counter_add_info (SpPerfCounter *self,
info->fdtag = g_source_add_unix_fd (self->source, info->fd, G_IO_ERR);
if (self->enabled)
sp_perf_counter_enable_info (self, info);
sysprof_perf_counter_enable_info (self, info);
}
void
sp_perf_counter_take_fd (SpPerfCounter *self,
sysprof_perf_counter_take_fd (SysprofPerfCounter *self,
int fd)
{
g_return_if_fail (self != NULL);
g_return_if_fail (fd > -1);
sp_perf_counter_add_info (self, fd, -1);
sysprof_perf_counter_add_info (self, fd, -1);
}
#ifdef ENABLE_POLKIT
@ -504,7 +504,7 @@ get_authorized_proxy (void)
}
static void
sp_perf_counter_ping_cb (GObject *object,
sysprof_perf_counter_ping_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
@ -526,7 +526,7 @@ sp_perf_counter_ping_cb (GObject *object,
}
static void
sp_perf_counter_acquire_cb (GObject *object,
sysprof_perf_counter_acquire_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
@ -563,12 +563,12 @@ sp_perf_counter_acquire_cb (GObject *object,
G_DBUS_CALL_FLAGS_NONE,
5000,
g_task_get_cancellable (task),
sp_perf_counter_ping_cb,
sysprof_perf_counter_ping_cb,
g_object_ref (task));
}
static void
sp_perf_counter_permission_cb (GObject *object,
sysprof_perf_counter_permission_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
@ -587,14 +587,14 @@ sp_perf_counter_permission_cb (GObject *object,
g_permission_acquire_async (permission,
g_task_get_cancellable (task),
sp_perf_counter_acquire_cb,
sysprof_perf_counter_acquire_cb,
g_object_ref (task));
g_object_unref (permission);
}
static void
sp_perf_counter_get_bus_cb (GObject *object,
sysprof_perf_counter_get_bus_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
@ -621,7 +621,7 @@ sp_perf_counter_get_bus_cb (GObject *object,
polkit_permission_new ("org.gnome.sysprof2.perf-event-open",
subject,
g_task_get_cancellable (task),
sp_perf_counter_permission_cb,
sysprof_perf_counter_permission_cb,
g_object_ref (task));
g_object_unref (subject);
@ -630,7 +630,7 @@ sp_perf_counter_get_bus_cb (GObject *object,
#endif
void
sp_perf_counter_authorize_async (GCancellable *cancellable,
sysprof_perf_counter_authorize_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
@ -643,7 +643,7 @@ sp_perf_counter_authorize_async (GCancellable *cancellable,
#ifdef ENABLE_POLKIT
g_bus_get (G_BUS_TYPE_SYSTEM,
cancellable,
sp_perf_counter_get_bus_cb,
sysprof_perf_counter_get_bus_cb,
g_object_ref (task));
#else
g_task_return_new_error (task,
@ -654,7 +654,7 @@ sp_perf_counter_authorize_async (GCancellable *cancellable,
}
gboolean
sp_perf_counter_authorize_finish (GAsyncResult *result,
sysprof_perf_counter_authorize_finish (GAsyncResult *result,
GError **error)
{
g_assert (G_IS_TASK (result));
@ -663,7 +663,7 @@ sp_perf_counter_authorize_finish (GAsyncResult *result,
}
gint
sp_perf_counter_open (SpPerfCounter *self,
sysprof_perf_counter_open (SysprofPerfCounter *self,
struct perf_event_attr *attr,
GPid pid,
gint cpu,
@ -689,7 +689,7 @@ sp_perf_counter_open (SpPerfCounter *self,
*/
if (-1 != (ret = syscall (__NR_perf_event_open, attr, pid, cpu, group_fd, flags)))
{
sp_perf_counter_take_fd (self, ret);
sysprof_perf_counter_take_fd (self, ret);
return ret;
}
@ -782,15 +782,15 @@ sp_perf_counter_open (SpPerfCounter *self,
return -1;
}
sp_perf_counter_take_fd (self, ret);
sysprof_perf_counter_take_fd (self, ret);
#endif
return ret;
}
void
sp_perf_counter_set_callback (SpPerfCounter *self,
SpPerfCounterCallback callback,
sysprof_perf_counter_set_callback (SysprofPerfCounter *self,
SysprofPerfCounterCallback callback,
gpointer callback_data,
GDestroyNotify callback_data_destroy)
{
@ -805,7 +805,7 @@ sp_perf_counter_set_callback (SpPerfCounter *self,
}
void
sp_perf_counter_enable (SpPerfCounter *self)
sysprof_perf_counter_enable (SysprofPerfCounter *self)
{
g_return_if_fail (self != NULL);
@ -815,15 +815,15 @@ sp_perf_counter_enable (SpPerfCounter *self)
for (i = 0; i < self->info->len; i++)
{
SpPerfCounterInfo *info = g_ptr_array_index (self->info, i);
SysprofPerfCounterInfo *info = g_ptr_array_index (self->info, i);
sp_perf_counter_enable_info (self, info);
sysprof_perf_counter_enable_info (self, info);
}
}
}
void
sp_perf_counter_disable (SpPerfCounter *self)
sysprof_perf_counter_disable (SysprofPerfCounter *self)
{
g_return_if_fail (self != NULL);
@ -833,13 +833,13 @@ sp_perf_counter_disable (SpPerfCounter *self)
for (i = 0; i < self->info->len; i++)
{
SpPerfCounterInfo *info = g_ptr_array_index (self->info, i);
SysprofPerfCounterInfo *info = g_ptr_array_index (self->info, i);
if (0 != ioctl (info->fd, PERF_EVENT_IOC_DISABLE))
g_warning ("Failed to disable counters");
if (!info->in_callback)
sp_perf_counter_flush (self, info);
sysprof_perf_counter_flush (self, info);
g_source_modify_unix_fd (self->source, info->fdtag, G_IO_ERR);
}

View File

@ -1,4 +1,4 @@
/* sp-perf-counter.h
/* sysprof-perf-counter.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
@ -34,9 +34,9 @@ G_BEGIN_DECLS
* These structs are the particular layouts that sysprof requests.
*/
#define SP_TYPE_PERF_COUNTER (sp_perf_counter_get_type())
#define SYSPROF_TYPE_PERF_COUNTER (sysprof_perf_counter_get_type())
typedef struct _SpPerfCounter SpPerfCounter;
typedef struct _SysprofPerfCounter SysprofPerfCounter;
#pragma pack(push, 1)
@ -48,7 +48,7 @@ typedef struct
guint32 tid;
guint32 ptid;
guint64 time;
} SpPerfCounterEventFork;
} SysprofPerfCounterEventFork;
typedef struct
{
@ -56,7 +56,7 @@ typedef struct
guint32 pid;
guint32 tid;
gchar comm[0];
} SpPerfCounterEventComm;
} SysprofPerfCounterEventComm;
typedef struct
{
@ -66,7 +66,7 @@ typedef struct
guint32 tid;
guint32 ptid;
guint64 time;
} SpPerfCounterEventExit;
} SysprofPerfCounterEventExit;
typedef struct
{
@ -77,7 +77,7 @@ typedef struct
guint64 len;
guint64 pgoff;
char filename[0];
} SpPerfCounterEventMmap;
} SysprofPerfCounterEventMmap;
typedef struct
{
@ -89,7 +89,7 @@ typedef struct
guint64 time;
guint64 n_ips;
guint64 ips[0];
} SpPerfCounterEventCallchain;
} SysprofPerfCounterEventCallchain;
typedef struct
{
@ -101,53 +101,53 @@ typedef struct
guint64 time;
guint32 raw_size;
guchar raw[];
} SpPerfCounterEventTracepoint;
} SysprofPerfCounterEventTracepoint;
typedef union
{
struct perf_event_header header;
guint8 raw[0];
SpPerfCounterEventFork fork;
SpPerfCounterEventComm comm;
SpPerfCounterEventExit exit;
SpPerfCounterEventMmap mmap;
SpPerfCounterEventCallchain callchain;
SpPerfCounterEventTracepoint tracepoint;
} SpPerfCounterEvent;
SysprofPerfCounterEventFork fork;
SysprofPerfCounterEventComm comm;
SysprofPerfCounterEventExit exit;
SysprofPerfCounterEventMmap mmap;
SysprofPerfCounterEventCallchain callchain;
SysprofPerfCounterEventTracepoint tracepoint;
} SysprofPerfCounterEvent;
#pragma pack(pop)
typedef void (*SpPerfCounterCallback) (SpPerfCounterEvent *event,
typedef void (*SysprofPerfCounterCallback) (SysprofPerfCounterEvent *event,
guint cpu,
gpointer user_data);
void sp_perf_counter_authorize_async (GCancellable *cancellable,
void sysprof_perf_counter_authorize_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean sp_perf_counter_authorize_finish (GAsyncResult *result,
gboolean sysprof_perf_counter_authorize_finish (GAsyncResult *result,
GError **error);
GType sp_perf_counter_get_type (void);
SpPerfCounter *sp_perf_counter_new (GMainContext *context);
void sp_perf_counter_set_callback (SpPerfCounter *self,
SpPerfCounterCallback callback,
GType sysprof_perf_counter_get_type (void);
SysprofPerfCounter *sysprof_perf_counter_new (GMainContext *context);
void sysprof_perf_counter_set_callback (SysprofPerfCounter *self,
SysprofPerfCounterCallback callback,
gpointer callback_data,
GDestroyNotify callback_data_destroy);
void sp_perf_counter_add_pid (SpPerfCounter *self,
void sysprof_perf_counter_add_pid (SysprofPerfCounter *self,
GPid pid);
gint sp_perf_counter_open (SpPerfCounter *self,
gint sysprof_perf_counter_open (SysprofPerfCounter *self,
struct perf_event_attr *attr,
GPid pid,
gint cpu,
gint group_fd,
gulong flags);
void sp_perf_counter_take_fd (SpPerfCounter *self,
void sysprof_perf_counter_take_fd (SysprofPerfCounter *self,
int fd);
void sp_perf_counter_enable (SpPerfCounter *self);
void sp_perf_counter_disable (SpPerfCounter *self);
void sp_perf_counter_close (SpPerfCounter *self,
void sysprof_perf_counter_enable (SysprofPerfCounter *self);
void sysprof_perf_counter_disable (SysprofPerfCounter *self);
void sysprof_perf_counter_close (SysprofPerfCounter *self,
gint fd);
SpPerfCounter *sp_perf_counter_ref (SpPerfCounter *self);
void sp_perf_counter_unref (SpPerfCounter *self);
SysprofPerfCounter *sysprof_perf_counter_ref (SysprofPerfCounter *self);
void sysprof_perf_counter_unref (SysprofPerfCounter *self);
G_END_DECLS

Some files were not shown because too many files have changed in this diff Show More