From f79a3c6d2e9c318721685be2f2d310786d26e2e8 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 25 May 2023 11:13:10 -0700 Subject: [PATCH] libsysprof-context: skip context switches at head of trace We can get stack traces which have a USER at the end, or KERNEL at the end, and nothing after it. Not really useful to us. --- src/libsysprof-analyze/sysprof-callgraph.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-callgraph.c b/src/libsysprof-analyze/sysprof-callgraph.c index 9280fab9..9d711d01 100644 --- a/src/libsysprof-analyze/sysprof-callgraph.c +++ b/src/libsysprof-analyze/sysprof-callgraph.c @@ -158,6 +158,16 @@ sysprof_callgraph_add_trace (SysprofCallgraph *self, parent = &self->root; + /* If the first thing we see is a context switch, then there is + * nothing after it to account for. Just skip the symbol as it + * provides nothing to us in the callgraph. + */ + if (_sysprof_symbol_is_context_switch (symbols[0])) + { + symbols++; + n_symbols--; + } + for (guint i = n_symbols - 1; i > 0; i--) { SysprofSymbol *symbol = symbols[i-1];