[xdebug-dev] xdebug xdebug/xdebug_code_coverage.c xdebug/tests/bug00334.inc xdebug/tests/bug00334.phpt - MFH: Fixed bug #334: Code Coverage Regressions.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 12 Nov 2007 23:27:50 +0100

Date: Mon Nov 12 23:27:50 CET 2007
User: Derick Rethans
Directory: xdebug

Log Message:
[2.50]
- MFH: Fixed bug #334: Code Coverage Regressions.

Modified files:
           xdebug/xdebug_code_coverage.c (version: 1.32.2.6)
Added files:
           xdebug/tests/bug00334.inc (new version: 1.1.2.2)
           xdebug/tests/bug00334.phpt (new version: 1.1.2.2)

[FILE: /xdebug/xdebug_code_coverage.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.32.2.5
retrieving revision 1.32.2.6
diff -u -r1.32.2.5 -r1.32.2.6
--- xdebug/xdebug_code_coverage.c:1.32.2.5 Sun Nov 11 13:33:24 2007 GMT
+++ xdebug/xdebug_code_coverage.c Mon Nov 12 21:27:50 2007 GMT
@@ -114,12 +114,12 @@
 
 static int xdebug_find_jump(zend_op_array *opa, unsigned int position, int *jmp1, int *jmp2)
 {
- zend_uint base_address = (zend_uint) &(opa->opcodes[0]);
+ zend_op *base_address = &(opa->opcodes[0]);
 
         zend_op opcode = opa->opcodes[position];
         if (opcode.opcode == ZEND_JMP) {
 #ifdef ZEND_ENGINE_2
- *jmp1 = (opcode.op1.u.opline_num - base_address) / sizeof(zend_op);
+ *jmp1 = (opcode.op1.u.jmp_addr - base_address) / sizeof(zend_op);
 #else
                 *jmp1 = opcode.op1.u.opline_num;
 #endif
@@ -132,7 +132,7 @@
         ) {
                 *jmp1 = position + 1;
 #ifdef ZEND_ENGINE_2
- *jmp2 = (opcode.op2.u.opline_num - base_address) / sizeof(zend_op);
+ *jmp2 = (opcode.op2.u.jmp_addr - base_address) / sizeof(zend_op);
 #else
                 *jmp2 = opcode.op1.u.opline_num;
 #endif
@@ -144,7 +144,7 @@
         } else if (opcode.opcode == ZEND_BRK || opcode.opcode == ZEND_CONT) {
                 zend_brk_cont_element *el;
 
- if (opcode.op2.op_type == IS_CONST && opcode.op1.u.opline_num > -1) {
+ if (opcode.op2.op_type == IS_CONST && opcode.op1.u.jmp_addr != (zend_op*) 0xFFFFFFFF) {
                         el = xdebug_find_brk_cont(&opcode.op2.u.constant, opcode.op1.u.opline_num, opa);
                         *jmp1 = opcode.opcode == ZEND_BRK ? el->brk : el->cont;
                         return 1;

[FILE: /xdebug/tests/bug00334.inc]

<?php
//FILE: faulty.php
do
{
        if(true){break;} // 'Continue' also causes problems
        }
while(0);
?>

[FILE: /xdebug/tests/bug00334.phpt]

--TEST--
Test for bug #334: Code Coverage Regressions
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.profiler_enable=0
xdebug.trace_format=0
--FILE--
<?php
// Run me from the PHP CLI
xdebug_start_code_coverage(XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED);
// MUST be both code coverage options to cause problems
include(dirname(__FILE__).'/bug00334.inc'); // File with problem in it.
var_dump(xdebug_get_code_coverage());
xdebug_stop_code_coverage();
?>
--EXPECTF--
array(2) {
  ["%sbug00334.php"]=>
  array(2) {
    [5]=>
    int(1)
    [6]=>
    int(1)
  }
  ["%sbug00334.inc"]=>
  array(3) {
    [5]=>
    int(1)
    [7]=>
    int(-2)
    [9]=>
    int(1)
  }
}
Received on Mon Nov 12 2007 - 23:27:51 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST