Help fixing debug-info source-code paths

I’m wondering if anyone can help me with a problem I’m having with trying to get correct debug-info source code paths when running pluginval

It’s a cmake-built tool that you use to debug audio plugins. I’d like to build it with debug info - including the source files - so that I can run it though LLDB/GDB and see the source code that is being used to test my plugin.

This is what I have in my nix flake to build it:

        pluginval = pkgs.stdenv.mkDerivation rec {
          pname = "pluginval";
          version = "1.0.3";

          src = pkgs.fetchFromGitHub {
            owner = "Tracktion";
            repo = "pluginval";
            rev = "v${version}";
            hash = "sha256-o253DBl3jHumaKzxHDZXK/MpFMrq06MmBia9HEYLtXs=";
            fetchSubmodules = true;
          };

          dontStrip = true;
          cmakeBuildType = "Debug";

          nativeBuildInputs = [
            pkgs.cmake
            pkgs.pkg-config
          ];

          buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux [
            pkgs.xorg.libX11
            pkgs.xorg.libXrandr
            pkgs.xorg.libXcursor
            pkgs.xorg.libXinerama
            pkgs.xorg.libXext
            pkgs.freetype
            pkgs.alsa-lib
            pkgs.curl
            pkgs.gtk3-x11
            pkgs.ladspa-sdk
          ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
            pkgs.darwin.apple_sdk.frameworks.CoreAudio
            pkgs.darwin.apple_sdk.frameworks.CoreMIDI
            pkgs.darwin.apple_sdk.frameworks.CoreFoundation
            pkgs.darwin.apple_sdk.frameworks.Cocoa
            pkgs.darwin.apple_sdk.frameworks.WebKit
            pkgs.darwin.apple_sdk.frameworks.MetalKit
            pkgs.darwin.apple_sdk.frameworks.Accelerate
            pkgs.darwin.apple_sdk.frameworks.CoreAudioKit
            pkgs.darwin.apple_sdk.frameworks.DiscRecording
          ];

          installPhase = ''
            mkdir -p $out/bin
          '' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
            cp $(find . -name "pluginval" -executable) $out/bin
          '' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
            mkdir -p $out/Applications
            cp -R $(find . -type d -name "pluginval.app") $out/Applications
            ln -s $out/Applications/pluginval.app/Contents/MacOS/pluginval $out/bin
          '';
        };

The binary file works great and it contains some good debug info but it’s missing some things.

  1. How do I retain the source code files (.h, .cpp, etc) along with the final binary files so that GDB/LLDB can find them?
  2. And how do I fix the debug info paths? If I run gdb pluginval and then info sources it prints out where it thinks the source files are. It shows paths like /build/source/Source/CommandLine.cpp which is clearly wrong and GDB can find no such file - I’d expect a full path starting with /nix/store.