summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@engin.umich.edu>1997-01-01 15:42:05 -0500
committerChip Salzenberg <chip@atlantic.net>1997-01-04 17:44:00 +1200
commita3d90dd510fe5a67ed9b80e603493d285c30aa97 (patch)
tree0dabca893a0ebce18c291b35804a173c350df3d3
parent7cfe7857715f78206e6d7d6f7fd52983de4dec44 (diff)
downloadperl-a3d90dd510fe5a67ed9b80e603493d285c30aa97.tar.gz
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>
-rw-r--r--cv.h6
-rw-r--r--pp_hot.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/cv.h b/cv.h
index d94fb45b62..57e814298f 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 f957deb956..b02a32ec05 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);