藤 吾郎
and 1 contributors

NAME

Devel::Optrace - Traces opcodes which are running now

VERSION

This document describes Devel::Optrace version 0.05.

SYNOPSIS

        use Devel::Optrace;
        Devel::Optrace->enable();  # enables  -trace, -stack and -runops
        # ...
        Devel::Optrace->disable(); # disables -trace, -stack and -runops

        # or command line:
        # $ perl -MDevel::Optrace=-all -e '...'  # normal way
        # $ perl -d:Optrace -e '...'             # shortcut

DESCRIPTION

Devel::Optrace is an opcode debugger which traces opcodes and stacks.

There are several trace options:

-trace

Traces opcodes like perl's -Dt, reporting "$opcode @op_private @op_flags" or "$opcode(@op_data) @op_private @op_flags".

The indent level indicates the depth of the context stacks.

-stack

Dumps the perl stack (PL_stack) like perl's -Ds.

-runops

Traces runops levels with the current stack info type (MAIN, OVERLOAD, DESTROY, etc.).

-all

Sets -trace, -stack and -runops on/off.

-count

Counts and reports opcodes executed.

-noopt

Disable the peephole optimizer.

EXAMPLES

perl -d:Optrace -e 'print qq{Hello, @ARGV world!\n}' Perl:

        Entering RUNOPS MAIN (-e:0)
        ()
        enter
         ()
         nextstate(main -e:1) VOID
         ()
         pushmark SCALAR
         ()
         const("Hello, ") SCALAR
         ("Hello, ")
         pushmark SCALAR
         ("Hello, ")
         gvsv($") SCALAR
         ("Hello, "," ")
         gv(*ARGV) SCALAR
         ("Hello, "," ",*ARGV)
         rv2av LIST KIDS
         ("Hello, "," ","Perl")
         join SCALAR KIDS
         ("Hello, ","Perl")
         concat SCALAR KIDS
         ("Hello, Perl")
         const(" world!\n") SCALAR
         ("Hello, Perl"," world!\n")
         concat SCALAR KIDS STACKED
         ("Hello, Perl world!\n")
         print VOID KIDS
         (YES)
         leave VOID KIDS PARENS
        ()
        Leaving RUNOPS MAIN (-e:0)

This reveals that the perl code print qq{Hello, @ARGV world!\n} is interpreted as print qq{Hello, } . join($", @ARGV) . qq{ world!\n}.

DEPENDENCIES

Perl 5.8.1 or later, and a C compiler.

BUGS

No bugs have been reported.

Please report any bugs or feature requests to the author.

SEE ALSO

perlrun.

B::Concise.

AUTHOR

Goro Fuji (gfx) <gfuji(at)cpan.org>.

LICENSE AND COPYRIGHT

Copyright (c) 2009, Goro Fuji (gfx). Some rights reserved.

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