| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: Trace.pm,v 1.7 2003/03/02 11:12:09 dsw Exp $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2001-2003, Juniper Networks, Inc. | ||||||||||||||||||||||||||||
| 6 | # All rights reserved. | ||||||||||||||||||||||||||||
| 7 | # Redistribution and use in source and binary forms, with or without | ||||||||||||||||||||||||||||
| 8 | # modification, are permitted provided that the following conditions are | ||||||||||||||||||||||||||||
| 9 | # met: | ||||||||||||||||||||||||||||
| 10 | # 1. Redistributions of source code must retain the above | ||||||||||||||||||||||||||||
| 11 | # copyright notice, this list of conditions and the following | ||||||||||||||||||||||||||||
| 12 | # disclaimer. | ||||||||||||||||||||||||||||
| 13 | # 2. Redistributions in binary form must reproduce the above | ||||||||||||||||||||||||||||
| 14 | # copyright notice, this list of conditions and the following disclaimer | ||||||||||||||||||||||||||||
| 15 | # in the documentation and/or other materials provided with the | ||||||||||||||||||||||||||||
| 16 | # distribution. | ||||||||||||||||||||||||||||
| 17 | # 3. The name of the copyright owner may not be used to | ||||||||||||||||||||||||||||
| 18 | # endorse or promote products derived from this software without specific | ||||||||||||||||||||||||||||
| 19 | # prior written permission. | ||||||||||||||||||||||||||||
| 20 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||||||||||||||||||||||||||
| 21 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||||||||||||||||||||||||||||
| 22 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||||||||||||||||||||||||||
| 23 | # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||||||||||||||||||||||||||||
| 24 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||||||||||||||||||||||||||||
| 25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||||||||||||||||||||||||||
| 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||||||||||||||||||||||||||
| 27 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||||||||||||||||||||||||||||
| 28 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||||||||||||||||||||||||||||
| 29 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||||||||||||||||||||||||||
| 30 | # POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | package JUNOS::Trace; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use vars qw(@ISA @EXPORT %trace_dont %trace_do $trace_all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2 | require Exporter; | |||||||||||||||||||||||||||
| 39 | 2 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 40 | 2 | @EXPORT = qw(trace tracept); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 2 | %trace_dont = (Noise => 1); | |||||||||||||||||||||||||||
| 43 | 2 | %trace_do = (Always => 1); | |||||||||||||||||||||||||||
| 44 | 2 | $trace_all = 0; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub set_trace | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_trace: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | foreach my $flag (@_) { | |||||||||||||||||||||||||||
| 49 | 0 | $trace_do{$flag} = 1; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub set_dont_trace | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_dont_trace: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | foreach my $flag (@_) { | |||||||||||||||||||||||||||
| 56 | 0 | $trace_dont{$flag} = 1; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub init | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my($all, $do, $dont) = @_; | |||||||||||||||||||||||||||
| 63 | 0 | $trace_all = $all; | |||||||||||||||||||||||||||
| 64 | 0 | set_trace(@$do); | |||||||||||||||||||||||||||
| 65 | 0 | set_dont_trace(@$dont); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | sub trace | ||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
trace: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | 0 | my $token = shift; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | return if $trace_dont{$token}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | return unless $trace_all or $trace_do{$token}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$JUNOS::Trace::trace_all or $JUNOS::Trace::trace_do{$token}
MC/DC0%0/2
$JUNOS::Trace::trace_all or $JUNOS::Trace::trace_do{$token}
$JUNOS::Trace::trace_all
$JUNOS::Trace::trace_do{$token}
Truth table0%0/3
A or B
A= $JUNOS::Trace::trace_allB= $JUNOS::Trace::trace_do{$token}
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | my $out = join("", @_); | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | $out .= "\n" unless $out =~ /\n$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | print $out; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub tracept | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
tracept: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $token = shift; | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | return if $trace_dont{$token}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return unless $trace_all or $trace_do{$token}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$JUNOS::Trace::trace_all or $JUNOS::Trace::trace_do{$token}
MC/DC0%0/2
$JUNOS::Trace::trace_all or $JUNOS::Trace::trace_do{$token}
$JUNOS::Trace::trace_all
$JUNOS::Trace::trace_do{$token}
Truth table0%0/3
A or B
A= $JUNOS::Trace::trace_allB= $JUNOS::Trace::trace_do{$token}
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | $DB::single = 1; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | 1; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||||||