This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.h: Fold 2 ANYOF flags into a single one
[perl5.git] / lib / DB.pm
index 2575423..404c57c 100644 (file)
--- a/lib/DB.pm
+++ b/lib/DB.pm
@@ -38,17 +38,17 @@ BEGIN {
 
   $DB::package = '';    # current package space
   $DB::filename = '';   # current filename
-  $DB::subname = '';    # currently executing sub (fullly qualified name)
+  $DB::subname = '';    # currently executing sub (fully qualified name)
   $DB::lineno = '';     # current line number
 
-  $DB::VERSION = $DB::VERSION = '1.0';
+  $DB::VERSION = $DB::VERSION = '1.08';
 
   # initialize private globals to avoid warnings
 
   $running = 1;         # are we running, or are we stopped?
   @stack = (0);
   @clients = ();
-  $deep = 100;
+  $deep = 1000;
   $ready = 0;
   @saved = ();
   @skippkg = ();
@@ -63,8 +63,7 @@ sub sub {
   push(@stack, $DB::single);
   $DB::single &= 1;
   $DB::single |= 4 if $#stack == $deep;
-#  print $DB::sub, "\n";
-  if ($DB::sub =~ /(?:^|::)DESTROY$/ or not defined wantarray) {
+  if ($DB::sub eq 'DESTROY' or substr($DB::sub, -9) eq '::DESTROY' or not defined wantarray) {
     &$DB::sub;
     $DB::single |= pop(@stack);
     $DB::ret = undef;
@@ -93,6 +92,7 @@ sub DB {
 
   $usrctxt = "package $DB::package;";          # this won't let them modify, alas
   local(*DB::dbline) = "::_<$DB::filename";
+
   my ($stop, $action);
   if (($stop,$action) = split(/\0/,$DB::dbline{$DB::lineno})) {
     if ($stop eq '1') {
@@ -244,8 +244,8 @@ sub backtrace {
     for (@a) {
       s/'/\\'/g;
       s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
-      s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
-      s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
+      require 'meta_notation.pm';
+      $_ = _meta_notation($_) if /[[:^print:]]/a;
     }
     $w = $w ? '@ = ' : '$ = ';
     $a = $h ? '(' . join(', ', @a) . ')' : '';
@@ -258,7 +258,7 @@ sub backtrace {
     } elsif ($s eq '(eval)') {
       $s = "eval {...}";
     }
-    $f = "file `$f'" unless $f eq '-e';
+    $f = "file '$f'" unless $f eq '-e';
     push @ret, "$w&$s$a from $f line $l";
     last if $DB::signal;
   }
@@ -406,8 +406,7 @@ sub _find_subline {
   $name = "main" . $name if substr($name,0,2) eq "::";
   my($fname, $from, $to) = ($DB::sub{$name} =~ /^(.*):(\d+)-(\d+)$/);
   if ($from) {
-    # XXX this needs local()-ization of some sort
-    *DB::dbline = "::_<$fname";
+    local *DB::dbline = "::_<$fname";
     ++$from while $DB::dbline[$from] == 0 && $from < $to;
     return $from;
   }
@@ -547,21 +546,21 @@ __END__
 
 =head1 NAME
 
-DB - programmatic interface to the Perl debugging API (draft, subject to
-change)
+DB - programmatic interface to the Perl debugging API
 
 =head1 SYNOPSIS
 
     package CLIENT;
     use DB;
     @ISA = qw(DB);
-    
+
     # these (inherited) methods can be called by the client
-    
+
     CLIENT->register()      # register a client package name
     CLIENT->done()          # de-register from the debugging API
     CLIENT->skippkg('hide::hide')  # ask DB not to stop in this package
-    CLIENT->cont([WHERE])       # run some more (until BREAK or another breakpt)
+    CLIENT->cont([WHERE])       # run some more (until BREAK or 
+                                # another breakpointt)
     CLIENT->step()              # single step
     CLIENT->next()              # step over
     CLIENT->ret()               # return from current subroutine
@@ -585,12 +584,13 @@ change)
     # These methods will be called at the appropriate times.
     # Stub versions provided do nothing.
     # None of these can block.
-    
+
     CLIENT->init()          # called when debug API inits itself
     CLIENT->stop(FILE,LINE) # when execution stops
     CLIENT->idle()          # while stopped (can be a client event loop)
     CLIENT->cleanup()       # just before exit
-    CLIENT->output(LIST)    # called to print any output that API must show
+    CLIENT->output(LIST)    # called to print any output that
+                            # the API must show
 
 =head1 DESCRIPTION