mtrace: init at 2.33-50

`mtrace(1)` is a small Perl script that interprets and provides
human-readable output for `malloc(3)` traces.

Even though this is actually part of `glibc` itself I decided to place
this into its own package. The main reason for this is that this script
has a runtime dependency on Perl which would complicate `stdenv`
bootstrapping since we'd have to compile another Perl that doesn't depend on
the bootstrap tools that is used as runtime dependency for the
stage2 glibc.

Since this is only a dev/debugging tool, splitting this up seemed like a
reasonable choice to me.

On a leaking C program, this can be used like this:

$ env MALLOC_TRACE=$(pwd)/trace ./a.out
$ ./result/bin/mtrace ./trace

Memory not freed:
-----------------
Address Size Caller
0x0000000001875690 0x4 at 0x401151

Closes #141924

+41 -1
+1 -1
pkgs/development/libraries/glibc/common.nix
··· 198 198 BASH_SHELL = "/bin/sh"; 199 199 200 200 # Used by libgcc, elf-header, and others to determine ABI 201 - passthru = { inherit version; }; 201 + passthru = { inherit version; minorRelease = version; }; 202 202 } 203 203 204 204 // (removeAttrs args [ "withLinuxHeaders" "withGd" ]) //
+38
pkgs/development/libraries/glibc/mtrace.nix
··· 1 + { glibc, perl }: 2 + 3 + # Small wrapper which only exposes `mtrace(3)` from `glibc`. This can't be placed 4 + # into `glibc` itself because it depends on Perl which would mean that the final 5 + # `glibc` inside a stdenv bootstrap has a dependency `glibc -> perl -> bootstrap tools`, 6 + # so this is now in its own package that isn't used for bootstrapping. 7 + # 8 + # `glibc` needs to be overridden here because it's still needed to `./configure` the source in order 9 + # to have a build environment where we can call the needed make target. 10 + 11 + glibc.overrideAttrs ({ meta ? {}, ... }: { 12 + pname = "glibc-mtrace"; 13 + 14 + buildPhase = '' 15 + runHook preBuild 16 + 17 + mkdir malloc 18 + make -C ../glibc-${glibc.minorRelease}/malloc objdir=`pwd` `pwd`/malloc/mtrace; 19 + 20 + runHook postBuild 21 + ''; 22 + 23 + installPhase = '' 24 + mkdir -p $out/bin 25 + mv malloc/mtrace $out/bin/ 26 + ''; 27 + 28 + # Perl interpreter used for `mtrace`. 29 + buildInputs = [ perl ]; 30 + 31 + # Reset a few things declared by `pkgs.glibc`. 32 + outputs = [ "out" ]; 33 + separateDebugInfo = false; 34 + 35 + meta = meta // { 36 + description = "Perl script used to interpret and provide human readable output of the trace log contained in the file mtracedata, whose contents were produced by mtrace(3)."; 37 + }; 38 + })
+2
pkgs/top-level/all-packages.nix
··· 16248 16248 stdenv = gccStdenv; # doesn't compile without gcc 16249 16249 }; 16250 16250 16251 + mtrace = callPackage ../development/libraries/glibc/mtrace.nix { }; 16252 + 16251 16253 # Provided by libc on Operating Systems that use the Extensible Linker Format. 16252 16254 elf-header = 16253 16255 if stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf"