diff --git a/src/libsysprof-profile/sysprof-instrument-private.h b/src/libsysprof-profile/sysprof-instrument-private.h index b5ceb73c..f8a4d9df 100644 --- a/src/libsysprof-profile/sysprof-instrument-private.h +++ b/src/libsysprof-profile/sysprof-instrument-private.h @@ -44,14 +44,20 @@ struct _SysprofInstrumentClass DexFuture *(*record) (SysprofInstrument *self, SysprofRecording *recording, GCancellable *cancellable); + DexFuture *(*process_started) (SysprofInstrument *self, + SysprofRecording *recording, + int pid); }; -DexFuture *_sysprof_instruments_acquire_policy (GPtrArray *instruments, - SysprofRecording *recording); -DexFuture *_sysprof_instruments_prepare (GPtrArray *instruments, - SysprofRecording *recording); -DexFuture *_sysprof_instruments_record (GPtrArray *instruments, - SysprofRecording *recording, - GCancellable *cancellable); +DexFuture *_sysprof_instruments_acquire_policy (GPtrArray *instruments, + SysprofRecording *recording); +DexFuture *_sysprof_instruments_prepare (GPtrArray *instruments, + SysprofRecording *recording); +DexFuture *_sysprof_instruments_record (GPtrArray *instruments, + SysprofRecording *recording, + GCancellable *cancellable); +DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments, + SysprofRecording *recording, + int pid); G_END_DECLS diff --git a/src/libsysprof-profile/sysprof-instrument.c b/src/libsysprof-profile/sysprof-instrument.c index 242f8bf3..37eba55d 100644 --- a/src/libsysprof-profile/sysprof-instrument.c +++ b/src/libsysprof-profile/sysprof-instrument.c @@ -174,6 +174,7 @@ _sysprof_instruments_record (GPtrArray *instruments, g_return_val_if_fail (instruments != NULL, NULL); g_return_val_if_fail (SYSPROF_IS_RECORDING (recording), NULL); + g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), NULL); futures = g_ptr_array_new_with_free_func (dex_unref); @@ -190,3 +191,32 @@ _sysprof_instruments_record (GPtrArray *instruments, return dex_future_allv ((DexFuture **)futures->pdata, futures->len); } + +DexFuture * +_sysprof_instruments_process_started (GPtrArray *instruments, + SysprofRecording *recording, + int pid) +{ + g_autoptr(GPtrArray) futures = NULL; + + g_return_val_if_fail (instruments != NULL, NULL); + g_return_val_if_fail (SYSPROF_IS_RECORDING (recording), NULL); + + futures = g_ptr_array_new_with_free_func (dex_unref); + + for (guint i = 0; i < instruments->len; i++) + { + SysprofInstrument *instrument = g_ptr_array_index (instruments, i); + + if (SYSPROF_INSTRUMENT_GET_CLASS (instruments)->process_started == NULL) + continue; + + g_ptr_array_add (futures, + SYSPROF_INSTRUMENT_GET_CLASS (instrument)->process_started (instrument, recording, pid)); + } + + if (futures->len == 0) + return dex_future_new_for_boolean (TRUE); + + return dex_future_allv ((DexFuture **)futures->pdata, futures->len); +}