Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INIT block in Inline.pm is intercepted by Perl debugger #63

Open
kolakode opened this issue Aug 15, 2017 · 0 comments
Open

INIT block in Inline.pm is intercepted by Perl debugger #63

kolakode opened this issue Aug 15, 2017 · 0 comments

Comments

@kolakode
Copy link

kolakode commented Aug 15, 2017

The "ugly hack" in Inline.pm is impacting the debugging of scripts (the INIT block is being intercepted by the Perl debugger). Here is the problematic code:

   196  #==============================================================================
   197  # Process delayed objects that don't have source code yet.
   198  #==============================================================================
   199  # This code is an ugly hack because of the fact that you can't use an
   200  # INIT block at "run-time proper". So we kill the warning and tell users
   201  # to use an Inline->init() call if they run into problems. (rare)
   202  
   203  eval <<END;
   204  no warnings;
   205  \$INIT = \$INIT; # Needed by Sarathy's patch.
   206  sub INIT {
   207      \$INIT++;
   208      &init;
   209  }
   210  END

When the Perl debugger launches for a script which uses Inline or a module which uses Inline, the debugger will start at line 206 of Inline instead of the first executable statement of the script. Hence, the INIT block in Inline.pm forces the script writer to step over the two INIT statements to get to the first statement of their program. Either the INIT block should be changed to a CHECK block, or $DB::single=2 statements should be inserted to step over the INIT statements, like this:

   196  #==============================================================================
   197  # Process delayed objects that don't have source code yet.
   198  #==============================================================================
   199  # This code is an ugly hack because of the fact that you can't use an
   200  # INIT block at "run-time proper". So we kill the warning and tell users
   201  # to use an Inline->init() call if they run into problems. (rare)
   202  
   203  eval <<'END';
   204  no warnings;
   205  $INIT = $INIT; # Needed by Sarathy's patch.
   206  sub INIT {
            $DB::single=2;  # make debugger skip over next statement
   207      $INIT++;
            $DB::single=2;  # make debugger skip over next statement
   208      &init;
   209  }
   210  END

Please implement one of my two proposals, or some other way to avoid this "ugly hack" and allow the Perl debugger to start where a script writer would expected it to.

Thank you!
-Shaun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant