Hi,
I am debugging a Perl application program which calls itself after resetting its environment variables.
For example, lets say there is a program called test.pl:
test,pl:
----------------------------
#!/usr//bin/perl -w
use Carp; # Included in distribution
use Cwd; # Included in distribution
use Getopt::Euclid; # CPAN install
if ( (!exists($ENV{'DP_MODESET'}) || $ENV{'DP_MODESET'} != $$) ) {
print "First run ...\n";
_restart();
} else {
print "Second run ...\n";
}
sub _restart {
my $currPath = $ENV{'PATH'};
$ENV{'PATH'} = "/abc/def/:$currPath" ;
$ENV{'PERL5LIB'} = "/abc/def/";
$ENV{'DP_MODESET'} = $$;
print "Inside _restart method, running test.pl @ARGV \n";
exec("test.pl" , @ARGV) # Start this program again with new environment
or croak("test.pl->_restart Could not restart dpProve.pl to run its TEST version:\n$!");
}
------------------------
Running this program through EPIC works OK, and gives me this result:
-------------------------
First run ...
Inside _restart method, running test.pl
Second run ...
--------------------------
But, when I am trying to use EPIC debugger using "step into" button and reach exec() mthod inside restart, I get this error:
----------------------------
<terminated, exit value143> Perl Debugger.
---------------------------
I understand that exec() method is not supposed to return back to original program. But why does Debugger exit with this "terminated" error.
Is there a way to get around it? The reason I am restarting my program is because I want to set new environment depending on extra flags that I pass (Not shown in this example).
I suspect that by running exec you are closing the TCP connections that the debugged process has to EPIC. I don't think there is a sensible workaround for that, and probably you wouldn't have much luck using Perl's command-line debugger (perl -d) either.