From: Mark-Jason Dominus Date: Tue, 12 Feb 2002 20:20:42 +0000 (-0500) Subject: New debugger option 'dumpDepth' controls recursion depth of 'x' command X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d03c2a1b901127d77518bbc18d5271b287c9e28b;p=p5sagit%2Fp5-mst-13.2.git New debugger option 'dumpDepth' controls recursion depth of 'x' command Message-ID: <20020213012042.25245.qmail@plover.com> p4raw-id: //depot/perl@14670 --- diff --git a/lib/dumpvar.pl b/lib/dumpvar.pl index 34a9c59..184faa3 100644 --- a/lib/dumpvar.pl +++ b/lib/dumpvar.pl @@ -30,7 +30,7 @@ sub main::dumpValue { local $^W=0; (print "undef\n"), return unless defined $_[0]; (print &stringify($_[0]), "\n"), return unless ref $_[0]; - dumpvar::unwrap($_[0],0); + dumpvar::unwrap($_[0],0, $_[1]); } # This one is good for variable names: @@ -115,7 +115,7 @@ sub DumpElem { join("' '", @{$v}[0..$tArrayDepth]) . "'$shortmore"; } else { print "$short\n"; - unwrap($_[0],$_[1]); + unwrap($_[0],$_[1],$_[2]); } } @@ -123,6 +123,8 @@ sub unwrap { return if $DB::signal; local($v) = shift ; local($s) = shift ; # extra no of spaces + local($m) = shift ; # maximum recursion depth + return if $m == 0; local(%v,@v,$sp,$value,$key,@sortKeys,$more,$shortmore,$short) ; local($tHashDepth,$tArrayDepth) ; @@ -187,7 +189,7 @@ sub unwrap { return if $DB::signal; $value = $ {$v}{$key} ; print "$sp", &stringify($key), " => "; - DumpElem $value, $s; + DumpElem $value, $s, $m-1; } print "$sp empty hash\n" unless @sortKeys; print "$sp$more" if defined $more ; @@ -218,7 +220,7 @@ sub unwrap { return if $DB::signal; print "$sp$num "; if (exists $v->[$num]) { - DumpElem $v->[$num], $s; + DumpElem $v->[$num], $s, $m-1; } else { print "empty slot\n"; } @@ -227,7 +229,7 @@ sub unwrap { print "$sp$more" if defined $more ; } elsif ( UNIVERSAL::isa($v, 'SCALAR') or ref $v eq 'REF' ) { print "$sp-> "; - DumpElem $$v, $s; + DumpElem $$v, $s, $m-1; } elsif ( UNIVERSAL::isa($v, 'CODE') ) { print "$sp-> "; dumpsub (0, $v); diff --git a/lib/perl5db.pl b/lib/perl5db.pl index c1996b0..1f50211 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -328,7 +328,8 @@ $trace = $signal = $single = 0; # Uninitialized warning suppression # (local $^W cannot help - other packages!). $inhibit_exit = $option{PrintRet} = 1; -@options = qw(hashDepth arrayDepth DumpDBFiles DumpPackages DumpReused +@options = qw(hashDepth arrayDepth dumpDepth + DumpDBFiles DumpPackages DumpReused compactDump veryCompact quote HighBit undefPrint globPrint PrintRet UsageOnly frame AutoTrace TTY noTTY ReadLine NonStop LineInfo maxTraceLen @@ -1826,7 +1827,10 @@ sub dumpit { do 'dumpvar.pl'; } if (defined &main::dumpValue) { - &main::dumpValue(shift); + my $v = shift; + my $maxdepth = shift || $option{dumpDepth}; + $maxdepth = -1 unless defined $maxdepth; # -1 means infinite depth + &main::dumpValue($v, $maxdepth); } else { print $OUT "dumpvar.pl not available.\n"; } @@ -2184,7 +2188,7 @@ sub parse_options { # too dangerous to let intuitive usage overwrite important things # defaultion should never be the default my %opt_needs_val = map { ( $_ => 1 ) } qw{ - arrayDepth hashDepth LineInfo maxTraceLen ornaments windowSize + dumpDepth arrayDepth hashDepth LineInfo maxTraceLen ornaments windowSize pager quote ReadLine recallCommand RemotePort ShellBang TTY }; while (length) { diff --git a/pod/perldebug.pod b/pod/perldebug.pod index b711094..833d887 100644 --- a/pod/perldebug.pod +++ b/pod/perldebug.pod @@ -581,6 +581,11 @@ commands: Print only first N elements ('' for all). +=item C + +Limit recursion depth to N levels when dumping structures. +Negative values are interpreted as infinity. Default: infinity. + =item C, C Change the style of array and hash output. If C, short array