From f7118874cfac04b8febf38ee9b073b6d46cc3f08 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sun, 3 Nov 2024 10:54:57 -0800 Subject: [PATCH 18/31] sysprof-cli: add support for live unwinding This allows you to specify --stack-size=(multiple_of_page_size) to unwind from captured stack contents. It will use the new SysprofUserSampler to unwind stack traces via sysprof-live-unwinder. --- src/sysprof-cli/sysprof-cli.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sysprof-cli/sysprof-cli.c b/src/sysprof-cli/sysprof-cli.c index e00bd6b1..1c9ce928 100644 --- a/src/sysprof-cli/sysprof-cli.c +++ b/src/sysprof-cli/sysprof-cli.c @@ -303,6 +303,7 @@ main (int argc, gboolean scheduler_details = FALSE; gboolean system_bus = FALSE; gboolean session_bus = FALSE; + int stack_size = 0; int pid = -1; int fd; int flags; @@ -335,6 +336,7 @@ main (int argc, { "version", 0, 0, G_OPTION_ARG_NONE, &version, N_("Print the sysprof-cli version and exit") }, { "buffer-size", 0, 0, G_OPTION_ARG_INT, &n_buffer_pages, N_("The size of the buffer in pages (1 = 1 page)") }, { "monitor-bus", 0, 0, G_OPTION_ARG_STRING_ARRAY, &monitor_bus, N_("Additional D-Bus address to monitor") }, + { "stack-size", 0, 0, G_OPTION_ARG_INT, &stack_size, N_("Stack size to copy for unwinding in user-space") }, { NULL } }; @@ -379,6 +381,10 @@ Examples:\n\ \n\ # Merge multiple syscap files into one\n\ sysprof-cli --merge a.syscap b.syscap > c.syscap\n\ +\n\ + # Unwind by capturing stack/register contents instead of frame-pointers\n\ + # where the stack-size is a multiple of page-size\n\ + sysprof-cli --stack-size=8192\n\ ")); if (!g_option_context_parse (context, &argc, &argv, &error)) @@ -533,7 +539,12 @@ Examples:\n\ sysprof_profiler_add_instrument (profiler, sysprof_system_logs_new ()); if (!no_perf) - sysprof_profiler_add_instrument (profiler, sysprof_sampler_new ()); + { + if (stack_size == 0) + sysprof_profiler_add_instrument (profiler, sysprof_sampler_new ()); + else + sysprof_profiler_add_instrument (profiler, sysprof_user_sampler_new (stack_size)); + } if (!no_disk) sysprof_profiler_add_instrument (profiler, sysprof_disk_usage_new ()); -- 2.45.2