dip - Dynamic instrumentation like DTrace, using aspects
# 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
This is the documentation for the dip program. If you are looking for the documentation on the dip module, use perldoc dip.pm or man 3 dip.
dip
perldoc dip.pm
man 3 dip
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.pm).
Takes a path to the dip script that should be run. This and the --exec option can be given several times and interleaved; they will be executed in the given order. For example:
--exec
dip -s foo.dip -e 'before { say "Hi" } call "Baz::new"' -s baz.dip
will result in the following code:
run q!foo.dip!; before { say "Hi" } call "Baz::new"; run q!baz.dip!;
Expects a dip script to be passed inline, much like perl -e expects an inline program.
perl -e
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 ... };
This option can be given several times; it will be available to the instrumentation code as well. In verbose mode, dip prints the command that is actually used to instrument the target program.
With this option you can pass values to the dip scripts. This option can be given several times and each time expects an argument of the form key=value. In the instrumentation code, these options are available in %opt.
key=value
%opt
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
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.
To install dip, copy and paste the appropriate command in to your terminal.
cpanm
cpanm dip
CPAN shell
perl -MCPAN -e shell install dip
For more information on module installation, please visit the detailed CPAN module installation guide.