6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bPeek\b/) {
8 print "1..0 # Skip: Devel::Peek was not built\n";
18 open(SAVERR, ">&STDERR") or die "Can't dup STDERR: $!";
23 if (open(OUT,">peek$$")) {
24 open(STDERR, ">&OUT") or die "Can't dup OUT: $!";
26 open(STDERR, ">&SAVERR") or die "Can't restore STDERR: $!";
28 if (open(IN, "peek$$")) {
30 $pattern =~ s/\$ADDR/0x[[:xdigit:]]+/g;
31 $pattern =~ s/\$FLOAT/(?:\\d*\\.\\d+(?:e[-+]\\d+)?|\\d+)/g;
32 # handle DEBUG_LEAKING_SCALARS prefix
33 $pattern =~ s/^(\s*)(SV =.* at )/(?:$1ALLOCATED at .*?\n)?$1$2/mg;
35 $pattern =~ s/^ *\$XSUB *\n/
36 ($] < 5.009) ? " XSUB = 0\n XSUBANY = 0\n" : '';
38 $pattern =~ s/^ *\$ROOT *\n/
39 ($] < 5.009) ? " ROOT = 0x0\n" : '';
44 print $pattern, "\n" if $DEBUG;
46 print $dump, "\n" if $DEBUG;
47 print "got:\n[\n$dump\n]\nexpected:\n[\n$pattern\n]\nnot "
48 unless $dump =~ /\A$pattern\Z/ms;
53 die "$0: failed to open peek$$: !\n";
56 die "$0: failed to create peek$$: $!\n";
68 'SV = PV\\($ADDR\\) at $ADDR
70 FLAGS = \\(POK,pPOK\\)
78 'SV = PV\\($ADDR\\) at $ADDR
80 FLAGS = \\(.*POK,READONLY,pPOK\\)
87 'SV = IV\\($ADDR\\) at $ADDR
89 FLAGS = \\(IOK,pIOK\\)
94 'SV = IV\\($ADDR\\) at $ADDR
96 FLAGS = \\(.*IOK,READONLY,pIOK\\)
101 'SV = IV\\($ADDR\\) at $ADDR
103 FLAGS = \\(PADMY,IOK,pIOK\\)
106 # If perl is built with PERL_PRESERVE_IVUV then maths is done as integers
107 # where possible and this scalar will be an IV. If NO_PERL_PRESERVE_IVUV then
108 # maths is done in floating point always, and this scalar will be an NV.
109 # ([NI]) captures the type, referred to by \1 in this regexp and $type for
110 # building subsequent regexps.
111 my $type = do_test( 6,
113 'SV = ([NI])V\\($ADDR\\) at $ADDR
115 FLAGS = \\(PADTMP,\1OK,p\1OK\\)
122 'SV = PVNV\\($ADDR\\) at $ADDR
124 FLAGS = \\(NOK,pNOK\\)
126 NV = 789\\.(?:1(?:000+\d+)?|0999+\d+)
133 'SV = IV\\($ADDR\\) at $ADDR
135 FLAGS = \\(.*IOK,READONLY,pIOK\\)
140 'SV = NULL\\(0x0\\) at $ADDR
146 'SV = RV\\($ADDR\\) at $ADDR
150 SV = PV\\($ADDR\\) at $ADDR
152 FLAGS = \\(POK,pPOK\\)
160 SV = PVNV\\($ADDR\\) at $ADDR
162 FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
168 SV = IV\\($ADDR\\) at $ADDR
170 FLAGS = \\(IOK,pIOK\\)
175 'SV = RV\\($ADDR\\) at $ADDR
179 SV = PVAV\\($ADDR\\) at $ADDR
188 SV = IV\\($ADDR\\) at $ADDR
190 FLAGS = \\(IOK,pIOK\\)
192 Elt No. 1' . $c_pattern);
196 'SV = RV\\($ADDR\\) at $ADDR
200 SV = PVHV\\($ADDR\\) at $ADDR
202 FLAGS = \\(SHAREKEYS\\)
203 ARRAY = $ADDR \\(0:7, 1:1\\)
204 hash quality = 100.0%
210 Elt "123" HASH = $ADDR' . $c_pattern);
214 'SV = RV\\($ADDR\\) at $ADDR
218 SV = PVCV\\($ADDR\\) at $ADDR
220 FLAGS = \\(PADMY,POK,pPOK,ANON,WEAKOUTSIDE\\)
223 COMP_STASH = $ADDR\\t"main"
224 START = $ADDR ===> \\d+
227 GVGV::GV = $ADDR\\t"main" :: "__ANON__[^"]*"
228 FILE = ".*\\b(?i:peek\\.t)"
235 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
236 OUTSIDE = $ADDR \\(MAIN\\)');
240 'SV = RV\\($ADDR\\) at $ADDR
244 SV = PVCV\\($ADDR\\) at $ADDR
248 COMP_STASH = $ADDR\\t"main"
249 START = $ADDR ===> \\d+
252 GVGV::GV = $ADDR\\t"main" :: "do_test"
253 FILE = ".*\\b(?i:peek\\.t)"
260 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
261 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern"
262 \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG" flags=0x0 index=0
263 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump"
264 OUTSIDE = $ADDR \\(MAIN\\)');
268 'SV = RV\\($ADDR\\) at $ADDR
272 SV = PVMG\\($ADDR\\) at $ADDR
274 FLAGS = \\(OBJECT,SMG\\)
280 MG_TYPE = PERL_MAGIC_qr\(r\)
282 STASH = $ADDR\\t"Regexp"');
286 'SV = RV\\($ADDR\\) at $ADDR
290 SV = PVHV\\($ADDR\\) at $ADDR
292 FLAGS = \\(OBJECT,SHAREKEYS\\)
293 STASH = $ADDR\\t"Tac"
303 'SV = PVGV\\($ADDR\\) at $ADDR
305 FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\)
309 MG_VIRTUAL = &PL_vtbl_glob
310 MG_TYPE = PERL_MAGIC_glob\(\*\)
314 GvSTASH = $ADDR\\t"main"
325 FILE = ".*\\b(?i:peek\\.t)"
329 if (ord('A') == 193) {
331 chr(256).chr(0).chr(512),
332 'SV = PV\\($ADDR\\) at $ADDR
334 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
335 PV = $ADDR "\\\214\\\101\\\0\\\235\\\101"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
340 chr(256).chr(0).chr(512),
341 'SV = PV\\($ADDR\\) at $ADDR
343 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
344 PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
349 if (ord('A') == 193) {
351 {chr(256)=>chr(512)},
352 'SV = RV\\($ADDR\\) at $ADDR
356 SV = PVHV\\($ADDR\\) at $ADDR
358 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
359 ARRAY = $ADDR \\(0:7, 1:1\\)
360 hash quality = 100.0%
366 Elt "\\\214\\\101" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
367 SV = PV\\($ADDR\\) at $ADDR
369 FLAGS = \\(POK,pPOK,UTF8\\)
370 PV = $ADDR "\\\235\\\101"\\\0 \[UTF8 "\\\x\{200\}"\]
375 {chr(256)=>chr(512)},
376 'SV = RV\\($ADDR\\) at $ADDR
380 SV = PVHV\\($ADDR\\) at $ADDR
382 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
383 ARRAY = $ADDR \\(0:7, 1:1\\)
384 hash quality = 100.0%
390 Elt "\\\304\\\200" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
391 SV = PV\\($ADDR\\) at $ADDR
393 FLAGS = \\(POK,pPOK,UTF8\\)
394 PV = $ADDR "\\\310\\\200"\\\0 \[UTF8 "\\\x\{200\}"\]
403 'SV = PVMG\\($ADDR\\) at $ADDR
405 FLAGS = \\(PADMY,SMG,POK,pPOK\\)
412 MG_VIRTUAL = &PL_vtbl_mglob
413 MG_TYPE = PERL_MAGIC_regex_global\\(g\\)
418 # TAINTEDDIR is not set on: OS2, AMIGAOS, WIN32, MSDOS
419 # environment variables may be invisibly case-forced, hence the (?i:PATH)
420 # C<scalar(@ARGV)> is turned into an IV on VMS hence the (?:IV)?
421 # VMS is setting FAKE and READONLY flags. What VMS uses for storing
422 # ENV hashes is also not always null terminated.
425 $ENV{PATH}=@ARGV, # scalar(@ARGV) is a handy known tainted value
426 'SV = PVMG\\($ADDR\\) at $ADDR
428 FLAGS = \\(GMG,SMG,RMG,pIOK,pPOK\\)
435 MG_VIRTUAL = &PL_vtbl_envelem
436 MG_TYPE = PERL_MAGIC_envelem\\(e\\)
440 MG_PTR = $ADDR (?:"(?i:PATH)"|=> HEf_SVKEY
441 SV = PV(?:IV)?\\($ADDR\\) at $ADDR
443 FLAGS = \\(TEMP,POK,(?:FAKE,READONLY,)?pPOK\\)
445 )? PV = $ADDR "(?i:PATH)"(?:\\\0)?
449 MG_VIRTUAL = &PL_vtbl_taint
450 MG_TYPE = PERL_MAGIC_taint\\(t\\)');
453 1 while unlink("peek$$");
458 bless(\\undef, 'Foobar'),
459 'SV = RV\\($ADDR\\) at $ADDR
463 SV = PVMG\\($ADDR\\) at $ADDR
465 FLAGS = \\(OBJECT,ROK\\)
469 SV = NULL\\(0x0\\) at $ADDR
471 FLAGS = \\(READONLY\\)
475 STASH = $ADDR\s+"Foobar"');
477 # Constant subroutines
485 'SV = RV\\($ADDR\\) at $ADDR
489 SV = PVCV\\($ADDR\\) at $ADDR
491 FLAGS = \\(POK,pPOK,CONST\\)
497 XSUBANY = $ADDR \\(CONST SV\\)
498 SV = PV\\($ADDR\\) at $ADDR
500 FLAGS = \\(.*POK,READONLY,pPOK\\)
501 PV = $ADDR "Perl rules"\\\0
504 GVGV::GV = $ADDR\\t"main" :: "const"
505 FILE = ".*\\b(?i:peek\\.t)"
512 OUTSIDE = 0x0 \\(null\\)');