summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.ohio-state.edu>1996-12-11 05:38:28 -0500
committerChip Salzenberg <chip@atlantic.net>1996-12-19 16:44:00 +1200
commit04fb8f4b3e8b019f89e231d686e94b476106c022 (patch)
tree5362523631dbe9b8de49edb3d7befa4723918327
parent18d2dc8c79d95eb6c44a7de3c7011396fa783741 (diff)
downloadperl-04fb8f4b3e8b019f89e231d686e94b476106c022.tar.gz
Debugger update
Subject: Re: Perl 5.003_11 is available This fixes the problems in debugger: a) frame=4 may loop infinitely if some arguments are tied or have "" overloaded b) `f file': better documentation. c) prints correctly arguments with embedded \0 (would put quotes at a wrong place otherwise). d) frame=4 would not clobber $_. e) backtrace save wrt -w and undefs as arguments. e) frame & 8: new feature: print tied and ""-overloaded argumentes in the stringified form. Enjoy, p5p-msgid: <199612111038.FAA24363@monk.mps.ohio-state.edu>
-rw-r--r--lib/perl5db.pl45
1 files changed, 30 insertions, 15 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index fcc30c6e7c..15b5295e06 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -475,7 +475,7 @@ sub DB {
}}
}
if (!defined $main::{'_<' . $file}) {
- print $OUT "There's no code here matching $file.\n";
+ print $OUT "No file matching `$file' is loaded.\n";
next CMD;
} elsif ($file ne $filename) {
*dbline = "::_<$file";
@@ -1033,6 +1033,7 @@ sub DB {
$piped= "";
}
} # CMD:
+ $exiting = 1 unless defined $cmd;
map {$evalarg = $_; &eval} @$post;
} # if ($single || $signal)
($@, $!, $,, $/, $\, $^W) = @saved;
@@ -1047,14 +1048,14 @@ sub sub {
if ($sub =~ /::AUTOLOAD$/) {
$al = " for $ {$` . '::AUTOLOAD'}";
}
- ($frame & 4
- ? ( (print $LINEINFO ' ' x $#stack, "in "),
- # Why -1? But it works! :-(
- print_trace($LINEINFO, -1, 1, 1, "$sub$al") )
- : print $LINEINFO ' ' x $#stack, "entering $sub$al\n") if $frame;
push(@stack, $single);
$single &= 1;
$single |= 4 if $#stack == $deep;
+ ($frame & 4
+ ? ( (print $LINEINFO ' ' x ($#stack - 1), "in "),
+ # Why -1? But it works! :-(
+ print_trace($LINEINFO, -1, 1, 1, "$sub$al") )
+ : print $LINEINFO ' ' x ($#stack - 1), "entering $sub$al\n") if $frame;
if (wantarray) {
@ret = &$sub;
$single |= pop(@stack);
@@ -1200,20 +1201,33 @@ sub dump_trace {
$skip++;
$count += $skip;
my ($p,$file,$line,$sub,$h,$args,$e,$r,@a,@sub,$context);
+ my $nothard = not $frame & 8;
+ local $frame = 0; # Do not want to trace this.
+ my $otrace = $trace;
+ $trace = 0;
for ($i = $skip;
$i < $count and ($p,$file,$line,$sub,$h,$context,$e,$r) = caller($i);
$i++) {
@a = ();
for $arg (@args) {
- $_ = "$arg";
- s/([\'\\])/\\$1/g;
- s/([^\0]*)/'$1'/
- unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
- s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
- s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
- push(@a, $_);
+ my $type;
+ if (not defined $arg) {
+ push @a, "undef";
+ } elsif ($nothard and tied $arg) {
+ push @a, "tied";
+ } elsif ($nothard and $type = ref $arg) {
+ push @a, "ref($type)";
+ } else {
+ local $_ = "$arg"; # Safe to stringify now - should not call f().
+ s/([\'\\])/\\$1/g;
+ s/(.*)/'$1'/s
+ unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
+ s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
+ s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
+ push(@a, $_);
+ }
}
- $context = $context ? '@' : '$';
+ $context = $context ? '@' : "\$";
$args = $h ? [@a] : undef;
$e =~ s/\n\s*\;\s*\Z// if $e;
$e =~ s/[\\\']/\\$1/g if $e;
@@ -1228,6 +1242,7 @@ sub dump_trace {
file => $file, line => $line});
last if $signal;
}
+ $trace = $otrace;
@sub;
}
@@ -1552,7 +1567,7 @@ l List next window of lines.
- List previous window of lines.
w [line] List window around line.
. Return to the executed line.
-f filename Switch to viewing filename.
+f filename Switch to viewing filename. Must be loaded.
/pattern/ Search forwards for pattern; final / is optional.
?pattern? Search backwards for pattern; final ? is optional.
L List all breakpoints and actions.