Devel::Chitin::Actionable - Get and set breakpoints and actions
my $unconditional_bp = Devel::Chitin::Breakpoint->new( file => $filename, line => 123 ); my $conditional_bp = Devel::Chitin::Breakpoint->new( file => $filename, $line => 123, code => q($a eq 'stop')); my $inactive_bp = Devel::Chitin::Breakpoint->new( file => $filename, $line 123, inactive => 1); my @bp = Devel::Chitin::Breakpoint->get(file => $filename, line => 123); printf("breakpoint on line %d of %s: %s\n", $bp[0]->line, $b[0]->file, $bp[0]->code);
Used to manipulate breakpoints and actions in the debugged program. Breakpoints are used to stop execution of the debugged program and let the debugging system take control there. Actions are used to run arbitrary code before a line in the debugged program executes.
Breakpoints are associated with a file and line number, and the same file/line combination may have more than one breakpoint. Before executing a line with one or more breakpoints, all those breakpoints with string code attributes are tested by eval-ing, as a string eval, their code in the context of the debugged program; these can be used to implement a conditional breakpoint that stops depending on some condition in the program code. Coderef code attributes are called directly, and get no special scoping.
code
If any of these tests returns true, the debugger will stop the program before executing that line.
my $bp = Devel::Chitin::Breakpoint->new(file => $f, line => $l, [ code => $code ], [ once => 1 ], [ inactive => 1]);
Creates a new Breakpoint object. file and line are required arguments. file must be a filename as it appears in $main::{"<_$file"}. If code is omitted, the value "1" is used as a default which creates an unconditional breakpoint. If once is a true value, then the breakpoint will delete itself after triggering. If inactive is true, the breakpoint will not trigger.
file
line
once
inactive
The breakpoint code can be either a string or a coderef. Strings are executed as a string-eval, and are evaluated in the context of the program being debugged. Coderefs are called directly, and behave according to normal scoping rules.
Retrieve breakpoints. Always returns a list of matching breakpoints. file is required, and if no other filters are used, returns all the breakpoints for that file. You may also filter by line, code and inactive.
Read-only accessors that return whatever values were used to create the breakpoint.
Mutator that retrieves the breakpoint's code condition, or sets it.
Mutator that retrieves the current inactive flag, or sets it.
Remove a breakpoint. Deleted breakpoints will never trigger again.
Actions are a lot like breakpoints; they are associated with a file and line number, and they have code that runs before that line in the program is executed. The difference is that the return value from the code is ignored.
The code is evaluated in the context of the running program if specified as a string, so it can, for example, affect variables there or print them out. Coderefs are called directly, and get no special scoping.
my $act = Devel::Chitin::Action->new(file => $f, line => $l, code => $code, [ once => 1], [ inactive => 1]);
Creates a new Action object. file, line and code are required arguments. file must be a filename as it appears in $main::{"<_$file"}. breakpoint. If once is a true value, then the action will delete itself after running. If inactive is true, the action will not run.
Retrieve actions. Always returns a list of matching actions. file is required, and if no other filters are used, returns all the actions for that file. You may also filter by line, code and inactive.
Read-only accessors that return whatever values were used to create the action.
Mutator that retrieves the action's code, or set it.
Remove an action. Deleted actions will never run again.
Devel::Chitin
Anthony Brummett <brummett@cpan.org>
Copyright 2017, Anthony Brummett. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
To install Devel::Chitin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Chitin
CPAN shell
perl -MCPAN -e shell install Devel::Chitin
For more information on module installation, please visit the detailed CPAN module installation guide.