From d2a38bf1a6de7e50cbddc77c7f9c32909641287c Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 9 Jun 2023 15:58:57 -0700 Subject: [PATCH] libsysprof-analyze: introduce [Unwindable] callgraph node This interjects a node for unwindable traces so that cost gets accounted to the process, but is not just at the [process] graph item as that makes it very hard to subtract to figure out what it was. Instead just insert an [Unwindable] node and cost-account to that. --- src/libsysprof-analyze/sysprof-callgraph.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-callgraph.c b/src/libsysprof-analyze/sysprof-callgraph.c index 4a8b30a0..b6d97921 100644 --- a/src/libsysprof-analyze/sysprof-callgraph.c +++ b/src/libsysprof-analyze/sysprof-callgraph.c @@ -84,6 +84,7 @@ G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofCallgraph, sysprof_callgraph, G_TYPE_OBJEC G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init)) static SysprofSymbol *everything; +static SysprofSymbol *untraceable; static void sysprof_callgraph_summary_free_all (SysprofCallgraphSummary *summary) @@ -182,6 +183,7 @@ sysprof_callgraph_class_init (SysprofCallgraphClass *klass) object_class->finalize = sysprof_callgraph_finalize; everything = _sysprof_symbol_new (g_ref_string_new_intern ("[Everything]"), NULL, NULL, 0, 0); + untraceable = _sysprof_symbol_new (g_ref_string_new_intern ("[Unwindable]"), NULL, NULL, 0, 0); } static void @@ -308,6 +310,18 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self, g_assert (n_symbols <= stack_depth); + /* Sometimes we get a very unhelpful unwind from the capture + * which is basically a single frame of "user space context". + * That means we got no amount of the stack, but we should + * really account costs to something in the application other + * than the [Application] entry itself so that it's more clear + * that it was a corrupted unwind when recording. + */ + if (n_symbols == 1 && + symbols[0]->is_context_switch && + final_context == SYSPROF_ADDRESS_CONTEXT_USER) + symbols[0] = untraceable; + /* We saved 3 extra spaces for these above so that we can * tack on the "Process" symbol and the "Everything" symbol. * If the final address context places us in Kernel, we want