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.


In reply to Re: How do I get a post mortem stack trace? by rinceWind
in thread How do I get a post mortem stack trace? by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.