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" : '';
41 $pattern =~ s/^ *\$IVNV *\n/
42 ($] < 5.009) ? " IV = 0\n NV = 0\n" : '';
47 print $pattern, "\n" if $DEBUG;
49 print $dump, "\n" if $DEBUG;
50 print "got:\n[\n$dump\n]\nexpected:\n[\n$pattern\n]\nnot "
51 unless $dump =~ /\A$pattern\Z/ms;
56 die "$0: failed to open peek$$: !\n";
59 die "$0: failed to create peek$$: $!\n";
71 'SV = PV\\($ADDR\\) at $ADDR
73 FLAGS = \\(POK,pPOK\\)
81 'SV = PV\\($ADDR\\) at $ADDR
83 FLAGS = \\(.*POK,READONLY,pPOK\\)
90 'SV = IV\\($ADDR\\) at $ADDR
92 FLAGS = \\(IOK,pIOK\\)
97 'SV = IV\\($ADDR\\) at $ADDR
99 FLAGS = \\(.*IOK,READONLY,pIOK\\)
104 'SV = IV\\($ADDR\\) at $ADDR
106 FLAGS = \\(PADMY,IOK,pIOK\\)
109 # If perl is built with PERL_PRESERVE_IVUV then maths is done as integers
110 # where possible and this scalar will be an IV. If NO_PERL_PRESERVE_IVUV then
111 # maths is done in floating point always, and this scalar will be an NV.
112 # ([NI]) captures the type, referred to by \1 in this regexp and $type for
113 # building subsequent regexps.
114 my $type = do_test( 6,
116 'SV = ([NI])V\\($ADDR\\) at $ADDR
118 FLAGS = \\(PADTMP,\1OK,p\1OK\\)
125 'SV = PVNV\\($ADDR\\) at $ADDR
127 FLAGS = \\(NOK,pNOK\\)
129 NV = 789\\.(?:1(?:000+\d+)?|0999+\d+)
136 'SV = IV\\($ADDR\\) at $ADDR
138 FLAGS = \\(.*IOK,READONLY,pIOK\\)
143 'SV = NULL\\(0x0\\) at $ADDR
149 'SV = RV\\($ADDR\\) at $ADDR
153 SV = PV\\($ADDR\\) at $ADDR
155 FLAGS = \\(POK,pPOK\\)
163 SV = PVNV\\($ADDR\\) at $ADDR
165 FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
171 SV = IV\\($ADDR\\) at $ADDR
173 FLAGS = \\(IOK,pIOK\\)
178 'SV = RV\\($ADDR\\) at $ADDR
182 SV = PVAV\\($ADDR\\) at $ADDR
191 SV = IV\\($ADDR\\) at $ADDR
193 FLAGS = \\(IOK,pIOK\\)
195 Elt No. 1' . $c_pattern);
199 'SV = RV\\($ADDR\\) at $ADDR
203 SV = PVHV\\($ADDR\\) at $ADDR
205 FLAGS = \\(SHAREKEYS\\)
206 ARRAY = $ADDR \\(0:7, 1:1\\)
207 hash quality = 100.0%
213 Elt "123" HASH = $ADDR' . $c_pattern);
217 'SV = RV\\($ADDR\\) at $ADDR
221 SV = PVCV\\($ADDR\\) at $ADDR
223 FLAGS = \\(PADMY,POK,pPOK,ANON,WEAKOUTSIDE\\)
226 COMP_STASH = $ADDR\\t"main"
227 START = $ADDR ===> \\d+
230 GVGV::GV = $ADDR\\t"main" :: "__ANON__[^"]*"
231 FILE = ".*\\b(?i:peek\\.t)"
238 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
239 OUTSIDE = $ADDR \\(MAIN\\)');
243 'SV = RV\\($ADDR\\) at $ADDR
247 SV = PVCV\\($ADDR\\) at $ADDR
251 COMP_STASH = $ADDR\\t"main"
252 START = $ADDR ===> \\d+
255 GVGV::GV = $ADDR\\t"main" :: "do_test"
256 FILE = ".*\\b(?i:peek\\.t)"
263 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
264 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern"
265 \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG" flags=0x0 index=0
266 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump"
267 OUTSIDE = $ADDR \\(MAIN\\)');
271 'SV = RV\\($ADDR\\) at $ADDR
275 SV = PVMG\\($ADDR\\) at $ADDR
277 FLAGS = \\(OBJECT,SMG\\)
283 MG_TYPE = PERL_MAGIC_qr\(r\)
285 STASH = $ADDR\\t"Regexp"');
289 'SV = RV\\($ADDR\\) at $ADDR
293 SV = PVHV\\($ADDR\\) at $ADDR
295 FLAGS = \\(OBJECT,SHAREKEYS\\)
296 STASH = $ADDR\\t"Tac"
306 'SV = PVGV\\($ADDR\\) at $ADDR
308 FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\)
312 MG_VIRTUAL = &PL_vtbl_glob
313 MG_TYPE = PERL_MAGIC_glob\(\*\)
317 GvSTASH = $ADDR\\t"main"
328 FILE = ".*\\b(?i:peek\\.t)"
332 if (ord('A') == 193) {
334 chr(256).chr(0).chr(512),
335 'SV = PV\\($ADDR\\) at $ADDR
337 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
338 PV = $ADDR "\\\214\\\101\\\0\\\235\\\101"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
343 chr(256).chr(0).chr(512),
344 'SV = PV\\($ADDR\\) at $ADDR
346 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
347 PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
352 if (ord('A') == 193) {
354 {chr(256)=>chr(512)},
355 'SV = RV\\($ADDR\\) at $ADDR
359 SV = PVHV\\($ADDR\\) at $ADDR
361 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
362 ARRAY = $ADDR \\(0:7, 1:1\\)
363 hash quality = 100.0%
369 Elt "\\\214\\\101" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
370 SV = PV\\($ADDR\\) at $ADDR
372 FLAGS = \\(POK,pPOK,UTF8\\)
373 PV = $ADDR "\\\235\\\101"\\\0 \[UTF8 "\\\x\{200\}"\]
378 {chr(256)=>chr(512)},
379 'SV = RV\\($ADDR\\) at $ADDR
383 SV = PVHV\\($ADDR\\) at $ADDR
385 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
386 ARRAY = $ADDR \\(0:7, 1:1\\)
387 hash quality = 100.0%
393 Elt "\\\304\\\200" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
394 SV = PV\\($ADDR\\) at $ADDR
396 FLAGS = \\(POK,pPOK,UTF8\\)
397 PV = $ADDR "\\\310\\\200"\\\0 \[UTF8 "\\\x\{200\}"\]
406 'SV = PVMG\\($ADDR\\) at $ADDR
408 FLAGS = \\(PADMY,SMG,POK,pPOK\\)
415 MG_VIRTUAL = &PL_vtbl_mglob
416 MG_TYPE = PERL_MAGIC_regex_global\\(g\\)
421 # TAINTEDDIR is not set on: OS2, AMIGAOS, WIN32, MSDOS
422 # environment variables may be invisibly case-forced, hence the (?i:PATH)
423 # C<scalar(@ARGV)> is turned into an IV on VMS hence the (?:IV)?
424 # VMS is setting FAKE and READONLY flags. What VMS uses for storing
425 # ENV hashes is also not always null terminated.
428 $ENV{PATH}=@ARGV, # scalar(@ARGV) is a handy known tainted value
429 'SV = PVMG\\($ADDR\\) at $ADDR
431 FLAGS = \\(GMG,SMG,RMG,pIOK,pPOK\\)
438 MG_VIRTUAL = &PL_vtbl_envelem
439 MG_TYPE = PERL_MAGIC_envelem\\(e\\)
443 MG_PTR = $ADDR (?:"(?i:PATH)"|=> HEf_SVKEY
444 SV = PV(?:IV)?\\($ADDR\\) at $ADDR
446 FLAGS = \\(TEMP,POK,(?:FAKE,READONLY,)?pPOK\\)
448 )? PV = $ADDR "(?i:PATH)"(?:\\\0)?
452 MG_VIRTUAL = &PL_vtbl_taint
453 MG_TYPE = PERL_MAGIC_taint\\(t\\)');
456 1 while unlink("peek$$");
461 bless(\\undef, 'Foobar'),
462 'SV = RV\\($ADDR\\) at $ADDR
466 SV = PVMG\\($ADDR\\) at $ADDR
468 FLAGS = \\(OBJECT,ROK\\)
472 SV = NULL\\(0x0\\) at $ADDR
474 FLAGS = \\(READONLY\\)
478 STASH = $ADDR\s+"Foobar"');
480 # Constant subroutines
488 'SV = RV\\($ADDR\\) at $ADDR
492 SV = PVCV\\($ADDR\\) at $ADDR
494 FLAGS = \\(POK,pPOK,CONST\\)
500 XSUBANY = $ADDR \\(CONST SV\\)
501 SV = PV\\($ADDR\\) at $ADDR
503 FLAGS = \\(.*POK,READONLY,pPOK\\)
504 PV = $ADDR "Perl rules"\\\0
507 GVGV::GV = $ADDR\\t"main" :: "const"
508 FILE = ".*\\b(?i:peek\\.t)"
515 OUTSIDE = 0x0 \\(null\\)');