mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-profile: add API to notify of process started
This will be used when we discover a process started like when the Perf instrument gets PERF_RECORD_COMM.
This commit is contained in:
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user