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: $!";
22 if (open(OUT,">peek$$")) {
23 open(STDERR, ">&OUT") or die "Can't dup OUT: $!";
25 open(STDERR, ">&SAVERR") or die "Can't restore STDERR: $!";
27 if (open(IN, "peek$$")) {
29 $pattern =~ s/\$ADDR/0x[[:xdigit:]]+/g;
30 $pattern =~ s/\$FLOAT/(?:\\d*\\.\\d+(?:e[-+]\\d+)?|\\d+)/g;
31 print $pattern, "\n" if $DEBUG;
33 print $dump, "\n" if $DEBUG;
34 print "[$dump] vs [$pattern]\nnot " unless $dump =~ /\A$pattern\Z/ms;
39 die "$0: failed to open peek$$: !\n";
42 die "$0: failed to create peek$$: $!\n";
53 'SV = PV\\($ADDR\\) at $ADDR
55 FLAGS = \\(POK,pPOK\\)
63 'SV = PV\\($ADDR\\) at $ADDR
65 FLAGS = \\(.*POK,READONLY,pPOK\\)
72 'SV = IV\\($ADDR\\) at $ADDR
74 FLAGS = \\(IOK,pIOK\\)
79 'SV = IV\\($ADDR\\) at $ADDR
81 FLAGS = \\(.*IOK,READONLY,pIOK\\)
86 'SV = IV\\($ADDR\\) at $ADDR
88 FLAGS = \\(PADMY,IOK,pIOK\\)
91 # If perl is built with PERL_PRESERVE_IVUV then maths is done as integers
92 # where possible and this scalar will be an IV. If NO_PERL_PRESERVE_IVUV then
93 # maths is done in floating point always, and this scalar will be an NV.
94 # ([NI]) captures the type, referred to by \1 in this regexp and $type for
95 # building subsequent regexps.
96 my $type = do_test( 6,
98 'SV = ([NI])V\\($ADDR\\) at $ADDR
100 FLAGS = \\(PADTMP,\1OK,p\1OK\\)
107 'SV = PVNV\\($ADDR\\) at $ADDR
109 FLAGS = \\(NOK,pNOK\\)
111 NV = 789\\.(?:1(?:000+\d+)?|0999+\d+)
118 'SV = IV\\($ADDR\\) at $ADDR
120 FLAGS = \\(.*IOK,READONLY,pIOK\\)
125 'SV = NULL\\(0x0\\) at $ADDR
131 'SV = RV\\($ADDR\\) at $ADDR
135 SV = PV\\($ADDR\\) at $ADDR
137 FLAGS = \\(POK,pPOK\\)
145 SV = PVNV\\($ADDR\\) at $ADDR
147 FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
153 SV = IV\\($ADDR\\) at $ADDR
155 FLAGS = \\(IOK,pIOK\\)
160 'SV = RV\\($ADDR\\) at $ADDR
164 SV = PVAV\\($ADDR\\) at $ADDR
175 SV = IV\\($ADDR\\) at $ADDR
177 FLAGS = \\(IOK,pIOK\\)
179 Elt No. 1' . $c_pattern);
183 'SV = RV\\($ADDR\\) at $ADDR
187 SV = PVHV\\($ADDR\\) at $ADDR
189 FLAGS = \\(SHAREKEYS\\)
192 ARRAY = $ADDR \\(0:7, 1:1\\)
193 hash quality = 100.0%
199 Elt "123" HASH = $ADDR' . $c_pattern);
203 'SV = RV\\($ADDR\\) at $ADDR
207 SV = PVCV\\($ADDR\\) at $ADDR
209 FLAGS = \\(PADMY,POK,pPOK,ANON,WEAKOUTSIDE\\)
213 COMP_STASH = $ADDR\\t"main"
214 START = $ADDR ===> \\d+
218 GVGV::GV = $ADDR\\t"main" :: "__ANON__[^"]*"
219 FILE = ".*\\b(?i:peek\\.t)"
226 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
227 OUTSIDE = $ADDR \\(MAIN\\)');
231 'SV = RV\\($ADDR\\) at $ADDR
235 SV = PVCV\\($ADDR\\) at $ADDR
240 COMP_STASH = $ADDR\\t"main"
241 START = $ADDR ===> \\d+
245 GVGV::GV = $ADDR\\t"main" :: "do_test"
246 FILE = ".*\\b(?i:peek\\.t)"
253 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
254 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern"
255 \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG"
256 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump"
257 OUTSIDE = $ADDR \\(MAIN\\)');
261 'SV = RV\\($ADDR\\) at $ADDR
265 SV = PVMG\\($ADDR\\) at $ADDR
267 FLAGS = \\(OBJECT,RMG\\)
273 MG_TYPE = PERL_MAGIC_qr\(r\)
275 STASH = $ADDR\\t"Regexp"');
279 'SV = RV\\($ADDR\\) at $ADDR
283 SV = PVHV\\($ADDR\\) at $ADDR
285 FLAGS = \\(OBJECT,SHAREKEYS\\)
288 STASH = $ADDR\\t"Tac"
298 'SV = PVGV\\($ADDR\\) at $ADDR
300 FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\)
304 MG_VIRTUAL = &PL_vtbl_glob
305 MG_TYPE = PERL_MAGIC_glob\(\*\)
309 GvSTASH = $ADDR\\t"main"
321 FILE = ".*\\b(?i:peek\\.t)"
325 if (ord('A') == 193) {
327 chr(256).chr(0).chr(512),
328 'SV = PV\\($ADDR\\) at $ADDR
330 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
331 PV = $ADDR "\\\214\\\101\\\0\\\235\\\101"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
336 chr(256).chr(0).chr(512),
337 'SV = PV\\($ADDR\\) at $ADDR
339 FLAGS = \\((?:PADTMP,)?POK,READONLY,pPOK,UTF8\\)
340 PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
345 if (ord('A') == 193) {
347 {chr(256)=>chr(512)},
348 'SV = RV\\($ADDR\\) at $ADDR
352 SV = PVHV\\($ADDR\\) at $ADDR
354 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
357 ARRAY = $ADDR \\(0:7, 1:1\\)
358 hash quality = 100.0%
364 Elt "\\\214\\\101" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
365 SV = PV\\($ADDR\\) at $ADDR
367 FLAGS = \\(POK,pPOK,UTF8\\)
368 PV = $ADDR "\\\235\\\101"\\\0 \[UTF8 "\\\x\{200\}"\]
373 {chr(256)=>chr(512)},
374 'SV = RV\\($ADDR\\) at $ADDR
378 SV = PVHV\\($ADDR\\) at $ADDR
380 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)?
423 $ENV{PATH}=@ARGV, # scalar(@ARGV) is a handy known tainted value
424 'SV = PVMG\\($ADDR\\) at $ADDR
426 FLAGS = \\(GMG,SMG,RMG,pIOK,pPOK\\)
433 MG_VIRTUAL = &PL_vtbl_envelem
434 MG_TYPE = PERL_MAGIC_envelem\\(e\\)
438 MG_PTR = $ADDR (?:"(?i:PATH)"|=> HEf_SVKEY
439 SV = PV(?:IV)?\\($ADDR\\) at $ADDR
441 FLAGS = \\(TEMP,POK,pPOK\\)
443 )? PV = $ADDR "(?i:PATH)"\\\0
447 MG_VIRTUAL = &PL_vtbl_taint
448 MG_TYPE = PERL_MAGIC_taint\\(t\\)');
451 1 while unlink("peek$$");
456 bless(\\undef, 'Foobar'),
457 'SV = RV\\($ADDR\\) at $ADDR
461 SV = PVMG\\($ADDR\\) at $ADDR
463 FLAGS = \\(OBJECT,ROK\\)
467 SV = NULL\\(0x0\\) at $ADDR
469 FLAGS = \\(READONLY\\)
473 STASH = $ADDR\s+"Foobar"');