| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ################################################################################ | 
| 2 |  |  |  |  |  |  | # | 
| 3 |  |  |  |  |  |  | # Apache::Voodoo::Debug::Common | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # Base class for all debugging plugins | 
| 6 |  |  |  |  |  |  | # | 
| 7 |  |  |  |  |  |  | ################################################################################ | 
| 8 |  |  |  |  |  |  | package Apache::Voodoo::Debug::Common; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | $VERSION = "3.0200"; | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 2 |  |  | 2 |  | 17 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 79 |  | 
| 13 | 2 |  |  | 2 |  | 11 | use warnings; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 69 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 2 |  |  | 2 |  | 12 | use Devel::StackTrace; | 
|  | 2 |  |  |  |  | 6 |  | 
|  | 2 |  |  |  |  | 1342 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub new { | 
| 18 | 0 |  |  | 0 | 0 |  | my $class = shift; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 0 |  |  |  |  |  | my $self = {}; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 0 |  |  |  |  |  | bless($self,$class); | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 0 |  |  |  |  |  | return $self; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 0 |  |  | 0 | 0 |  | sub bootstrapped { return; } | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 0 |  |  | 0 | 0 |  | sub init      { return; } | 
| 30 | 0 |  |  | 0 | 0 |  | sub shutdown  { return; } | 
| 31 | 0 |  |  | 0 | 0 |  | sub debug     { return; } | 
| 32 | 0 |  |  | 0 | 0 |  | sub info      { return; } | 
| 33 | 0 |  |  | 0 | 0 |  | sub warn      { return; } | 
| 34 | 0 |  |  | 0 | 0 |  | sub error     { return; } | 
| 35 | 0 |  |  | 0 | 0 |  | sub exception { return; } | 
| 36 | 0 |  |  | 0 | 0 |  | sub trace     { return; } | 
| 37 | 0 |  |  | 0 | 0 |  | sub table     { return; } | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 0 |  |  | 0 | 0 |  | sub mark          { return; } | 
| 40 | 0 |  |  | 0 | 0 |  | sub return_data   { return; } | 
| 41 | 0 |  |  | 0 | 0 |  | sub session_id    { return; } | 
| 42 | 0 |  |  | 0 | 0 |  | sub url           { return; } | 
| 43 | 0 |  |  | 0 | 0 |  | sub status        { return; } | 
| 44 | 0 |  |  | 0 | 0 |  | sub params        { return; } | 
| 45 | 0 |  |  | 0 | 0 |  | sub template_conf { return; } | 
| 46 | 0 |  |  | 0 | 0 |  | sub session       { return; } | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 0 |  |  | 0 | 0 |  | sub finalize { return (); } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub stack_trace { | 
| 51 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 52 | 0 |  |  |  |  |  | my $full = shift; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 0 |  |  |  |  |  | my @trace; | 
| 55 | 0 |  |  |  |  |  | my $i = 1; | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 0 |  |  |  |  |  | my $st = Devel::StackTrace->new(); | 
| 58 | 0 |  |  |  |  |  | while (my $frame = $st->frame($i++)) { | 
| 59 | 0 | 0 |  |  |  |  | last if ($frame->package =~ /^Apache::Voodoo::Engine/); | 
| 60 | 0 | 0 |  |  |  |  | next if ($frame->package =~ /^Apache::Voodoo/); | 
| 61 | 0 | 0 |  |  |  |  | next if ($frame->package =~ /(eval)/); | 
| 62 |  |  |  |  |  |  |  | 
| 63 | 0 | 0 |  |  |  |  | my $f = { | 
| 64 |  |  |  |  |  |  | 'class'    => $frame->package, | 
| 65 |  |  |  |  |  |  | 'function' => defined($st->frame($i))?$st->frame($i)->subroutine:'', | 
| 66 |  |  |  |  |  |  | 'file'     => $frame->filename, | 
| 67 |  |  |  |  |  |  | 'line'     => $frame->line, | 
| 68 |  |  |  |  |  |  | }; | 
| 69 | 0 |  |  |  |  |  | $f->{'function'} =~ s/^$f->{'class'}:://; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 0 | 0 |  |  |  |  | my @a = defined($st->frame($i))?$st->frame($i)->args:''; | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | # if the first item is a reference to same class, then this was a method call | 
| 74 | 0 | 0 |  |  |  |  | if (ref($a[0]) eq $f->{'class'}) { | 
| 75 | 0 |  |  |  |  |  | shift @a; | 
| 76 | 0 |  |  |  |  |  | $f->{'type'} = '->'; | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  | else { | 
| 79 | 0 |  |  |  |  |  | $f->{'type'} = '::'; | 
| 80 |  |  |  |  |  |  | } | 
| 81 | 0 |  |  |  |  |  | $f->{'instruction'} = $f->{'class'}.$f->{'type'}.$f->{'function'}; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  |  | push(@trace,$f); | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 0 | 0 |  |  |  |  | if ($full) { | 
| 86 | 0 |  |  |  |  |  | $f->{'args'} = \@a; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  | } | 
| 89 | 0 |  |  |  |  |  | return @trace; | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | 1; | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | ################################################################################ | 
| 95 |  |  |  |  |  |  | # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). | 
| 96 |  |  |  |  |  |  | # All rights reserved. | 
| 97 |  |  |  |  |  |  | # | 
| 98 |  |  |  |  |  |  | # You may use and distribute Apache::Voodoo under the terms described in the | 
| 99 |  |  |  |  |  |  | # LICENSE file include in this package. The summary is it's a legalese version | 
| 100 |  |  |  |  |  |  | # of the Artistic License :) | 
| 101 |  |  |  |  |  |  | # | 
| 102 |  |  |  |  |  |  | ################################################################################ |