From 643a54168be3e7690cb09ca39c95b88fed5f2fd0 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 8 Aug 2025 00:49:11 +0900 Subject: [PATCH] test/interactive: helper scripts for tracing The vm state is discarded often, and it is quite cumbersome to set everything up again when the shell history is gone. Signed-off-by: Ophestra --- test/interactive/trace.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/interactive/trace.nix diff --git a/test/interactive/trace.nix b/test/interactive/trace.nix new file mode 100644 index 0000000..f055e0b --- /dev/null +++ b/test/interactive/trace.nix @@ -0,0 +1,28 @@ +{ lib, pkgs, ... }: +let + tracing = name: "\"/sys/kernel/debug/tracing/${name}\""; +in +{ + environment.systemPackages = [ + (pkgs.writeShellScriptBin "hakurei-set-up-tracing" '' + set -e + echo "$1" > ${tracing "set_graph_function"} + echo function_graph > ${tracing "current_tracer"} + echo funcgraph-tail > ${tracing "trace_options"} + echo funcgraph-retval > ${tracing "trace_options"} + echo nofuncgraph-cpu > ${tracing "trace_options"} + echo nofuncgraph-overhead > ${tracing "trace_options"} + echo nofuncgraph-duration > ${tracing "trace_options"} + '') + (pkgs.writeShellScriptBin "hakurei-print-trace" "exec cat ${tracing "trace"}") + (pkgs.writeShellScriptBin "hakurei-consume-trace" "exec cat ${tracing "trace_pipe"}") + ]; + + boot.kernelPatches = [ + { + name = "funcgraph-retval"; + patch = null; + extraStructuredConfig.FUNCTION_GRAPH_RETVAL = lib.kernel.yes; + } + ]; +}