mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-profile: add augmentation phase to instruments
This allows an instrument to augment the capture with additional information before the capture is closed/flushed to storage.
This commit is contained in:
@ -44,6 +44,8 @@ struct _SysprofInstrumentClass
|
|||||||
DexFuture *(*record) (SysprofInstrument *self,
|
DexFuture *(*record) (SysprofInstrument *self,
|
||||||
SysprofRecording *recording,
|
SysprofRecording *recording,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable);
|
||||||
|
DexFuture *(*augment) (SysprofInstrument *self,
|
||||||
|
SysprofRecording *recording);
|
||||||
DexFuture *(*process_started) (SysprofInstrument *self,
|
DexFuture *(*process_started) (SysprofInstrument *self,
|
||||||
SysprofRecording *recording,
|
SysprofRecording *recording,
|
||||||
int pid);
|
int pid);
|
||||||
@ -56,6 +58,8 @@ DexFuture *_sysprof_instruments_prepare (GPtrArray *instruments,
|
|||||||
DexFuture *_sysprof_instruments_record (GPtrArray *instruments,
|
DexFuture *_sysprof_instruments_record (GPtrArray *instruments,
|
||||||
SysprofRecording *recording,
|
SysprofRecording *recording,
|
||||||
GCancellable *cancellable);
|
GCancellable *cancellable);
|
||||||
|
DexFuture *_sysprof_instruments_augment (GPtrArray *instruments,
|
||||||
|
SysprofRecording *recording);
|
||||||
DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments,
|
DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments,
|
||||||
SysprofRecording *recording,
|
SysprofRecording *recording,
|
||||||
int pid);
|
int pid);
|
||||||
|
|||||||
@ -256,6 +256,30 @@ _sysprof_instruments_record (GPtrArray *instruments,
|
|||||||
return dex_future_allv ((DexFuture **)futures->pdata, futures->len);
|
return dex_future_allv ((DexFuture **)futures->pdata, futures->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DexFuture *
|
||||||
|
_sysprof_instruments_augment (GPtrArray *instruments,
|
||||||
|
SysprofRecording *recording)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
g_ptr_array_add (futures, _sysprof_instrument_augment (instrument, recording));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (futures->len == 0)
|
||||||
|
return dex_future_new_for_boolean (TRUE);
|
||||||
|
|
||||||
|
return dex_future_allv ((DexFuture **)futures->pdata, futures->len);
|
||||||
|
}
|
||||||
|
|
||||||
DexFuture *
|
DexFuture *
|
||||||
_sysprof_instruments_process_started (GPtrArray *instruments,
|
_sysprof_instruments_process_started (GPtrArray *instruments,
|
||||||
SysprofRecording *recording,
|
SysprofRecording *recording,
|
||||||
|
|||||||
@ -76,6 +76,7 @@ sysprof_recording_fiber (gpointer user_data)
|
|||||||
g_autoptr(DexFuture) record = NULL;
|
g_autoptr(DexFuture) record = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
gint64 begin_time;
|
gint64 begin_time;
|
||||||
|
gint64 end_time;
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_RECORDING (self));
|
g_assert (SYSPROF_IS_RECORDING (self));
|
||||||
|
|
||||||
@ -128,13 +129,21 @@ sysprof_recording_fiber (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop_recording:
|
stop_recording:
|
||||||
|
end_time = SYSPROF_CAPTURE_CURRENT_TIME;
|
||||||
|
|
||||||
/* Signal cancellable so that anything lingering has a chance to be
|
/* Signal cancellable so that anything lingering has a chance to be
|
||||||
* cleaned up, cascading into other subsystems.
|
* cleaned up, cascading into other subsystems.
|
||||||
*/
|
*/
|
||||||
g_cancellable_cancel (cancellable);
|
g_cancellable_cancel (cancellable);
|
||||||
|
|
||||||
|
/* Let instruments augment the capture. Some instruments may include
|
||||||
|
* extra information about the capture such as symbol names and their
|
||||||
|
* address ranges per-process.
|
||||||
|
*/
|
||||||
|
dex_await (_sysprof_instruments_augment (self->instruments, self), NULL);
|
||||||
|
|
||||||
/* Update start/end times to be the "running time" */
|
/* Update start/end times to be the "running time" */
|
||||||
_sysprof_capture_writer_set_time_range (self->writer, begin_time, SYSPROF_CAPTURE_CURRENT_TIME);
|
_sysprof_capture_writer_set_time_range (self->writer, begin_time, end_time);
|
||||||
|
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||||
|
|||||||
Reference in New Issue
Block a user