mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-profile: give access to GSubprocess
This is needed to be able to proxy exit/signal information via sysprof-agent.
This commit is contained in:
@ -77,6 +77,9 @@ struct _SysprofRecording
|
|||||||
* from outside of the fiber.
|
* from outside of the fiber.
|
||||||
*/
|
*/
|
||||||
DexChannel *channel;
|
DexChannel *channel;
|
||||||
|
|
||||||
|
/* The process we have spawned, if any */
|
||||||
|
GSubprocess *subprocess;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -91,18 +94,18 @@ G_DEFINE_FINAL_TYPE (SysprofRecording, sysprof_recording, G_TYPE_OBJECT)
|
|||||||
static GParamSpec *properties[N_PROPS];
|
static GParamSpec *properties[N_PROPS];
|
||||||
|
|
||||||
static DexFuture *
|
static DexFuture *
|
||||||
_sysprof_recording_spawn (SysprofSpawnable *spawnable)
|
_sysprof_recording_spawn (SysprofSpawnable *spawnable,
|
||||||
|
GSubprocess **subprocess)
|
||||||
{
|
{
|
||||||
g_autoptr(GSubprocess) subprocess = NULL;
|
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
DexFuture *ret;
|
DexFuture *ret;
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_SPAWNABLE (spawnable));
|
g_assert (SYSPROF_IS_SPAWNABLE (spawnable));
|
||||||
|
|
||||||
if (!(subprocess = sysprof_spawnable_spawn (spawnable, &error)))
|
if (!(*subprocess = sysprof_spawnable_spawn (spawnable, &error)))
|
||||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||||
|
|
||||||
ret = dex_subprocess_wait_check (subprocess);
|
ret = dex_subprocess_wait_check (*subprocess);
|
||||||
dex_async_pair_set_cancel_on_discard (DEX_ASYNC_PAIR (ret), FALSE);
|
dex_async_pair_set_cancel_on_discard (DEX_ASYNC_PAIR (ret), FALSE);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -180,9 +183,11 @@ sysprof_recording_fiber (gpointer user_data)
|
|||||||
/* Now take our begin time now that all instruments are notified */
|
/* Now take our begin time now that all instruments are notified */
|
||||||
begin_time = SYSPROF_CAPTURE_CURRENT_TIME;
|
begin_time = SYSPROF_CAPTURE_CURRENT_TIME;
|
||||||
|
|
||||||
|
g_assert (self->subprocess == NULL);
|
||||||
|
|
||||||
/* If we need to spawn a subprocess, do it now */
|
/* If we need to spawn a subprocess, do it now */
|
||||||
if (self->spawnable != NULL)
|
if (self->spawnable != NULL)
|
||||||
monitor = _sysprof_recording_spawn (self->spawnable);
|
monitor = _sysprof_recording_spawn (self->spawnable, &self->subprocess);
|
||||||
else
|
else
|
||||||
monitor = dex_future_new_infinite ();
|
monitor = dex_future_new_infinite ();
|
||||||
|
|
||||||
@ -388,6 +393,7 @@ sysprof_recording_finalize (GObject *object)
|
|||||||
g_clear_pointer (&self->instruments, g_ptr_array_unref);
|
g_clear_pointer (&self->instruments, g_ptr_array_unref);
|
||||||
g_clear_object (&self->spawnable);
|
g_clear_object (&self->spawnable);
|
||||||
g_clear_object (&self->diagnostics);
|
g_clear_object (&self->diagnostics);
|
||||||
|
g_clear_object (&self->subprocess);
|
||||||
dex_clear (&self->fiber);
|
dex_clear (&self->fiber);
|
||||||
|
|
||||||
G_OBJECT_CLASS (sysprof_recording_parent_class)->finalize (object);
|
G_OBJECT_CLASS (sysprof_recording_parent_class)->finalize (object);
|
||||||
@ -880,3 +886,19 @@ sysprof_recording_dup_fd (SysprofRecording *self)
|
|||||||
|
|
||||||
return _sysprof_capture_writer_dup_fd (self->writer);
|
return _sysprof_capture_writer_dup_fd (self->writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_recording_get_subprocess:
|
||||||
|
* @self: a #SysprofRecording
|
||||||
|
*
|
||||||
|
* Gets the #GSubprocess if one was spawned.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (nullable): a #GSubprocess or %NULL
|
||||||
|
*/
|
||||||
|
GSubprocess *
|
||||||
|
sysprof_recording_get_subprocess (SysprofRecording *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_RECORDING (self), NULL);
|
||||||
|
|
||||||
|
return self->subprocess;
|
||||||
|
}
|
||||||
|
|||||||
@ -38,6 +38,8 @@ gint64 sysprof_recording_get_duration (SysprofRecording *
|
|||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
gint64 sysprof_recording_get_event_count (SysprofRecording *self);
|
gint64 sysprof_recording_get_event_count (SysprofRecording *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GSubprocess *sysprof_recording_get_subprocess (SysprofRecording *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
void sysprof_recording_wait_async (SysprofRecording *self,
|
void sysprof_recording_wait_async (SysprofRecording *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
|
|||||||
Reference in New Issue
Block a user