The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

dip - Dynamic instrumentation like DTrace, using aspects

SYNOPSIS

    # run a dip script from a file; pass perl switches after the '--'
    $ dip -s toolkit/count_new.dip -- -S myapp.pl

    # run an inline dip script
    $ dip -e 'before { count("constructor", ARGS(1), ustack(5)); $c{total}++ }
        call "URI::new"' test.pl

    # a more complex dip script
    $ cat quant-requests.dip
    # quantize request handling time, separated by request URI
    before { $ts_start = [gettimeofday] }
        call 'Dancer::Handler::handle_request';
    after { quantize ARGS(1)->request_uri => 10**6*tv_interval($ts_start) }
        call qr/Dancer::Handler::handle_request/;
    $ dip -s request-quant.dip test.pl
    ...
    /
           value  ------------------ Distribution ------------------ count
            1024 |                                                   0
            2048 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    95
            4096 |@@                                                 4
            8192 |                                                   0
           16384 |@                                                  1
           32768 |                                                   0

    /login
           value  ------------------ Distribution ------------------ count
             512 |                                                   0
            1024 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                70
            2048 |@@@@@@@@@@@@@@@                                    30
            4096 |                                                   0

    # The next example relies on Aspect::Library::Profiler, so
    # if something goes wrong, you need to look in the Aspect modules.
    $ dip -e 'aspect Profiler => call qr/^Person::set_/' myapp.pl

DESCRIPTION

dip is a dynamic instrumentation framework for troubleshooting Perl programs in real time. dip can provide fine-grained information, such as a log of the arguments with which a specific function is being called.

Please see the documentation of the dip module for more information (perldoc dip).

COMMANDS

-s, --script

Takes a path to the dip script that should be run.

-e, --exec

Expects a dip script to be passed inline, much like perl -e expects an inline program.

-d, --delay

Tells dip not to activate the instrumentation at the beginning of the program. Instead the program to be instrumented should activate it manually using:

    $dip::dip && $dip::dip->();

This is useful if your program loads other code that should be instrumented at runtime. For example, to test a web application that uses Plack you might use:

    use Plack::Util;
    use Plack::Test;
    use HTTP::Request;

    test_psgi
        app => Plack::Util::load_psgi('mywebapp.pl'),
        client => sub {
            my $cb = shift;
            # now we're sure that mywebapp.pl has been loaded
            $dip::dip && $dip::dip->();
            # ... now make requests and test the responses ...
        };
-v, --verbose

The command-line options given to dip are used to call the program to be instrumented in a special way. Using the --verbose option tells dip to print that command-line.

SEE ALSO

dip

AUTHOR

The following person is the author of all the files provided in this distribution unless explicitly noted otherwise.

Marcel Gruenauer <marcel@cpan.org>, http://perlservices.at

COPYRIGHT AND LICENSE

The following copyright notice applies to all the files provided in this distribution, including binary files, unless explicitly noted otherwise.

This software is copyright (c) 2011 by Marcel Gruenauer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.