Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed issue #756: Added support for ZEND_*_*_OBJ and self::*.

  • Loading branch information...
commit 8a54fca2be916675262f0aa951b3c05e9080a4f7 1 parent a251fd5
Derick Rethans authored February 28, 2012
59  tests/bug00756.phpt
... ...
@@ -0,0 +1,59 @@
  1
+--TEST--
  2
+Test for bug #756: Tracing doesn't always understand the variables and shows IS_VAR
  3
+--INI--
  4
+xdebug.auto_trace=0
  5
+xdebug.trace_options=0
  6
+xdebug.trace_output_dir=/tmp
  7
+xdebug.trace_output_name=trace.%c
  8
+xdebug.collect_return=1
  9
+xdebug.collect_params=3
  10
+xdebug.collect_assignments=1
  11
+xdebug.auto_profile=0
  12
+xdebug.profiler_enable=0
  13
+xdebug.dump_globals=0
  14
+xdebug.show_mem_delta=0
  15
+xdebug.trace_format=0
  16
+--FILE--
  17
+<?php
  18
+class foo
  19
+{
  20
+	static $bar;
  21
+	public $foo;
  22
+
  23
+	static function bar() 
  24
+	{
  25
+		self::$bar++;
  26
+	}
  27
+
  28
+	function foo()
  29
+	{
  30
+		$this->foo++;
  31
+	}
  32
+}
  33
+
  34
+$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE));
  35
+$trace_file = xdebug_get_tracefile_name();
  36
+
  37
+foo::bar();
  38
+$f = new foo;
  39
+$f->foo();
  40
+
  41
+echo file_get_contents($trace_file);
  42
+unlink($trace_file);
  43
+echo "DONE\n";
  44
+?>
  45
+--EXPECTF--
  46
+TRACE START [%d-%d-%d %d:%d:%d]
  47
+                         => $tf = '/tmp/xdt%s.%s.xt' %sbug00756.php:18
  48
+%w%f %w%d     -> xdebug_get_tracefile_name() %sbug00756.php:19
  49
+                           >=> '/tmp/xdt%s.%s.xt'
  50
+                         => $trace_file = '/tmp/xdt%s.%s.xt' %sbug00756.php:19
  51
+%w%f %w%d     -> foo::bar() %sbug00756.php:21
  52
+                           => self::bar++ %sbug00756.php:9
  53
+%w%f %w%d     -> foo->foo() %sbug00756.php:22
  54
+                           => $this->foo++ %sbug00756.php:14
  55
+                         => $f = class foo { public $foo = 1 } %sbug00756.php:22
  56
+%w%f %w%d     -> foo->foo() %sbug00756.php:23
  57
+                           => $this->foo++ %sbug00756.php:14
  58
+%w%f %w%d     -> file_get_contents('/tmp/xdt%s.%s.xt') %sbug00756.php:25
  59
+DONE
4  xdebug.c
@@ -577,6 +577,10 @@ PHP_MINIT_FUNCTION(xdebug)
577 577
 	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(post_inc, ZEND_POST_INC);
578 578
 	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(pre_dec, ZEND_PRE_DEC);
579 579
 	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(post_dec, ZEND_POST_DEC);
  580
+	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(pre_inc_obj, ZEND_PRE_INC_OBJ);
  581
+	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(post_inc_obj, ZEND_POST_INC_OBJ);
  582
+	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(pre_dec_obj, ZEND_PRE_DEC_OBJ);
  583
+	XDEBUG_SET_OPCODE_OVERRIDE_ASSIGN(post_dec_obj, ZEND_POST_DEC_OBJ);
580 584
 
581 585
 	zend_set_user_opcode_handler(ZEND_BEGIN_SILENCE, xdebug_silence_handler);
582 586
 	zend_set_user_opcode_handler(ZEND_END_SILENCE, xdebug_silence_handler);
29  xdebug_code_coverage.c
@@ -121,6 +121,10 @@ static char *xdebug_find_var_name(zend_execute_data *execute_data TSRMLS_DC)
121 121
 			xdebug_str_add(&name,xdebug_sprintf("[%s]", zval_value), 1);
122 122
 		}
123 123
 	}
  124
+	if (cur_opcode->opcode >= ZEND_PRE_INC_OBJ && cur_opcode->opcode <= ZEND_POST_DEC_OBJ) {
  125
+		zval_value = xdebug_get_zval_value(xdebug_get_zval(execute_data, &cur_opcode->op2, execute_data->Ts, &is_var), 0, options);
  126
+		xdebug_str_add(&name, xdebug_sprintf("$this->%s", zval_value), 1);
  127
+	}
124 128
 	if (zval_value) {
125 129
 		xdfree(zval_value);
126 130
 		zval_value = NULL;
@@ -129,7 +133,7 @@ static char *xdebug_find_var_name(zend_execute_data *execute_data TSRMLS_DC)
129 133
 	/* Scroll back to start of FETCHES */
130 134
 	gohungfound = 0;
131 135
 	opcode_ptr = prev_opcode;
132  
-	while (opcode_ptr->opcode == ZEND_FETCH_DIM_W || opcode_ptr->opcode == ZEND_FETCH_OBJ_W || opcode_ptr->opcode == ZEND_FETCH_W) {
  136
+	while (opcode_ptr->opcode == ZEND_FETCH_DIM_W || opcode_ptr->opcode == ZEND_FETCH_OBJ_W || opcode_ptr->opcode == ZEND_FETCH_W || opcode_ptr->opcode == ZEND_FETCH_RW) {
133 137
 		opcode_ptr = opcode_ptr - 1;
134 138
 		gohungfound = 1;
135 139
 	}
@@ -148,6 +152,10 @@ static char *xdebug_find_var_name(zend_execute_data *execute_data TSRMLS_DC)
148 152
 				zval_value = xdebug_get_zval_value(xdebug_get_zval(execute_data, &opcode_ptr->op1, execute_data->Ts, &is_var), 0, options);
149 153
 				xdebug_str_add(&name, xdebug_sprintf("%s", zval_value), 1);
150 154
 			}
  155
+			if (is_static && opcode_ptr->opcode == ZEND_FETCH_RW) {
  156
+				zval_value = xdebug_get_zval_value(xdebug_get_zval(execute_data, &opcode_ptr->op1, execute_data->Ts, &is_var), 0, options);
  157
+				xdebug_str_add(&name, xdebug_sprintf("%s", zval_value), 1);
  158
+			}
151 159
 			if (opcode_ptr->opcode == ZEND_FETCH_DIM_W) {
152 160
 				zval_value = xdebug_get_zval_value(xdebug_get_zval(execute_data, &opcode_ptr->op2, execute_data->Ts, &is_var), 0, NULL);
153 161
 				xdebug_str_add(&name, xdebug_sprintf("[%s]", zval_value), 1);
@@ -160,7 +168,7 @@ static char *xdebug_find_var_name(zend_execute_data *execute_data TSRMLS_DC)
160 168
 				xdfree(zval_value);
161 169
 				zval_value = NULL;
162 170
 			}
163  
-		} while (opcode_ptr->opcode == ZEND_FETCH_DIM_W || opcode_ptr->opcode == ZEND_FETCH_OBJ_W || opcode_ptr->opcode == ZEND_FETCH_W);
  171
+		} while (opcode_ptr->opcode == ZEND_FETCH_DIM_W || opcode_ptr->opcode == ZEND_FETCH_OBJ_W || opcode_ptr->opcode == ZEND_FETCH_W || opcode_ptr->opcode == ZEND_FETCH_RW);
164 172
 	}
165 173
 
166 174
 	if (cur_opcode->opcode == ZEND_ASSIGN_OBJ) {
@@ -223,6 +231,19 @@ static int xdebug_common_assign_dim_handler(char *op, int do_cc, ZEND_OPCODE_HAN
223 231
 			full_varname = tmp_varname;
224 232
 
225 233
 			val = xdebug_get_zval(execute_data, &cur_opcode->op1, execute_data->Ts, &is_var);
  234
+		} else if (cur_opcode->opcode >= ZEND_PRE_INC_OBJ && cur_opcode->opcode <= ZEND_POST_DEC_OBJ) {
  235
+			char *tmp_varname;
  236
+
  237
+			switch (cur_opcode->opcode) {
  238
+				case ZEND_PRE_INC_OBJ:  tmp_varname = xdebug_sprintf("++%s", full_varname); break;
  239
+				case ZEND_POST_INC_OBJ: tmp_varname = xdebug_sprintf("%s++", full_varname); break;
  240
+				case ZEND_PRE_DEC_OBJ:  tmp_varname = xdebug_sprintf("--%s", full_varname); break;
  241
+				case ZEND_POST_DEC_OBJ: tmp_varname = xdebug_sprintf("%s--", full_varname); break;
  242
+			}
  243
+			xdfree(full_varname);
  244
+			full_varname = tmp_varname;
  245
+
  246
+			val = xdebug_get_zval(execute_data, &cur_opcode->op2, execute_data->Ts, &is_var);
226 247
 		} else if (next_opcode->opcode == ZEND_OP_DATA) {
227 248
 			val = xdebug_get_zval(execute_data, &next_opcode->op1, execute_data->Ts, &is_var);
228 249
 		} else {
@@ -257,6 +278,10 @@ XDEBUG_OPCODE_OVERRIDE_ASSIGN(pre_inc,"",0)
257 278
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(post_inc,"",0)
258 279
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(pre_dec,"",0)
259 280
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(post_dec,"",0)
  281
+XDEBUG_OPCODE_OVERRIDE_ASSIGN(pre_inc_obj,"",0)
  282
+XDEBUG_OPCODE_OVERRIDE_ASSIGN(post_inc_obj,"",0)
  283
+XDEBUG_OPCODE_OVERRIDE_ASSIGN(pre_dec_obj,"",0)
  284
+XDEBUG_OPCODE_OVERRIDE_ASSIGN(post_dec_obj,"",0)
260 285
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(assign_concat,".=",1)
261 286
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(assign_bw_or,"|=",0)
262 287
 XDEBUG_OPCODE_OVERRIDE_ASSIGN(assign_bw_and,"&=",0)
4  xdebug_code_coverage.h
@@ -61,6 +61,10 @@ XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(pre_inc);
61 61
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(post_inc);
62 62
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(pre_dec);
63 63
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(post_dec);
  64
+XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(pre_inc_obj);
  65
+XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(post_inc_obj);
  66
+XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(pre_dec_obj);
  67
+XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(post_dec_obj);
64 68
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(assign_concat);
65 69
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(assign_bw_or);
66 70
 XDEBUG_OPCODE_OVERRIDE_ASSIGN_DECL(assign_bw_and);
2  xdebug_var.c
@@ -92,8 +92,6 @@ zval *xdebug_get_zval(zend_execute_data *zdata, znode *node, temp_variable *Ts,
92 92
 			*is_var = 1;
93 93
 			if (T(node->u.var).var.ptr) {
94 94
 				return T(node->u.var).var.ptr;
95  
-			} else {
96  
-				fprintf(stderr, "\nIS_VAR\n");
97 95
 			}
98 96
 			break;
99 97
 

0 notes on commit 8a54fca

Please sign in to comment.
Something went wrong with that request. Please try again.