home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / unixtool.zip / TOOLS / lib / perl / perldb.pl < prev    next >
Perl Script  |  2000-04-21  |  17KB  |  607 lines

  1. package DB;
  2.  
  3. # modified Perl debugger, to be run from Emacs in perldb-mode
  4. # Ray Lischner (uunet!mntgfx!lisch) as of 5 Nov 1990
  5. # Johan Vromans -- upgrade to 4.0 pl 10
  6.  
  7. $header = '$RCSfile: perldb.pl,v $$Revision: 1.2 $$Date: 1996/07/29 21:20:18 $';
  8. #
  9. # This file is automatically included if you do perl -d.
  10. # It's probably not useful to include this yourself.
  11. #
  12. # Perl supplies the values for @line and %sub.  It effectively inserts
  13. # a do DB'DB(<linenum>); in front of every place that can
  14. # have a breakpoint.  It also inserts a do 'perldb.pl' before the first line.
  15. #
  16. # $Log: perldb.pl,v $
  17. # Revision 1.2  1996/07/29 21:20:18  jfk
  18. # merge GK branch into trunk
  19. #
  20. # Revision 1.1.2.2  1996/03/05 16:07:46  johnson
  21. # Fixed PR 13178.  Avoid doing pattern matching which overrides values of $', $`, and $&.
  22. #
  23. # Revision 1.1  1993/04/22  15:49:12  isdk
  24. # Initial load of perl source for NT port
  25. #
  26. # Revision 4.0.1.3  92/06/08  13:43:57  lwall
  27. # patch20: support for MSDOS folded into perldb.pl
  28. # patch20: perldb couldn't debug file containing '-', such as STDIN designator
  29. # Revision 4.0.1.2  91/11/05  17:55:58  lwall
  30. # patch11: perldb.pl modified to run within emacs in perldb-mode
  31. # Revision 4.0.1.1  91/06/07  11:17:44  lwall
  32. # patch4: added $^P variable to control calling of perldb routines
  33. # patch4: debugger sometimes listed wrong number of lines for a statement
  34. # Revision 4.0  91/03/20  01:25:50  lwall
  35. # 4.0 baseline.
  36. # Revision 3.0.1.6  91/01/11  18:08:58  lwall
  37. # patch42: @_ couldn't be accessed from debugger
  38. # Revision 3.0.1.5  90/11/10  01:40:26  lwall
  39. # patch38: the debugger wouldn't stop correctly or do action routines
  40. # Revision 3.0.1.4  90/10/15  17:40:38  lwall
  41. # patch29: added caller
  42. # patch29: the debugger now understands packages and evals
  43. # patch29: scripts now run at almost full speed under the debugger
  44. # patch29: more variables are settable from debugger
  45. # Revision 3.0.1.3  90/08/09  04:00:58  lwall
  46. # patch19: debugger now allows continuation lines
  47. # patch19: debugger can now dump lists of variables
  48. # patch19: debugger can now add aliases easily from prompt
  49. # Revision 3.0.1.2  90/03/12  16:39:39  lwall
  50. # patch13: perl -d didn't format stack traces of *foo right
  51. # patch13: perl -d wiped out scalar return values of subroutines
  52. # Revision 3.0.1.1  89/10/26  23:14:02  lwall
  53. # patch1: RCS expanded an unintended $Header in lib/perldb.pl
  54. # Revision 3.0  89/10/18  15:19:46  lwall
  55. # 3.0 baseline
  56. # Revision 2.0  88/06/05  00:09:45  root
  57. # Baseline version 2.0.
  58. #
  59.  
  60. if (-e "/dev/tty") {
  61.     $console = "/dev/tty";
  62.     $rcfile=".perldb";
  63. }
  64. else {
  65.     $console = "con";
  66.     $rcfile="perldb.ini";
  67. }
  68.  
  69. open(IN, "<$console") || open(IN,  "<&STDIN");    # so we don't dingle stdin
  70. open(OUT,">$console") || open(OUT, ">&STDOUT");    # so we don't dongle stdout
  71. select(OUT);
  72. $| = 1;                # for DB'OUT
  73. select(STDOUT);
  74. $| = 1;                # for real STDOUT
  75. $sub = '';
  76.  
  77. # Is Perl being run from Emacs?
  78. $emacs = $main'ARGV[$[] eq '-emacs';
  79. shift(@main'ARGV) if $emacs;
  80.  
  81. $header =~ s/.Header: ([^,]+),v(\s+\S+\s+\S+).*$/$1$2/;
  82. print OUT "\nLoading DB routines from $header\n";
  83. print OUT ("Emacs support ",
  84.        $emacs ? "enabled" : "available",
  85.        ".\n");
  86. print OUT "\nEnter h for help.\n\n";
  87.  
  88. sub DB {
  89.     &save;
  90.     ($package, $filename, $line) = caller;
  91.     $usercontext = '($@, $!, $[, $,, $/, $\) = @saved;' .
  92.     "package $package;";        # this won't let them modify, alas
  93.     local($^P) = 0;            # don't debug our own evals
  94.     local(*dbline) = "_<$filename";
  95.     $max = $#dbline;
  96.     if (($stop,$action) = split(/\0/,$dbline{$line})) {
  97.     if ($stop eq '1') {
  98.         $signal |= 1;
  99.     }
  100.     else {
  101.         $evalarg = "\$DB'signal |= do {$stop;}"; &eval;
  102.         $dbline{$line} =~ s/;9($|\0)/$1/;
  103.     }
  104.     }
  105.     if ($single || $trace || $signal) {
  106.     if ($emacs) {
  107.         print OUT "\032\032$filename:$line:0\n";
  108.     } else {
  109.         # We don't use $sub =~ /'/ because that sets special variables
  110.         # and may affect the results of the script we're debugging.
  111.         print OUT "$package'" unless index($sub,"'") != $[ - 1;
  112.         print OUT "$sub($filename:$line):\t",$dbline[$line];
  113.         for ($i = $line + 1; $i <= $max && $dbline[$i] == 0; ++$i) {
  114.         last if $dbline[$i] =~ /^\s*(}|#|\n)/;
  115.         print OUT "$sub($filename:$i):\t",$dbline[$i];
  116.         }
  117.     }
  118.     }
  119.     $evalarg = $action, &eval if $action;
  120.     if ($single || $signal) {
  121.     $evalarg = $pre, &eval if $pre;
  122.     print OUT $#stack . " levels deep in subroutine calls!\n"
  123.         if $single & 4;
  124.     $start = $line;
  125.       CMD:
  126.     while ((print OUT "  DB<", $#hist+1, "> "), $cmd=&gets) {
  127.         {
  128.         $single = 0;
  129.         $signal = 0;
  130.         $cmd eq '' && exit 0;
  131.         chop($cmd);
  132.         $cmd =~ s/\\$// && do {
  133.             print OUT "  cont: ";
  134.             $cmd .= &gets;
  135.             redo CMD;
  136.         };
  137.         $cmd =~ /^q$/ && exit 0;
  138.         $cmd =~ /^$/ && ($cmd = $laststep);
  139.         push(@hist,$cmd) if length($cmd) > 1;
  140.         ($i) = split(/\s+/,$cmd);
  141.         eval "\$cmd =~ $alias{$i}", print OUT $@ if $alias{$i};
  142.         $cmd =~ /^h$/ && do {
  143.             print OUT "
  144. T        Stack trace.
  145. s        Single step.
  146. n        Next, steps over subroutine calls.
  147. r        Return from current subroutine.
  148. c [line]    Continue; optionally inserts a one-time-only breakpoint 
  149.         at the specified line.
  150. <CR>        Repeat last n or s.
  151. l min+incr    List incr+1 lines starting at min.
  152. l min-max    List lines.
  153. l line        List line;
  154. l        List next window.
  155. -        List previous window.
  156. w line        List window around line.
  157. l subname    List subroutine.
  158. f filename    Switch to filename.
  159. /pattern/    Search forwards for pattern; final / is optional.
  160. ?pattern?    Search backwards for pattern.
  161. L        List breakpoints and actions.
  162. S        List subroutine names.
  163. t        Toggle trace mode.
  164. b [line] [condition]
  165.         Set breakpoint; line defaults to the current execution line; 
  166.         condition breaks if it evaluates to true, defaults to \'1\'.
  167. b subname [condition]
  168.         Set breakpoint at first line of subroutine.
  169. d [line]    Delete breakpoint.
  170. D        Delete all breakpoints.
  171. a [line] command
  172.         Set an action to be done before the line is executed.
  173.         Sequence is: check for breakpoint, print line if necessary,
  174.         do action, prompt user if breakpoint or step, evaluate line.
  175. A        Delete all actions.
  176. V [pkg [vars]]    List some (default all) variables in package (default current).
  177. X [vars]    Same as \"V currentpackage [vars]\".
  178. < command    Define command before prompt.
  179. > command    Define command after prompt.
  180. ! number    Redo command (default previous command).
  181. ! -number    Redo number\'th to last command.
  182. H -number    Display last number commands (default all).
  183. q or ^D        Quit.
  184. p expr        Same as \"print DB'OUT expr\" in current package.
  185. = [alias value]    Define a command alias, or list current aliases.
  186. command        Execute as a perl statement in current package.
  187.  
  188. ";
  189.             next CMD; };
  190.         $cmd =~ /^t$/ && do {
  191.             $trace = !$trace;
  192.             print OUT "Trace = ".($trace?"on":"off")."\n";
  193.             next CMD; };
  194.         $cmd =~ /^S$/ && do {
  195.             foreach $subname (sort(keys %sub)) {
  196.             print OUT $subname,"\n";
  197.             }
  198.             next CMD; };
  199.         $cmd =~ s/^X\b/V $package/;
  200.         $cmd =~ /^V$/ && do {
  201.             $cmd = 'V $package'; };
  202.         $cmd =~ /^V\b\s*(\S+)\s*(.*)/ && do {
  203.             $packname = $1;
  204.             @vars = split(' ',$2);
  205.             do 'dumpvar.pl' unless defined &main'dumpvar;
  206.             if (defined &main'dumpvar) {
  207.             &main'dumpvar($packname,@vars);
  208.             }
  209.             else {
  210.             print DB'OUT "dumpvar.pl not available.\n";
  211.             }
  212.             next CMD; };
  213.         $cmd =~ /^f\b\s*(.*)/ && do {
  214.             $file = $1;
  215.             if (!$file) {
  216.             print OUT "The old f command is now the r command.\n";
  217.             print OUT "The new f command switches filenames.\n";
  218.             next CMD;
  219.             }
  220.             if (!defined $_main{'_<' . $file}) {
  221.             if (($try) = grep(m#^_<.*$file#, keys %_main)) {
  222.                 $file = substr($try,2);
  223.                 print "\n$file:\n";
  224.             }
  225.             }
  226.             if (!defined $_main{'_<' . $file}) {
  227.             print OUT "There's no code here anything matching $file.\n";
  228.             next CMD;
  229.             }
  230.             elsif ($file ne $filename) {
  231.             *dbline = "_<$file";
  232.             $max = $#dbline;
  233.             $filename = $file;
  234.             $start = 1;
  235.             $cmd = "l";
  236.             } };
  237.         $cmd =~ /^l\b\s*(['A-Za-z_]['\w]*)/ && do {
  238.             $subname = $1;
  239.             $subname = "main'" . $subname unless $subname =~ /'/;
  240.             $subname = "main" . $subname if substr($subname,0,1) eq "'";
  241.             ($file,$subrange) = split(/:/,$sub{$subname});
  242.             if ($file ne $filename) {
  243.             *dbline = "_<$file";
  244.             $max = $#dbline;
  245.             $filename = $file;
  246.             }
  247.             if ($subrange) {
  248.             if (eval($subrange) < -$window) {
  249.                 $subrange =~ s/-.*/+/;
  250.             }
  251.             $cmd = "l $subrange";
  252.             } else {
  253.             print OUT "Subroutine $1 not found.\n";
  254.             next CMD;
  255.             } };
  256.         $cmd =~ /^w\b\s*(\d*)$/ && do {
  257.             $incr = $window - 1;
  258.             $start = $1 if $1;
  259.             $start -= $preview;
  260.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  261.         $cmd =~ /^-$/ && do {
  262.             $incr = $window - 1;
  263.             $cmd = 'l ' . ($start-$window*2) . '+'; };
  264.         $cmd =~ /^l$/ && do {
  265.             $incr = $window - 1;
  266.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  267.         $cmd =~ /^l\b\s*(\d*)\+(\d*)$/ && do {
  268.             $start = $1 if $1;
  269.             $incr = $2;
  270.             $incr = $window - 1 unless $incr;
  271.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  272.         $cmd =~ /^l\b\s*(([\d\$\.]+)([-,]([\d\$\.]+))?)?/ && do {
  273.             $end = (!$2) ? $max : ($4 ? $4 : $2);
  274.             $end = $max if $end > $max;
  275.             $i = $2;
  276.             $i = $line if $i eq '.';
  277.             $i = 1 if $i < 1;
  278.             if ($emacs) {
  279.             print OUT "\032\032$filename:$i:0\n";
  280.             $i = $end;
  281.             } else {
  282.             for (; $i <= $end; $i++) {
  283.                 print OUT "$i:\t", $dbline[$i];
  284.                 last if $signal;
  285.             }
  286.             }
  287.             $start = $i;    # remember in case they want more
  288.             $start = $max if $start > $max;
  289.             next CMD; };
  290.         $cmd =~ /^D$/ && do {
  291.             print OUT "Deleting all breakpoints...\n";
  292.             for ($i = 1; $i <= $max ; $i++) {
  293.             if (defined $dbline{$i}) {
  294.                 $dbline{$i} =~ s/^[^\0]+//;
  295.                 if ($dbline{$i} =~ s/^\0?$//) {
  296.                 delete $dbline{$i};
  297.                 }
  298.             }
  299.             }
  300.             next CMD; };
  301.         $cmd =~ /^L$/ && do {
  302.             for ($i = 1; $i <= $max; $i++) {
  303.             if (defined $dbline{$i}) {
  304.                 print OUT "$i:\t", $dbline[$i];
  305.                 ($stop,$action) = split(/\0/, $dbline{$i});
  306.                 print OUT "  break if (", $stop, ")\n" 
  307.                 if $stop;
  308.                 print OUT "  action:  ", $action, "\n" 
  309.                 if $action;
  310.                 last if $signal;
  311.             }
  312.             }
  313.             next CMD; };
  314.         $cmd =~ /^b\b\s*(['A-Za-z_]['\w]*)\s*(.*)/ && do {
  315.             $subname = $1;
  316.             $cond = $2 || '1';
  317.             $subname = "$package'" . $subname unless $subname =~ /'/;
  318.             $subname = "main" . $subname if substr($subname,0,1) eq "'";
  319.             ($filename,$i) = split(/:/, $sub{$subname});
  320.             $i += 0;
  321.             if ($i) {
  322.             *dbline = "_<$filename";
  323.             ++$i while $dbline[$i] == 0 && $i < $#dbline;
  324.             $dbline{$i} =~ s/^[^\0]*/$cond/;
  325.             } else {
  326.             print OUT "Subroutine $subname not found.\n";
  327.             }
  328.             next CMD; };
  329.         $cmd =~ /^b\b\s*(\d*)\s*(.*)/ && do {
  330.             $i = ($1?$1:$line);
  331.             $cond = $2 || '1';
  332.             if ($dbline[$i] == 0) {
  333.             print OUT "Line $i not breakable.\n";
  334.             } else {
  335.             $dbline{$i} =~ s/^[^\0]*/$cond/;
  336.             }
  337.             next CMD; };
  338.         $cmd =~ /^d\b\s*(\d+)?/ && do {
  339.             $i = ($1?$1:$line);
  340.             $dbline{$i} =~ s/^[^\0]*//;
  341.             delete $dbline{$i} if $dbline{$i} eq '';
  342.             next CMD; };
  343.         $cmd =~ /^A$/ && do {
  344.             for ($i = 1; $i <= $max ; $i++) {
  345.             if (defined $dbline{$i}) {
  346.                 $dbline{$i} =~ s/\0[^\0]*//;
  347.                 delete $dbline{$i} if $dbline{$i} eq '';
  348.             }
  349.             }
  350.             next CMD; };
  351.         $cmd =~ /^<\s*(.*)/ && do {
  352.             $pre = do action($1);
  353.             next CMD; };
  354.         $cmd =~ /^>\s*(.*)/ && do {
  355.             $post = do action($1);
  356.             next CMD; };
  357.         $cmd =~ /^a\b\s*(\d+)(\s+(.*))?/ && do {
  358.             $i = $1;
  359.             if ($dbline[$i] == 0) {
  360.             print OUT "Line $i may not have an action.\n";
  361.             } else {
  362.             $dbline{$i} =~ s/\0[^\0]*//;
  363.             $dbline{$i} .= "\0" . do action($3);
  364.             }
  365.             next CMD; };
  366.         $cmd =~ /^n$/ && do {
  367.             $single = 2;
  368.             $laststep = $cmd;
  369.             last CMD; };
  370.         $cmd =~ /^s$/ && do {
  371.             $single = 1;
  372.             $laststep = $cmd;
  373.             last CMD; };
  374.         $cmd =~ /^c\b\s*(\d*)\s*$/ && do {
  375.             $i = $1;
  376.             if ($i) {
  377.             if ($dbline[$i] == 0) {
  378.                 print OUT "Line $i not breakable.\n";
  379.                 next CMD;
  380.             }
  381.             $dbline{$i} =~ s/(\0|$)/;9$1/;    # add one-time-only b.p.
  382.             }
  383.             for ($i=0; $i <= $#stack; ) {
  384.             $stack[$i++] &= ~1;
  385.             }
  386.             last CMD; };
  387.         $cmd =~ /^r$/ && do {
  388.             $stack[$#stack] |= 2;
  389.             last CMD; };
  390.         $cmd =~ /^T$/ && do {
  391.             local($p,$f,$l,$s,$h,$a,@a,@sub);
  392.             for ($i = 1; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
  393.             @a = @args;
  394.             for (@a) {
  395.                 if (/^StB\000/ && length($_) == length($_main{'_main'})) {
  396.                 $_ = sprintf("%s",$_);
  397.                 }
  398.                 else {
  399.                 s/'/\\'/g;
  400.                 s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
  401.                 s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
  402.                 s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
  403.                 }
  404.             }
  405.             $w = $w ? '@ = ' : '$ = ';
  406.             $a = $h ? '(' . join(', ', @a) . ')' : '';
  407.             push(@sub, "$w&$s$a from file $f line $l\n");
  408.             last if $signal;
  409.             }
  410.             for ($i=0; $i <= $#sub; $i++) {
  411.             last if $signal;
  412.             print OUT $sub[$i];
  413.             }
  414.             next CMD; };
  415.         $cmd =~ /^\/(.*)$/ && do {
  416.             $inpat = $1;
  417.             $inpat =~ s:([^\\])/$:$1:;
  418.             if ($inpat ne "") {
  419.             eval '$inpat =~ m'."\n$inpat\n";    
  420.             if ($@ ne "") {
  421.                 print OUT "$@";
  422.                 next CMD;
  423.             }
  424.             $pat = $inpat;
  425.             }
  426.             $end = $start;
  427.             eval '
  428.             for (;;) {
  429.             ++$start;
  430.             $start = 1 if ($start > $max);
  431.             last if ($start == $end);
  432.             if ($dbline[$start] =~ m'."\n$pat\n".'i) {
  433.                 if ($emacs) {
  434.                 print OUT "\032\032$filename:$start:0\n";
  435.                 } else {
  436.                 print OUT "$start:\t", $dbline[$start], "\n";
  437.                 }
  438.                 last;
  439.             }
  440.             } ';
  441.             print OUT "/$pat/: not found\n" if ($start == $end);
  442.             next CMD; };
  443.         $cmd =~ /^\?(.*)$/ && do {
  444.             $inpat = $1;
  445.             $inpat =~ s:([^\\])\?$:$1:;
  446.             if ($inpat ne "") {
  447.             eval '$inpat =~ m'."\n$inpat\n";    
  448.             if ($@ ne "") {
  449.                 print OUT "$@";
  450.                 next CMD;
  451.             }
  452.             $pat = $inpat;
  453.             }
  454.             $end = $start;
  455.             eval '
  456.             for (;;) {
  457.             --$start;
  458.             $start = $max if ($start <= 0);
  459.             last if ($start == $end);
  460.             if ($dbline[$start] =~ m'."\n$pat\n".'i) {
  461.                 if ($emacs) {
  462.                 print OUT "\032\032$filename:$start:0\n";
  463.                 } else {
  464.                 print OUT "$start:\t", $dbline[$start], "\n";
  465.                 }
  466.                 last;
  467.             }
  468.             } ';
  469.             print OUT "?$pat?: not found\n" if ($start == $end);
  470.             next CMD; };
  471.         $cmd =~ /^!+\s*(-)?(\d+)?$/ && do {
  472.             pop(@hist) if length($cmd) > 1;
  473.             $i = ($1?($#hist-($2?$2:1)):($2?$2:$#hist));
  474.             $cmd = $hist[$i] . "\n";
  475.             print OUT $cmd;
  476.             redo CMD; };
  477.         $cmd =~ /^!(.+)$/ && do {
  478.             $pat = "^$1";
  479.             pop(@hist) if length($cmd) > 1;
  480.             for ($i = $#hist; $i; --$i) {
  481.             last if $hist[$i] =~ $pat;
  482.             }
  483.             if (!$i) {
  484.             print OUT "No such command!\n\n";
  485.             next CMD;
  486.             }
  487.             $cmd = $hist[$i] . "\n";
  488.             print OUT $cmd;
  489.             redo CMD; };
  490.         $cmd =~ /^H\b\s*(-(\d+))?/ && do {
  491.             $end = $2?($#hist-$2):0;
  492.             $hist = 0 if $hist < 0;
  493.             for ($i=$#hist; $i>$end; $i--) {
  494.             print OUT "$i: ",$hist[$i],"\n"
  495.                 unless $hist[$i] =~ /^.?$/;
  496.             };
  497.             next CMD; };
  498.         $cmd =~ s/^p( .*)?$/print DB'OUT$1/;
  499.         $cmd =~ /^=/ && do {
  500.             if (local($k,$v) = ($cmd =~ /^=\s*(\S+)\s+(.*)/)) {
  501.             $alias{$k}="s~$k~$v~";
  502.             print OUT "$k = $v\n";
  503.             } elsif ($cmd =~ /^=\s*$/) {
  504.             foreach $k (sort keys(%alias)) {
  505.                 if (($v = $alias{$k}) =~ s~^s\~$k\~(.*)\~$~$1~) {
  506.                 print OUT "$k = $v\n";
  507.                 } else {
  508.                 print OUT "$k\t$alias{$k}\n";
  509.                 };
  510.             };
  511.             };
  512.             next CMD; };
  513.         }
  514.         $evalarg = $cmd; &eval;
  515.         print OUT "\n";
  516.     }
  517.     if ($post) {
  518.         $evalarg = $post; &eval;
  519.     }
  520.     }
  521.     ($@, $!, $[, $,, $/, $\) = @saved;
  522. }
  523.  
  524. sub save {
  525.     @saved = ($@, $!, $[, $,, $/, $\);
  526.     $[ = 0; $, = ""; $/ = "\n"; $\ = "";
  527. }
  528.  
  529. # The following takes its argument via $evalarg to preserve current @_
  530.  
  531. sub eval {
  532.     eval "$usercontext $evalarg; &DB'save";
  533.     print OUT $@;
  534. }
  535.  
  536. sub action {
  537.     local($action) = @_;
  538.     while ($action =~ s/\\$//) {
  539.     print OUT "+ ";
  540.     $action .= &gets;
  541.     }
  542.     $action;
  543. }
  544.  
  545. sub gets {
  546.     local($.);
  547.     <IN>;
  548. }
  549.  
  550. sub catch {
  551.     $signal = 1;
  552. }
  553.  
  554. sub sub {
  555.     push(@stack, $single);
  556.     $single &= 1;
  557.     $single |= 4 if $#stack == $deep;
  558.     if (wantarray) {
  559.     @i = &$sub;
  560.     $single |= pop(@stack);
  561.     @i;
  562.     }
  563.     else {
  564.     $i = &$sub;
  565.     $single |= pop(@stack);
  566.     $i;
  567.     }
  568. }
  569.  
  570. $single = 1;            # so it stops on first executable statement
  571. @hist = ('?');
  572. $SIG{'INT'} = "DB'catch";
  573. $deep = 100;        # warning if stack gets this deep
  574. $window = 10;
  575. $preview = 3;
  576.  
  577. @stack = (0);
  578. @ARGS = @ARGV;
  579. for (@args) {
  580.     s/'/\\'/g;
  581.     s/(.*)/'$1'/ unless /^-?[\d.]+$/;
  582. }
  583.  
  584. if (-f $rcfile) {
  585.     do "./$rcfile";
  586. }
  587. elsif (-f "$ENV{'LOGDIR'}/$rcfile") {
  588.     do "$ENV{'LOGDIR'}/$rcfile";
  589. }
  590. elsif (-f "$ENV{'HOME'}/$rcfile") {
  591.     do "$ENV{'HOME'}/$rcfile";
  592. }
  593.  
  594. 1;
  595.