14 if (! -c "/dev/null") {
15 print "1..0 # Skip: no /dev/null\n";
19 my $dev_tty = '/dev/tty';
20 $dev_tty = 'TT:' if ($^O eq 'VMS');
22 print "1..0 # Skip: no $dev_tty\n";
26 print "1..0 # Skip: \$ENV{PERL5DB} is already set to '$ENV{PERL5DB}'\n";
33 my $rc_filename = '.perldb';
36 open my $rc_fh, '>', $rc_filename
41 # overly permissive perms gives "Must not source insecure rcfile"
42 # and hangs at the DB(1> prompt
43 chmod 0644, $rc_filename;
50 open my $in, '<', $filename
51 or die "Cannot open '$filename' for slurping - $!";
61 my $out_fn = 'db.out';
65 return _slurp($out_fn);
69 my $target = '../lib/perl5db/t/eval-line-bug';
73 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
83 "p \\\@{'main::_<$target'}",
91 local $ENV{PERLDB_OPTS} = "ReadLine=0";
92 runperl(switches => [ '-d' ], progfile => $target);
96 like(_out_contents(), qr/sub factorial/,
97 'The ${main::_<filename} variable in the debugger was not destroyed'
101 my $target = '../lib/perl5db/t/eval-line-bug';
105 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
108 push(\@DB::typeahead,
112 'x "new_var = <\$new_var>\\n";',
120 local $ENV{PERLDB_OPTS} = "ReadLine=0";
121 runperl(switches => [ '-d' ], progfile => $target);
125 like(_out_contents(), qr/new_var = <Foo>/,
126 "no strict 'vars' in evaluated lines.",
130 local $ENV{PERLDB_OPTS} = "ReadLine=0";
131 my $output = runperl(switches => [ '-d' ], progfile => '../lib/perl5db/t/lvalue-bug');
132 like($output, qr/foo is defined/, 'lvalue subs work in the debugger');
136 local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
137 my $output = runperl(switches => [ '-d' ], progfile => '../lib/perl5db/t/symbol-table-bug');
138 like($output, qr/Undefined symbols 0/, 'there are no undefined values in the symbol table');
142 if ( $Config{usethreads} ) {
143 skip('This perl has threads, skipping non-threaded debugger tests');
145 my $error = 'This Perl not built to support threads';
146 my $output = runperl( switches => [ '-dt' ], stderr => 1 );
147 like($output, qr/$error/, 'Perl debugger correctly complains that it was not built with threads');
152 if ( $Config{usethreads} ) {
153 local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
154 my $output = runperl(switches => [ '-dt' ], progfile => '../lib/perl5db/t/symbol-table-bug');
155 like($output, qr/Undefined symbols 0/, 'there are no undefined values in the symbol table when running with thread support');
157 skip("This perl is not threaded, skipping threaded debugger tests");
166 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
177 my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/rt-61222');
178 unlike(_out_contents(), qr/INCORRECT/, "[perl #61222]");
183 # Test for Proxy constants
188 &parse_options("NonStop=0 ReadLine=0 TTY=db.out LineInfo=db.out");
200 my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/proxy-constants');
201 is($output, "", "proxy constant subroutines");
204 # Testing that we can set a line in the middle of the file.
207 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
210 push (@DB::typeahead,
211 'b ../lib/perl5db/t/MyModule.pm:12',
213 q/do { use IO::Handle; STDOUT->autoflush(1); print "Var=$var\n"; }/,
221 my $output = runperl(switches => [ '-d', '-I', '../lib/perl5db/t', ], stderr => 1, progfile => '../lib/perl5db/t/filename-line-breakpoint');
231 "Can set breakpoint in a line in the middle of the file.");
235 # [perl #66110] Call a subroutine inside a regex
237 local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
238 my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/rt-66110');
239 like($output, "All tests successful.", "[perl #66110]");
242 # [perl 104168] level option for tracing
245 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
248 push (@DB::typeahead,
257 my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/rt-104168');
261 open I, "<", 'db.out' or die $!;
265 like($contents, qr/level 2/, "[perl #104168]");
266 unlike($contents, qr/baz/, "[perl #104168]");
272 local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
273 my $output = runperl(switches => [ '-d', '-T' ], stderr => 1,
274 progfile => '../lib/perl5db/t/taint');
275 chomp $output if $^O eq 'VMS'; # newline guaranteed at EOF
276 is($output, '[$^X][done]', "taint");
279 # Testing that we can set a breakpoint
282 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
285 push (@DB::typeahead,
288 q/do { use IO::Handle; STDOUT->autoflush(1); print "X={$x}\n"; }/,
296 my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/breakpoint-bug');
301 "Can set breakpoint in a line.");
305 # Testing that we can disable a breakpoint at a numeric line.
308 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
311 push (@DB::typeahead,
316 q/print "X={$x}\n";/,
324 my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-1'); +
328 "Can set breakpoint in a line.");
331 # Testing that we can re-enable a breakpoint at a numeric line.
334 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
337 push (@DB::typeahead,
344 q/print "X={$x}\n";/,
352 my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-2');
354 X=\{SecondValOneHundred\}
356 "Can set breakpoint in a line.");
360 # Disable and enable for breakpoints on outer files.
363 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
366 push (@DB::typeahead,
368 'b ../lib/perl5db/t/EnableModule.pm:14',
369 'disable ../lib/perl5db/t/EnableModule.pm:14',
371 'enable ../lib/perl5db/t/EnableModule.pm:14',
373 q/print "X={$x}\n";/,
381 my $output = runperl(switches => [ '-d', '-I', '../lib/perl5db/t', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-3'); +
383 X=\{SecondValTwoHundred\}
385 "Can set breakpoint in a line.");
388 # Testing that the prompt with the information appears.
391 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
394 push (@DB::typeahead,
401 my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-1');
403 like(_out_contents(), qr/
404 ^main::\([^\)]*\bdisable-breakpoints-1:2\):\n
405 2:\s+my\ \$x\ =\ "One";\n
407 "Prompt should display the first line of code.");
410 # Testing that R (restart) and "B *" work.
413 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
416 push (@DB::typeahead,
423 q/print "X={$x};dummy={$dummy}\n";/,
430 my $output = runperl(switches => [ '-d', ], stderr => 1, progfile => '../lib/perl5db/t/disable-breakpoints-1');
432 X=\{FirstVal\};dummy=\{1\}
434 "Restart and delete all breakpoints work properly.");
438 1 while unlink ($rc_filename, $out_fn);