From 1b0c212a950af46c8e8f8d962fb4b145bc9e27f7 Mon Sep 17 00:00:00 2001 From: Bill Fenner <> Date: Thu, 15 Feb 2007 23:10:55 +0000 Subject: [PATCH] Increased debugging in _load_attr(). The most verbose requires Debug = 2. Print an error in AUTOLOAD if it's called without a class; this is likely to be a typo in a function call in a module implementation and the default error message is just confusing. --- Info.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Info.pm b/Info.pm index 93b78c79..77b6c97e 100644 --- a/Info.pm +++ b/Info.pm @@ -599,7 +599,8 @@ Set to C<0> to turn off loop detection. =item Debug -Prints Lots of debugging messages +Prints Lots of debugging messages. +Pass 2 to print even more debugging messages. (default off) @@ -2645,7 +2646,7 @@ sub _load_attr { } $self->debug() and print "SNMP::Info::_load_attr $attr : $leaf", - defined $partial ? "($partial)" : '', "\n"; + defined $partial ? "($partial / $varleaf)" : '', "\n"; my $var = new SNMP::Varbind([$varleaf]); @@ -2716,6 +2717,11 @@ sub _load_attr { $errornum = $sess->{ErrorNum}; } + if ($self->debug() > 1) { + use Data::Dumper; + print "SNMP::Info::_load_attr $attr : leaf = $leaf , var = ", Dumper($var); + } + # Check if we've left the requested subtree last if $var->[0] ne $leaf; my $iid = $var->[1]; @@ -2739,7 +2745,7 @@ sub _load_attr { # Check to make sure we are still in partial land if (defined $partial and $iid !~ /^$partial$/ and $iid !~ /^$partial\./){ - #print "$iid makes us leave partial land.\n"; + $self->debug() and print "$iid makes us leave partial land.\n"; last; } @@ -2895,6 +2901,16 @@ sub AUTOLOAD { # Sub name is the last part $sub_name =~ s/.*://; + # Typos in function calls in SNMP::Info subclasses turn into + # AUTOLOAD requests for non-methods. While this is deprecated, + # we'll still get called, so report a less confusing error. + if (ref($self) !~ /^SNMP::Info/) { + # croak reports one level too high. die reports here. + # I would really like to get the place that's likely to + # have the typo, but perl doesn't want me to. + croak("SNMP::Info::AUTOLOAD($AUTOLOAD) called with no class (probably typo of function call to $sub_name)"); + } + my $attr = $sub_name; $attr =~ s/^(load|set)_//; $attr =~ s/^orig_//;