From 1897e8bfd345c6816359ecd644ffaf0de17acb23 Mon Sep 17 00:00:00 2001 From: bluhm Date: Mon, 28 Jun 2021 08:55:06 +0000 Subject: [PATCH] Also show the time spent in userland when analyzing the kernel stack in flame graph. Only when both kernel and userland are displayed, the whole picture of system activity becomes clear. Fixes a parsing bug in the flame graph tool where userland time was interpreted as invalid kernel stack. OK kn@ --- usr.sbin/btrace/btrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 961500a3a68..75966f836a4 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.37 2021/06/23 11:24:01 dv Exp $ */ +/* $OpenBSD: btrace.c,v 1.38 2021/06/28 08:55:06 bluhm Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot @@ -638,8 +638,10 @@ builtin_stack(struct dt_evt *dtev, int kernel) size_t i; int sz; - if (!kernel || st->st_count == 0) + if (!kernel) return ""; + if (st->st_count == 0) + return "\nuserland\n"; buf[0] = '\0'; bp = buf; @@ -658,7 +660,7 @@ builtin_stack(struct dt_evt *dtev, int kernel) bp += l; sz -= l; } - snprintf(bp, sz, "\n"); + snprintf(bp, sz, "\nkernel\n"); return buf; } -- 2.20.1