Devel::STrace

SUMMARY: CONSTR | METHOD | DETAIL: CONSTR | METHOD

## Class Devel::STrace

Provides a minimal strace/truss-like utility for Perl scripts. Using Devel::RingBuffer, each new subroutine call is logged to an mmap'ed shared memory region (as provided by IPC::Mmap). As each statement is executed, the line number and Time::HiRes:;time() timestamp are written to the current ringbuffer slot. An external application can then monitor a running application by inspecting the mmap'ed area (see Devel::STrace::Monitor and the associated plstrace.pl application for an example).

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

Author:
  D. Arnold
Since:
  2006-05-01
See Also:
  perdebguts

Unless otherwise noted, `$self` is the object instance variable.

Method Summary
`CLONE()` (class method) Threads clone method
`DB()` (class method) Debug a single statement
`sub()` (class method) Debug a subroutine call

Method Details

### CLONE

    CLONE()

  (class method) Threads clone method. Allocates a new ring, and and populates the existing cloned ring object with the newly allocate ring information.

### DB

    DB()

  (class method) Debug a single statement. Creates a ringbuffer if none exists. Allocates a new ring if executed in a new process. Updates the ring's current slot with the current line number and timestamp.

### sub

    sub()

  (class method) Debug a subroutine call. If trace is enabled in the ring, the next slot is allocated and the called subroutine (from $DB::sub) is written to it. The subroutine is then called with the caller's return context, and then the slot is freed before returning. Note that this method requires additional control to handle re-entrancy when DB::DB() or DB::sub() make calls to the various support functions.

  Returns:
    The subroutine's return value(s), if the caller is not in void context.

Generated by psichedoc on Wed May 3 08:01:49 2006