mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
build: rename all symbols to use sysprof_ as prefix
As we gain in usage, we need to be more careful about using a prefix that will not collide with other symbols. So version 3 of our ABI will change to using Sysprof/SYSPROF/sysprof as the various prefixes. The soname/api version bump will happen later on this branch so that things are easier to test up until then.
This commit is contained in:
@ -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++)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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));
|
||||
}
|
||||
@ -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
|
||||
@ -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)
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -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
|
||||
125
src/libsysprof/sysprof-jitmap-symbol-resolver.c
Normal file
125
src/libsysprof/sysprof-jitmap-symbol-resolver.c
Normal 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);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-kernel-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_KERNEL_SYMBOL_RESOLVER (sp_kernel_symbol_resolver_get_type())
|
||||
#define SYSPROF_TYPE_JITMAP_SYMBOL_RESOLVER (sysprof_jitmap_symbol_resolver_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (SpKernelSymbolResolver, sp_kernel_symbol_resolver, SP, KERNEL_SYMBOL_RESOLVER, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofJitmapSymbolResolver, sysprof_jitmap_symbol_resolver, SYSPROF, JITMAP_SYMBOL_RESOLVER, GObject)
|
||||
|
||||
SpSymbolResolver *sp_kernel_symbol_resolver_new (void);
|
||||
SysprofSymbolResolver *sysprof_jitmap_symbol_resolver_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
@ -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)
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-jitmap-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_JITMAP_SYMBOL_RESOLVER (sp_jitmap_symbol_resolver_get_type())
|
||||
#define SYSPROF_TYPE_KERNEL_SYMBOL_RESOLVER (sysprof_kernel_symbol_resolver_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (SpJitmapSymbolResolver, sp_jitmap_symbol_resolver, SP, JITMAP_SYMBOL_RESOLVER, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofKernelSymbolResolver, sysprof_kernel_symbol_resolver, SYSPROF, KERNEL_SYMBOL_RESOLVER, GObject)
|
||||
|
||||
SpSymbolResolver *sp_jitmap_symbol_resolver_new (void);
|
||||
SysprofSymbolResolver *sysprof_kernel_symbol_resolver_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
@ -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);
|
||||
@ -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
|
||||
@ -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;
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -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
|
||||
@ -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);
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-perf-source.c
|
||||
/* sysprof-perf-source.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -47,28 +47,28 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sp-clock.h"
|
||||
#include "sp-line-reader.h"
|
||||
#include "sp-perf-counter.h"
|
||||
#include "sp-perf-source.h"
|
||||
#include "sysprof-clock.h"
|
||||
#include "sysprof-line-reader.h"
|
||||
#include "sysprof-perf-counter.h"
|
||||
#include "sysprof-perf-source.h"
|
||||
|
||||
#define N_WAKEUP_EVENTS 149
|
||||
|
||||
/* Identifiers for the various tracepoints we might watch for */
|
||||
enum SpTracepoint {
|
||||
enum SysprofTracepoint {
|
||||
DRM_VBLANK,
|
||||
DRM_I915_BEGIN,
|
||||
DRM_I915_END,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
enum SpTracepoint tp;
|
||||
enum SysprofTracepoint tp;
|
||||
const char *path;
|
||||
const char **fields;
|
||||
} SpOptionalTracepoint;
|
||||
} SysprofOptionalTracepoint;
|
||||
|
||||
/* Global list of the optional tracepoints we might want to watch. */
|
||||
static const SpOptionalTracepoint optional_tracepoints[] = {
|
||||
static const SysprofOptionalTracepoint optional_tracepoints[] = {
|
||||
/* This event fires just after the vblank IRQ handler starts.
|
||||
*
|
||||
* Note that on many platforms when nothing is waiting for vblank
|
||||
@ -104,29 +104,29 @@ static const SpOptionalTracepoint optional_tracepoints[] = {
|
||||
* number and MSC.
|
||||
*/
|
||||
typedef struct {
|
||||
enum SpTracepoint tp;
|
||||
enum SysprofTracepoint tp;
|
||||
gsize field_offsets[0];
|
||||
} SpTracepointDesc;
|
||||
} SysprofTracepointDesc;
|
||||
|
||||
struct _SpPerfSource
|
||||
struct _SysprofPerfSource
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
SpCaptureWriter *writer;
|
||||
SpPerfCounter *counter;
|
||||
SysprofCaptureWriter *writer;
|
||||
SysprofPerfCounter *counter;
|
||||
GHashTable *pids;
|
||||
|
||||
/* Mapping from perf sample identifiers to SpTracepointDesc. */
|
||||
/* Mapping from perf sample identifiers to SysprofTracepointDesc. */
|
||||
GHashTable *tracepoint_event_ids;
|
||||
|
||||
guint running : 1;
|
||||
guint is_ready : 1;
|
||||
};
|
||||
|
||||
static void source_iface_init (SpSourceInterface *iface);
|
||||
static void source_iface_init (SysprofSourceInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (SpPerfSource, sp_perf_source, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (SP_TYPE_SOURCE, source_iface_init))
|
||||
G_DEFINE_TYPE_EXTENDED (SysprofPerfSource, sysprof_perf_source, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
|
||||
|
||||
enum {
|
||||
TARGET_EXITED,
|
||||
@ -136,43 +136,43 @@ enum {
|
||||
static guint signals [N_SIGNALS];
|
||||
|
||||
static void
|
||||
sp_perf_source_real_target_exited (SpPerfSource *self)
|
||||
sysprof_perf_source_real_target_exited (SysprofPerfSource *self)
|
||||
{
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
sp_source_emit_finished (SP_SOURCE (self));
|
||||
sysprof_source_emit_finished (SYSPROF_SOURCE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_finalize (GObject *object)
|
||||
sysprof_perf_source_finalize (GObject *object)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)object;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)object;
|
||||
|
||||
g_clear_pointer (&self->writer, sp_capture_writer_unref);
|
||||
g_clear_pointer (&self->counter, sp_perf_counter_unref);
|
||||
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
|
||||
g_clear_pointer (&self->counter, sysprof_perf_counter_unref);
|
||||
g_clear_pointer (&self->pids, g_hash_table_unref);
|
||||
g_clear_pointer (&self->tracepoint_event_ids, g_hash_table_unref);
|
||||
|
||||
G_OBJECT_CLASS (sp_perf_source_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (sysprof_perf_source_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_class_init (SpPerfSourceClass *klass)
|
||||
sysprof_perf_source_class_init (SysprofPerfSourceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sp_perf_source_finalize;
|
||||
object_class->finalize = sysprof_perf_source_finalize;
|
||||
|
||||
signals [TARGET_EXITED] =
|
||||
g_signal_new_class_handler ("target-exited",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_CALLBACK (sp_perf_source_real_target_exited),
|
||||
G_CALLBACK (sysprof_perf_source_real_target_exited),
|
||||
NULL, NULL, NULL, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_init (SpPerfSource *self)
|
||||
sysprof_perf_source_init (SysprofPerfSource *self)
|
||||
{
|
||||
self->pids = g_hash_table_new (NULL, NULL);
|
||||
self->tracepoint_event_ids = g_hash_table_new (NULL, NULL);
|
||||
@ -181,7 +181,7 @@ sp_perf_source_init (SpPerfSource *self)
|
||||
static gboolean
|
||||
do_emit_exited (gpointer data)
|
||||
{
|
||||
g_autoptr(SpPerfSource) self = data;
|
||||
g_autoptr(SysprofPerfSource) self = data;
|
||||
|
||||
g_signal_emit (self, signals [TARGET_EXITED], 0);
|
||||
|
||||
@ -189,15 +189,15 @@ do_emit_exited (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_handle_tracepoint (SpPerfSource *self,
|
||||
sysprof_perf_source_handle_tracepoint (SysprofPerfSource *self,
|
||||
gint cpu,
|
||||
const SpPerfCounterEventTracepoint *sample,
|
||||
SpTracepointDesc *tp_desc)
|
||||
const SysprofPerfCounterEventTracepoint *sample,
|
||||
SysprofTracepointDesc *tp_desc)
|
||||
{
|
||||
gchar *message = NULL;
|
||||
|
||||
/* Note that field_offsets[] correspond to the
|
||||
* SpOptionalTracepoint->fields[] strings. Yes, this is gross.
|
||||
* SysprofOptionalTracepoint->fields[] strings. Yes, this is gross.
|
||||
*/
|
||||
switch (tp_desc->tp)
|
||||
{
|
||||
@ -208,7 +208,7 @@ sp_perf_source_handle_tracepoint (SpPerfSource *self,
|
||||
*(guint *)(sample->raw +
|
||||
tp_desc->field_offsets[1]));
|
||||
|
||||
sp_capture_writer_add_mark (self->writer,
|
||||
sysprof_capture_writer_add_mark (self->writer,
|
||||
sample->time,
|
||||
cpu,
|
||||
sample->pid,
|
||||
@ -228,7 +228,7 @@ sp_perf_source_handle_tracepoint (SpPerfSource *self,
|
||||
*(guint *)(sample->raw +
|
||||
tp_desc->field_offsets[2]));
|
||||
|
||||
sp_capture_writer_add_mark (self->writer,
|
||||
sysprof_capture_writer_add_mark (self->writer,
|
||||
sample->time,
|
||||
cpu,
|
||||
sample->pid,
|
||||
@ -247,15 +247,15 @@ sp_perf_source_handle_tracepoint (SpPerfSource *self,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_handle_callchain (SpPerfSource *self,
|
||||
sysprof_perf_source_handle_callchain (SysprofPerfSource *self,
|
||||
gint cpu,
|
||||
const SpPerfCounterEventCallchain *sample)
|
||||
const SysprofPerfCounterEventCallchain *sample)
|
||||
{
|
||||
const guint64 *ips;
|
||||
gint n_ips;
|
||||
guint64 trace[3];
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
g_assert (sample != NULL);
|
||||
|
||||
ips = sample->ips;
|
||||
@ -282,7 +282,7 @@ sp_perf_source_handle_callchain (SpPerfSource *self,
|
||||
}
|
||||
}
|
||||
|
||||
sp_capture_writer_add_sample (self->writer,
|
||||
sysprof_capture_writer_add_sample (self->writer,
|
||||
sample->time,
|
||||
cpu,
|
||||
sample->pid,
|
||||
@ -299,16 +299,16 @@ realign (gsize *pos,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
sysprof_perf_source_handle_event (SysprofPerfCounterEvent *event,
|
||||
guint cpu,
|
||||
gpointer user_data)
|
||||
{
|
||||
SpPerfSource *self = user_data;
|
||||
SpTracepointDesc *tp_desc;
|
||||
SysprofPerfSource *self = user_data;
|
||||
SysprofTracepointDesc *tp_desc;
|
||||
gsize offset;
|
||||
gint64 time;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
g_assert (event != NULL);
|
||||
|
||||
switch (event->header.type)
|
||||
@ -319,7 +319,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
offset += sizeof (GPid) + sizeof (GPid);
|
||||
memcpy (&time, event->comm.comm + offset, sizeof time);
|
||||
|
||||
sp_capture_writer_add_process (self->writer,
|
||||
sysprof_capture_writer_add_process (self->writer,
|
||||
time,
|
||||
cpu,
|
||||
event->comm.pid,
|
||||
@ -328,7 +328,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
break;
|
||||
|
||||
case PERF_RECORD_EXIT:
|
||||
sp_capture_writer_add_exit (self->writer,
|
||||
sysprof_capture_writer_add_exit (self->writer,
|
||||
event->exit.time,
|
||||
cpu,
|
||||
event->exit.pid);
|
||||
@ -340,7 +340,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
if (self->running && (g_hash_table_size (self->pids) == 0))
|
||||
{
|
||||
self->running = FALSE;
|
||||
sp_perf_counter_disable (self->counter);
|
||||
sysprof_perf_counter_disable (self->counter);
|
||||
g_timeout_add (0, do_emit_exited, g_object_ref (self));
|
||||
}
|
||||
}
|
||||
@ -348,7 +348,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
break;
|
||||
|
||||
case PERF_RECORD_FORK:
|
||||
sp_capture_writer_add_fork (self->writer,
|
||||
sysprof_capture_writer_add_fork (self->writer,
|
||||
event->fork.time,
|
||||
cpu,
|
||||
event->fork.ppid,
|
||||
@ -370,7 +370,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
offset += sizeof (GPid) + sizeof (GPid);
|
||||
memcpy (&time, event->mmap.filename + offset, sizeof time);
|
||||
|
||||
sp_capture_writer_add_map (self->writer,
|
||||
sysprof_capture_writer_add_map (self->writer,
|
||||
time,
|
||||
cpu,
|
||||
event->mmap.pid,
|
||||
@ -394,12 +394,12 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
GINT_TO_POINTER (event->callchain.identifier));
|
||||
if (tp_desc)
|
||||
{
|
||||
sp_perf_source_handle_tracepoint (self, cpu, &event->tracepoint,
|
||||
sysprof_perf_source_handle_tracepoint (self, cpu, &event->tracepoint,
|
||||
tp_desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp_perf_source_handle_callchain (self, cpu, &event->callchain);
|
||||
sysprof_perf_source_handle_callchain (self, cpu, &event->callchain);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -411,7 +411,7 @@ sp_perf_source_handle_event (SpPerfCounterEvent *event,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_perf_get_tracepoint_config (const char *path, gint64 *config)
|
||||
sysprof_perf_get_tracepoint_config (const char *path, gint64 *config)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
gchar *contents;
|
||||
@ -437,8 +437,8 @@ sp_perf_get_tracepoint_config (const char *path, gint64 *config)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_perf_get_tracepoint_fields (SpTracepointDesc *tp_desc,
|
||||
const SpOptionalTracepoint *optional_tp,
|
||||
sysprof_perf_get_tracepoint_fields (SysprofTracepointDesc *tp_desc,
|
||||
const SysprofOptionalTracepoint *optional_tp,
|
||||
GError **error)
|
||||
{
|
||||
gchar *filename = NULL;
|
||||
@ -510,14 +510,14 @@ sp_perf_get_tracepoint_fields (SpTracepointDesc *tp_desc,
|
||||
* when present, but may be kernel version or driver-specific.
|
||||
*/
|
||||
static void
|
||||
sp_perf_source_add_optional_tracepoint (SpPerfSource *self,
|
||||
sysprof_perf_source_add_optional_tracepoint (SysprofPerfSource *self,
|
||||
GPid pid,
|
||||
gint cpu,
|
||||
const SpOptionalTracepoint *optional_tracepoint,
|
||||
const SysprofOptionalTracepoint *optional_tracepoint,
|
||||
GError **error)
|
||||
{
|
||||
struct perf_event_attr attr = { 0 };
|
||||
SpTracepointDesc *tp_desc;
|
||||
SysprofTracepointDesc *tp_desc;
|
||||
gulong flags = 0;
|
||||
gint fd;
|
||||
gint64 config;
|
||||
@ -525,7 +525,7 @@ sp_perf_source_add_optional_tracepoint (SpPerfSource *self,
|
||||
int ret;
|
||||
gint num_fields;
|
||||
|
||||
if (!sp_perf_get_tracepoint_config(optional_tracepoint->path, &config))
|
||||
if (!sysprof_perf_get_tracepoint_config(optional_tracepoint->path, &config))
|
||||
return;
|
||||
|
||||
attr.type = PERF_TYPE_TRACEPOINT;
|
||||
@ -539,13 +539,13 @@ sp_perf_source_add_optional_tracepoint (SpPerfSource *self,
|
||||
attr.sample_period = 1;
|
||||
|
||||
#ifdef HAVE_PERF_CLOCKID
|
||||
attr.clockid = sp_clock;
|
||||
attr.clockid = sysprof_clock;
|
||||
attr.use_clockid = 1;
|
||||
#endif
|
||||
|
||||
attr.size = sizeof attr;
|
||||
|
||||
fd = sp_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
fd = sysprof_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
|
||||
ret = ioctl (fd, PERF_EVENT_IOC_ID, &id);
|
||||
if (ret != 0)
|
||||
@ -572,7 +572,7 @@ sp_perf_source_add_optional_tracepoint (SpPerfSource *self,
|
||||
|
||||
tp_desc->tp = optional_tracepoint->tp;
|
||||
|
||||
if (!sp_perf_get_tracepoint_fields (tp_desc, optional_tracepoint, error))
|
||||
if (!sysprof_perf_get_tracepoint_fields (tp_desc, optional_tracepoint, error))
|
||||
{
|
||||
free(tp_desc);
|
||||
close(fd);
|
||||
@ -592,7 +592,7 @@ sp_perf_source_add_optional_tracepoint (SpPerfSource *self,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_perf_source_start_pid (SpPerfSource *self,
|
||||
sysprof_perf_source_start_pid (SysprofPerfSource *self,
|
||||
GPid pid,
|
||||
GError **error)
|
||||
{
|
||||
@ -603,7 +603,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
gint fd;
|
||||
gint i;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
attr.sample_type = PERF_SAMPLE_IP
|
||||
| PERF_SAMPLE_TID
|
||||
@ -619,7 +619,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
attr.sample_id_all = 1;
|
||||
|
||||
#ifdef HAVE_PERF_CLOCKID
|
||||
attr.clockid = sp_clock;
|
||||
attr.clockid = sysprof_clock;
|
||||
attr.use_clockid = 1;
|
||||
#endif
|
||||
|
||||
@ -640,7 +640,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
attr.config = PERF_COUNT_HW_CPU_CYCLES;
|
||||
attr.sample_period = 1200000;
|
||||
|
||||
fd = sp_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
fd = sysprof_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
@ -654,7 +654,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
|
||||
errno = 0;
|
||||
|
||||
fd = sp_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
fd = sysprof_perf_counter_open (self->counter, &attr, pid, cpu, -1, flags);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
@ -670,7 +670,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
_("An error occurred while attempting to access performance counters: %s"),
|
||||
g_strerror (errno));
|
||||
|
||||
sp_source_stop (SP_SOURCE (self));
|
||||
sysprof_source_stop (SYSPROF_SOURCE (self));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -678,7 +678,7 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(optional_tracepoints); i++)
|
||||
{
|
||||
sp_perf_source_add_optional_tracepoint (self, pid, cpu,
|
||||
sysprof_perf_source_add_optional_tracepoint (self, pid, cpu,
|
||||
&optional_tracepoints[i],
|
||||
error);
|
||||
}
|
||||
@ -688,17 +688,17 @@ sp_perf_source_start_pid (SpPerfSource *self,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_start (SpSource *source)
|
||||
sysprof_perf_source_start (SysprofSource *source)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
self->counter = sp_perf_counter_new (NULL);
|
||||
self->counter = sysprof_perf_counter_new (NULL);
|
||||
|
||||
sp_perf_counter_set_callback (self->counter,
|
||||
sp_perf_source_handle_event,
|
||||
sysprof_perf_counter_set_callback (self->counter,
|
||||
sysprof_perf_source_handle_event,
|
||||
self, NULL);
|
||||
|
||||
if (g_hash_table_size (self->pids) > 0)
|
||||
@ -712,66 +712,66 @@ sp_perf_source_start (SpSource *source)
|
||||
{
|
||||
GPid pid = GPOINTER_TO_INT (key);
|
||||
|
||||
if (!sp_perf_source_start_pid (self, pid, &error))
|
||||
if (!sysprof_perf_source_start_pid (self, pid, &error))
|
||||
{
|
||||
sp_source_emit_failed (source, error);
|
||||
sysprof_source_emit_failed (source, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sp_perf_source_start_pid (self, -1, &error))
|
||||
if (!sysprof_perf_source_start_pid (self, -1, &error))
|
||||
{
|
||||
sp_source_emit_failed (source, error);
|
||||
sysprof_source_emit_failed (source, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self->running = TRUE;
|
||||
|
||||
sp_perf_counter_enable (self->counter);
|
||||
sysprof_perf_counter_enable (self->counter);
|
||||
|
||||
sp_source_emit_ready (source);
|
||||
sysprof_source_emit_ready (source);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_stop (SpSource *source)
|
||||
sysprof_perf_source_stop (SysprofSource *source)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
if (self->running)
|
||||
{
|
||||
self->running = FALSE;
|
||||
sp_perf_counter_disable (self->counter);
|
||||
sysprof_perf_counter_disable (self->counter);
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->counter, sp_perf_counter_unref);
|
||||
g_clear_pointer (&self->counter, sysprof_perf_counter_unref);
|
||||
|
||||
sp_source_emit_finished (source);
|
||||
sysprof_source_emit_finished (source);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_set_writer (SpSource *source,
|
||||
SpCaptureWriter *writer)
|
||||
sysprof_perf_source_set_writer (SysprofSource *source,
|
||||
SysprofCaptureWriter *writer)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
g_assert (writer != NULL);
|
||||
|
||||
self->writer = sp_capture_writer_ref (writer);
|
||||
self->writer = sysprof_capture_writer_ref (writer);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_add_pid (SpSource *source,
|
||||
sysprof_perf_source_add_pid (SysprofSource *source,
|
||||
GPid pid)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
|
||||
g_return_if_fail (SP_IS_PERF_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_PERF_SOURCE (self));
|
||||
g_return_if_fail (pid >= -1);
|
||||
g_return_if_fail (self->writer == NULL);
|
||||
|
||||
@ -779,34 +779,34 @@ sp_perf_source_add_pid (SpSource *source,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_emit_ready (SpPerfSource *self)
|
||||
sysprof_perf_source_emit_ready (SysprofPerfSource *self)
|
||||
{
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
self->is_ready = TRUE;
|
||||
sp_source_emit_ready (SP_SOURCE (self));
|
||||
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_authorize_cb (GObject *object,
|
||||
sysprof_perf_source_authorize_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(SpPerfSource) self = user_data;
|
||||
g_autoptr(SysprofPerfSource) self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
|
||||
if (!sp_perf_counter_authorize_finish (result, &error))
|
||||
if (!sysprof_perf_counter_authorize_finish (result, &error))
|
||||
{
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
|
||||
{
|
||||
sp_source_emit_failed (SP_SOURCE (self), error);
|
||||
sysprof_source_emit_failed (SYSPROF_SOURCE (self), error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sp_perf_source_emit_ready (self);
|
||||
sysprof_perf_source_emit_ready (self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -815,7 +815,7 @@ user_owns_pid (uid_t uid,
|
||||
{
|
||||
g_autofree gchar *contents = NULL;
|
||||
g_autofree gchar *path = NULL;
|
||||
g_autoptr(SpLineReader) reader = NULL;
|
||||
g_autoptr(SysprofLineReader) reader = NULL;
|
||||
gchar *line;
|
||||
gsize len;
|
||||
gsize line_len;
|
||||
@ -825,9 +825,9 @@ user_owns_pid (uid_t uid,
|
||||
if (!g_file_get_contents (path, &contents, &len, NULL))
|
||||
return FALSE;
|
||||
|
||||
reader = sp_line_reader_new (contents, len);
|
||||
reader = sysprof_line_reader_new (contents, len);
|
||||
|
||||
while (NULL != (line = (gchar *)sp_line_reader_next (reader, &line_len)))
|
||||
while (NULL != (line = (gchar *)sysprof_line_reader_next (reader, &line_len)))
|
||||
{
|
||||
if (g_str_has_prefix (line, "Uid:"))
|
||||
{
|
||||
@ -856,13 +856,13 @@ user_owns_pid (uid_t uid,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_perf_source_needs_auth (SpPerfSource *self)
|
||||
sysprof_perf_source_needs_auth (SysprofPerfSource *self)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
uid_t uid;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
if (g_hash_table_size (self->pids) == 0)
|
||||
return TRUE;
|
||||
@ -883,56 +883,56 @@ sp_perf_source_needs_auth (SpPerfSource *self)
|
||||
}
|
||||
|
||||
static void
|
||||
sp_perf_source_prepare (SpSource *source)
|
||||
sysprof_perf_source_prepare (SysprofSource *source)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
if (sp_perf_source_needs_auth (self))
|
||||
sp_perf_counter_authorize_async (NULL,
|
||||
sp_perf_source_authorize_cb,
|
||||
if (sysprof_perf_source_needs_auth (self))
|
||||
sysprof_perf_counter_authorize_async (NULL,
|
||||
sysprof_perf_source_authorize_cb,
|
||||
g_object_ref (self));
|
||||
else
|
||||
sp_perf_source_emit_ready (self);
|
||||
sysprof_perf_source_emit_ready (self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_perf_source_get_is_ready (SpSource *source)
|
||||
sysprof_perf_source_get_is_ready (SysprofSource *source)
|
||||
{
|
||||
SpPerfSource *self = (SpPerfSource *)source;
|
||||
SysprofPerfSource *self = (SysprofPerfSource *)source;
|
||||
|
||||
g_assert (SP_IS_PERF_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PERF_SOURCE (self));
|
||||
|
||||
return self->is_ready;
|
||||
}
|
||||
|
||||
static void
|
||||
source_iface_init (SpSourceInterface *iface)
|
||||
source_iface_init (SysprofSourceInterface *iface)
|
||||
{
|
||||
iface->start = sp_perf_source_start;
|
||||
iface->stop = sp_perf_source_stop;
|
||||
iface->set_writer = sp_perf_source_set_writer;
|
||||
iface->add_pid = sp_perf_source_add_pid;
|
||||
iface->prepare = sp_perf_source_prepare;
|
||||
iface->get_is_ready = sp_perf_source_get_is_ready;
|
||||
iface->start = sysprof_perf_source_start;
|
||||
iface->stop = sysprof_perf_source_stop;
|
||||
iface->set_writer = sysprof_perf_source_set_writer;
|
||||
iface->add_pid = sysprof_perf_source_add_pid;
|
||||
iface->prepare = sysprof_perf_source_prepare;
|
||||
iface->get_is_ready = sysprof_perf_source_get_is_ready;
|
||||
}
|
||||
|
||||
SpSource *
|
||||
sp_perf_source_new (void)
|
||||
SysprofSource *
|
||||
sysprof_perf_source_new (void)
|
||||
{
|
||||
return g_object_new (SP_TYPE_PERF_SOURCE, NULL);
|
||||
return g_object_new (SYSPROF_TYPE_PERF_SOURCE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_perf_source_set_target_pid (SpPerfSource *self,
|
||||
sysprof_perf_source_set_target_pid (SysprofPerfSource *self,
|
||||
GPid pid)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PERF_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_PERF_SOURCE (self));
|
||||
g_return_if_fail (pid >= -1);
|
||||
|
||||
if (pid == -1)
|
||||
g_hash_table_remove_all (self->pids);
|
||||
else
|
||||
sp_perf_source_add_pid (SP_SOURCE (self), pid);
|
||||
sysprof_perf_source_add_pid (SYSPROF_SOURCE (self), pid);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-perf-source.h
|
||||
/* sysprof-perf-source.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -22,19 +22,19 @@
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
#include "sysprof-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PERF_SOURCE (sp_perf_source_get_type())
|
||||
#define SYSPROF_TYPE_PERF_SOURCE (sysprof_perf_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpPerfSource, sp_perf_source, SP, PERF_SOURCE, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofPerfSource, sysprof_perf_source, SYSPROF, PERF_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_perf_source_new (void);
|
||||
SysprofSource *sysprof_perf_source_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_perf_source_set_target_pid (SpPerfSource *self,
|
||||
void sysprof_perf_source_set_target_pid (SysprofPerfSource *self,
|
||||
GPid pid);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-proc-source.c
|
||||
/* sysprof-proc-source.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -43,22 +43,22 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-proc-source.h"
|
||||
#include "sysprof-proc-source.h"
|
||||
|
||||
struct _SpProcSource
|
||||
struct _SysprofProcSource
|
||||
{
|
||||
GObject parent_instance;
|
||||
SpCaptureWriter *writer;
|
||||
SysprofCaptureWriter *writer;
|
||||
GArray *pids;
|
||||
};
|
||||
|
||||
static void source_iface_init (SpSourceInterface *iface);
|
||||
static void source_iface_init (SysprofSourceInterface *iface);
|
||||
static gchar **proc_readlines (const gchar *format,
|
||||
...)
|
||||
G_GNUC_PRINTF (1, 2);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (SpProcSource, sp_proc_source, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (SP_TYPE_SOURCE, source_iface_init))
|
||||
G_DEFINE_TYPE_EXTENDED (SysprofProcSource, sysprof_proc_source, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
|
||||
|
||||
static gchar **
|
||||
proc_readlines (const gchar *format,
|
||||
@ -86,7 +86,7 @@ proc_readlines (const gchar *format,
|
||||
}
|
||||
|
||||
gchar *
|
||||
sp_proc_source_get_command_line (GPid pid,
|
||||
sysprof_proc_source_get_command_line (GPid pid,
|
||||
gboolean *is_kernel)
|
||||
{
|
||||
gchar *ret;
|
||||
@ -136,18 +136,18 @@ sp_proc_source_get_command_line (GPid pid,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_populate_process (SpProcSource *self,
|
||||
sysprof_proc_source_populate_process (SysprofProcSource *self,
|
||||
GPid pid)
|
||||
{
|
||||
gchar *cmdline;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
g_assert (pid > 0);
|
||||
|
||||
if (NULL != (cmdline = sp_proc_source_get_command_line (pid, NULL)))
|
||||
if (NULL != (cmdline = sysprof_proc_source_get_command_line (pid, NULL)))
|
||||
{
|
||||
sp_capture_writer_add_process (self->writer,
|
||||
SP_CAPTURE_CURRENT_TIME,
|
||||
sysprof_capture_writer_add_process (self->writer,
|
||||
SYSPROF_CAPTURE_CURRENT_TIME,
|
||||
-1,
|
||||
pid,
|
||||
cmdline);
|
||||
@ -197,7 +197,7 @@ find_mount (GStrv mounts,
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_proc_source_translate_path:
|
||||
* sysprof_proc_source_translate_path:
|
||||
* @file: the path to the file inside target mount namespace
|
||||
* @mountinfo: mount info to locate translated path
|
||||
* @out_file: (out): location for the translated path
|
||||
@ -210,7 +210,7 @@ find_mount (GStrv mounts,
|
||||
* The result is stored in @out_file and will always be NULL terminated.
|
||||
*/
|
||||
static void
|
||||
sp_proc_source_translate_path (const gchar *file,
|
||||
sysprof_proc_source_translate_path (const gchar *file,
|
||||
GStrv mountinfo,
|
||||
GStrv mounts,
|
||||
gchar *out_file,
|
||||
@ -297,7 +297,7 @@ failure:
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_populate_maps (SpProcSource *self,
|
||||
sysprof_proc_source_populate_maps (SysprofProcSource *self,
|
||||
GPid pid,
|
||||
GStrv mounts)
|
||||
{
|
||||
@ -305,7 +305,7 @@ sp_proc_source_populate_maps (SpProcSource *self,
|
||||
g_auto(GStrv) mountinfo = NULL;
|
||||
guint i;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
g_assert (pid > 0);
|
||||
|
||||
if (NULL == (lines = proc_readlines ("/proc/%d/maps", pid)))
|
||||
@ -359,7 +359,7 @@ sp_proc_source_populate_maps (SpProcSource *self,
|
||||
* look at /proc/$pid/mountinfo to locate the longest-common-prefix
|
||||
* for the path.
|
||||
*/
|
||||
sp_proc_source_translate_path (file,
|
||||
sysprof_proc_source_translate_path (file,
|
||||
mountinfo,
|
||||
mounts,
|
||||
translated,
|
||||
@ -367,8 +367,8 @@ sp_proc_source_populate_maps (SpProcSource *self,
|
||||
fileptr = translated;
|
||||
}
|
||||
|
||||
sp_capture_writer_add_map (self->writer,
|
||||
SP_CAPTURE_CURRENT_TIME,
|
||||
sysprof_capture_writer_add_map (self->writer,
|
||||
SYSPROF_CAPTURE_CURRENT_TIME,
|
||||
-1,
|
||||
pid,
|
||||
start,
|
||||
@ -380,13 +380,13 @@ sp_proc_source_populate_maps (SpProcSource *self,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_populate (SpProcSource *self)
|
||||
sysprof_proc_source_populate (SysprofProcSource *self)
|
||||
{
|
||||
g_auto(GStrv) mounts = NULL;
|
||||
const gchar *name;
|
||||
GDir *dir;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
|
||||
if (NULL == (mounts = proc_readlines ("/proc/mounts")))
|
||||
return;
|
||||
@ -399,8 +399,8 @@ sp_proc_source_populate (SpProcSource *self)
|
||||
{
|
||||
GPid pid = g_array_index (self->pids, GPid, i);
|
||||
|
||||
sp_proc_source_populate_process (self, pid);
|
||||
sp_proc_source_populate_maps (self, pid, mounts);
|
||||
sysprof_proc_source_populate_process (self, pid);
|
||||
sysprof_proc_source_populate_maps (self, pid, mounts);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -418,55 +418,55 @@ sp_proc_source_populate (SpProcSource *self)
|
||||
if (pid <= 0 || *end != '\0')
|
||||
continue;
|
||||
|
||||
sp_proc_source_populate_process (self, pid);
|
||||
sp_proc_source_populate_maps (self, pid, mounts);
|
||||
sysprof_proc_source_populate_process (self, pid);
|
||||
sysprof_proc_source_populate_maps (self, pid, mounts);
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_start (SpSource *source)
|
||||
sysprof_proc_source_start (SysprofSource *source)
|
||||
{
|
||||
SpProcSource *self = (SpProcSource *)source;
|
||||
SysprofProcSource *self = (SysprofProcSource *)source;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
g_assert (self->writer != NULL);
|
||||
|
||||
sp_proc_source_populate (self);
|
||||
sp_source_emit_finished (source);
|
||||
sysprof_proc_source_populate (self);
|
||||
sysprof_source_emit_finished (source);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_stop (SpSource *source)
|
||||
sysprof_proc_source_stop (SysprofSource *source)
|
||||
{
|
||||
SpProcSource *self = (SpProcSource *)source;
|
||||
SysprofProcSource *self = (SysprofProcSource *)source;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
|
||||
g_clear_pointer (&self->writer, sp_capture_writer_unref);
|
||||
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_set_writer (SpSource *source,
|
||||
SpCaptureWriter *writer)
|
||||
sysprof_proc_source_set_writer (SysprofSource *source,
|
||||
SysprofCaptureWriter *writer)
|
||||
{
|
||||
SpProcSource *self = (SpProcSource *)source;
|
||||
SysprofProcSource *self = (SysprofProcSource *)source;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
g_assert (writer != NULL);
|
||||
|
||||
self->writer = sp_capture_writer_ref (writer);
|
||||
self->writer = sysprof_capture_writer_ref (writer);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_add_pid (SpSource *source,
|
||||
sysprof_proc_source_add_pid (SysprofSource *source,
|
||||
GPid pid)
|
||||
{
|
||||
SpProcSource *self = (SpProcSource *)source;
|
||||
SysprofProcSource *self = (SysprofProcSource *)source;
|
||||
guint i;
|
||||
|
||||
g_assert (SP_IS_PROC_SOURCE (self));
|
||||
g_assert (SYSPROF_IS_PROC_SOURCE (self));
|
||||
g_assert (pid > -1);
|
||||
|
||||
for (i = 0; i < self->pids->len; i++)
|
||||
@ -481,41 +481,41 @@ sp_proc_source_add_pid (SpSource *source,
|
||||
}
|
||||
|
||||
static void
|
||||
source_iface_init (SpSourceInterface *iface)
|
||||
source_iface_init (SysprofSourceInterface *iface)
|
||||
{
|
||||
iface->set_writer = sp_proc_source_set_writer;
|
||||
iface->start = sp_proc_source_start;
|
||||
iface->stop = sp_proc_source_stop;
|
||||
iface->add_pid = sp_proc_source_add_pid;
|
||||
iface->set_writer = sysprof_proc_source_set_writer;
|
||||
iface->start = sysprof_proc_source_start;
|
||||
iface->stop = sysprof_proc_source_stop;
|
||||
iface->add_pid = sysprof_proc_source_add_pid;
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_finalize (GObject *object)
|
||||
sysprof_proc_source_finalize (GObject *object)
|
||||
{
|
||||
SpProcSource *self = (SpProcSource *)object;
|
||||
SysprofProcSource *self = (SysprofProcSource *)object;
|
||||
|
||||
g_clear_pointer (&self->writer, sp_capture_writer_unref);
|
||||
g_clear_pointer (&self->writer, sysprof_capture_writer_unref);
|
||||
g_clear_pointer (&self->pids, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (sp_proc_source_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (sysprof_proc_source_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_class_init (SpProcSourceClass *klass)
|
||||
sysprof_proc_source_class_init (SysprofProcSourceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sp_proc_source_finalize;
|
||||
object_class->finalize = sysprof_proc_source_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
sp_proc_source_init (SpProcSource *self)
|
||||
sysprof_proc_source_init (SysprofProcSource *self)
|
||||
{
|
||||
self->pids = g_array_new (FALSE, FALSE, sizeof (GPid));
|
||||
}
|
||||
|
||||
SpSource *
|
||||
sp_proc_source_new (void)
|
||||
SysprofSource *
|
||||
sysprof_proc_source_new (void)
|
||||
{
|
||||
return g_object_new (SP_TYPE_PROC_SOURCE, NULL);
|
||||
return g_object_new (SYSPROF_TYPE_PROC_SOURCE, NULL);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-proc-source.h
|
||||
/* sysprof-proc-source.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -22,19 +22,19 @@
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
#include "sysprof-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROC_SOURCE (sp_proc_source_get_type())
|
||||
#define SYSPROF_TYPE_PROC_SOURCE (sysprof_proc_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcSource, sp_proc_source, SP, PROC_SOURCE, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofProcSource, sysprof_proc_source, SYSPROF, PROC_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_proc_source_new (void);
|
||||
SysprofSource *sysprof_proc_source_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gchar *sp_proc_source_get_command_line (GPid pid,
|
||||
gchar *sysprof_proc_source_get_command_line (GPid pid,
|
||||
gboolean *is_kernel);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-process-model-item.c
|
||||
/* sysprof-process-model-item.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -22,12 +22,12 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-process-model-item.h"
|
||||
#include "sysprof-process-model-item.h"
|
||||
#ifdef __linux__
|
||||
# include "sp-proc-source.h"
|
||||
# include "sysprof-proc-source.h"
|
||||
#endif
|
||||
|
||||
struct _SpProcessModelItem
|
||||
struct _SysprofProcessModelItem
|
||||
{
|
||||
GObject parent_instance;
|
||||
GPid pid;
|
||||
@ -36,7 +36,7 @@ struct _SpProcessModelItem
|
||||
guint is_kernel : 1;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (SpProcessModelItem, sp_process_model_item, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (SysprofProcessModelItem, sysprof_process_model_item, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -48,23 +48,23 @@ enum {
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sp_process_model_item_finalize (GObject *object)
|
||||
sysprof_process_model_item_finalize (GObject *object)
|
||||
{
|
||||
SpProcessModelItem *self = (SpProcessModelItem *)object;
|
||||
SysprofProcessModelItem *self = (SysprofProcessModelItem *)object;
|
||||
|
||||
g_clear_pointer (&self->command_line, g_free);
|
||||
g_clear_pointer (&self->argv, g_strfreev);
|
||||
|
||||
G_OBJECT_CLASS (sp_process_model_item_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (sysprof_process_model_item_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_item_get_property (GObject *object,
|
||||
sysprof_process_model_item_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SpProcessModelItem *self = SP_PROCESS_MODEL_ITEM (object);
|
||||
SysprofProcessModelItem *self = SYSPROF_PROCESS_MODEL_ITEM (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -82,12 +82,12 @@ sp_process_model_item_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_item_set_property (GObject *object,
|
||||
sysprof_process_model_item_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SpProcessModelItem *self = SP_PROCESS_MODEL_ITEM (object);
|
||||
SysprofProcessModelItem *self = SYSPROF_PROCESS_MODEL_ITEM (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -105,13 +105,13 @@ sp_process_model_item_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_item_class_init (SpProcessModelItemClass *klass)
|
||||
sysprof_process_model_item_class_init (SysprofProcessModelItemClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sp_process_model_item_finalize;
|
||||
object_class->get_property = sp_process_model_item_get_property;
|
||||
object_class->set_property = sp_process_model_item_set_property;
|
||||
object_class->finalize = sysprof_process_model_item_finalize;
|
||||
object_class->get_property = sysprof_process_model_item_get_property;
|
||||
object_class->set_property = sysprof_process_model_item_set_property;
|
||||
|
||||
properties [PROP_COMMAND_LINE] =
|
||||
g_param_spec_string ("command-line",
|
||||
@ -133,22 +133,22 @@ sp_process_model_item_class_init (SpProcessModelItemClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_item_init (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_init (SysprofProcessModelItem *self)
|
||||
{
|
||||
}
|
||||
|
||||
SpProcessModelItem *
|
||||
sp_process_model_item_new (GPid pid)
|
||||
SysprofProcessModelItem *
|
||||
sysprof_process_model_item_new (GPid pid)
|
||||
{
|
||||
g_autofree gchar *cmdline = NULL;
|
||||
SpProcessModelItem *ret;
|
||||
SysprofProcessModelItem *ret;
|
||||
gboolean is_kernel = FALSE;
|
||||
|
||||
#ifdef __linux__
|
||||
cmdline = sp_proc_source_get_command_line (pid, &is_kernel);
|
||||
cmdline = sysprof_proc_source_get_command_line (pid, &is_kernel);
|
||||
#endif
|
||||
|
||||
ret = g_object_new (SP_TYPE_PROCESS_MODEL_ITEM,
|
||||
ret = g_object_new (SYSPROF_TYPE_PROCESS_MODEL_ITEM,
|
||||
"command-line", cmdline,
|
||||
"pid", (int)pid,
|
||||
NULL);
|
||||
@ -158,50 +158,50 @@ sp_process_model_item_new (GPid pid)
|
||||
}
|
||||
|
||||
guint
|
||||
sp_process_model_item_hash (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_hash (SysprofProcessModelItem *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ITEM (self), 0);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ITEM (self), 0);
|
||||
|
||||
return self->pid;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_process_model_item_equal (SpProcessModelItem *self,
|
||||
SpProcessModelItem *other)
|
||||
sysprof_process_model_item_equal (SysprofProcessModelItem *self,
|
||||
SysprofProcessModelItem *other)
|
||||
{
|
||||
g_assert (SP_IS_PROCESS_MODEL_ITEM (self));
|
||||
g_assert (SP_IS_PROCESS_MODEL_ITEM (other));
|
||||
g_assert (SYSPROF_IS_PROCESS_MODEL_ITEM (self));
|
||||
g_assert (SYSPROF_IS_PROCESS_MODEL_ITEM (other));
|
||||
|
||||
return ((self->pid == other->pid) &&
|
||||
(g_strcmp0 (self->command_line, other->command_line) == 0));
|
||||
}
|
||||
|
||||
GPid
|
||||
sp_process_model_item_get_pid (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_get_pid (SysprofProcessModelItem *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ITEM (self), 0);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ITEM (self), 0);
|
||||
|
||||
return self->pid;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
sp_process_model_item_get_command_line (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_get_command_line (SysprofProcessModelItem *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ITEM (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ITEM (self), NULL);
|
||||
|
||||
return self->command_line;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_process_model_item_is_kernel (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_is_kernel (SysprofProcessModelItem *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ITEM (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ITEM (self), FALSE);
|
||||
|
||||
return self->is_kernel;
|
||||
}
|
||||
|
||||
const gchar * const *
|
||||
sp_process_model_item_get_argv (SpProcessModelItem *self)
|
||||
sysprof_process_model_item_get_argv (SysprofProcessModelItem *self)
|
||||
{
|
||||
g_autofree gchar *contents = NULL;
|
||||
g_autofree gchar *path = NULL;
|
||||
@ -211,12 +211,12 @@ sp_process_model_item_get_argv (SpProcessModelItem *self)
|
||||
gsize size = 0;
|
||||
GPid pid;
|
||||
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL_ITEM (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL_ITEM (self), NULL);
|
||||
|
||||
if (self->argv)
|
||||
return (const gchar * const *)self->argv;
|
||||
|
||||
if ((pid = sp_process_model_item_get_pid (self)) < 0)
|
||||
if ((pid = sysprof_process_model_item_get_pid (self)) < 0)
|
||||
return NULL;
|
||||
|
||||
path = g_strdup_printf ("/proc/%u/cmdline", (guint)pid);
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-process-model-item.h
|
||||
/* sysprof-process-model-item.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -26,25 +26,25 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROCESS_MODEL_ITEM (sp_process_model_item_get_type())
|
||||
#define SYSPROF_TYPE_PROCESS_MODEL_ITEM (sysprof_process_model_item_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcessModelItem, sp_process_model_item, SP, PROCESS_MODEL_ITEM, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofProcessModelItem, sysprof_process_model_item, SYSPROF, PROCESS_MODEL_ITEM, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProcessModelItem *sp_process_model_item_new (GPid pid);
|
||||
SysprofProcessModelItem *sysprof_process_model_item_new (GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sp_process_model_item_hash (SpProcessModelItem *self);
|
||||
guint sysprof_process_model_item_hash (SysprofProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_process_model_item_equal (SpProcessModelItem *self,
|
||||
SpProcessModelItem *other);
|
||||
gboolean sysprof_process_model_item_equal (SysprofProcessModelItem *self,
|
||||
SysprofProcessModelItem *other);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GPid sp_process_model_item_get_pid (SpProcessModelItem *self);
|
||||
GPid sysprof_process_model_item_get_pid (SysprofProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sp_process_model_item_get_command_line (SpProcessModelItem *self);
|
||||
const gchar *sysprof_process_model_item_get_command_line (SysprofProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_process_model_item_is_kernel (SpProcessModelItem *self);
|
||||
gboolean sysprof_process_model_item_is_kernel (SysprofProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar * const *sp_process_model_item_get_argv (SpProcessModelItem *self);
|
||||
const gchar * const *sysprof_process_model_item_get_argv (SysprofProcessModelItem *self);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-process-model.c
|
||||
/* sysprof-process-model.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -22,12 +22,12 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sp-process-model.h"
|
||||
#include "sp-process-model-item.h"
|
||||
#include "sysprof-process-model.h"
|
||||
#include "sysprof-process-model-item.h"
|
||||
|
||||
#define QUEUE_RELOAD_TIMEOUT_MSEC 100
|
||||
|
||||
struct _SpProcessModel
|
||||
struct _SysprofProcessModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
guint reload_source;
|
||||
@ -36,13 +36,13 @@ struct _SpProcessModel
|
||||
|
||||
static void list_model_iface_init (GListModelInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (SpProcessModel, sp_process_model, G_TYPE_OBJECT, 0,
|
||||
G_DEFINE_TYPE_EXTENDED (SysprofProcessModel, sysprof_process_model, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
|
||||
|
||||
static void
|
||||
sp_process_model_finalize (GObject *object)
|
||||
sysprof_process_model_finalize (GObject *object)
|
||||
{
|
||||
SpProcessModel *self = (SpProcessModel *)object;
|
||||
SysprofProcessModel *self = (SysprofProcessModel *)object;
|
||||
|
||||
if (self->reload_source)
|
||||
{
|
||||
@ -52,23 +52,23 @@ sp_process_model_finalize (GObject *object)
|
||||
|
||||
g_clear_pointer (&self->items, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (sp_process_model_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (sysprof_process_model_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_class_init (SpProcessModelClass *klass)
|
||||
sysprof_process_model_class_init (SysprofProcessModelClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sp_process_model_finalize;
|
||||
object_class->finalize = sysprof_process_model_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_init (SpProcessModel *self)
|
||||
sysprof_process_model_init (SysprofProcessModel *self)
|
||||
{
|
||||
self->items = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
|
||||
sp_process_model_queue_reload (self);
|
||||
sysprof_process_model_queue_reload (self);
|
||||
}
|
||||
|
||||
static guint
|
||||
@ -81,8 +81,8 @@ find_index (GPtrArray *ar,
|
||||
|
||||
for (i = 0; i < ar->len; i++)
|
||||
{
|
||||
SpProcessModelItem *item = g_ptr_array_index (ar, i);
|
||||
GPid item_pid = sp_process_model_item_get_pid (item);
|
||||
SysprofProcessModelItem *item = g_ptr_array_index (ar, i);
|
||||
GPid item_pid = sysprof_process_model_item_get_pid (item);
|
||||
|
||||
g_assert (pid != item_pid);
|
||||
|
||||
@ -94,18 +94,18 @@ find_index (GPtrArray *ar,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_merge_cb (GObject *object,
|
||||
sysprof_process_model_merge_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SpProcessModel *self = (SpProcessModel *)object;
|
||||
SysprofProcessModel *self = (SysprofProcessModel *)object;
|
||||
g_autoptr(GPtrArray) ret = NULL;
|
||||
g_autoptr(GHashTable) old_hash = NULL;
|
||||
g_autoptr(GHashTable) new_hash = NULL;
|
||||
GError *error = NULL;
|
||||
guint i;
|
||||
|
||||
g_assert (SP_IS_PROCESS_MODEL (self));
|
||||
g_assert (SYSPROF_IS_PROCESS_MODEL (self));
|
||||
g_assert (G_IS_TASK (result));
|
||||
|
||||
ret = g_task_propagate_pointer (G_TASK (result), &error);
|
||||
@ -122,21 +122,21 @@ sp_process_model_merge_cb (GObject *object,
|
||||
* and do a proper 2-way merge.
|
||||
*/
|
||||
|
||||
old_hash = g_hash_table_new ((GHashFunc)sp_process_model_item_hash,
|
||||
(GEqualFunc)sp_process_model_item_equal);
|
||||
new_hash = g_hash_table_new ((GHashFunc)sp_process_model_item_hash,
|
||||
(GEqualFunc)sp_process_model_item_equal);
|
||||
old_hash = g_hash_table_new ((GHashFunc)sysprof_process_model_item_hash,
|
||||
(GEqualFunc)sysprof_process_model_item_equal);
|
||||
new_hash = g_hash_table_new ((GHashFunc)sysprof_process_model_item_hash,
|
||||
(GEqualFunc)sysprof_process_model_item_equal);
|
||||
|
||||
for (i = 0; i < self->items->len; i++)
|
||||
{
|
||||
SpProcessModelItem *item = g_ptr_array_index (self->items, i);
|
||||
SysprofProcessModelItem *item = g_ptr_array_index (self->items, i);
|
||||
|
||||
g_hash_table_insert (old_hash, item, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < ret->len; i++)
|
||||
{
|
||||
SpProcessModelItem *item = g_ptr_array_index (ret, i);
|
||||
SysprofProcessModelItem *item = g_ptr_array_index (ret, i);
|
||||
|
||||
g_hash_table_insert (new_hash, item, NULL);
|
||||
}
|
||||
@ -144,7 +144,7 @@ sp_process_model_merge_cb (GObject *object,
|
||||
for (i = self->items->len; i > 0; i--)
|
||||
{
|
||||
guint index = i - 1;
|
||||
SpProcessModelItem *item = g_ptr_array_index (self->items, index);
|
||||
SysprofProcessModelItem *item = g_ptr_array_index (self->items, index);
|
||||
|
||||
if (!g_hash_table_contains (new_hash, item))
|
||||
{
|
||||
@ -155,14 +155,14 @@ sp_process_model_merge_cb (GObject *object,
|
||||
|
||||
for (i = 0; i < ret->len; i++)
|
||||
{
|
||||
SpProcessModelItem *item = g_ptr_array_index (ret, i);
|
||||
SysprofProcessModelItem *item = g_ptr_array_index (ret, i);
|
||||
GPid pid;
|
||||
guint index;
|
||||
|
||||
if (g_hash_table_contains (old_hash, item))
|
||||
continue;
|
||||
|
||||
pid = sp_process_model_item_get_pid (item);
|
||||
pid = sysprof_process_model_item_get_pid (item);
|
||||
index = find_index (self->items, pid);
|
||||
|
||||
g_ptr_array_insert (self->items, index, g_object_ref (item));
|
||||
@ -174,14 +174,14 @@ static gint
|
||||
compare_by_pid (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
SpProcessModelItem **aitem = (SpProcessModelItem **)a;
|
||||
SpProcessModelItem **bitem = (SpProcessModelItem **)b;
|
||||
SysprofProcessModelItem **aitem = (SysprofProcessModelItem **)a;
|
||||
SysprofProcessModelItem **bitem = (SysprofProcessModelItem **)b;
|
||||
|
||||
return sp_process_model_item_get_pid (*aitem) - sp_process_model_item_get_pid (*bitem);
|
||||
return sysprof_process_model_item_get_pid (*aitem) - sysprof_process_model_item_get_pid (*bitem);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_process_model_reload_worker (GTask *task,
|
||||
sysprof_process_model_reload_worker (GTask *task,
|
||||
gpointer source_object,
|
||||
gpointer task_data,
|
||||
GCancellable *cancellable)
|
||||
@ -191,7 +191,7 @@ sp_process_model_reload_worker (GTask *task,
|
||||
GError *error = NULL;
|
||||
GDir *dir;
|
||||
|
||||
g_assert (SP_IS_PROCESS_MODEL (source_object));
|
||||
g_assert (SYSPROF_IS_PROCESS_MODEL (source_object));
|
||||
g_assert (G_IS_TASK (task));
|
||||
|
||||
dir = g_dir_open ("/proc", 0, &error);
|
||||
@ -206,7 +206,7 @@ sp_process_model_reload_worker (GTask *task,
|
||||
|
||||
while ((name = g_dir_read_name (dir)))
|
||||
{
|
||||
SpProcessModelItem *item;
|
||||
SysprofProcessModelItem *item;
|
||||
GPid pid;
|
||||
gchar *end;
|
||||
|
||||
@ -214,9 +214,9 @@ sp_process_model_reload_worker (GTask *task,
|
||||
if (pid <= 0 || *end != '\0')
|
||||
continue;
|
||||
|
||||
item = sp_process_model_item_new (pid);
|
||||
item = sysprof_process_model_item_new (pid);
|
||||
|
||||
if (sp_process_model_item_is_kernel (item))
|
||||
if (sysprof_process_model_item_is_kernel (item))
|
||||
{
|
||||
g_object_unref (item);
|
||||
continue;
|
||||
@ -232,32 +232,32 @@ sp_process_model_reload_worker (GTask *task,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sp_process_model_do_reload (gpointer user_data)
|
||||
sysprof_process_model_do_reload (gpointer user_data)
|
||||
{
|
||||
SpProcessModel *self = user_data;
|
||||
SysprofProcessModel *self = user_data;
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
self->reload_source = 0;
|
||||
|
||||
task = g_task_new (self, NULL, sp_process_model_merge_cb, NULL);
|
||||
task = g_task_new (self, NULL, sysprof_process_model_merge_cb, NULL);
|
||||
g_task_set_priority (task, G_PRIORITY_LOW);
|
||||
g_task_run_in_thread (task, sp_process_model_reload_worker);
|
||||
g_task_run_in_thread (task, sysprof_process_model_reload_worker);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
SpProcessModel *
|
||||
sp_process_model_new (void)
|
||||
SysprofProcessModel *
|
||||
sysprof_process_model_new (void)
|
||||
{
|
||||
return g_object_new (SP_TYPE_PROCESS_MODEL, NULL);
|
||||
return g_object_new (SYSPROF_TYPE_PROCESS_MODEL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_process_model_reload (SpProcessModel *self)
|
||||
sysprof_process_model_reload (SysprofProcessModel *self)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
g_return_if_fail (SP_IS_PROCESS_MODEL (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROCESS_MODEL (self));
|
||||
|
||||
if (self->reload_source != 0)
|
||||
{
|
||||
@ -267,43 +267,43 @@ sp_process_model_reload (SpProcessModel *self)
|
||||
|
||||
task = g_task_new (self, NULL, NULL, NULL);
|
||||
g_task_set_priority (task, G_PRIORITY_LOW);
|
||||
g_task_run_in_thread_sync (task, sp_process_model_reload_worker);
|
||||
g_task_run_in_thread_sync (task, sysprof_process_model_reload_worker);
|
||||
|
||||
sp_process_model_merge_cb (G_OBJECT (self), G_ASYNC_RESULT (task), NULL);
|
||||
sysprof_process_model_merge_cb (G_OBJECT (self), G_ASYNC_RESULT (task), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_process_model_queue_reload (SpProcessModel *self)
|
||||
sysprof_process_model_queue_reload (SysprofProcessModel *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROCESS_MODEL (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROCESS_MODEL (self));
|
||||
|
||||
if (self->reload_source == 0)
|
||||
self->reload_source = g_timeout_add (QUEUE_RELOAD_TIMEOUT_MSEC,
|
||||
sp_process_model_do_reload,
|
||||
sysprof_process_model_do_reload,
|
||||
self);
|
||||
}
|
||||
|
||||
static GType
|
||||
sp_process_model_get_item_type (GListModel *model)
|
||||
sysprof_process_model_get_item_type (GListModel *model)
|
||||
{
|
||||
return SP_TYPE_PROCESS_MODEL_ITEM;
|
||||
return SYSPROF_TYPE_PROCESS_MODEL_ITEM;
|
||||
}
|
||||
|
||||
static guint
|
||||
sp_process_model_get_n_items (GListModel *model)
|
||||
sysprof_process_model_get_n_items (GListModel *model)
|
||||
{
|
||||
SpProcessModel *self = (SpProcessModel *)model;
|
||||
SysprofProcessModel *self = (SysprofProcessModel *)model;
|
||||
|
||||
return self->items->len;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
sp_process_model_get_item (GListModel *model,
|
||||
sysprof_process_model_get_item (GListModel *model,
|
||||
guint position)
|
||||
{
|
||||
SpProcessModel *self = (SpProcessModel *)model;
|
||||
SysprofProcessModel *self = (SysprofProcessModel *)model;
|
||||
|
||||
g_return_val_if_fail (SP_IS_PROCESS_MODEL (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROCESS_MODEL (self), NULL);
|
||||
g_return_val_if_fail (position < self->items->len, NULL);
|
||||
|
||||
return g_object_ref (g_ptr_array_index (self->items, position));
|
||||
@ -312,7 +312,7 @@ sp_process_model_get_item (GListModel *model,
|
||||
static void
|
||||
list_model_iface_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = sp_process_model_get_item_type;
|
||||
iface->get_n_items = sp_process_model_get_n_items;
|
||||
iface->get_item = sp_process_model_get_item;
|
||||
iface->get_item_type = sysprof_process_model_get_item_type;
|
||||
iface->get_n_items = sysprof_process_model_get_n_items;
|
||||
iface->get_item = sysprof_process_model_get_item;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-process-model.h
|
||||
/* sysprof-process-model.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -26,16 +26,16 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROCESS_MODEL (sp_process_model_get_type())
|
||||
#define SYSPROF_TYPE_PROCESS_MODEL (sysprof_process_model_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcessModel, sp_process_model, SP, PROCESS_MODEL, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofProcessModel, sysprof_process_model, SYSPROF, PROCESS_MODEL, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProcessModel *sp_process_model_new (void);
|
||||
SysprofProcessModel *sysprof_process_model_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_process_model_reload (SpProcessModel *self);
|
||||
void sysprof_process_model_reload (SysprofProcessModel *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_process_model_queue_reload (SpProcessModel *self);
|
||||
void sysprof_process_model_queue_reload (SysprofProcessModel *self);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-profile.c
|
||||
/* sysprof-profile.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -20,12 +20,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-profile.h"
|
||||
#include "sysprof-profile.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpProfile, sp_profile, G_TYPE_OBJECT)
|
||||
G_DEFINE_INTERFACE (SysprofProfile, sysprof_profile, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
dummy_generate (SpProfile *self,
|
||||
dummy_generate (SysprofProfile *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@ -37,7 +37,7 @@ dummy_generate (SpProfile *self,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dummy_generate_finish (SpProfile *self,
|
||||
dummy_generate_finish (SysprofProfile *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
@ -45,41 +45,41 @@ dummy_generate_finish (SpProfile *self,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_profile_default_init (SpProfileInterface *iface)
|
||||
sysprof_profile_default_init (SysprofProfileInterface *iface)
|
||||
{
|
||||
iface->generate = dummy_generate;
|
||||
iface->generate_finish = dummy_generate_finish;
|
||||
}
|
||||
|
||||
void
|
||||
sp_profile_generate (SpProfile *self,
|
||||
sysprof_profile_generate (SysprofProfile *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILE (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILE (self));
|
||||
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
SP_PROFILE_GET_IFACE (self)->generate (self, cancellable, callback, user_data);
|
||||
SYSPROF_PROFILE_GET_IFACE (self)->generate (self, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profile_generate_finish (SpProfile *self,
|
||||
sysprof_profile_generate_finish (SysprofProfile *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROFILE (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILE (self), FALSE);
|
||||
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
|
||||
|
||||
return SP_PROFILE_GET_IFACE (self)->generate_finish (self, result, error);
|
||||
return SYSPROF_PROFILE_GET_IFACE (self)->generate_finish (self, result, error);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profile_set_reader (SpProfile *self,
|
||||
SpCaptureReader *reader)
|
||||
sysprof_profile_set_reader (SysprofProfile *self,
|
||||
SysprofCaptureReader *reader)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILE (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILE (self));
|
||||
g_return_if_fail (reader != NULL);
|
||||
|
||||
SP_PROFILE_GET_IFACE (self)->set_reader (self, reader);
|
||||
SYSPROF_PROFILE_GET_IFACE (self)->set_reader (self, reader);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-profile.h
|
||||
/* sysprof-profile.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
@ -24,40 +24,40 @@
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-capture-reader.h"
|
||||
#include "sysprof-capture-reader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROFILE (sp_profile_get_type ())
|
||||
#define SYSPROF_TYPE_PROFILE (sysprof_profile_get_type ())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (SpProfile, sp_profile, SP, PROFILE, GObject)
|
||||
G_DECLARE_INTERFACE (SysprofProfile, sysprof_profile, SYSPROF, PROFILE, GObject)
|
||||
|
||||
struct _SpProfileInterface
|
||||
struct _SysprofProfileInterface
|
||||
{
|
||||
GTypeInterface parent;
|
||||
|
||||
void (*set_reader) (SpProfile *self,
|
||||
SpCaptureReader *reader);
|
||||
void (*generate) (SpProfile *self,
|
||||
void (*set_reader) (SysprofProfile *self,
|
||||
SysprofCaptureReader *reader);
|
||||
void (*generate) (SysprofProfile *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean (*generate_finish) (SpProfile *self,
|
||||
gboolean (*generate_finish) (SysprofProfile *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profile_set_reader (SpProfile *self,
|
||||
SpCaptureReader *reader);
|
||||
void sysprof_profile_set_reader (SysprofProfile *self,
|
||||
SysprofCaptureReader *reader);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profile_generate (SpProfile *self,
|
||||
void sysprof_profile_generate (SysprofProfile *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profile_generate_finish (SpProfile *self,
|
||||
gboolean sysprof_profile_generate_finish (SysprofProfile *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-profiler.c
|
||||
/* sysprof-profiler.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-profiler"
|
||||
#define G_LOG_DOMAIN "sysprof-profiler"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-profiler.h"
|
||||
#include "sysprof-profiler.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpProfiler, sp_profiler, G_TYPE_OBJECT)
|
||||
G_DEFINE_INTERFACE (SysprofProfiler, sysprof_profiler, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
FAILED,
|
||||
@ -35,19 +35,19 @@ enum {
|
||||
static guint signals [N_SIGNALS];
|
||||
|
||||
static void
|
||||
sp_profiler_default_init (SpProfilerInterface *iface)
|
||||
sysprof_profiler_default_init (SysprofProfilerInterface *iface)
|
||||
{
|
||||
signals [FAILED] = g_signal_new ("failed",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (SpProfilerInterface, failed),
|
||||
G_STRUCT_OFFSET (SysprofProfilerInterface, failed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, G_TYPE_ERROR);
|
||||
|
||||
signals [STOPPED] = g_signal_new ("stopped",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (SpProfilerInterface, stopped),
|
||||
G_STRUCT_OFFSET (SysprofProfilerInterface, stopped),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
@ -76,7 +76,7 @@ sp_profiler_default_init (SpProfilerInterface *iface)
|
||||
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_boolean ("spawn-inherit-environ",
|
||||
"Spawn Inherit Environ",
|
||||
"Sysprofawn Inherit Environ",
|
||||
"If the spawned child should inherit the parents environment",
|
||||
TRUE,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
@ -90,208 +90,208 @@ sp_profiler_default_init (SpProfilerInterface *iface)
|
||||
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_boolean ("spawn",
|
||||
"Spawn",
|
||||
"Sysprofawn",
|
||||
"If configured child should be spawned",
|
||||
TRUE,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_boxed ("spawn-argv",
|
||||
"Spawn Argv",
|
||||
"Sysprofawn Argv",
|
||||
"The arguments for the spawn child",
|
||||
G_TYPE_STRV,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_boxed ("spawn-env",
|
||||
"Spawn Environment",
|
||||
"Sysprofawn Environment",
|
||||
"The environment for the spawn child",
|
||||
G_TYPE_STRV,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
}
|
||||
|
||||
gdouble
|
||||
sp_profiler_get_elapsed (SpProfiler *self)
|
||||
sysprof_profiler_get_elapsed (SysprofProfiler *self)
|
||||
{
|
||||
gdouble value = 0.0;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), 0.0);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), 0.0);
|
||||
g_object_get (self, "elapsed", &value, NULL);
|
||||
return value;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profiler_get_is_running (SpProfiler *self)
|
||||
sysprof_profiler_get_is_running (SysprofProfiler *self)
|
||||
{
|
||||
gboolean is_running = FALSE;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), FALSE);
|
||||
g_object_get (self, "is-running", &is_running, NULL);
|
||||
return is_running;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profiler_get_is_mutable (SpProfiler *self)
|
||||
sysprof_profiler_get_is_mutable (SysprofProfiler *self)
|
||||
{
|
||||
gboolean is_mutable = FALSE;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), FALSE);
|
||||
g_object_get (self, "is-mutable", &is_mutable, NULL);
|
||||
return is_mutable;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profiler_get_spawn_inherit_environ (SpProfiler *self)
|
||||
sysprof_profiler_get_spawn_inherit_environ (SysprofProfiler *self)
|
||||
{
|
||||
gboolean spawn_inherit_environ = FALSE;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), FALSE);
|
||||
g_object_get (self, "spawn-inherit-environ", &spawn_inherit_environ, NULL);
|
||||
return spawn_inherit_environ;
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_spawn_inherit_environ (SpProfiler *self,
|
||||
sysprof_profiler_set_spawn_inherit_environ (SysprofProfiler *self,
|
||||
gboolean spawn_inherit_environ)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_object_set (self, "spawn-inherit-environ", !!spawn_inherit_environ, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profiler_get_spawn (SpProfiler *self)
|
||||
sysprof_profiler_get_spawn (SysprofProfiler *self)
|
||||
{
|
||||
gboolean spawn = FALSE;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), FALSE);
|
||||
g_object_get (self, "spawn", &spawn, NULL);
|
||||
return spawn;
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_spawn (SpProfiler *self,
|
||||
sysprof_profiler_set_spawn (SysprofProfiler *self,
|
||||
gboolean spawn)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_object_set (self, "spawn", !!spawn, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_profiler_get_whole_system (SpProfiler *self)
|
||||
sysprof_profiler_get_whole_system (SysprofProfiler *self)
|
||||
{
|
||||
gboolean whole_system = FALSE;
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), FALSE);
|
||||
g_object_get (self, "whole-system", &whole_system, NULL);
|
||||
return whole_system;
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_whole_system (SpProfiler *self,
|
||||
sysprof_profiler_set_whole_system (SysprofProfiler *self,
|
||||
gboolean whole_system)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_object_set (self, "whole-system", !!whole_system, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_spawn_argv (SpProfiler *self,
|
||||
sysprof_profiler_set_spawn_argv (SysprofProfiler *self,
|
||||
const gchar * const *spawn_argv)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_object_set (self, "spawn-argv", spawn_argv, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_spawn_env (SpProfiler *self,
|
||||
sysprof_profiler_set_spawn_env (SysprofProfiler *self,
|
||||
const gchar * const *spawn_env)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_object_set (self, "spawn-env", spawn_env, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_add_source (SpProfiler *self,
|
||||
SpSource *source)
|
||||
sysprof_profiler_add_source (SysprofProfiler *self,
|
||||
SysprofSource *source)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SP_IS_SOURCE (source));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (source));
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->add_source (self, source);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->add_source (self, source);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_set_writer (SpProfiler *self,
|
||||
SpCaptureWriter *writer)
|
||||
sysprof_profiler_set_writer (SysprofProfiler *self,
|
||||
SysprofCaptureWriter *writer)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->set_writer (self, writer);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->set_writer (self, writer);
|
||||
}
|
||||
|
||||
SpCaptureWriter *
|
||||
sp_profiler_get_writer (SpProfiler *self)
|
||||
SysprofCaptureWriter *
|
||||
sysprof_profiler_get_writer (SysprofProfiler *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), NULL);
|
||||
|
||||
return SP_PROFILER_GET_IFACE (self)->get_writer (self);
|
||||
return SYSPROF_PROFILER_GET_IFACE (self)->get_writer (self);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_start (SpProfiler *self)
|
||||
sysprof_profiler_start (SysprofProfiler *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->start (self);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->start (self);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_stop (SpProfiler *self)
|
||||
sysprof_profiler_stop (SysprofProfiler *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->stop (self);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->stop (self);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_add_pid (SpProfiler *self,
|
||||
sysprof_profiler_add_pid (SysprofProfiler *self,
|
||||
GPid pid)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_return_if_fail (pid > -1);
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->add_pid (self, pid);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->add_pid (self, pid);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_remove_pid (SpProfiler *self,
|
||||
sysprof_profiler_remove_pid (SysprofProfiler *self,
|
||||
GPid pid)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_return_if_fail (pid > -1);
|
||||
|
||||
SP_PROFILER_GET_IFACE (self)->remove_pid (self, pid);
|
||||
SYSPROF_PROFILER_GET_IFACE (self)->remove_pid (self, pid);
|
||||
}
|
||||
|
||||
const GPid *
|
||||
sp_profiler_get_pids (SpProfiler *self,
|
||||
sysprof_profiler_get_pids (SysprofProfiler *self,
|
||||
guint *n_pids)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_PROFILER (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_PROFILER (self), NULL);
|
||||
g_return_val_if_fail (n_pids != NULL, NULL);
|
||||
|
||||
return SP_PROFILER_GET_IFACE (self)->get_pids (self, n_pids);
|
||||
return SYSPROF_PROFILER_GET_IFACE (self)->get_pids (self, n_pids);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_emit_failed (SpProfiler *self,
|
||||
sysprof_profiler_emit_failed (SysprofProfiler *self,
|
||||
const GError *error)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
g_return_if_fail (error != NULL);
|
||||
|
||||
g_signal_emit (self, signals [FAILED], 0, error);
|
||||
}
|
||||
|
||||
void
|
||||
sp_profiler_emit_stopped (SpProfiler *self)
|
||||
sysprof_profiler_emit_stopped (SysprofProfiler *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_PROFILER (self));
|
||||
g_return_if_fail (SYSPROF_IS_PROFILER (self));
|
||||
|
||||
g_signal_emit (self, signals [STOPPED], 0);
|
||||
}
|
||||
184
src/libsysprof/sysprof-profiler.h
Normal file
184
src/libsysprof/sysprof-profiler.h
Normal file
@ -0,0 +1,184 @@
|
||||
/* sysprof-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 "sysprof-capture-writer.h"
|
||||
#include "sysprof-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_PROFILER (sysprof_profiler_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (SysprofProfiler, sysprof_profiler, SYSPROF, PROFILER, GObject)
|
||||
|
||||
struct _SysprofProfilerInterface
|
||||
{
|
||||
GTypeInterface parent_interface;
|
||||
|
||||
/**
|
||||
* SysprofProfiler::failed:
|
||||
* @self: A #SysprofProfiler
|
||||
* @reason: A #GError representing the reason for the failure
|
||||
*
|
||||
* This signal is emitted if the profiler failed. Note that
|
||||
* #SysprofProfiler::stopped will also be emitted, but does not allow for
|
||||
* receiving the error condition.
|
||||
*/
|
||||
void (*failed) (SysprofProfiler *self,
|
||||
const GError *error);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::stopped:
|
||||
* @self: A #SysprofProfiler
|
||||
*
|
||||
* This signal is emitted when a profiler is stopped. It will always be
|
||||
* emitted after a sysprof_profiler_start() has been called, either after
|
||||
* completion of sysprof_profiler_stop() or after a failure or after asynchronous
|
||||
* completion of stopping.
|
||||
*/
|
||||
void (*stopped) (SysprofProfiler *self);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::add_source:
|
||||
*
|
||||
* Adds a source to the profiler.
|
||||
*/
|
||||
void (*add_source) (SysprofProfiler *profiler,
|
||||
SysprofSource *source);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::set_writer:
|
||||
*
|
||||
* Sets the writer to use for the profiler.
|
||||
*/
|
||||
void (*set_writer) (SysprofProfiler *self,
|
||||
SysprofCaptureWriter *writer);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::get_writer:
|
||||
*
|
||||
* Gets the writer that is being used to capture.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): A #SysprofCaptureWriter.
|
||||
*/
|
||||
SysprofCaptureWriter *(*get_writer) (SysprofProfiler *self);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::start:
|
||||
*
|
||||
* Starts the profiler.
|
||||
*/
|
||||
void (*start) (SysprofProfiler *self);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::stop:
|
||||
*
|
||||
* Stops the profiler.
|
||||
*/
|
||||
void (*stop) (SysprofProfiler *self);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::add_pid:
|
||||
*
|
||||
* Add a pid to be profiled.
|
||||
*/
|
||||
void (*add_pid) (SysprofProfiler *self,
|
||||
GPid pid);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::remove_pid:
|
||||
*
|
||||
* Remove a pid from the profiler. This will not be called after
|
||||
* SysprofProfiler::start has been called.
|
||||
*/
|
||||
void (*remove_pid) (SysprofProfiler *self,
|
||||
GPid pid);
|
||||
|
||||
/**
|
||||
* SysprofProfiler::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) (SysprofProfiler *self,
|
||||
guint *n_pids);
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_emit_failed (SysprofProfiler *self,
|
||||
const GError *error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_emit_stopped (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gdouble sysprof_profiler_get_elapsed (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_profiler_get_is_mutable (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_profiler_get_spawn_inherit_environ (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_spawn_inherit_environ (SysprofProfiler *self,
|
||||
gboolean spawn_inherit_environ);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_profiler_get_whole_system (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_whole_system (SysprofProfiler *self,
|
||||
gboolean whole_system);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_profiler_get_spawn (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_spawn (SysprofProfiler *self,
|
||||
gboolean spawn);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_spawn_argv (SysprofProfiler *self,
|
||||
const gchar * const *spawn_argv);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_spawn_env (SysprofProfiler *self,
|
||||
const gchar * const *spawn_env);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_add_source (SysprofProfiler *self,
|
||||
SysprofSource *source);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_set_writer (SysprofProfiler *self,
|
||||
SysprofCaptureWriter *writer);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureWriter *sysprof_profiler_get_writer (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_profiler_get_is_running (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_start (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_stop (SysprofProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_add_pid (SysprofProfiler *self,
|
||||
GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_profiler_remove_pid (SysprofProfiler *self,
|
||||
GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const GPid *sysprof_profiler_get_pids (SysprofProfiler *self,
|
||||
guint *n_pids);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-selection.c
|
||||
/* sysprof-selection.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-selection"
|
||||
#define G_LOG_DOMAIN "sysprof-selection"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-selection.h"
|
||||
#include "sysprof-selection.h"
|
||||
|
||||
struct _SpSelection
|
||||
struct _SysprofSelection
|
||||
{
|
||||
GObject parent_instance;
|
||||
GArray *ranges;
|
||||
@ -36,7 +36,7 @@ typedef struct
|
||||
gint64 end;
|
||||
} Range;
|
||||
|
||||
G_DEFINE_TYPE (SpSelection, sp_selection, G_TYPE_OBJECT)
|
||||
G_DEFINE_TYPE (SysprofSelection, sysprof_selection, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -65,27 +65,27 @@ int64_swap (gint64 *a,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_selection_finalize (GObject *object)
|
||||
sysprof_selection_finalize (GObject *object)
|
||||
{
|
||||
SpSelection *self = (SpSelection *)object;
|
||||
SysprofSelection *self = (SysprofSelection *)object;
|
||||
|
||||
g_clear_pointer (&self->ranges, g_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (sp_selection_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (sysprof_selection_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sp_selection_get_property (GObject *object,
|
||||
sysprof_selection_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SpSelection *self = SP_SELECTION (object);
|
||||
SysprofSelection *self = SYSPROF_SELECTION (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_HAS_SELECTION:
|
||||
g_value_set_boolean (value, sp_selection_get_has_selection (self));
|
||||
g_value_set_boolean (value, sysprof_selection_get_has_selection (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -94,12 +94,12 @@ sp_selection_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
sp_selection_class_init (SpSelectionClass *klass)
|
||||
sysprof_selection_class_init (SysprofSelectionClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sp_selection_finalize;
|
||||
object_class->get_property = sp_selection_get_property;
|
||||
object_class->finalize = sysprof_selection_finalize;
|
||||
object_class->get_property = sysprof_selection_get_property;
|
||||
|
||||
properties [PROP_HAS_SELECTION] =
|
||||
g_param_spec_boolean ("has-selection",
|
||||
@ -111,7 +111,7 @@ sp_selection_class_init (SpSelectionClass *klass)
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
/**
|
||||
* SpSelection::changed:
|
||||
* SysprofSelection::changed:
|
||||
*
|
||||
* This signal is emitted when the selection has changed.
|
||||
*/
|
||||
@ -123,33 +123,33 @@ sp_selection_class_init (SpSelectionClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
sp_selection_init (SpSelection *self)
|
||||
sysprof_selection_init (SysprofSelection *self)
|
||||
{
|
||||
self->ranges = g_array_new (FALSE, FALSE, sizeof (Range));
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_selection_get_has_selection (SpSelection *self)
|
||||
sysprof_selection_get_has_selection (SysprofSelection *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_SELECTION (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_SELECTION (self), FALSE);
|
||||
|
||||
return self->ranges->len > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_selection_foreach:
|
||||
* @self: A #SpSelection
|
||||
* sysprof_selection_foreach:
|
||||
* @self: A #SysprofSelection
|
||||
* @foreach_func: (scope call): a callback for each range
|
||||
* @user_data: user data for @foreach_func
|
||||
*
|
||||
* Calls @foreach_func for every selected range.
|
||||
*/
|
||||
void
|
||||
sp_selection_foreach (SpSelection *self,
|
||||
SpSelectionForeachFunc foreach_func,
|
||||
sysprof_selection_foreach (SysprofSelection *self,
|
||||
SysprofSelectionForeachFunc foreach_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SELECTION (self));
|
||||
g_return_if_fail (SYSPROF_IS_SELECTION (self));
|
||||
g_return_if_fail (foreach_func != NULL);
|
||||
|
||||
for (guint i = 0; i < self->ranges->len; i++)
|
||||
@ -160,13 +160,13 @@ sp_selection_foreach (SpSelection *self,
|
||||
}
|
||||
|
||||
void
|
||||
sp_selection_select_range (SpSelection *self,
|
||||
sysprof_selection_select_range (SysprofSelection *self,
|
||||
gint64 begin_time,
|
||||
gint64 end_time)
|
||||
{
|
||||
Range range = { 0 };
|
||||
|
||||
g_return_if_fail (SP_IS_SELECTION (self));
|
||||
g_return_if_fail (SYSPROF_IS_SELECTION (self));
|
||||
|
||||
int64_swap (&begin_time, &end_time);
|
||||
|
||||
@ -181,11 +181,11 @@ sp_selection_select_range (SpSelection *self,
|
||||
}
|
||||
|
||||
void
|
||||
sp_selection_unselect_range (SpSelection *self,
|
||||
sysprof_selection_unselect_range (SysprofSelection *self,
|
||||
gint64 begin,
|
||||
gint64 end)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SELECTION (self));
|
||||
g_return_if_fail (SYSPROF_IS_SELECTION (self));
|
||||
|
||||
int64_swap (&begin, &end);
|
||||
|
||||
@ -205,9 +205,9 @@ sp_selection_unselect_range (SpSelection *self,
|
||||
}
|
||||
|
||||
void
|
||||
sp_selection_unselect_all (SpSelection *self)
|
||||
sysprof_selection_unselect_all (SysprofSelection *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SELECTION (self));
|
||||
g_return_if_fail (SYSPROF_IS_SELECTION (self));
|
||||
|
||||
if (self->ranges->len > 0)
|
||||
{
|
||||
@ -218,7 +218,7 @@ sp_selection_unselect_all (SpSelection *self)
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_selection_contains (SpSelection *self,
|
||||
sysprof_selection_contains (SysprofSelection *self,
|
||||
gint64 time_at)
|
||||
{
|
||||
if (self == NULL || self->ranges->len == 0)
|
||||
@ -235,15 +235,15 @@ sp_selection_contains (SpSelection *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SpSelection *
|
||||
sp_selection_copy (const SpSelection *self)
|
||||
SysprofSelection *
|
||||
sysprof_selection_copy (const SysprofSelection *self)
|
||||
{
|
||||
SpSelection *copy;
|
||||
SysprofSelection *copy;
|
||||
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
|
||||
copy = g_object_new (SP_TYPE_SELECTION, NULL);
|
||||
copy = g_object_new (SYSPROF_TYPE_SELECTION, NULL);
|
||||
|
||||
for (guint i = 0; i < self->ranges->len; i++)
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-selection.h
|
||||
/* sysprof-selection.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -26,36 +26,36 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_SELECTION (sp_selection_get_type())
|
||||
#define SYSPROF_TYPE_SELECTION (sysprof_selection_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpSelection, sp_selection, SP, SELECTION, GObject)
|
||||
G_DECLARE_FINAL_TYPE (SysprofSelection, sysprof_selection, SYSPROF, SELECTION, GObject)
|
||||
|
||||
typedef void (*SpSelectionForeachFunc) (SpSelection *self,
|
||||
typedef void (*SysprofSelectionForeachFunc) (SysprofSelection *self,
|
||||
gint64 begin_time,
|
||||
gint64 end_time,
|
||||
gpointer user_data);
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_selection_get_has_selection (SpSelection *self);
|
||||
gboolean sysprof_selection_get_has_selection (SysprofSelection *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_selection_contains (SpSelection *self,
|
||||
gboolean sysprof_selection_contains (SysprofSelection *self,
|
||||
gint64 time_at);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_select_range (SpSelection *self,
|
||||
void sysprof_selection_select_range (SysprofSelection *self,
|
||||
gint64 begin_time,
|
||||
gint64 end_time);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_unselect_range (SpSelection *self,
|
||||
void sysprof_selection_unselect_range (SysprofSelection *self,
|
||||
gint64 begin,
|
||||
gint64 end);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_unselect_all (SpSelection *self);
|
||||
void sysprof_selection_unselect_all (SysprofSelection *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_foreach (SpSelection *self,
|
||||
SpSelectionForeachFunc foreach_func,
|
||||
void sysprof_selection_foreach (SysprofSelection *self,
|
||||
SysprofSelectionForeachFunc foreach_func,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSelection *sp_selection_copy (const SpSelection *self);
|
||||
SysprofSelection *sysprof_selection_copy (const SysprofSelection *self);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-source-util-private.h
|
||||
/* sysprof-source-util-private.h
|
||||
*
|
||||
* Copyright 2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -24,11 +24,11 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean sp_host_file_get_contents (const gchar *host_path,
|
||||
gboolean sysprof_host_file_get_contents (const gchar *host_path,
|
||||
gchar **contents,
|
||||
gsize *len,
|
||||
GError **error);
|
||||
gchar **sp_host_list_directories (const gchar *directory,
|
||||
gchar **sysprof_host_list_directories (const gchar *directory,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-source-util.c
|
||||
/* sysprof-source-util.c
|
||||
*
|
||||
* Copyright 2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -23,10 +23,10 @@
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-source-util-private.h"
|
||||
#include "sysprof-source-util-private.h"
|
||||
|
||||
gboolean
|
||||
sp_host_file_get_contents (const gchar *host_path,
|
||||
sysprof_host_file_get_contents (const gchar *host_path,
|
||||
gchar **contents,
|
||||
gsize *len,
|
||||
GError **error)
|
||||
@ -96,7 +96,7 @@ sp_host_file_get_contents (const gchar *host_path,
|
||||
}
|
||||
|
||||
gchar **
|
||||
sp_host_list_directories (const gchar *directory,
|
||||
sysprof_host_list_directories (const gchar *directory,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree gchar *alt_path = NULL;
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-source.c
|
||||
/* sysprof-source.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,9 +20,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
#include "sysprof-source.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpSource, sp_source, G_TYPE_OBJECT)
|
||||
G_DEFINE_INTERFACE (SysprofSource, sysprof_source, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
FAILED,
|
||||
@ -34,7 +34,7 @@ enum {
|
||||
static guint signals [N_SIGNALS];
|
||||
|
||||
static void
|
||||
sp_source_default_init (SpSourceInterface *iface)
|
||||
sysprof_source_default_init (SysprofSourceInterface *iface)
|
||||
{
|
||||
signals [FAILED] = g_signal_new ("failed",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
@ -55,87 +55,87 @@ sp_source_default_init (SpSourceInterface *iface)
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_add_pid (SpSource *self,
|
||||
sysprof_source_add_pid (SysprofSource *self,
|
||||
GPid pid)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
g_return_if_fail (pid != FALSE);
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->add_pid)
|
||||
SP_SOURCE_GET_IFACE (self)->add_pid (self, pid);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->add_pid)
|
||||
SYSPROF_SOURCE_GET_IFACE (self)->add_pid (self, pid);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_emit_finished (SpSource *self)
|
||||
sysprof_source_emit_finished (SysprofSource *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
|
||||
g_signal_emit (self, signals [FINISHED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_emit_failed (SpSource *self,
|
||||
sysprof_source_emit_failed (SysprofSource *self,
|
||||
const GError *error)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
g_return_if_fail (error != NULL);
|
||||
|
||||
g_signal_emit (self, signals [FAILED], 0, error);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_emit_ready (SpSource *self)
|
||||
sysprof_source_emit_ready (SysprofSource *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
|
||||
g_signal_emit (self, signals [READY], 0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sp_source_get_is_ready (SpSource *self)
|
||||
sysprof_source_get_is_ready (SysprofSource *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_SOURCE (self), FALSE);
|
||||
g_return_val_if_fail (SYSPROF_IS_SOURCE (self), FALSE);
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->get_is_ready)
|
||||
return SP_SOURCE_GET_IFACE (self)->get_is_ready (self);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->get_is_ready)
|
||||
return SYSPROF_SOURCE_GET_IFACE (self)->get_is_ready (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_prepare (SpSource *self)
|
||||
sysprof_source_prepare (SysprofSource *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->prepare)
|
||||
SP_SOURCE_GET_IFACE (self)->prepare (self);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->prepare)
|
||||
SYSPROF_SOURCE_GET_IFACE (self)->prepare (self);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_set_writer (SpSource *self,
|
||||
SpCaptureWriter *writer)
|
||||
sysprof_source_set_writer (SysprofSource *self,
|
||||
SysprofCaptureWriter *writer)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->set_writer)
|
||||
SP_SOURCE_GET_IFACE (self)->set_writer (self, writer);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->set_writer)
|
||||
SYSPROF_SOURCE_GET_IFACE (self)->set_writer (self, writer);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_start (SpSource *self)
|
||||
sysprof_source_start (SysprofSource *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->start)
|
||||
SP_SOURCE_GET_IFACE (self)->start (self);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->start)
|
||||
SYSPROF_SOURCE_GET_IFACE (self)->start (self);
|
||||
}
|
||||
|
||||
void
|
||||
sp_source_stop (SpSource *self)
|
||||
sysprof_source_stop (SysprofSource *self)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SOURCE (self));
|
||||
g_return_if_fail (SYSPROF_IS_SOURCE (self));
|
||||
|
||||
if (SP_SOURCE_GET_IFACE (self)->stop)
|
||||
SP_SOURCE_GET_IFACE (self)->stop (self);
|
||||
if (SYSPROF_SOURCE_GET_IFACE (self)->stop)
|
||||
SYSPROF_SOURCE_GET_IFACE (self)->stop (self);
|
||||
}
|
||||
132
src/libsysprof/sysprof-source.h
Normal file
132
src/libsysprof/sysprof-source.h
Normal file
@ -0,0 +1,132 @@
|
||||
/* sysprof-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 "sysprof-capture-writer.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_SOURCE (sysprof_source_get_type())
|
||||
|
||||
G_DECLARE_INTERFACE (SysprofSource, sysprof_source, SYSPROF, SOURCE, GObject)
|
||||
|
||||
struct _SysprofSourceInterface
|
||||
{
|
||||
GTypeInterface parent_iface;
|
||||
|
||||
/**
|
||||
* SysprofSource::get_is_ready:
|
||||
* @self: A SysprofSource.
|
||||
*
|
||||
* This function should return %TRUE if the source is ready to start
|
||||
* profiling. If the source is not ready until after sysprof_source_start() has
|
||||
* been called, use sysprof_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) (SysprofSource *self);
|
||||
|
||||
/**
|
||||
* SysprofSource::set_writer:
|
||||
* @self: A #SysprofSource.
|
||||
* @writer: A #SysprofCaptureWriter
|
||||
*
|
||||
* Sets the #SysprofCaptureWriter 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 #SysprofCaptureWriter and then splice that into this
|
||||
* writer from the main thread when profiling completes.
|
||||
*
|
||||
* See sysprof_capture_writer_splice() for information on splicing writers.
|
||||
*/
|
||||
void (*set_writer) (SysprofSource *self,
|
||||
SysprofCaptureWriter *writer);
|
||||
|
||||
/**
|
||||
* SysprofSource::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 SysprofSource::is-ready
|
||||
* property once that asynchronous work has been performed. Until it
|
||||
* is ready, #SysprofSource::is-ready must return FALSE.
|
||||
*/
|
||||
void (*prepare) (SysprofSource *self);
|
||||
|
||||
/**
|
||||
* SysprofSource::add_pid:
|
||||
* @self: A #SysprofSource
|
||||
* @pid: A pid_t > -1
|
||||
*
|
||||
* This function is used to notify the #SysprofSource 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) (SysprofSource *self,
|
||||
GPid pid);
|
||||
|
||||
/**
|
||||
* SysprofSource::start:
|
||||
* @self: A #SysprofSource.
|
||||
*
|
||||
* Start profiling as configured.
|
||||
*
|
||||
* If a failure occurs while processing, the source should notify the
|
||||
* profiling session via sysprof_source_emit_failed() from the main thread.
|
||||
*/
|
||||
void (*start) (SysprofSource *self);
|
||||
|
||||
/**
|
||||
* SysprofSource::stop:
|
||||
* @self: A #SysprofSource.
|
||||
*
|
||||
* 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 sysprof_source_set_writer().
|
||||
*
|
||||
* If you need to perform asynchronous cleanup, call
|
||||
* sysprof_source_emit_finished() once that work has completed. If you do
|
||||
* not need to perform asynchronous cleanup, call
|
||||
* sysprof_source_emit_finished() from this function.
|
||||
*
|
||||
* sysprof_source_emit_finished() must be called from the main-thread.
|
||||
*/
|
||||
void (*stop) (SysprofSource *self);
|
||||
};
|
||||
|
||||
void sysprof_source_add_pid (SysprofSource *self,
|
||||
GPid pid);
|
||||
void sysprof_source_emit_ready (SysprofSource *self);
|
||||
void sysprof_source_emit_finished (SysprofSource *self);
|
||||
void sysprof_source_emit_failed (SysprofSource *self,
|
||||
const GError *error);
|
||||
gboolean sysprof_source_get_is_ready (SysprofSource *self);
|
||||
void sysprof_source_prepare (SysprofSource *self);
|
||||
void sysprof_source_set_writer (SysprofSource *self,
|
||||
SysprofCaptureWriter *writer);
|
||||
void sysprof_source_start (SysprofSource *self);
|
||||
void sysprof_source_stop (SysprofSource *self);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-symbol-dirs.c
|
||||
/* sysprof-symbol-dirs.c
|
||||
*
|
||||
* Copyright 2017-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,19 +20,19 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-symbol-dirs.h"
|
||||
#include "sysprof-symbol-dirs.h"
|
||||
|
||||
static GPtrArray *sp_symbol_dirs;
|
||||
static GPtrArray *sysprof_symbol_dirs;
|
||||
|
||||
G_LOCK_DEFINE (sp_symbol_dirs);
|
||||
G_LOCK_DEFINE (sysprof_symbol_dirs);
|
||||
|
||||
static GPtrArray *
|
||||
sp_get_symbol_dirs_locked (void)
|
||||
sysprof_get_symbol_dirs_locked (void)
|
||||
{
|
||||
if (sp_symbol_dirs == NULL)
|
||||
if (sysprof_symbol_dirs == NULL)
|
||||
{
|
||||
sp_symbol_dirs = g_ptr_array_new ();
|
||||
g_ptr_array_add (sp_symbol_dirs, g_strdup ("/usr/lib/debug"));
|
||||
sysprof_symbol_dirs = g_ptr_array_new ();
|
||||
g_ptr_array_add (sysprof_symbol_dirs, g_strdup ("/usr/lib/debug"));
|
||||
|
||||
/* Add path to host system if we have it */
|
||||
if (g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS))
|
||||
@ -44,22 +44,22 @@ sp_get_symbol_dirs_locked (void)
|
||||
for (guint i = 0; i < G_N_ELEMENTS (tries); i++)
|
||||
{
|
||||
if (g_file_test (tries[i], G_FILE_TEST_EXISTS))
|
||||
g_ptr_array_add (sp_symbol_dirs, g_strdup (tries[i]));
|
||||
g_ptr_array_add (sysprof_symbol_dirs, g_strdup (tries[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sp_symbol_dirs;
|
||||
return sysprof_symbol_dirs;
|
||||
}
|
||||
|
||||
void
|
||||
sp_symbol_dirs_add (const gchar *path)
|
||||
sysprof_symbol_dirs_add (const gchar *path)
|
||||
{
|
||||
GPtrArray *ar;
|
||||
|
||||
G_LOCK (sp_symbol_dirs);
|
||||
G_LOCK (sysprof_symbol_dirs);
|
||||
|
||||
ar = sp_get_symbol_dirs_locked ();
|
||||
ar = sysprof_get_symbol_dirs_locked ();
|
||||
|
||||
for (guint i = 0; i < ar->len; i++)
|
||||
{
|
||||
@ -72,17 +72,17 @@ sp_symbol_dirs_add (const gchar *path)
|
||||
g_ptr_array_add (ar, g_strdup (path));
|
||||
|
||||
skip:
|
||||
G_UNLOCK (sp_symbol_dirs);
|
||||
G_UNLOCK (sysprof_symbol_dirs);
|
||||
}
|
||||
|
||||
void
|
||||
sp_symbol_dirs_remove (const gchar *path)
|
||||
sysprof_symbol_dirs_remove (const gchar *path)
|
||||
{
|
||||
GPtrArray *ar;
|
||||
|
||||
G_LOCK (sp_symbol_dirs);
|
||||
G_LOCK (sysprof_symbol_dirs);
|
||||
|
||||
ar = sp_get_symbol_dirs_locked ();
|
||||
ar = sysprof_get_symbol_dirs_locked ();
|
||||
|
||||
for (guint i = 0; i < ar->len; i++)
|
||||
{
|
||||
@ -95,11 +95,11 @@ sp_symbol_dirs_remove (const gchar *path)
|
||||
}
|
||||
}
|
||||
|
||||
G_UNLOCK (sp_symbol_dirs);
|
||||
G_UNLOCK (sysprof_symbol_dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_symbol_dirs_get_paths:
|
||||
* sysprof_symbol_dirs_get_paths:
|
||||
* @dir: the directory containing the library
|
||||
* @name: the name of the file in @dir
|
||||
*
|
||||
@ -109,7 +109,7 @@ sp_symbol_dirs_remove (const gchar *path)
|
||||
* Returns: (transfer full): A #GStrv of possible paths.
|
||||
*/
|
||||
gchar **
|
||||
sp_symbol_dirs_get_paths (const gchar *dir,
|
||||
sysprof_symbol_dirs_get_paths (const gchar *dir,
|
||||
const gchar *name)
|
||||
{
|
||||
GPtrArray *ret = g_ptr_array_new ();
|
||||
@ -117,9 +117,9 @@ sp_symbol_dirs_get_paths (const gchar *dir,
|
||||
|
||||
g_ptr_array_add (ret, g_build_filename (dir, name, NULL));
|
||||
|
||||
G_LOCK (sp_symbol_dirs);
|
||||
G_LOCK (sysprof_symbol_dirs);
|
||||
|
||||
ar = sp_get_symbol_dirs_locked ();
|
||||
ar = sysprof_get_symbol_dirs_locked ();
|
||||
|
||||
for (guint i = 0; i < ar->len; i++)
|
||||
{
|
||||
@ -132,7 +132,7 @@ sp_symbol_dirs_get_paths (const gchar *dir,
|
||||
g_ptr_array_add (ret, g_build_filename (dir, ".debug", name, NULL));
|
||||
g_ptr_array_add (ret, g_build_filename (DEBUGDIR, dir, name, NULL));
|
||||
|
||||
G_UNLOCK (sp_symbol_dirs);
|
||||
G_UNLOCK (sysprof_symbol_dirs);
|
||||
|
||||
g_ptr_array_add (ret, NULL);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-symbol-dirs.h
|
||||
/* sysprof-symbol-dirs.h
|
||||
*
|
||||
* Copyright 2017-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -27,11 +27,11 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_symbol_dirs_add (const gchar *dir);
|
||||
void sysprof_symbol_dirs_add (const gchar *dir);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_symbol_dirs_remove (const gchar *dir);
|
||||
void sysprof_symbol_dirs_remove (const gchar *dir);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gchar **sp_symbol_dirs_get_paths (const gchar *dir,
|
||||
gchar **sysprof_symbol_dirs_get_paths (const gchar *dir,
|
||||
const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-symbol-resolver.c
|
||||
/* sysprof-symbol-resolver.c
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -20,15 +20,15 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-symbol-resolver.h"
|
||||
#include "sysprof-symbol-resolver.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpSymbolResolver, sp_symbol_resolver, G_TYPE_OBJECT)
|
||||
G_DEFINE_INTERFACE (SysprofSymbolResolver, sysprof_symbol_resolver, G_TYPE_OBJECT)
|
||||
|
||||
static gchar *
|
||||
sp_symbol_resolver_real_resolve (SpSymbolResolver *self,
|
||||
sysprof_symbol_resolver_real_resolve (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpCaptureAddress address,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag)
|
||||
{
|
||||
*tag = 0;
|
||||
@ -36,42 +36,42 @@ sp_symbol_resolver_real_resolve (SpSymbolResolver *self,
|
||||
}
|
||||
|
||||
static gchar *
|
||||
sp_symbol_resolver_real_resolve_with_context (SpSymbolResolver *self,
|
||||
sysprof_symbol_resolver_real_resolve_with_context (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpAddressContext context,
|
||||
SpCaptureAddress address,
|
||||
SysprofAddressContext context,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag)
|
||||
{
|
||||
*tag = 0;
|
||||
|
||||
if (SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
|
||||
return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
|
||||
if (SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
|
||||
return SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sp_symbol_resolver_default_init (SpSymbolResolverInterface *iface)
|
||||
sysprof_symbol_resolver_default_init (SysprofSymbolResolverInterface *iface)
|
||||
{
|
||||
iface->resolve = sp_symbol_resolver_real_resolve;
|
||||
iface->resolve_with_context = sp_symbol_resolver_real_resolve_with_context;
|
||||
iface->resolve = sysprof_symbol_resolver_real_resolve;
|
||||
iface->resolve_with_context = sysprof_symbol_resolver_real_resolve_with_context;
|
||||
}
|
||||
|
||||
void
|
||||
sp_symbol_resolver_load (SpSymbolResolver *self,
|
||||
SpCaptureReader *reader)
|
||||
sysprof_symbol_resolver_load (SysprofSymbolResolver *self,
|
||||
SysprofCaptureReader *reader)
|
||||
{
|
||||
g_return_if_fail (SP_IS_SYMBOL_RESOLVER (self));
|
||||
g_return_if_fail (SYSPROF_IS_SYMBOL_RESOLVER (self));
|
||||
g_return_if_fail (reader != NULL);
|
||||
|
||||
if (SP_SYMBOL_RESOLVER_GET_IFACE (self)->load)
|
||||
SP_SYMBOL_RESOLVER_GET_IFACE (self)->load (self, reader);
|
||||
if (SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->load)
|
||||
SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->load (self, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_symbol_resolver_resolve:
|
||||
* @self: A #SpSymbolResolver
|
||||
* sysprof_symbol_resolver_resolve:
|
||||
* @self: A #SysprofSymbolResolver
|
||||
* @time: The time of the sample
|
||||
* @pid: The process generating the sample
|
||||
* @address: the sample address
|
||||
@ -86,37 +86,37 @@ sp_symbol_resolver_load (SpSymbolResolver *self,
|
||||
* Returns: (nullable) (transfer full): A newly allocated string, or %NULL.
|
||||
*/
|
||||
gchar *
|
||||
sp_symbol_resolver_resolve (SpSymbolResolver *self,
|
||||
sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpCaptureAddress address,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag)
|
||||
{
|
||||
GQuark dummy;
|
||||
|
||||
g_return_val_if_fail (SP_IS_SYMBOL_RESOLVER (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_SYMBOL_RESOLVER (self), NULL);
|
||||
|
||||
if (tag == NULL)
|
||||
tag = &dummy;
|
||||
|
||||
*tag = 0;
|
||||
|
||||
if (SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
|
||||
return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
|
||||
if (SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
|
||||
return SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* sp_symbol_resolver_resolve_with_context:
|
||||
* @self: A #SpSymbolResolver
|
||||
* sysprof_symbol_resolver_resolve_with_context:
|
||||
* @self: A #SysprofSymbolResolver
|
||||
* @time: The time of the sample
|
||||
* @pid: The process generating the sample
|
||||
* @context: the address context
|
||||
* @address: the sample address
|
||||
* @tag: (out): A tag for the symbol.
|
||||
*
|
||||
* This function is like sp_symbol_resolver_resolve() but allows
|
||||
* This function is like sysprof_symbol_resolver_resolve() but allows
|
||||
* access to the address context, which might be necessary to
|
||||
* determine the difference between user space and kernel space
|
||||
* addresses.
|
||||
@ -124,21 +124,21 @@ sp_symbol_resolver_resolve (SpSymbolResolver *self,
|
||||
* Returns: (nullable) (transfer full): A newly allocated string, or %NULL.
|
||||
*/
|
||||
gchar *
|
||||
sp_symbol_resolver_resolve_with_context (SpSymbolResolver *self,
|
||||
sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpAddressContext context,
|
||||
SpCaptureAddress address,
|
||||
SysprofAddressContext context,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag)
|
||||
{
|
||||
GQuark dummy;
|
||||
|
||||
g_return_val_if_fail (SP_IS_SYMBOL_RESOLVER (self), NULL);
|
||||
g_return_val_if_fail (SYSPROF_IS_SYMBOL_RESOLVER (self), NULL);
|
||||
|
||||
if (tag == NULL)
|
||||
tag = &dummy;
|
||||
|
||||
*tag = 0;
|
||||
|
||||
return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve_with_context (self, time, pid, context, address, tag);
|
||||
return SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve_with_context (self, time, pid, context, address, tag);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/* sp-symbol-resolver.h
|
||||
/* sysprof-symbol-resolver.h
|
||||
*
|
||||
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
|
||||
*
|
||||
@ -22,46 +22,46 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "sp-address.h"
|
||||
#include "sp-capture-reader.h"
|
||||
#include "sysprof-address.h"
|
||||
#include "sysprof-capture-reader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_SYMBOL_RESOLVER (sp_symbol_resolver_get_type())
|
||||
#define SYSPROF_TYPE_SYMBOL_RESOLVER (sysprof_symbol_resolver_get_type())
|
||||
|
||||
G_DECLARE_INTERFACE (SpSymbolResolver, sp_symbol_resolver, SP, SYMBOL_RESOLVER, GObject)
|
||||
G_DECLARE_INTERFACE (SysprofSymbolResolver, sysprof_symbol_resolver, SYSPROF, SYMBOL_RESOLVER, GObject)
|
||||
|
||||
struct _SpSymbolResolverInterface
|
||||
struct _SysprofSymbolResolverInterface
|
||||
{
|
||||
GTypeInterface parent_interface;
|
||||
|
||||
void (*load) (SpSymbolResolver *self,
|
||||
SpCaptureReader *reader);
|
||||
gchar *(*resolve) (SpSymbolResolver *self,
|
||||
void (*load) (SysprofSymbolResolver *self,
|
||||
SysprofCaptureReader *reader);
|
||||
gchar *(*resolve) (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpCaptureAddress address,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag);
|
||||
gchar *(*resolve_with_context) (SpSymbolResolver *self,
|
||||
gchar *(*resolve_with_context) (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpAddressContext context,
|
||||
SpCaptureAddress address,
|
||||
SysprofAddressContext context,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag);
|
||||
};
|
||||
|
||||
void sp_symbol_resolver_load (SpSymbolResolver *self,
|
||||
SpCaptureReader *reader);
|
||||
gchar *sp_symbol_resolver_resolve (SpSymbolResolver *self,
|
||||
void sysprof_symbol_resolver_load (SysprofSymbolResolver *self,
|
||||
SysprofCaptureReader *reader);
|
||||
gchar *sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpCaptureAddress address,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag);
|
||||
gchar *sp_symbol_resolver_resolve_with_context (SpSymbolResolver *self,
|
||||
gchar *sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self,
|
||||
guint64 time,
|
||||
GPid pid,
|
||||
SpAddressContext context,
|
||||
SpCaptureAddress address,
|
||||
SysprofAddressContext context,
|
||||
SysprofCaptureAddress address,
|
||||
GQuark *tag);
|
||||
|
||||
G_END_DECLS
|
||||
@ -24,29 +24,29 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_INSIDE
|
||||
|
||||
# include "sp-callgraph-profile.h"
|
||||
# include "sp-capture-gobject.h"
|
||||
# include "sp-local-profiler.h"
|
||||
# include "sp-kallsyms.h"
|
||||
# include "sp-profile.h"
|
||||
# include "sp-profiler.h"
|
||||
# include "sp-map-lookaside.h"
|
||||
# include "sp-source.h"
|
||||
# include "sp-elf-symbol-resolver.h"
|
||||
# include "sp-jitmap-symbol-resolver.h"
|
||||
# include "sp-kernel-symbol-resolver.h"
|
||||
# include "sp-kernel-symbol.h"
|
||||
# include "sp-symbol-dirs.h"
|
||||
# include "sp-symbol-resolver.h"
|
||||
# include "sp-map-lookaside.h"
|
||||
# include "sp-selection.h"
|
||||
# include "sysprof-callgraph-profile.h"
|
||||
# include "sysprof-capture-gobject.h"
|
||||
# include "sysprof-local-profiler.h"
|
||||
# include "sysprof-kallsyms.h"
|
||||
# include "sysprof-profile.h"
|
||||
# include "sysprof-profiler.h"
|
||||
# include "sysprof-map-lookaside.h"
|
||||
# include "sysprof-source.h"
|
||||
# include "sysprof-elf-symbol-resolver.h"
|
||||
# include "sysprof-jitmap-symbol-resolver.h"
|
||||
# include "sysprof-kernel-symbol-resolver.h"
|
||||
# include "sysprof-kernel-symbol.h"
|
||||
# include "sysprof-symbol-dirs.h"
|
||||
# include "sysprof-symbol-resolver.h"
|
||||
# include "sysprof-map-lookaside.h"
|
||||
# include "sysprof-selection.h"
|
||||
|
||||
#ifdef __linux__
|
||||
# include "sp-gjs-source.h"
|
||||
# include "sp-hostinfo-source.h"
|
||||
# include "sp-memory-source.h"
|
||||
# include "sp-perf-source.h"
|
||||
# include "sp-proc-source.h"
|
||||
# include "sysprof-gjs-source.h"
|
||||
# include "sysprof-hostinfo-source.h"
|
||||
# include "sysprof-memory-source.h"
|
||||
# include "sysprof-perf-source.h"
|
||||
# include "sysprof-proc-source.h"
|
||||
#endif
|
||||
|
||||
#undef SYSPROF_INSIDE
|
||||
|
||||
Reference in New Issue
Block a user