in reply to How do I get a post mortem stack trace?

Thanks everyone for your suggestions here.

Of course (Doh!) once I know the line where the program is failing, I can set a break in the previous executable line, and if it's the first line in a sub, set a break on the sub.

This has given me enough information for a bug report for the original problem I had, but I could imagine there might be some problems if the code is inside a coderef and/or an eval (yes, I do do tortuous things with coderefs sometimes as fever knows :-).

However, I still think that the debugger could benefit from a better handler to catch $SIG{__DIE__}, enabling you to look at lexical variables in scope at the point where it dies, and the good ol' stack trace. Where or to whom do I post such a suggestion?

Also, I could use (and I am thinking of writing when I get a round tuit) a generic script called confessor.pl, which takes a script and argv list, sets up the die handler which will confess, then requires in the script. I have had a brief stab at this, but there are issues with BEGIN code, and the scripts are not designed to be 'require'd so they do not return true.

Update: Maybe a form of use Carp qw(verbose); should catch $SIG{__DIE__}. Possibly use Carp qw(verbose,catchdie);

Update 2: Just tried the suggestion use diagnostics; or rather perl -Mdiagnostics foobar.pl from anonymonk below. It does the business! Anonymonk++ whoever you are! Sign up to the monastery with an ID, your input is most welcome.

Replies are listed 'Best First'.
Re: Re: How do I get a post mortem stack trace?
by demerphq (Chancellor) on Nov 12, 2002 at 11:04 UTC
    Recently a very interesting post/patch was made to p5p that looks like it could meet your debugging requirements (and make Carp::Assert redundant). If it gets in it will be in version 5.10 however. :-(

    --- demerphq
    my friends call me, usually because I'm late....

Re: Re: How do I get a post mortem stack trace?
by BrowserUk (Patriarch) on Nov 12, 2002 at 11:07 UTC

    and the scripts are not designed to be 'require'd so they do not return true.

    Maybe you could use the do 'stat.pl'; syntax instead?


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.