From: Gurusamy Sarathy Date: Wed, 1 Jan 1997 20:42:05 +0000 (-0500) Subject: Introduce CVf_NODEBUG flag X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3d90dd510fe5a67ed9b80e603493d285c30aa97;p=p5sagit%2Fp5-mst-13.2.git Introduce CVf_NODEBUG flag Subject: Re: debugger and XSUBs On Wed, 01 Jan 1997 13:45:32 EST, Chip Salzenberg wrote: >According to Gurusamy Sarathy: >> P.S: Porters: Come to think of if, I can't seem to find a >> good enough reason for why even XSUBs (like Alias::attr()) >> must be called by DB::sub() and not directly by perl (when >> perldb). Anyone else can? > >Nope. Actually, there is a case for it, since you may want to profile XSUBs. >> I ask because the fix will be much simpler in perl (just skip the >> OPpENTERSUB_DB indirection in pp_entersub() for XSUBs). > >I vote for this change. It's even a performance improvement. Here's a simple patch that offers the best of both worlds. I have added a new flag CVf_NODEBUG, that can be used to turn off the DB::sub indirection for specific CVs. This is most likely to be used on XSUBs that must depend on the calling scope's structure (which C<-d> alters), but can be used on the CV of plain subs as well. This facility will also be useful in Dprof, where one can conceivably turn off the profiling of all subs except the target one in the interest of accurately timing the target sub's performance. I do the following now in the BOOT: section of Alias.xs to disable debugging of Alias::attr(): BOOT: { GV *gv = gv_fetchpv("Alias::attr", FALSE, SVt_PVCV); if (gv && GvCV(gv)) CvNODEBUG_on(GvCV(gv)); } Perlanoids will be happy to note that this patch has no effect unless the -d switch is used. p5p-msgid: <199701012042.PAA25994@aatma.engin.umich.edu> --- diff --git a/cv.h b/cv.h index d94fb45..57e8142 100644 --- a/cv.h +++ b/cv.h @@ -48,6 +48,8 @@ struct xpvcv { #define CVf_ANON 0x04 /* CvGV() can't be trusted */ #define CVf_OLDSTYLE 0x08 #define CVf_UNIQUE 0x10 /* can't be cloned */ +#define CVf_NODEBUG 0x20 /* no DB::sub indirection for this CV + (esp. useful for special XSUBs) */ #define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE) #define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE) @@ -68,3 +70,7 @@ struct xpvcv { #define CvUNIQUE(cv) (CvFLAGS(cv) & CVf_UNIQUE) #define CvUNIQUE_on(cv) (CvFLAGS(cv) |= CVf_UNIQUE) #define CvUNIQUE_off(cv) (CvFLAGS(cv) &= ~CVf_UNIQUE) + +#define CvNODEBUG(cv) (CvFLAGS(cv) & CVf_NODEBUG) +#define CvNODEBUG_on(cv) (CvFLAGS(cv) |= CVf_NODEBUG) +#define CvNODEBUG_off(cv) (CvFLAGS(cv) &= ~CVf_NODEBUG) diff --git a/pp_hot.c b/pp_hot.c index f957deb..b02a32e 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1760,7 +1760,7 @@ PP(pp_entersub) } gimme = GIMME; - if ((op->op_private & OPpENTERSUB_DB)) { + if ((op->op_private & OPpENTERSUB_DB) && !CvNODEBUG(cv)) { SV *oldsv = sv; sv = GvSV(DBsub); save_item(sv);