Created
June 24, 2020 23:51
-
-
Save exodist/cc355b975cab0d3a1dcae67f6e25f18c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Test2::Plugin::Cover; | |
use strict; | |
use warnings; | |
our $VERSION = '0.000001'; | |
use XSLoader; | |
XSLoader::load(__PACKAGE__, $VERSION); | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <EXTERN.h> | |
#include <perl.h> | |
#include <XSUB.h> | |
#include <stdio.h> | |
Perl_ppaddr_t orig_subhandler; | |
SV *one; | |
static OP* my_subhandler(pTHX) { | |
OP* out = orig_subhandler(aTHX); | |
if (out->op_type == OP_NEXTSTATE || out->op_type == OP_DBSTATE) { | |
char *file = CopFILE(cCOPx(out)); | |
long len = strlen(file); | |
HV *files = get_hv("Test2::Plugin::Cover::FILES", 0); | |
if (!hv_exists(files, file, len)) { | |
SvREFCNT_inc(one); | |
hv_store(files, file, len, one, 0); | |
} | |
} | |
return out; | |
} | |
MODULE = Test2::Plugin::Cover PACKAGE = Test2::Plugin::Cover | |
PROTOTYPES: ENABLE | |
BOOT: | |
{ | |
MY_CXT_INIT; | |
one = newSVnv(1); | |
SvREFCNT_inc(one); | |
orig_subhandler = PL_ppaddr[OP_ENTERSUB]; | |
PL_ppaddr[OP_ENTERSUB] = my_subhandler; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test2::Plugin::Cover; | |
use Cpanel::JSON::XS; | |
__END__ | |
No output, exit code 139 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test2::Plugin::Cover; | |
use Data::UUID; | |
Data::UUID->new; | |
__END__ | |
No output, exit code 139 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test2::Plugin::Cover; | |
sub foo { 'foo' } | |
print foo(), "\n"; | |
__END__ | |
Output: foo | |
Exit code: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment