Devel:...eTrace(3pm)

πŸ“¦
version 0.08 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ‘‘ Devel::SimpleTrace β€” the manual, but make it slay

okay bestie, gather round πŸ’– this is Devel::SimpleTrace (you'll see it styled as Devel:...eTrace(3pm) in the wild, and it lives in the User Contributed Perl Documentation section of the perl man pages). It's a perl module, it's tiny, it's powerful, and it will find the exact spot where your code is screaming. no cap.


✨ NAME ✨

Devel::SimpleTrace β€” See where you code warns and dies using stack traces πŸ¦‹

(yes, "you code" β€” that's literally how it's written, we don't fix, we preserve πŸ’…)


🌸 VERSION 🌸

Version 0.08


πŸŽ€ SYNOPSIS πŸŽ€

From the command-line, just yeet it in there with -M:

perl -wMDevel::SimpleTrace program_with_strange_errors.pl

Or, inside a module, lowkey just:

use Devel::SimpleTrace;

πŸ’œ DESCRIPTION πŸ’œ

So here's the vibe: this module helps you spot the exact place where a program or a module starts generating errors. it's giving "personal detective for your bugs" πŸ”

And the way you use it?? Extremely simple. Like, reduced to just useing it. that's the whole thing. iconic behaviour honestly.

The way it works is by modifying the functions warn() and die() so that instead of the standard messages you get complete stack traces that precisely indicate how and where the error or warning happened πŸ˜­πŸ‘‘

Other than that, their use should stay completely unchanged β€” even when you're using die() inside eval(). fr fr, nothing else shifts.


✨ OPTIONS ✨

You set options at import time, like this:

perl -wMDevel::SimpleTrace=option1,option2

or this:

use Devel::SimpleTrace qw(option1 option2);

The available options are:

  • showrefs β€” turning this on tells Devel::SimpleTrace to stringify objects and references that get passed in as an argument to die(). This option is disabled by default, and that's on purpose β€” it leaves your objects and references untouched until you say otherwise 🫢

🌈 EXAMPLE 🌈

So HTTP::Proxy version 0.14 was out here suffering from some strange warnings 😭, and its author Philippe Bruhat was lowkey having a hard time trying to figure out where they could even be coming from. the mystery era.

getsockname() on closed socket Symbol::GEN7 at /System/Library/Perl/darwin/IO/Socket.pm line 186.
Use of uninitialized value in numeric ne (!=) at /Library/Perl/HTTP/Daemon.pm line 53.

Hmm.. like, there's obviously something wrong here, bestie, but spotting the right line?? not easy. not easy at all πŸ™ˆ

So β€” re-running the same script, unchanged, just adding -MDevel::SimpleTrace to the perl arguments, produces this:

getsockname() on closed socket Symbol::GEN7
        at IO::Socket::sockname(/System/Library/Perl/darwin/IO/Socket.pm:186)
        at IO::Socket::INET::sockport(/System/Library/Perl/IO/Socket/INET.pm:231)
        at HTTP::Daemon::url(/Library/Perl/HTTP/Daemon.pm:52)
        at HTTP::Daemon::ClientConn::get_request(/Library/Perl/HTTP/Daemon.pm:139)
        at HTTP::Proxy::serve_connections(/Library/Perl/HTTP/Proxy.pm:500)
        at HTTP::Proxy::start(/Library/Perl/HTTP/Proxy.pm:392)
        at t::Utils::fork_proxy(t/Utils.pm:72)
        at main::(t/50standard.t:138)
Use of uninitialized value in numeric ne (!=)
        at HTTP::Daemon::url(/Library/Perl/HTTP/Daemon.pm:53)
        at HTTP::Daemon::ClientConn::get_request(/Library/Perl/HTTP/Daemon.pm:139)
        at HTTP::Proxy::serve_connections(/Library/Perl/HTTP/Proxy.pm:500)
        at HTTP::Proxy::start(/Library/Perl/HTTP/Proxy.pm:392)
        at t::Utils::fork_proxy(t/Utils.pm:72)
        at main::(t/50standard.t:138)

Aha! Much better πŸ’… Finding the bug is now a trivial task ;-) β€” we love to see it. main character energy for real.


🩺 DIAGNOSTICS 🩺

Unknown option: %s

  • (W) This warning occurs if you try to set an unknown option. yeah. it said what it said. πŸ’€

⚠️ CAVEATS ⚠️

Listen bestie, this is important: this module is currently not compatible with other modules that also work by overriding die() and warn(), like CGI::Carp. They're fighting for the same lane and it does NOT end well. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Sebastien Aperghis-Tramoni <sebastien@aperghis.net>


πŸ› BUGS πŸ›

Please report any bugs or feature requests to bug-Devel-SimpleTrace@rt.cpan.org, or through the web interface at <https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-SimpleTrace>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. we stay in the loop together 🫢


Devel::SimpleTrace is Copyright (C)2004-2011 Sebastien Aperghis-Tramoni.

This program is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸŽ€ go forth, catch those warnings, and remember β€” every stack trace is just your code telling you where it hurts. nailed it.

this has been perl v5.36.0, last touched 2022-10-22 β€” stay hydrated, stay traced, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from