Perl debuuger: on a run-time error, the debugger terminates with a cryptic message instead of “catching” the error

橙三吉。 提交于 2019-12-11 17:59:29

问题


Note: edited 5/28/2012 according to tuxuday's comment, indeed it's a Perl debugger problem, not EPIC/Eclipse - see at the end.

I am running PERL EPIC on Eclipse, trying to debug a Perl program.

I am encountering a strange and annoying problem: when a run-time error occurs (for example, trying to open a non-existing file), the EPIC debugger terminates with this cryptic message (instead of pinpointing the error and providing a call trace):

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

More details:

The project has two modules: a Perl program called "Load print copy conv.pl", and a support module called: "Utilities.pm".

Here is part of the code of Utilites.pm, where the termination occurs (for example, if the file it's trying to open doesn't exist):

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

The problem shows up, for example, in sub OpenFile 7th line, in this statement:

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

Software, versions and system: Eclipse version 3.7.1 build M20110909-1335, EPIC version 0.6.44, Active Perl 5.14.2 running on Windows 7.

When running the program under the debugger, it terminates with the messages:

1 at F:/WIN 7 programs/System/Environments/Active Perl/lib/perl5db.pl line 7799.

Debugged program terminated.  Use q to quit or R to restart

  DB<1> T
$ = DB::fake::at_exit() called from file `F:/WIN 7 programs/System/Environments/Active Perl/lib/perl5db.pl' line 9137
$ = DB::END() called from file `(eval 123)[F:/WIN 7 programs/System/Environments/Active Perl/lib/Fatal.pm:1103]' line 114
$ = eval {...} called from file `(eval 123)[F:/WIN 7 programs/System/Environments/Active Perl/lib/Fatal.pm:1103]' line 114

来源:https://stackoverflow.com/questions/10775274/perl-debuuger-on-a-run-time-error-the-debugger-terminates-with-a-cryptic-messa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!