logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Sub::WrapPackages::CallTree - show a tree of function calls

Bugs And Improvements

       Please report bugs and submit improvements via Github.

Conspiracy

       This code is also free-as-in-mason.

perl v5.34.0                                       2022-07-23                   Sub::WrapPackages::CallTree(3pm)

Description

       Tool that uses Sub::WrapPackages to show on STDERR a tree of function calls as your code runs, including
       arguments and a list of return values

Name

       Sub::WrapPackages::CallTree - show a tree of function calls

Parameters

       The arguments are the same as those you would pass as the "packages" option to Sub::WrapPackages. The
       other options have sensible defaults and can not (currently) be set. If you would like to be able to
       over-ride the defaults please submit a pull request with tests.

Synopsis

       In your code - in a test file, perhaps:

           use Sub::WrapPackages::CallTree qw(My::App::* And::Another::Namespace)

       Or in your environment:

           PERL5OPT=-MSub::WrapPackages::CallTree=My::App::*,And::Another::Namespace

       The results will look something like this:

           Called Sub::WrapPackages::Tests::Victim::foo with: [Sub::WrapPackages::Tests::Victim]
             Called Sub::WrapPackages::Tests::Victim::bar with: [1]
               Called Sub::WrapPackages::Tests::Victim::baz with: [OMG, ROBOTS, 5]
               Return from Sub::WrapPackages::Tests::Victim::baz with: [OMG, ROBOTS, 5]
             Return from Sub::WrapPackages::Tests::Victim::bar with: [OMG, ROBOTS, 5]
           Return from Sub::WrapPackages::Tests::Victim::foo with: [2, OMG, ROBOTS, 5]

       NB that all arguments and return values are stringified for display, as there is no way of nicely
       displaying a tree of function calls as well as complex data structures, and the tree of function calls is
       more important.

Thanks To

       Thanks to Will Shepherd, who berated me for cut n pasting the code that implements this all over the
       place while debugging, and prompting me to wrap it up into a much smaller piece of code that I can
       splatter all over the place while debugging.

See Also