aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/interactive/trace.nix
blob: e307361f9890f2571b6b7558b149d2b63d3e6027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
      structuredExtraConfig.FUNCTION_GRAPH_RETVAL = lib.kernel.yes;
    }
  ];
}