New command syntax for 'x' command
authorMark-Jason Dominus <mjd@plover.com>
Tue, 12 Feb 2002 20:54:01 +0000 (15:54 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 13 Feb 2002 05:12:28 +0000 (05:12 +0000)
Message-ID: <20020213015401.25685.qmail@plover.com>

p4raw-id: //depot/perl@14671

lib/perl5db.pl
pod/perldebug.pod

index 1f50211..4e7ff9e 100644 (file)
@@ -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";
            }
index 833d887..fce444e 100644 (file)
@@ -78,7 +78,7 @@ data structures and objects are not dumped, unlike with the C<x> command.
 The C<DB::OUT> filehandle is opened to F</dev/tty>, 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<Dumpvalue> if you'd like to do this yourself.
 The output format is governed by multiple options described under
 L<"Configurable Options">.
 
+If the C<maxdepth> is included, it must be a numeral I<N>; the value is
+dumped only I<N> levels deep, as if the C<dumpDepth> option had been
+deporarily set to I<N>.
+
 =item V [pkg [vars]]
 
 Display all (or some) variables in package (defaulting to C<main>)