From 202129e3b57821f0162fde491e5982a091618c9d Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Mon, 3 Feb 2025 22:25:45 +0530 Subject: [PATCH] sysprof: Enable debuginfod option in tests Signed-off-by: varun-r-mallya --- src/libsysprof/tests/test-profiler.c | 5 ----- src/libsysprof/tests/test-symbolize.c | 16 +++++++++++++++- src/sysprof/sysprof-greeter.ui | 2 +- src/sysprof/sysprof-recording-template.c | 3 --- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libsysprof/tests/test-profiler.c b/src/libsysprof/tests/test-profiler.c index 78056488..a07927f7 100644 --- a/src/libsysprof/tests/test-profiler.c +++ b/src/libsysprof/tests/test-profiler.c @@ -32,7 +32,6 @@ static gboolean memprof; static gboolean tracer; static gboolean gnome_shell; static gboolean bundle_symbols; -// static gboolean debuginfod; static gboolean session_bus; static gboolean system_bus; static gboolean gjs; @@ -47,7 +46,6 @@ static const GOptionEntry entries[] = { { "session-bus", 0, 0, G_OPTION_ARG_NONE, &session_bus, "Record D-Bus messages on the session bus" }, { "system-bus", 0, 0, G_OPTION_ARG_NONE, &system_bus, "Record D-Bus messages on the system bus" }, { "bundle-symbols", 'b', 0, G_OPTION_ARG_STRING, &bundle_symbols, "Bundle symbols with the capture" }, - // { "debuginfod", 'b', 0, G_OPTION_ARG_STRING, &debuginfod, "Enable debuginfod" }, { 0 } }; @@ -194,9 +192,6 @@ main (int argc, if (bundle_symbols) sysprof_profiler_add_instrument (profiler, sysprof_symbols_bundle_new ()); - // if (debuginfod) /*TODO: this function has not been created anywhere yet*/ - // sysprof_profiler_add_instrument (profiler, sysprof_debuginfod_new()); - if (power_profile) sysprof_profiler_add_instrument (profiler, sysprof_power_profile_new (power_profile)); diff --git a/src/libsysprof/tests/test-symbolize.c b/src/libsysprof/tests/test-symbolize.c index d3fdd2c2..892a1f9a 100644 --- a/src/libsysprof/tests/test-symbolize.c +++ b/src/libsysprof/tests/test-symbolize.c @@ -7,6 +7,7 @@ static GMainLoop *main_loop; static gboolean silent; static gboolean no_bundled; +static gboolean debuginfod; static char **debug_dirs; static char *kallsyms_path; static const GOptionEntry entries[] = { @@ -14,10 +15,10 @@ static const GOptionEntry entries[] = { { "silent", 's', 0, G_OPTION_ARG_NONE, &silent, "Do not print symbol information" }, { "debug-dir", 'd', 0, G_OPTION_ARG_FILENAME_ARRAY, &debug_dirs, "Specify external debug directory, may be repeated" }, { "kallsyms", 'k', 0, G_OPTION_ARG_FILENAME, &kallsyms_path, "Specify path to kallsyms for kernel symbolizing" }, + { "debuginfod", 'D', 0, G_OPTION_ARG_NONE, &debuginfod, "Use debuginfod for automatically fetching debug symbols" }, { 0 } }; - static void load_cb (GObject *object, GAsyncResult *result, @@ -163,6 +164,19 @@ main (int argc, sysprof_multi_symbolizer_take (multi, elf); sysprof_multi_symbolizer_take (multi, sysprof_jitmap_symbolizer_new ()); +#if HAVE_DEBUGINFOD + if (debuginfod) + { + g_autoptr(SysprofSymbolizer) debuginfod_symbolizer = NULL; + g_autoptr(GError) debuginfod_error = NULL; + + if (!(debuginfod_symbolizer = sysprof_debuginfod_symbolizer_new (&debuginfod_error))) + g_warning ("Failed to create debuginfod symbolizer: %s", debuginfod_error->message); + else + sysprof_multi_symbolizer_take (multi, g_steal_pointer (&debuginfod_symbolizer)); + } +#endif + sysprof_document_loader_set_symbolizer (loader, SYSPROF_SYMBOLIZER (multi)); } diff --git a/src/sysprof/sysprof-greeter.ui b/src/sysprof/sysprof-greeter.ui index b6f56017..e69e2658 100644 --- a/src/sysprof/sysprof-greeter.ui +++ b/src/sysprof/sysprof-greeter.ui @@ -625,7 +625,7 @@ debuginfod Debuginfod - Enable Debuginfod + Enable Debuginfod to automatically fetch debug symbols diff --git a/src/sysprof/sysprof-recording-template.c b/src/sysprof/sysprof-recording-template.c index 4de647c2..d41040a4 100644 --- a/src/sysprof/sysprof-recording-template.c +++ b/src/sysprof/sysprof-recording-template.c @@ -625,9 +625,6 @@ sysprof_recording_template_apply (SysprofRecordingTemplate *self, if (self->bundle_symbols) sysprof_profiler_add_instrument (profiler, sysprof_symbols_bundle_new ()); - // if (self->debuginfod) /*TODO: This just uses an a preexisting function.*/ - // sysprof_profiler_add_instrument (profiler, this_should_be_a_handler_function()); - if (self->cpu_usage) sysprof_profiler_add_instrument (profiler, sysprof_cpu_usage_new ());