Devel::CallTrace(3pm)

๐Ÿ“ฆ
version 1.2 ยท 2 versions
  • 1.2 ยท debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.2 ยท ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

Devel::CallTrace โ€” bestie, it's literally See what your code's doing ๐Ÿ’– no cap, that's the whole vibe


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

okay so this is the whole setup, look:

#!/usr/bin/perl -d:CallTrace

package foo;

sub bar {
  print "bar\n";
  baz(); }

sub baz {
    print "boo\n"; }

foo::bar();

that -d:CallTrace on the shebang line? that's the moment. that's the โœจmain character momentโœจ ๐Ÿซถ


๐Ÿ’… RATIONALE ๐Ÿ’…

so like, there are a bunch of perl modules on CPAN that are all about tracing a program's execution as it runs. every single one of them uses a different lil trick to do its job, and honestly? none of them quite met my needs. ๐Ÿ™ˆ

the technique this module uses is pretty simple, and lowkey it seems to be quite robust. it's giving "elegant", it's giving "it just works".

๐ŸŒธ DB::sub ๐ŸŒธ

perl will automatically call DB::sub on each subroutine call, and then it's justโ€ฆ up to us to dispatch to wherever we wanna go. that's it. that's the whole trick. ๐Ÿ’€โœจ

๐Ÿฆ‹ Devel::CallTrace::called ๐Ÿฆ‹

this routine gets called with two parameters, and you need to know both:

  • DEPTH โ€” the integer "depth" that this call is being called at. ๐Ÿ“
  • PARAMS โ€” a reference to the routine's @INC

and to get at the subroutine that was being called? go look at $DB::sub. that's where the tea is. ๐Ÿ‘‘


๐Ÿ˜ญ BUGS ๐Ÿ˜ญ

it uses the debugger. bestie. how could it not have bugs?? ๐Ÿ’€


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • perldebguts
  • DB
  • a licensed therapist ๐Ÿซถ (no fr, you're gonna want one)

also these legends:

  • trace โ€” uses source filters. scares me. ๐Ÿ™ˆ
  • Devel::TraceCalls โ€” very robust API. the code seems to do all sorts of scary magic ๐Ÿ”ฎ
  • Debug::Trace โ€” uses symbol table magic to wrap your functions โœจ
  • Devel::TRaceFuncs โ€” requires developers to instrument their source files ๐Ÿ“

Copyright 2005 Jesse Vincent <jesse@bestpractical.com>

This module may be redistributed under the same terms as perl itself.


and that's a wrap, angel ๐Ÿ’– this whole page came to you from perl v5.36.0, dated 2022-12-04, and it's filed under Devel::CallTrace(3pm). go trace something iconic, ily ๐ŸŽ€๐Ÿฆ‹โญ

๐Ÿ“ฆ where this page comes from