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>
#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)
#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)
}
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);