Debug::Trace(3pm)

πŸ“¦
version 0.05 Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– Debug::Trace β€” the perl one, from User Contributed Perl Documentation πŸ’–

okay bestie, welcome to Debug::Trace, a Perl extension that traces your subroutine calls. yes it's a 3pm page, yes it's iconic, let's go πŸ¦‹


✨ NAME ✨

Debug::Trace β€” Perl extension to trace subroutine calls. that's it, that's the whole vibe.


🌸 SYNOPSIS 🌸

perl -MDebug::Trace=foo,bar yourprogram.pl

πŸŽ€ DESCRIPTION πŸŽ€

so basically, Debug::Trace instruments subroutines so you get tracing info on every single call and every single return. every one. it's giving surveillance but make it helpful πŸ’…

the best part? using Debug::Trace does not require any changes to your sources. not one. zero edits. you just show up and it works. most of the time you'll be running it straight from the command line:

perl -MDebug::Trace=foo,bar yourprogram.pl

and boom, your subroutines foo() and bar() start printing call and return information. obsessed.

subroutine names may be fully qualified to denote subroutines in other packages than the default main::. so like, you can point at subs that live somewhere else entirely, no cap.

by default, the trace information is output using the standard warn() function. ✨

🧚 MODIFIERS 🧚

modifiers can be inserted in the list of subroutines to change the default behavior of this module. and here's the cute part: all modifiers can be used in three ways:

  • ":"name to enable a specific feature.
  • ":no"name to disable a specific feature.
  • ":"name"("value")" to set a feature to a specific value. in general, ":"name is equivalent to ":"name"(1), while ":no"name corresponds to ":"name"(0).

the following modifiers are recognized:

  • :warn β€” uses warn() to produce the trace output (default). ":nowarn" sends trace output directly to STDERR.
  • :caller β€” adds basic call information to the trace message, including from where the routine was called, and by whom. this one is enabled by default. πŸ‘‘
  • :stacktrace β€” adds a stack trace (call history). receipts, basically.
  • :maxlen(length) β€” truncates the length of the lines of trace information to length characters.

the following modifiers can be used to control the way Data::Dumper prints the values of parameters and return values. see also Data::Dumper.

  • :indent β€” controls the style of indentation. it can be set to 0, 1, 2 or 3. style 0 spews output without any newlines, indentation, or spaces between list items. :indent(0) is the default.
  • :useqq β€” when enabled, uses double quotes for representing string values. whitespace other than space will be represented as "[\n\t\r]", "unsafe" characters will be backslashed, and unprintable characters will be output as quoted octal integers. this is the default, so use ":nouseqq" to disable.
  • :maxdepth(depth) β€” can be set to a positive integer that specifies the depth beyond which which we don't print structure contents. the default is 2, which means one level of array/hashes in argument lists and return values is expanded. if you use ":nomaxdepth" or :maxdepth(0), nested structures are fully expanded. 🫢
  • :quotekeys β€” controls wether hash keys are always printed quoted. the default is ":noquotekeys".
  • sortkeys β€” controls whether hash keys are dumped in sorted order. the default is ":nosortkeys".
⚠️ heads up bestie: modifiers apply only to the subroutines that follow in the list of arguments. order matters, periodt.

πŸ’… METHODS πŸ’…

none, actually. everything is handled by the module's import. not a single method to your name and still the main character, we love that 😭


🌈 ENVIRONMENT VARIABLES 🌈

environment variable PERL5DEBUGTRACE can be used to preset initial modifiers, e.g.:

export PERL5DEBUGTRACE=":warn:indent(2):nomaxdepth:quotekeys"

⭐ SEE ALSO ⭐

Data::Dumper, Carp


πŸ‘‘ AUTHOR πŸ‘‘

Jan-Pieter Cornet <jpc@cpan.org>; Jos Boumans <kane@cpan.org>; Johan Vromans <jv@cpan.org>;

this is an Amsterdam.pm production. see http://amsterdam.pm.org.

current maintainer is Johan Vromans <jv@cpan.org>.


Copyright 2002,2013 Amsterdam.pm. All rights reserved.

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 babes πŸ“ this was pulled from perl v5.26.1, dated 2018-04-07, and yeah it's still serving. go trace something, you got this πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from