In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Matthew O. Persico) writes:
>On 11 Jan 2004 17:33:32 -0000, Peter Scott wrote:
>> In article <[EMAIL PROTECTED]>,
>> [EMAIL PROTECTED] (Gabor Szabo) writes:
>>>
>>> Any idea how can I use the debugger to find the cause of
>>> a deep recursion in my code ?
>>
>> I don't see the need for the debugger.  Deep recursion is a
>> warning, so
>> just turn the warning into a fatal error with stack trace:
>>
>> % perl -MCarp=confess -we '$SIG{__WARN__} = sub {confess @_ }; \
>> sub foo { foo() } foo'
>
>Since this will turn ALL warnings into errors, you will have to make sure
> you don't have any warning-causing code in your program before you get to
> the recursion. 

True.  In which case, something like

        $SIG{__WARN__} = sub { $_[0] =~ /recursion/ and confess @_; warn @_ }

should work (untested).

> You will also have to throw the -w switch when you call perl
> (as specified in the example above). If you currently are not running with
> -w (or use warnings;), be prepared for some cleanup work.

The "deep recursion" message only shows up with -w/use warnings, so I
assumed one of them was already turned on.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/

Reply via email to