Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

schwern
  (email not shown publicly)
http://schwern.net/
AOL IM: MichaelSchwern (Add Buddy, Send Message)
Jabber: schwern@gmail.com

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Monday October 10, 2005
06:17 AM

I need a module name.

[ #27095 ]

Its simple. A module which turns every warning and death into a Carp::confess/cluck style stack trace. Everything, even if the warning or error is generated by Perl. I also want to see function arguments in the stack trace, extremely useful information, which is where all the other Java-esque stack trace modules on CPAN come up short.

I know how to implement it, just a little CORE::GLOBAL and $SIG{__FOO__} magic and let Carp::longmess() take care of the rest. What I don't have is a name. My working title at the moment is Carp::Everywhere. Got a better one?

(Someone please let me know if this module already exists, I don't need to maintain another.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Would you be thinking of Acme::JavaTrace [cpan.org] by any chance? I've never used it myself, but saw a good lightning talk about it at Belfast last year.

    • Sorry, I confused myself, I meant Devel::SimpleTrace [cpan.org]
      perl -MDevel::SimpleTrace  -e 'sub foo { die }; foo()'
      Died
              at main::foo(-e:1)
              at main::(-e:1)
      • That doesn't display the arguments passed to the functions in the caller stack.

        Devel::TraceSubs comes closer, but it gets confused if you do odd things with @_. I have a couple of bugs (13287 and 13302) on the issue. I've been trying to find the time to patch it but so far unsuccessful.

  • I would call it Carp::Enter :-)
  • I wrote such a module recently. I've called it Carp::Indeed and it uses import()> with CORE::GLOBAL::die() and CORE::GLOBAL::warn() to make it work. To be really honest, this current implementation does not work all the time. I thought about changing the implementation to use $SIG{__FOO__} stuff (which is probably even shorter than the current one - around ten lines of code), but I didn't made the time for this yet. Acme::JavaTrace inspired me.
    • I've just uploaded to CPAN the release 0.03 which does right a couple of things:

      $ perl -MCarp::Indeed -e "sub f { die 'horrible death' }; f('a')"
      horrible death at -e line 1
              main::f('a') called at -e line 1

      $ perl -MCarp::Indeed -e "sub f { use strict; my $a; my @a = @$a }; f('a')"
      Can't use an undefined value as an ARRAY reference at -e line 1
              main::f('a') called at -e line 1

      It is not as robust as it should yet, but better. Thanks, Schwern, for reassu

      • Carp::Indeed 0.03 is indeed doing almost exactly what I want in almost exactly the way I'd written it. Thank you.

        Except the name stinks, why did you choose that name? And the documentation is rather ranty... but that's fixable.
        • He he he. Well, from my non-native English speaker viewpoint, I even thought it was a good name. Yes, the documentation can be pruned down to a description up to the point. I will work on this. But wrt the name, I don't have a clue for a good name (as you noticed).
          • Carp::StackTrace would be a good name then. One would already have a pretty good idea what the module does, without opening the documentation.

            • Not a very good name if you ask me. The important thing isn't that it allows you to make stack traces, Carp already does that. Its that it allows you to make stack traces everywhere! This is why Carp::Everywhere appeals to me.
              • Oh right, I forgot that Carp could already do that. Still, I find "Everywhere" has a slightly cutesy ring to it.

                • Carp::Detailed
                • Carp::Maximum, ::Maximally
                • Carp::Verbose

                Besides, the functionality you want is confess, not carp...

                • Confess::Everything
                • Confess::Deathbed

                Some of my best friends are Catholics. I'll go ask them for some ideas :)

                • Still, I find "Everywhere" has a slightly cutesy ring to it.

                  At what point in this conversation did we stop talking about Perl and switch to Java?

                  Besides, the functionality you want is confess, not carp...
                   
                      Confess::Everything

                  I kinda like that one. We can add more layers of cultural references...

                          Inquisition::Spanish
                          Comfy::Chair
                          Soft::Pillow

                  • Alas, Monty::Python::Inquisition::Spanish is where Guido the Parselmouth [wikipedia.org] got his inspiration for thumbscrew indentation, so we loyal camelistas can't even quote the Camel Spotting sketch [ibras.dk] for fear of endorsing The Other Language [wikipedia.org].

                    Oh dear, I've gone and quoted it ... I'll have to go outside and turn three times.

                    </JOKE>

                    --
                    Bill
                    # I had a sig when sigs were cool
                    use Sig;
  • Would

        use warnings FATAL => qw(all);

    do something useful for you?
    • $ perl -wle 'use warnings FATAL => qw(all);  sub foo { warn "bar" }  foo(23);'
      bar at -e line 1.
      Note the remarkable lack of a stack trace. Also, I don't want warnings to die, I just want to be able to more easily diagnose them.
  • use lib '/home/msw';
    use MSW::Debug::DieWithCallStack;
    $SIG{__WARN__} = $SIG{__DIE__};
    That's not Rentrak code if you wanted to steal it for whatever purpose.
  • Carp::ChickenLittle
  • Or else, I like hfb's idea.

    --
    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
  • To point out the guilty party (culpability).
  • Carp::Tacular ? :)

    Carp::Vomit :D
    Carp::TheWhole9Yards

    ok enough silliness, what about Carp::StackTrace?
  • Carp::More

    Carpe'Diem

    :)

    --

    -DA [coder.com]

  • Devel::Errors::WithStackTrace