#include "perl.h"
#include "XSUB.h"
+/* define DBG_SUB to cause a warning on each subroutine entry. */
/*#define DBG_SUB 1 */
-/*#define DBG_TIMER 1 */
+
+/* define DBG_TIMER to cause a warning when the timer is turned on and off. */
+/*#define DBG_TIMER 1 */
#ifdef DBG_SUB
-# define DBG_SUB_NOTIFY(A,B) warn(A, B)
+# define DBG_SUB_NOTIFY(A) dprof_dbg_sub_notify(A)
+void
+dprof_dbg_sub_notify(SV *Sub) {
+ CV *cv = INT2PTR(CV*,SvIVX(Sub));
+ GV *gv = cv ? CvGV(cv) : NULL;
+ if (cv && gv) {
+ warn("XS DBsub(%s::%s)\n",
+ ((GvSTASH(gv) && HvNAME(GvSTASH(gv))) ?
+ HvNAME(GvSTASH(gv)) : "(null)"),
+ GvNAME(gv));
+ } else {
+ warn("XS DBsub(unknown) at %x", Sub);
+ }
+}
#else
-# define DBG_SUB_NOTIFY(A,B) /* nothing */
+# define DBG_SUB_NOTIFY(A) /* nothing */
#endif
+
#ifdef DBG_TIMER
# define DBG_TIMER_NOTIFY(A) warn(A)
#else
{
HV *oldstash = PL_curstash;
- DBG_SUB_NOTIFY("XS DBsub(%s)\n", SvPV_nolen(Sub));
+ DBG_SUB_NOTIFY(Sub);
SAVEDESTRUCTOR_X(check_depth, INT2PTR(void*,g_depth));
g_depth++;
HV *oldstash = PL_curstash;
SV *Sub = GvSV(PL_DBsub); /* name of current sub */
/* SP -= items; added by xsubpp */
- DBG_SUB_NOTIFY("XS DBsub(%s)\n", SvPV_nolen(Sub));
+ DBG_SUB_NOTIFY(Sub);
sv_setiv(PL_DBsingle, 0); /* disable DB single-stepping */