]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
spawn: add #line CPP directives to ease debugging
authorEric Wong <e@80x24.org>
Fri, 8 May 2026 04:02:29 +0000 (04:02 +0000)
committerEric Wong <e@80x24.org>
Fri, 8 May 2026 21:26:07 +0000 (21:26 +0000)
Having reasonably accurate file and line number makes debugging
much easier since Inline::C clobbers temporary Spawn_*.xs files
by default.

lib/PublicInbox/Spawn.pm

index 3a35b4d5f5b75a4c9ff3ec5506f3fe1dce197a2d..692037e8cf45d5a52580f2aa759a69eb2405c39d 100644 (file)
@@ -34,7 +34,7 @@ use autodie qw(close open pipe seek sysseek truncate);
 
 BEGIN {
        @RLIMITS = qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA);
-       my $all_libc = <<'ALL_LIBC'; # all *nix systems we support
+       my $all_libc = qq[#line ${\__LINE__} "${\__FILE__}"\n]. <<'ALL_LIBC';
 #include <sys/resource.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -306,6 +306,7 @@ ALL_LIBC
                ).'/public-inbox/inline-c';
        undef $all_libc unless -d $inline_dir;
        if (defined $all_libc) {
+               $all_libc .= qq[#line ${\__LINE__} "${\__FILE__}"\n];
                for (@RLIMITS, 'RLIM_INFINITY') {
                        $all_libc .= <<EOM;
        Inline_Stack_Push(sv_2mortal(newSVpvs("$_")));