The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Implements the deprecated "GIMME" in perlapi.

Returns non-zero if the sub calling this function is being called in an lvalue context. Returns 0 otherwise.

The XSUB-writer's equivalent of caller(). The returned PERL_CONTEXT structure can be interrogated to find all the information returned to Perl by caller. Note that XSUBs don't get a stack frame, so caller_cx(0, NULL) will return information for the immediately-surrounding Perl code.

This function skips over the automatic calls to &DB::sub made on the behalf of the debugger. If the stack frame requested was a sub called by DB::sub, the return value will be the frame for the call to DB::sub, since that has the correct line number/etc. for the call site. If dbcxp is non-NULL, it will be set to a pointer to the frame for the sub call itself.

Interpose, for the current op and RUNOPS loop,

    - a new JMPENV stack catch frame, and
    - an inner RUNOPS loop to run all the remaining ops following the
      current PL_op.

Then handle any exceptions raised while in that loop. For a caught eval at this level, re-enter the loop with the specified restart op (i.e. the op following the OP_LEAVETRY etc); otherwise re-throw the exception.

docatch() is intended to be used like this:

    PP(pp_entertry)
    {
        if (CATCH_GET)
            return docatch(Perl_pp_entertry);

        ... rest of function ...
        return PL_op->op_next;
    }

If a new catch frame isn't needed, the op behaves normally. Otherwise it calls docatch(), which recursively calls pp_entertry(), this time with CATCH_GET() false, so the rest of the body of the entertry is run. Then docatch() calls CALLRUNOPS() which executes all the ops following the entertry. When the loop finally finishes, control returns to docatch(), which pops the JMPENV and returns to the parent pp_entertry(), which itself immediately returns. Note that *all* subsequent ops are run within the inner RUNOPS loop, not just the body of the eval. For example, in

    sub TIEARRAY { eval {1}; my $x }
    tie @a, "main";

at the point the 'my' is executed, the C stack will look something like:

    #10 main()
    #9  perl_run()              # JMPENV_PUSH level 1 here
    #8  S_run_body()
    #7  Perl_runops_standard()  # main RUNOPS loop
    #6  Perl_pp_tie()
    #5  Perl_call_sv()
    #4  Perl_runops_standard()  # unguarded RUNOPS loop: no new JMPENV
    #3  Perl_pp_entertry()
    #2  S_docatch()             # JMPENV_PUSH level 2 here
    #1  Perl_runops_standard()  # docatch()'s RUNOPs loop
    #0  Perl_pp_padsv()

Basically, any section of the perl core which starts a RUNOPS loop may make a promise that it will catch any exceptions and restart the loop if necessary. If it's not prepared to do that (like call_sv() isn't), then it sets CATCH_GET() to true, so that any later eval-like code knows to set up a new handler and loop (via docatch()).

See "Exception handing" in perlinterp for further details.

Locate the CV corresponding to the currently executing sub or eval. If db_seqp is non_null, skip CVs that are in the DB package and populate *db_seqp with the cop sequence number at the point that the DB:: code was entered. (This allows debuggers to eval in the scope of the breakpoint rather than in the scope of the debugger itself.)