diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2003-06-27 23:26:24 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-06-28 15:39:57 +0000 |
commit | b4ab917c3d812d8e61d365bfa48d9bf7675bc113 (patch) | |
tree | 03f4a25b24bafea2e817ad09779a5859dc55790b | |
parent | 1d26cd9ec5ffb2d7823fb6941a001dc8e9a6d1c6 (diff) | |
download | perl-b4ab917c3d812d8e61d365bfa48d9bf7675bc113.tar.gz |
Two debugging patches.
The first allows to hold symbolic switches in $^D
and more generally fixes assignment to $^D. The
second one improves the information given by -Dl.
Subject: [PATCH] allow $^D = "flags"
Date: Fri, 27 Jun 2003 22:26:24 +0100
Message-ID: <20030627212624.GB12887@fdgroup.com>
Subject: [PATCH] make -Dl show more scope info
From: Dave Mitchell <davem@fdgroup.com>
Date: Fri, 27 Jun 2003 23:00:36 +0100
Message-ID: <20030627220036.GC12887@fdgroup.com>
p4raw-id: //depot/perl@19870
-rw-r--r-- | cop.h | 4 | ||||
-rw-r--r-- | embed.fnc | 3 | ||||
-rw-r--r-- | embed.h | 10 | ||||
-rw-r--r-- | mg.c | 7 | ||||
-rw-r--r-- | perl.c | 54 | ||||
-rw-r--r-- | perl.h | 7 | ||||
-rw-r--r-- | pod/perlvar.pod | 3 | ||||
-rw-r--r-- | proto.h | 3 | ||||
-rw-r--r-- | scope.h | 6 |
9 files changed, 72 insertions, 25 deletions
@@ -334,6 +334,7 @@ struct block { PL_retstack_ix = cx->blk_oldretsp, \ pm = cx->blk_oldpm, \ gimme = cx->blk_gimme; \ + DEBUG_SCOPE("POPBLOCK"); \ DEBUG_l( PerlIO_printf(Perl_debug_log, "Leaving block %ld, type %s\n", \ (long)cxstack_ix+1,PL_block_type[CxTYPE(cx)]); ) @@ -343,7 +344,8 @@ struct block { PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp, \ PL_scopestack_ix = cx->blk_oldscopesp, \ PL_retstack_ix = cx->blk_oldretsp, \ - PL_curpm = cx->blk_oldpm + PL_curpm = cx->blk_oldpm; \ + DEBUG_SCOPE("TOPBLOCK"); /* substitution context */ struct subst { @@ -1386,6 +1386,9 @@ sd |void |cv_dump |CV *cv|char *title #endif pd |CV* |find_runcv |U32 *db_seqp p |void |free_tied_hv_pool +#if defined(DEBUGGING) +p |int |get_debug_opts |char **s +#endif @@ -2141,6 +2141,11 @@ #ifdef PERL_CORE #define free_tied_hv_pool Perl_free_tied_hv_pool #endif +#if defined(DEBUGGING) +#ifdef PERL_CORE +#define get_debug_opts Perl_get_debug_opts +#endif +#endif #define ck_anoncode Perl_ck_anoncode #define ck_bitop Perl_ck_bitop #define ck_concat Perl_ck_concat @@ -4618,6 +4623,11 @@ #ifdef PERL_CORE #define free_tied_hv_pool() Perl_free_tied_hv_pool(aTHX) #endif +#if defined(DEBUGGING) +#ifdef PERL_CORE +#define get_debug_opts(a) Perl_get_debug_opts(aTHX_ a) +#endif +#endif #define ck_anoncode(a) Perl_ck_anoncode(aTHX_ a) #define ck_bitop(a) Perl_ck_bitop(aTHX_ a) #define ck_concat(a) Perl_ck_concat(aTHX_ a) @@ -1975,8 +1975,13 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; case '\004': /* ^D */ - PL_debug = (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) | DEBUG_TOP_FLAG; +#ifdef DEBUGGING + s = SvPV_nolen(sv); + PL_debug = get_debug_opts(&s) | DEBUG_TOP_FLAG; DEBUG_x(dump_all()); +#else + PL_debug = (SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) | DEBUG_TOP_FLAG; +#endif break; case '\005': /* ^E */ if (*(mg->mg_ptr+1) == '\0') { @@ -2196,6 +2196,40 @@ NULL PerlIO_printf(PerlIO_stdout(), "\n %s", *p++); } +/* convert a string of -D options (or digits) into an int. + * sets *s to point to the char after the options */ + +#ifdef DEBUGGING +int +Perl_get_debug_opts(pTHX_ char **s) +{ + int i = 0; + if (isALPHA(**s)) { + /* if adding extra options, remember to update DEBUG_MASK */ + static char debopts[] = "psltocPmfrxu HXDSTRJvC"; + + for (; isALNUM(**s); (*s)++) { + char *d = strchr(debopts,**s); + if (d) + i |= 1 << (d - debopts); + else if (ckWARN_d(WARN_DEBUGGING)) + Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), + "invalid option -D%c\n", **s); + } + } + else { + i = atoi(*s); + for (; isALNUM(**s); (*s)++) ; + } +# ifdef EBCDIC + if ((i & DEBUG_p_FLAG) && ckWARN_d(WARN_DEBUGGING)) + Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), + "-Dp not implemented on this platform\n"); +# endif + return i; +} +#endif + /* This routine handles any switches that can be given during run */ char * @@ -2295,24 +2329,8 @@ Perl_moreswitches(pTHX_ char *s) { #ifdef DEBUGGING forbid_setid("-D"); - if (isALPHA(s[1])) { - /* if adding extra options, remember to update DEBUG_MASK */ - static char debopts[] = "psltocPmfrxu HXDSTRJvC"; - char *d; - - for (s++; *s && (d = strchr(debopts,*s)); s++) - PL_debug |= 1 << (d - debopts); - } - else { - PL_debug = atoi(s+1); - for (s++; isDIGIT(*s); s++) ; - } -#ifdef EBCDIC - if (DEBUG_p_TEST_ && ckWARN_d(WARN_DEBUGGING)) - Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), - "-Dp not implemented on this platform\n"); -#endif - PL_debug |= DEBUG_TOP_FLAG; + s++; + PL_debug = get_debug_opts(&s) | DEBUG_TOP_FLAG; #else /* !DEBUGGING */ if (ckWARN_d(WARN_DEBUGGING)) Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), @@ -2628,6 +2628,13 @@ Gid_t getegid (void); #endif /* DEBUGGING */ +#define DEBUG_SCOPE(where) \ + DEBUG_l(WITH_THR(Perl_deb(aTHX_ "%s scope %ld at %s:%d\n", \ + where, PL_scopestack_ix, __FILE__, __LINE__))); + + + + /* These constants should be used in preference to raw characters * when using magic. Note that some perl guts still assume * certain character properties of these constants, namely that diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 6e2a853007..ad791dd71b 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -902,7 +902,8 @@ C<$^C = 1> is similar to calling C<B::minus_c>. =item $^D The current value of the debugging flags. (Mnemonic: value of B<-D> -switch.) +switch.) May be read or set. Like its command-line equivalent, you can use +numeric or symbolic values, eg C<$^D = 10> or C<$^D = "st">. =item $SYSTEM_FD_MAX @@ -1326,6 +1326,9 @@ STATIC void S_cv_dump(pTHX_ CV *cv, char *title); #endif PERL_CALLCONV CV* Perl_find_runcv(pTHX_ U32 *db_seqp); PERL_CALLCONV void Perl_free_tied_hv_pool(pTHX); +#if defined(DEBUGGING) +PERL_CALLCONV int Perl_get_debug_opts(pTHX_ char **s); +#endif @@ -96,13 +96,11 @@ Closing bracket on a callback. See C<ENTER> and L<perlcall>. #define ENTER \ STMT_START { \ push_scope(); \ - DEBUG_l(WITH_THR(Perl_deb(aTHX_ "ENTER scope %ld at %s:%d\n", \ - PL_scopestack_ix, __FILE__, __LINE__))); \ + DEBUG_SCOPE("ENTER") \ } STMT_END #define LEAVE \ STMT_START { \ - DEBUG_l(WITH_THR(Perl_deb(aTHX_ "LEAVE scope %ld at %s:%d\n", \ - PL_scopestack_ix, __FILE__, __LINE__))); \ + DEBUG_SCOPE("LEAVE") \ pop_scope(); \ } STMT_END #else |