From a9f149ec3deb1abf5665239c427f1af2c3ab03c2 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 13 Jun 2023 11:42:48 -0700 Subject: [PATCH] libsysprof-profile: add diagnostics for perf event open failure --- src/libsysprof-profile/sysprof-sampler.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libsysprof-profile/sysprof-sampler.c b/src/libsysprof-profile/sysprof-sampler.c index bd66c079..4c2ac1e4 100644 --- a/src/libsysprof-profile/sysprof-sampler.c +++ b/src/libsysprof-profile/sysprof-sampler.c @@ -293,7 +293,28 @@ sysprof_sampler_prepare_fiber (gpointer user_data) (GDestroyNotify)sysprof_capture_writer_unref)); if (!dex_await (dex_future_allv ((DexFuture **)futures->pdata, futures->len), &error)) - return dex_future_new_for_error (g_steal_pointer (&error)); + { + guint failed = 0; + + for (guint i = 0; i < futures->len; i++) + { + DexFuture *future = g_ptr_array_index (futures, i); + + if (dex_future_get_status (future) == DEX_FUTURE_STATUS_REJECTED) + { + g_autoptr(GError) future_error = NULL; + dex_future_get_value (future, &future_error); + _sysprof_recording_diagnostic (prepare->recording, + "Sampler", + "Failed to load Perf event stream for CPU %d: %s", + i, future_error->message); + failed++; + } + } + + if (failed == futures->len) + return dex_future_new_for_error (g_steal_pointer (&error)); + } /* Save each of the streams (currently corked), so that we can * uncork them while recording. We already checked that all the