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

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.

Replies are listed 'Best First'.
Re^5: Debug recursion ?
by GrandFather (Saint) on Feb 25, 2007 at 00:42 UTC

    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
Re^5: Debug recursion ?
by diotalevi (Canon) on Feb 25, 2007 at 00:32 UTC

    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.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊