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 = \\(PADBUSY,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 = \\(PADBUSY,PADMY,POK,pPOK,ANON\\)
213 COMP_STASH = $ADDR\\t"main"
214 START = $ADDR ===> \\d+
218 GVGV::GV = $ADDR\\t"main" :: "__ANON__[^"]*"
219 FILE = ".*\\b(?i:peek\\.t)"
225 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
226 OUTSIDE = $ADDR \\(MAIN\\)');
230 'SV = RV\\($ADDR\\) at $ADDR
234 SV = PVCV\\($ADDR\\) at $ADDR
239 COMP_STASH = $ADDR\\t"main"
240 START = $ADDR ===> \\d+
244 GVGV::GV = $ADDR\\t"main" :: "do_test"
245 FILE = ".*\\b(?i:peek\\.t)"
251 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
252 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern"
253 \\d+\\. $ADDR<\\d+> FAKE \\(\\d+,\\d+\\) "\\$DEBUG"
254 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump"
255 OUTSIDE = $ADDR \\(MAIN\\)');
259 'SV = RV\\($ADDR\\) at $ADDR
263 SV = PVMG\\($ADDR\\) at $ADDR
265 FLAGS = \\(OBJECT,RMG\\)
271 MG_TYPE = PERL_MAGIC_qr\(r\)
273 STASH = $ADDR\\t"Regexp"');
277 'SV = RV\\($ADDR\\) at $ADDR
281 SV = PVHV\\($ADDR\\) at $ADDR
283 FLAGS = \\(OBJECT,SHAREKEYS\\)
286 STASH = $ADDR\\t"Tac"
296 'SV = PVGV\\($ADDR\\) at $ADDR
298 FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\)
302 MG_VIRTUAL = &PL_vtbl_glob
303 MG_TYPE = PERL_MAGIC_glob\(\*\)
307 GvSTASH = $ADDR\\t"main"
319 FILE = ".*\\b(?i:peek\\.t)"
323 if (ord('A') == 193) {
325 chr(256).chr(0).chr(512),
326 'SV = PV\\($ADDR\\) at $ADDR
328 FLAGS = \\((?:PADBUSY,PADTMP,)?POK,READONLY,pPOK,UTF8\\)
329 PV = $ADDR "\\\214\\\101\\\0\\\235\\\101"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
334 chr(256).chr(0).chr(512),
335 'SV = PV\\($ADDR\\) at $ADDR
337 FLAGS = \\((?:PADBUSY,PADTMP,)?POK,READONLY,pPOK,UTF8\\)
338 PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
343 if (ord('A') == 193) {
345 {chr(256)=>chr(512)},
346 'SV = RV\\($ADDR\\) at $ADDR
350 SV = PVHV\\($ADDR\\) at $ADDR
352 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
355 ARRAY = $ADDR \\(0:7, 1:1\\)
356 hash quality = 100.0%
362 Elt "\\\214\\\101" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
363 SV = PV\\($ADDR\\) at $ADDR
365 FLAGS = \\(POK,pPOK,UTF8\\)
366 PV = $ADDR "\\\235\\\101"\\\0 \[UTF8 "\\\x\{200\}"\]
371 {chr(256)=>chr(512)},
372 'SV = RV\\($ADDR\\) at $ADDR
376 SV = PVHV\\($ADDR\\) at $ADDR
378 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
381 ARRAY = $ADDR \\(0:7, 1:1\\)
382 hash quality = 100.0%
388 Elt "\\\304\\\200" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
389 SV = PV\\($ADDR\\) at $ADDR
391 FLAGS = \\(POK,pPOK,UTF8\\)
392 PV = $ADDR "\\\310\\\200"\\\0 \[UTF8 "\\\x\{200\}"\]
401 'SV = PVMG\\($ADDR\\) at $ADDR
403 FLAGS = \\(PADBUSY,PADMY,SMG,POK,pPOK\\)
410 MG_VIRTUAL = &PL_vtbl_mglob
411 MG_TYPE = PERL_MAGIC_regex_global\\(g\\)
416 # TAINTEDDIR is not set on: OS2, AMIGAOS, WIN32, MSDOS
417 # environment variables may be invisibly case-forced, hence the (?i:PATH)
420 $ENV{PATH}=@ARGV, # scalar(@ARGV) is a handy known tainted value
421 'SV = PVMG\\($ADDR\\) at $ADDR
423 FLAGS = \\(GMG,SMG,RMG,pIOK,pPOK\\)
430 MG_VIRTUAL = &PL_vtbl_envelem
431 MG_TYPE = PERL_MAGIC_envelem\\(e\\)
435 MG_PTR = $ADDR "(?i:PATH)"
437 MG_VIRTUAL = &PL_vtbl_taint
438 MG_TYPE = PERL_MAGIC_taint\\(t\\)');
441 1 while unlink("peek$$");
446 bless(\\undef, 'Foobar'),
447 'SV = RV\\($ADDR\\) at $ADDR
451 SV = PVMG\\($ADDR\\) at $ADDR
453 FLAGS = \\(OBJECT,ROK\\)
457 SV = NULL\\(0x0\\) at $ADDR
459 FLAGS = \\(READONLY\\)
463 STASH = $ADDR\s+"Foobar"');