[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
@{"_<$filename"} is unreasonably tied to use of DB::DB ($^P & 0x2)
The perldebguts pod says that @{"_<$filename"} holds the lines of
source code of $filename. That's implemented by a call in pp_ctl.c
to save_lines().
The call to save_lines() is only made if PERLDB_LINE is true ($^P & 0x2).
PERLDB_LINE is used primarily to enable single-stepping or profiling
by calling the DB::DB() for every statement.
So currently you can't introspect the source code of files (or evals,
and "perl -" or "perl -e '...'") without enabling single-stepping!
This is an issue for NYTProf because it would like to be able to save
the source code of evals etc. but would like to avoid using the slow
expensive DB::DB style of profiling.
The attached basic patch enables a separate bit to control saving source
lines.
Any chance this, or something like it, could go into 5.10.1?
Tim.
--- perl-5.10.0/perl.h 2007-12-18 10:47:08.000000000 +0000
+++ perl-5.10.0-savesrc/perl.h 2008-10-28 15:07:39.000000000 +0000
@@ -5240,7 +5240,8 @@
#define PERLDB_ALL (PERLDBf_SUB | PERLDBf_LINE | \
PERLDBf_NOOPT | PERLDBf_INTER | \
PERLDBf_SUBLINE| PERLDBf_SINGLE| \
- PERLDBf_NAMEEVAL| PERLDBf_NAMEANON )
+ PERLDBf_NAMEEVAL| PERLDBf_NAMEANON | \
+ PERLDBf_SAVESRC)
/* No _NONAME, _GOTO, _ASSERTION */
#define PERLDBf_SUB 0x01 /* Debug sub enter/exit */
#define PERLDBf_LINE 0x02 /* Keep line # */
@@ -5253,6 +5254,8 @@
#define PERLDBf_GOTO 0x80 /* Report goto: call DB::goto */
#define PERLDBf_NAMEEVAL 0x100 /* Informative names for evals */
#define PERLDBf_NAMEANON 0x200 /* Informative names for anon subs */
+/* PERLDB_ASSERTION 0x400 -- deprecated? */
+#define PERLDBf_SAVESRC 0x800 /* Save source lines into @{"_<$filename"} */
#define PERLDB_SUB (PL_perldb && (PL_perldb & PERLDBf_SUB))
#define PERLDB_LINE (PL_perldb && (PL_perldb & PERLDBf_LINE))
@@ -5265,6 +5268,7 @@
#define PERLDB_NAMEEVAL (PL_perldb && (PL_perldb & PERLDBf_NAMEEVAL))
#define PERLDB_NAMEANON (PL_perldb && (PL_perldb & PERLDBf_NAMEANON))
#define PERLDB_ASSERTION (PL_perldb && (PL_perldb & PERLDBf_ASSERTION))
+#define PERLDB_SAVESRC (PL_perldb && (PL_perldb & PERLDBf_SAVESRC))
#ifdef USE_LOCALE_NUMERIC
diff -u perl-5.10.0/pp_ctl.c perl-5.10.0-savesrc/pp_ctl.c
--- perl-5.10.0/pp_ctl.c 2007-12-18 10:47:08.000000000 +0000
+++ perl-5.10.0-savesrc/pp_ctl.c 2008-10-28 10:03:56.000000000 +0000
@@ -3609,7 +3609,7 @@
/* prepare to compile string */
- if (PERLDB_LINE && PL_curstash != PL_debstash)
+ if (PERLDB_SAVESRC && PL_curstash != PL_debstash)
save_lines(CopFILEAV(&PL_compiling), PL_parser->linestr);
PUTBACK;
ok = doeval(gimme, NULL, runcv, seq);
- Follow-Ups from:
-
Nicholas Clark <nick@ccl4.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]