in reply to Re^2: Debug recursion ?
in thread Debug recursion ?

Your example is still not clear. However, if you have a breakpoint set inside the recursive function and want to stop breaking on it at some point simply remove the breakpoint. If you want to recurse to some depth then break you can typically set a "hit count" for the break point so that it doesn't fire until the line containing the breakpoint has been executed some specified number of times.

Note too that it is also possible to set a breakpoint that fires when some specific condition is true.

(This is based on the facilities provided by the Perl debugging in Komodo which I presume uses the standard Perl debugger under the hood.)


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^4: Debug recursion ?
by Alien (Monk) on Feb 24, 2007 at 23:46 UTC
    My breakpoint is after the recursive function. But the debugger can't reach that point because of the deep recursion. Here is an example code :
    sub fact { my $n=shift; if($n==0 || $n==1) { return 1; } return $n*fact($n-1); } print fact(107); print "\nOk\n";
    Start the program under the debugger and issue the following command : c 10 ( this should run the debugger to the 10th line , the one with print "\nOk\n" ) Instead , i receive the following message "100 levels deep in subroutine calls!" and using r can't return from the function.

      So why didn't you say that in your initial post? If you provide crap information you will get crap answers - surely you don't expect anything else?

      How about now you post something representative of your real problem?

      At worst you may need to revert to using print statements to trace execution and state rather than using the debugger, but it is likely that there are better ways to tackle your problem. If you tell us what the actual problem is we can help with some appropriate techniques for solving it.


      DWIM is Perl's answer to Gödel

      Right. You're wishing for abnormal flow control. Either that "100 levels deep" call into being a fatal error and catch it or contrive to change $n so that the recursion stops. The latter is trivial in the debugger.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊