lib/perl5db.t Tests for the Perl debugger
lib/perl5db/t/breakpoint-bug Test script used by perl5db.t
lib/perl5db/t/eval-line-bug Tests for the Perl debugger
+lib/perl5db/t/filename-line-breakpoint Tests for the Perl debugger
lib/perl5db/t/lvalue-bug Tests for the Perl debugger
+lib/perl5db/t/MyModule.pm Tests for the Perl debugger
lib/perl5db/t/proxy-constants Tests for the Perl debugger
lib/perl5db/t/rt-61222 Tests for the Perl debugger
lib/perl5db/t/rt-66110 Tests for the Perl debugger
my $dbline = shift;
# Make . the current line number if it's there..
- $line =~ s/^\./$dbline/;
+ $line =~ s/^\.\b/$dbline/;
# No line number, no condition. Simple break on current line.
if ( $line =~ /^\s*$/ ) {
# Save the break type for this sub.
$postponed{$subname} = $break ? "break +0 if $cond" : "compile";
} ## end elsif ($line =~ ...
-
+ # b <filename>:<line> [<condition>]
+ elsif ($line =~ /\A(\S+[^:]):(\d+)\s*(.*)/ms) {
+ my ($filename, $line_num, $cond) = ($1, $2, $3);
+ cmd_b_filename_line(
+ $filename,
+ $line_num,
+ (length($cond) ? $cond : '1'),
+ );
+ }
# b <sub name> [<condition>]
elsif ( $line =~ /^([':A-Za-z_][':\w]*(?:\[.*\])?)\s*(.*)/ ) {
};
} ## end sub cmd_b_line
+=head3 cmd_b_filename_line(line, [condition]) (command)
+
+Wrapper for C<break_on_filename_line>. Prints the failure message if it
+doesn't work.
+
+=cut
+
+sub cmd_b_filename_line {
+ eval { break_on_filename_line(@_); 1 } or do {
+ local $\ = '';
+ print $OUT $@ and return;
+ };
+}
+
=head3 break_on_filename_line(file, line, [condition]) (API)
Switches to the file specified and then calls C<break_on_line> to set
my $cond = length $2 ? $2 : '1';
&cmd_b_sub( $subname, $cond );
}
-
# b <line> [<condition>].
elsif ( $cmd =~ /^(\d*)\s*(.*)/ ) {
my $i = $1 || $dbline;
}
}
-plan(10);
+plan(11);
sub rc {
open RC, ">", ".perldb" or die $!;
is($output, "", "proxy constant subroutines");
}
+# Testing that we can set a line in the middle of the file.
+{
+ rc(<<'EOF');
+&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+
+sub afterinit {
+ push (@DB::typeahead,
+ 'b ../lib/perl5db/t/MyModule.pm:12',
+ 'c',
+ q/do { use IO::Handle; STDOUT->autoflush(1); print "Var=$var\n"; }/,
+ 'c',
+ 'q',
+ );
+
+}
+EOF
+
+ my $output = runperl(switches => [ '-d', '-I', '../lib/perl5db/t', ], stderr => 1, progfile => '../lib/perl5db/t/filename-line-breakpoint');
+
+ like($output, qr/
+ ^Var=Bar$
+ .*
+ ^In\ MyModule\.$
+ .*
+ ^In\ Main\ File\.$
+ .*
+ /msx,
+ "Can set breakpoint in a line in the middle of the file.");
+}
+
# [perl #66110] Call a subroutine inside a regex
{
--- /dev/null
+package MyModule;
+
+use strict;
+use warnings;
+
+use vars qw($var);
+
+$var = "Bar";
+
+sub function
+{
+ print "In MyModule.\n";
+}
+
+1;
--- /dev/null
+#!/perl
+
+use strict;
+use warnings;
+
+use MyModule;
+
+my $x = "Foo";
+
+MyModule::function();
+
+print "In Main File.\n";
+
+1;
b 237 ++$count237 < 11
b 33 /pattern/i
+=item b [file]:[line] [condition]
+X<breakpoint>
+X<debugger command, b>
+
+Set a breakpoint before the given line in a (possibly different) file. If a
+condition is specified, it's evaluated each time the statement is reached: a
+breakpoint is taken only if the condition is true. Breakpoints may only be set
+on lines that begin an executable statement. Conditions don't use C<if>:
+
+ b lib/MyModule.pm:237 $x > 30
+ b /usr/lib/perl5/site_perl/CGI.pm:100 ++$count100 < 11
+
=item b subname [condition]
X<breakpoint>
X<debugger command, b>