Skip to content

Commit

Permalink
disable line debugging for generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
mauke committed Sep 19, 2024
1 parent 13f4c96 commit 7ca8d03
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Parameters.xs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,25 @@ static SV *sentinel_mortalize(Sentinel sen, SV *sv) {
return sv;
}

DEFSTRUCT(RStore_U32) {
U32 *where;
U32 what;
};

static void resource_store_u32(pTHX_ void *p) {
PERL_UNUSED_CONTEXT;
RStore_U32 *rs = p;
*rs->where = rs->what;
Safefree(rs);
}

static void sentinel_save_u32(Sentinel sen, U32 *pu) {
RStore_U32 *rs;
Newx(rs, 1, RStore_U32);
rs->where = pu;
rs->what = *pu;
sentinel_register(sen, rs, resource_store_u32);
}

#if HAVE_PERL_VERSION(5, 17, 2)
#define MY_OP_SLABBED(O) ((O)->op_slabbed)
Expand Down Expand Up @@ -1773,6 +1792,11 @@ static int parse_fun(pTHX_ Sentinel sen, OP **pop, const char *keyword_ptr, STRL
Perl_croak(aTHX_ "In %"SVf": I was expecting a function body, not \"%c\"", SVfARG(declarator), (int)c);
}

/* turn off line debugging for generated code */
sentinel_save_u32(sen, &PL_perldb);
const U32 prev_db_line = PL_perldb & PERLDBf_LINE;
PL_perldb &= ~PERLDBf_LINE;

/* surprise predeclaration! */
if (saw_name && !spec->install_sub && !(spec->flags & FLAG_RUNTIME)) {
/* 'sub NAME (PROTO);' to make name/proto known to perl before it
Expand Down Expand Up @@ -2365,6 +2389,8 @@ static int parse_fun(pTHX_ Sentinel sen, OP **pop, const char *keyword_ptr, STRL
}
}

PL_perldb |= prev_db_line;

/* finally let perl parse the actual subroutine body */
body = parse_block(0);

Expand Down

0 comments on commit 7ca8d03

Please sign in to comment.