Dean Arnold > Devel-STrace-0.31 > Devel::STrace

Download:
Devel-STrace-0.31.tar.gz

Dependencies

Annotate this POD

Related Modules

Devel::DProf
Thread::Queue
Devel::CoreStack
Time::HiRes
IPC::Mmap
Devel::RingBuffer
Net::hostent
IO::Socket
XML::XPath
XML::Parser
more...
By perlmonks.org

CPAN RT

New  1
Open  0
View/Report Bugs
Source  

NAME ^

Devel::STrace - strace-like runtime call trace for Perl applications

SYNOPSIS ^

    #
    #    setup environment variables to control
    #    configuration of Devel::RingBuffer's mmap'ed
    #    memory
    #
    export DEVEL_RINGBUF_SLOTS=10
    export DEVEL_RINGBUF_BUFFERS=50
    export DEVEL_RINGBUF_FILE='somescript.prof'
    #
    #    run the script under STrace
    perl -d:STrace somescript
    #
    #    use another terminal to view the
    #    contents of the ringbuffers
    #
    plstrace.pl -f $DEVEL_RINGBUF_FILE -s 10 -d 100

DESCRIPTION ^

Provides a strace/truss-like runtime call monitor for Perl applications. Note that, while strace/truss only dumps system calls, Devel::STrace dumps all calls to Perl subs on the application's stack. Also note that Devel::STrace cannot trace non-Perl calls (e.g., calls inside XS/C modules), so an additional external strace/truss monitor may be needed to fully diagnose a misbehaving Perl script.

Devel::STrace captures each subroutine call (via DB::sub()) using ring buffers in a memory mapped file using Devel::RingBuffer and IPC::Mmap. Refer to Devel::RingBuffer for configuration details.

As each subroutine is entered (ie, when DB::sub() is called), the next available ring buffer slot is allocated (possibly overwriting the oldest in-use slot) and $DB::sub is written to the slot - possibly suffixed by the $AUTOLOAD value if the call is an AUTOLOAD - and the line number and timestamp (as returned by Time::HiRes) are set to -1, 0, respectively. The line number and timestamp are filled in by DB::DB() as each Perl statement is executed.

Note that no explicit locks are used during the slot updates, in order to minimize the profiling overhead,

Also note that exit timings are not provided, as this tool is intended for debugging, rather than profiling, purposes.

The Devel::STrace::Monitor module provides a minimal set of functions for external applications to

The included plstrace.pl script implements a simple command line monitoring view using Devel::STrace::Monitor. More feature rich debugging applications (esp. GUI based) are planned.

Application Notes ^

Implements DB::DB and DB::sub. The ringbuffer is created by the Devel::RingBuffer class, which also acts as a factory for individual Devel::RingBuffer::Ring objects (representing a single ring buffer).

On POSIX-based systems, a file must be physically created to be mmap()'ed and read by a separate monitoring process. While this possibly permits post-mortem analysis of the execution when things die (though not guaranteed due to file flushing issues), it is possible to accumulate trace files in the /tmp directory if a trace file is not explicitly defined via DEVEL_RINGBUF_FILE, as Devel::STrace doesn't currently know when to safely unlink such files.

TO DO ^

SEE ALSO ^

Devel::RingBuffer

Devel::STrace::Monitor

IPC::Mmap

perldebguts

strace(1) (or truss(1))

AUTHOR, COPYRIGHT, AND LICENSE ^

Dean Arnold mailto:darnold@presicient.com

Copyright(C) 2006, Dean Arnold, Presicient Corp., USA. All rights reserved.

Permission is granted to use this software under the same terms as Perl itself. Refer to the Perl Artistic License for details.

syntax highlighting: