From 3ae893bd03a243c0d4ba2d7741ae988e0043470f Mon Sep 17 00:00:00 2001 From: Mark-Jason Dominus Date: Tue, 12 Feb 2002 15:54:01 -0500 Subject: [PATCH] New command syntax for 'x' command Message-ID: <20020213015401.25685.qmail@plover.com> p4raw-id: //depot/perl@14671 --- lib/perl5db.pl | 17 ++++++++++++++--- pod/perldebug.pod | 6 +++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 1f50211..4e7ff9e 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -23,8 +23,13 @@ sub eval { if ($at) { print $OUT $at; } elsif ($onetimeDump) { - dumpit($OUT, \@res) if $onetimeDump eq 'dump'; - methods($res[0]) if $onetimeDump eq 'methods'; + if ($onetimeDump eq 'dump') { + local $option{dumpDepth} = $onetimedumpDepth + if defined $onetimedumpDepth; + dumpit($OUT, \@res); + } elsif ($onetimeDump eq 'methods') { + methods($res[0]) ; + } } @res; } @@ -821,7 +826,12 @@ EOP select ($savout); next CMD; }; $cmd =~ s/^x\b/ / && do { # So that will be evaled - $onetimeDump = 'dump'; }; + $onetimeDump = 'dump'; + # handle special "x 3 blah" syntax + if ($cmd =~ s/^\s*(\d+)(?=\s)/ /) { + $onetimedumpDepth = $1; + } + }; $cmd =~ s/^m\s+([\w:]+)\s*$/ / && do { methods($1); next CMD}; $cmd =~ s/^m\b/ / && do { # So this will be evaled @@ -1522,6 +1532,7 @@ EOP $evalarg = "\$^D = \$^D | \$DB::db_stop;\n$cmd"; &eval; if ($onetimeDump) { $onetimeDump = undef; + $onetimedumpDepth = undef; } elsif ($term_pid == $$) { print $OUT "\n"; } diff --git a/pod/perldebug.pod b/pod/perldebug.pod index 833d887..fce444e 100644 --- a/pod/perldebug.pod +++ b/pod/perldebug.pod @@ -78,7 +78,7 @@ data structures and objects are not dumped, unlike with the C command. The C filehandle is opened to F, regardless of where STDOUT may be redirected to. -=item x expr +=item x [maxdepth] expr Evaluates its expression in list context and dumps out the result in a pretty-printed fashion. Nested data structures are printed out @@ -88,6 +88,10 @@ See L if you'd like to do this yourself. The output format is governed by multiple options described under L<"Configurable Options">. +If the C is included, it must be a numeral I; the value is +dumped only I levels deep, as if the C option had been +deporarily set to I. + =item V [pkg [vars]] Display all (or some) variables in package (defaulting to C
) -- 2.7.4