diff options
author | Yves Orton <demerphq@gmail.com> | 2016-03-11 10:36:25 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2016-03-13 12:39:23 +0100 |
commit | cb41e5d6f2193df9fd06cf60a96285694ec458ba (patch) | |
tree | 3c3d1c14ff4fa8705920eaeb1ab6378977d4948c /proto.h | |
parent | febe9c7a66e3a16aba6a75e5550c8005ecb52f10 (diff) | |
download | perl-cb41e5d6f2193df9fd06cf60a96285694ec458ba.tar.gz |
Rework diagnostics in the regex engine
This introduces three new subs:
Perl_re_printf() which is a wrapper for
PerlIO_printf( Perl_debug_log, ... ),
which cuts down on clutter in the code. Arguably this could be moved
to util.c and renamed something like PerlIO_debugf() and then we could
declutter all the statements that write to the Perl_debug_log
filehandle. But that is a bit too ambituous for me right now, so
I leave this as a regex engine only sub for now.
Perl_re_indentf() which is a wrapper for PerlIO_re_printf(),
which adds an indent argument and automatically indents the
line appropriately, and is used in regcomp.c for trace diagnostics
during compilation.
Perl_re_indentfo() which is similar to Perl_re_indentf() but
is used in regexec.c which adds a specific prefix to each indented
line to account for the fact that during execution we normally have
string position information on the left.
The end result of this patch is that a lot of clutter in the debugging
statements in the regex engine is reduced, exposing what is actually
going on. It should also now be easier to add new diagnostics which
"do the right thing".
Over time the debugging trace output in regexec has become
very cluttered and confusing. This patch cleans much of it up,
if something happens at a given recursion depth it is output
at the right depth, etc, and formats have been changed to not have
leading spaces so you can actually see the indentation properly.
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -3854,6 +3854,9 @@ STATIC void S_put_code_point(pTHX_ SV* sv, UV c); STATIC void S_put_range(pTHX_ SV* sv, UV start, const UV end, const bool allow_literals); #define PERL_ARGS_ASSERT_PUT_RANGE \ assert(sv) +PERL_CALLCONV int Perl_re_indentf(const char *fmt, U32 depth, ...); +#define PERL_ARGS_ASSERT_RE_INDENTF \ + assert(fmt) STATIC void S_regdump_extflags(pTHX_ const char *lead, const U32 flags); STATIC void S_regdump_intflags(pTHX_ const char *lead, const U32 flags); STATIC U8 S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode *p, const regnode *val, U32 depth); @@ -3864,9 +3867,12 @@ STATIC U8 S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode *p, const reg STATIC void S_debug_start_match(pTHX_ const REGEXP *prog, const bool do_utf8, const char *start, const char *end, const char *blurb); #define PERL_ARGS_ASSERT_DEBUG_START_MATCH \ assert(prog); assert(start); assert(end); assert(blurb) -STATIC void S_dump_exec_pos(pTHX_ const char *locinput, const regnode *scan, const char *loc_regeol, const char *loc_bostr, const char *loc_reg_starttry, const bool do_utf8); +STATIC void S_dump_exec_pos(pTHX_ const char *locinput, const regnode *scan, const char *loc_regeol, const char *loc_bostr, const char *loc_reg_starttry, const bool do_utf8, U32 depth); #define PERL_ARGS_ASSERT_DUMP_EXEC_POS \ assert(locinput); assert(scan); assert(loc_regeol); assert(loc_bostr); assert(loc_reg_starttry) +PERL_CALLCONV int Perl_re_indentfo(const char *fmt, U32 depth, ...); +#define PERL_ARGS_ASSERT_RE_INDENTFO \ + assert(fmt) # endif # if defined(PERL_IN_SV_C) STATIC void S_del_sv(pTHX_ SV *p); @@ -4938,6 +4944,9 @@ PERL_CALLCONV SV* Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, co #define PERL_ARGS_ASSERT__GET_REGCLASS_NONBITMAP_DATA \ assert(node) PERL_CALLCONV void Perl__load_PL_utf8_foldclosures(pTHX); +PERL_CALLCONV int Perl_re_printf(const char *fmt, ...); +#define PERL_ARGS_ASSERT_RE_PRINTF \ + assert(fmt) PERL_CALLCONV void Perl_regprop(pTHX_ const regexp *prog, SV* sv, const regnode* o, const regmatch_info *reginfo, const RExC_state_t *pRExC_state); #define PERL_ARGS_ASSERT_REGPROP \ assert(sv); assert(o) |