[xdebug-dev] xdebug xdebug/xdebug_code_coverage.c xdebug/tests/bug00213.inc xdebug/tests/bug00213.phpt - Fixed bug #213: Dead code analysis doesn't take catches for throws into

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Wed, 18 Oct 2006 20:46:45 +0200

Date: Wed Oct 18 20:46:44 CEST 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[0.50]
- Fixed bug #213: Dead code analysis doesn't take catches for throws into
  account.

Modified files:
           xdebug/xdebug_code_coverage.c (version: 1.28)
Added files:
           xdebug/tests/bug00213.inc (new version: 1.1)
           xdebug/tests/bug00213.phpt (new version: 1.1)

[FILE: /xdebug/xdebug_code_coverage.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- xdebug/xdebug_code_coverage.c:1.27 Mon Oct 16 18:11:23 2006 GMT
+++ xdebug/xdebug_code_coverage.c Wed Oct 18 16:46:44 2006 GMT
@@ -192,7 +192,15 @@
                 /* See if we have a throw instruction */
                 if (opa->opcodes[position].opcode == ZEND_THROW) {
                         /* fprintf(stderr, "X* Throw found\n"); */
- break;
+ /* Now we need to go forward to the first
+ * zend_fetch_class/zend_catch combo */
+ while (position < opa->size) {
+ position++;
+ if (opa->opcodes[position].opcode == ZEND_CATCH) {
+ position -= 2;
+ break;
+ }
+ }
                 }
 #endif
 

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

<?php

try
{
    throw new Exception();
        echo strlen( "Revenge is a dish best served cold.\n" );
}
catch(Exception $e)
{
}

echo strlen( "The fire is always hotter on someone elses face." ), "\n";
?>

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

--TEST--
Test for bug #213: Dead code analysis doesn't take catches for throws into account.
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--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.auto_profile=0
xdebug.profiler_enable=0
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
--FILE--
<?php
        xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
        $file = realpath('./tests/bug00213.inc');
        include $file;
        $cc = xdebug_get_code_coverage();
        xdebug_stop_code_coverage();
        var_dump($cc[$file]);
?>
--EXPECT--
48
array(5) {
  [5]=>
  int(1)
  [6]=>
  int(-2)
  [8]=>
  int(1)
  [12]=>
  int(1)
  [14]=>
  int(1)
}
Received on Wed Oct 18 2006 - 20:46:53 BST

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