Perl debuuger:在运行时错误中,调试器以一个神秘的消息终止,而不是“捕获”错误

时间:2012-05-27 15:52:12

标签: windows perl debugging runtime-error

注意:根据tuxuday的评论编辑于5/28/2012,确实这是一个Perl调试器问题,而不是EPIC / Eclipse - 最后看到。

我在Eclipse上运行PERL EPIC,尝试调试Perl程序。

我遇到了一个奇怪且烦人的问题:当发生运行时错误时(例如,尝试打开一个不存在的文件),EPIC调试器会终止这个神秘的消息(而不是查明错误并提供一个呼叫追踪):

1 at E:/My Documents/Technical/Perl/Eclipse workspace/.metadata/.plugins/org.epic.debug/perl5db.pl line 7800.

更多详情:

该项目有两个模块:一个名为“Load print copy conv.pl”的Perl程序和一个名为“Utilities.pm”的支持模块。

这是Utilites.pm的代码的一部分,其中终止发生(例如,如果它试图打开的文件不存在):

package  Utilities;
require  Exporter;
@ISA   = qw(Exporter);
@EXPORT  = qw(OpenFile TimeString PrintT PrintDebug LoadConvTable PrintConv RenumberConv
            CopyConv LoadParameters CheckParmType CheckParmNo);
 use strict;
 use warnings;
 use Encode;
 use 5.014;
 use utf8;      
 use Win32::Console;
 use autodie; 
 use warnings    qw< FATAL  utf8     >;
 use Carp;
 use Text::Balanced qw< extract_bracketed >;   # for extracting between parentheses in LoadConvTable
 .
 .
 .
 sub OpenFile {     # Call: OpenFile (\%FileStruct, $Mode, $Message);
    my ($FileRef, $Mode, $Message ) =@_;
    my ($HANDLE, $FileName);
    $FileName = $FileRef->{FileName};
    if ((@_ ==3) && ($Message ne '') ) {say $Message;};
    if (! defined $FileName) { confess 'Utilities::OpenFile: $FileName undefined';}
    my $sta = open ($HANDLE, $Mode, $FileName);
    if (!$sta) { say "Can't open $HANDLE: $FileName file, exiting"; exit;
    } else {
        $FileRef->{HANDLE} = $HANDLE;
    }   # end if (!$sta)
    return $sta;
  }  # end sub OpenFile 
.
.
.
sub LoadParameters {
    my ($i,$j, $ParmFilename);
    my ($ParmFileRef,$FilesHashRef, $LOG, $Debug) = @_; 
    $ParmFilename = $ParmFileRef->{FileName};
    if ( ref($FilesHashRef) ne 'HASH') {
        say 'LoadParameters: line '.__LINE__.': \$FilesHashRef not a hash reference';
        return;
    }   # end if ( ref($FilesHashRef) ne 'HASH') 
    if ((@_<3) || (@_>4)) {
        say 'LoadParameters: line '.__LINE__.": wrong No of parameters, \@_=@_";
        return;
    }
    if (@_ == 3) {$Debug = 0};
    unless (-e $LOG) {
        say 'LoadParameters: line '.__LINE__.':\$LOG does not exist';
        return;
    }
    OpenFile($ParmFileRef, "<",
            "LoadParameters: opening file:'$ParmFilename'");
    my $PARAMETERS = $ParmFileRef->{HANDLE};
    while (<$PARAMETERS>) {
        chomp;
    say $_;
    if ( m{^\s*#}) {    # parameter line starts with a comment
        next;
    }
    $i = index($_,"\x20"); # find the first space
    $j = substr($_, $i+1);          
    $$FilesHashRef{substr($_,0,$i)} = $j;
    }; # while (<$PARAMETERS>)
    if ($Debug) {
            while ( ($i,$j) = each %$FilesHashRef) {
        PrintT($LOG, "$i => $j");
        }
    }   # end if ($Debug)
    close $ParmFileRef->{HANDLE};
}   # end  sub LoadParameters
< p> package Utilities; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(OpenFile TimeString PrintT PrintDebug LoadConvTable PrintConv RenumberConv CopyConv LoadParameters CheckParmType CheckParmNo); use strict; use warnings; use Encode; use 5.014; use utf8; use Win32::Console; use autodie; use warnings qw< FATAL utf8 >; use Carp; use Text::Balanced qw< extract_bracketed >; # for extracting between parentheses in LoadConvTable . . . sub OpenFile { # Call: OpenFile (\%FileStruct, $Mode, $Message); my ($FileRef, $Mode, $Message ) =@_; my ($HANDLE, $FileName); $FileName = $FileRef->{FileName}; if ((@_ ==3) && ($Message ne '') ) {say $Message;}; if (! defined $FileName) { confess 'Utilities::OpenFile: $FileName undefined';} my $sta = open ($HANDLE, $Mode, $FileName); if (!$sta) { say "Can't open $HANDLE: $FileName file, exiting"; exit; } else { $FileRef->{HANDLE} = $HANDLE; } # end if (!$sta) return $sta; } # end sub OpenFile . . . sub LoadParameters { my ($i,$j, $ParmFilename); my ($ParmFileRef,$FilesHashRef, $LOG, $Debug) = @_; $ParmFilename = $ParmFileRef->{FileName}; if ( ref($FilesHashRef) ne 'HASH') { say 'LoadParameters: line '.__LINE__.': \$FilesHashRef not a hash reference'; return; } # end if ( ref($FilesHashRef) ne 'HASH') if ((@_<3) || (@_>4)) { say 'LoadParameters: line '.__LINE__.": wrong No of parameters, \@_=@_"; return; } if (@_ == 3) {$Debug = 0}; unless (-e $LOG) { say 'LoadParameters: line '.__LINE__.':\$LOG does not exist'; return; } OpenFile($ParmFileRef, "<", "LoadParameters: opening file:'$ParmFilename'"); my $PARAMETERS = $ParmFileRef->{HANDLE}; while (<$PARAMETERS>) { chomp; say $_; if ( m{^\s*#}) { # parameter line starts with a comment next; } $i = index($_,"\x20"); # find the first space $j = substr($_, $i+1); $$FilesHashRef{substr($_,0,$i)} = $j; }; # while (<$PARAMETERS>) if ($Debug) { while ( ($i,$j) = each %$FilesHashRef) { PrintT($LOG, "$i => $j"); } } # end if ($Debug) close $ParmFileRef->{HANDLE}; } # end sub LoadParameters

问题出现在例如子OpenFile第7行中,在此声明中:

软件,版本和系统:Eclipse版本3.7.1在Windows 7上运行M20110909-1335,EPIC版本0.6.44,Active Perl 5.14.2。

在调试器下运行程序时,它会以消息终止:

my $sta = open ($HANDLE, $Mode, $FileName);

0 个答案:

没有答案