How do I `perf probe -L ...` in NixOS

I have recently moved to NixOS and I am unable to get perf probe -L ... to work.

Eg.

janmejay@jdell:~ » perf --debug verbose probe -k /run/booted-system/kernel -s /home/janmejay/projects/linux -L 'syscall_user_dispatch'                     1 ↵
Use vmlinux: /run/booted-system/kernel
Problems creating module maps, continuing anyway...
symsrc__init: cannot get elf header.
Failed to find debuginfo in debuginfod.
Failed to find the path for the kernel: Invalid ELF file
  Error: Failed to show lines. Reason: No such file or directory (Code: -2)
janmejay@jdell:~ »                                                                                                                                       254 ↵

I have the debug-info enabled

  boot = {
    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };

    kernelPatches = [{
      name = "dev-config";
      patch = null;
      extraConfig = ''
          DEBUG_INFO y
          GDB_SCRIPTS y
          FUNCTION_ERROR_INJECTION y
          FAULT_INJECTION y
          FAULT_INJECTION_DEBUG_FS y
          FAIL_FUNCTION y
        '';
    }];
  };

I guess the kernel-binary is the same size it was before I enabled debug symbols, so it seems something stripped them away.

What is the right way of setting up the kernel with debug-symbols?

No luck without the path to vmlinux either

janmejay@jdell:~ » sudo perf --debug verbose probe -L 'syscall_user_dispatch'                                                                            254 ↵
maps__set_modules_path_dir: cannot open /lib/modules/6.6.44 dir
Problems setting modules path maps, continuing anyway...
Looking at the vmlinux_path (8 entries long)
symsrc__init: cannot get elf header.
Failed to find debuginfo in debuginfod.
Failed to find the path for the kernel: Invalid ELF file
  Error: Failed to show lines. Reason: No such file or directory (Code: -2)
janmejay@jdell:~ »                                                                                                                                       254 ↵

Nothing else I can think of works either. Have tried copying over the bzImage and extract-vmlinux etc without any luck.

Have you ensured that perf is from the same linuxPackages whose kernel is currently booted?

@Atemu yes, I use

  environment.systemPackages = with pkgs; [
    ...
    config.boot.kernelPackages.perf
  ];

to pull them in here: nixos.d/nixos/common-configuration.nix at fc60eb81f1dac6f8ed7e135e0cf0978b51da3616 · janmejay/nixos.d · GitHub

2 Likes