diff --git a/src/libsysprof-profile/sysprof-instrument-private.h b/src/libsysprof-profile/sysprof-instrument-private.h index f8a4d9df..9474ab9c 100644 --- a/src/libsysprof-profile/sysprof-instrument-private.h +++ b/src/libsysprof-profile/sysprof-instrument-private.h @@ -44,6 +44,8 @@ struct _SysprofInstrumentClass DexFuture *(*record) (SysprofInstrument *self, SysprofRecording *recording, GCancellable *cancellable); + DexFuture *(*augment) (SysprofInstrument *self, + SysprofRecording *recording); DexFuture *(*process_started) (SysprofInstrument *self, SysprofRecording *recording, int pid); @@ -56,6 +58,8 @@ DexFuture *_sysprof_instruments_prepare (GPtrArray *instruments, DexFuture *_sysprof_instruments_record (GPtrArray *instruments, SysprofRecording *recording, GCancellable *cancellable); +DexFuture *_sysprof_instruments_augment (GPtrArray *instruments, + SysprofRecording *recording); DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments, SysprofRecording *recording, int pid); diff --git a/src/libsysprof-profile/sysprof-instrument.c b/src/libsysprof-profile/sysprof-instrument.c index 790efa94..9c0b33a1 100644 --- a/src/libsysprof-profile/sysprof-instrument.c +++ b/src/libsysprof-profile/sysprof-instrument.c @@ -256,6 +256,30 @@ _sysprof_instruments_record (GPtrArray *instruments, 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 * _sysprof_instruments_process_started (GPtrArray *instruments, SysprofRecording *recording, diff --git a/src/libsysprof-profile/sysprof-recording.c b/src/libsysprof-profile/sysprof-recording.c index bfbec64f..8ed6a816 100644 --- a/src/libsysprof-profile/sysprof-recording.c +++ b/src/libsysprof-profile/sysprof-recording.c @@ -76,6 +76,7 @@ sysprof_recording_fiber (gpointer user_data) g_autoptr(DexFuture) record = NULL; g_autoptr(GError) error = NULL; gint64 begin_time; + gint64 end_time; g_assert (SYSPROF_IS_RECORDING (self)); @@ -128,13 +129,21 @@ sysprof_recording_fiber (gpointer user_data) } stop_recording: + end_time = SYSPROF_CAPTURE_CURRENT_TIME; + /* Signal cancellable so that anything lingering has a chance to be * cleaned up, cascading into other subsystems. */ 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" */ - _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) return dex_future_new_for_error (g_steal_pointer (&error));