Permalink
Browse files

Fixed issue #766: Xdebug doesn't understand ZEND_RETURN_BY_REF in PHP…

… 5.4.
  • Loading branch information...
1 parent edd2845 commit 04f80138fbdf14c34cf70ced8728abe0497e1e6d @derickr committed Jan 12, 2012
Showing with 66 additions and 1 deletion.
  1. +10 −0 tests/bug00766.inc
  2. +47 −0 tests/bug00766.phpt
  3. +3 −0 xdebug.c
  4. +6 −1 xdebug_code_coverage.c
View
10 tests/bug00766.inc
@@ -0,0 +1,10 @@
+<?php
+class Foo {
+ static $domains = array('a' => 'b');
+
+ static public function &getDomain($domain) {
+ return self::$domains[$domain];
+ }
+}
+
+Foo::getDomain('a');
View
47 tests/bug00766.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test for bug #766: Xdebug doesn't understand ZEND_RETURN_BY_REF (>= PHP 5.4)
+--SKIPIF--
+<?php if (!version_compare(phpversion(), "5.4", '>=')) echo "skip >= PHP 5.4 needed\n"; ?>
+--INI--
+xdebug.default_enable=1
+xdebug.auto_trace=0
+xdebug.trace_options=0
+xdebug.trace_output_dir=/tmp
+xdebug.collect_params=1
+xdebug.collect_return=0
+xdebug.collect_assignments=0
+xdebug.auto_profile=0
+xdebug.profiler_enable=0
+xdebug.dump_globals=0
+xdebug.show_mem_delta=0
+xdebug.trace_format=0
+xdebug.extended_info=1
+xdebug.coverage_enable=1
+xdebug.overload_var_dump=0
+--FILE--
+<?php
+ xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
+
+ include 'bug00766.inc';
+ $cc = xdebug_get_code_coverage();
+ ksort($cc);
+ var_dump(array_slice($cc, 0, 1));
+
+ xdebug_stop_code_coverage(false);
+?>
+--EXPECTF--
+array(1) {
+ ["%sbug00766.inc"]=>
+ array(5) {
+ [2]=>
+ int(1)
+ [6]=>
+ int(1)
+ [7]=>
+ int(-2)
+ [10]=>
+ int(1)
+ [11]=>
+ int(1)
+ }
+}
View
3 xdebug.c
@@ -562,6 +562,9 @@ PHP_MINIT_FUNCTION(xdebug)
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_ADD_ARRAY_ELEMENT);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_RETURN);
+#if PHP_VERSION_ID >= 50400
+ XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_RETURN_BY_REF);
+#endif
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_EXT_STMT);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_RAISE_ABSTRACT_ERROR);
XDEBUG_SET_OPCODE_OVERRIDE_COMMON(ZEND_SEND_VAR);
View
7 xdebug_code_coverage.c
@@ -446,7 +446,12 @@ static void xdebug_analyse_branch(zend_op_array *opa, unsigned int position, xde
break;
}
/* See if we have a return instruction */
- if (opa->opcodes[position].opcode == ZEND_RETURN) {
+ if (
+ opa->opcodes[position].opcode == ZEND_RETURN
+#if PHP_VERSION_ID >= 50400
+ || opa->opcodes[position].opcode == ZEND_RETURN_BY_REF
+#endif
+ ) {
/*(fprintf(stderr, "XDEBUG Return found\n");)*/
break;
}

0 comments on commit 04f8013

Please sign in to comment.