From 4fd30c9565dc9ee4fdc59beee0e98c2f0508178e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 9 Dec 2015 17:21:57 +0300 Subject: [PATCH] Improve debugging of non-local variables --- ext/opcache/Optimizer/block_pass.c | 9 ++------- ext/opcache/Optimizer/zend_optimizer.h | 2 ++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 6aab22eff5..8c0bc91762 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -30,8 +30,6 @@ #include "zend_cfg.h" #include "zend_dump.h" -#define DEBUG_BLOCKPASS 0 - /* Checks if a constant (like "true") may be replaced by its value */ int zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy) { @@ -1534,15 +1532,14 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use } } -#if DEBUG_BLOCKPASS > 2 - { + if (ctx->debug_level & ZEND_DUMP_BLOCK_PASS_VARS) { int printed = 0; uint32_t i; for (i = op_array->last_var; i< op_array->T; i++) { if (zend_bitset_in(used_ext, i)) { if (!printed) { - fprintf(stderr, "NON-LOCAL-VARS: %s: %d", op_array->function_name ? op_array->function_name->val : "(null)", i); + fprintf(stderr, "NON-LOCAL-VARS: %d", i); printed = 1; } else { fprintf(stderr, ", %d", i); @@ -1551,10 +1548,8 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use } if (printed) { fprintf(stderr, "\n"); - zend_dump_op_array(op_array, cfg, 0); } } -#endif for (n = 0; n < cfg->blocks_count; n++) { block = cfg->blocks + n; diff --git a/ext/opcache/Optimizer/zend_optimizer.h b/ext/opcache/Optimizer/zend_optimizer.h index c8e33c368e..c1013013ce 100644 --- a/ext/opcache/Optimizer/zend_optimizer.h +++ b/ext/opcache/Optimizer/zend_optimizer.h @@ -62,8 +62,10 @@ #define ZEND_DUMP_BEFORE_OPTIMIZER (1<<16) #define ZEND_DUMP_AFTER_OPTIMIZER (1<<17) + #define ZEND_DUMP_BEFORE_BLOCK_PASS (1<<18) #define ZEND_DUMP_AFTER_BLOCK_PASS (1<<19) +#define ZEND_DUMP_BLOCK_PASS_VARS (1<<20) typedef struct _zend_script { zend_string *filename; -- 2.40.0