[xdebug-dev] Bug 0000212: coverage coverage inaccurate

From: <xdebug-dev[@]lists.xdebug.org>
Date: Wed, 18 Oct 2006 16:43:34 +0200

The following bug has been RESOLVED.
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000212
======================================================================
Reporter: swestcott
Handler: derick
======================================================================
Project: Xdebug
Bug ID: 212
Category: Debug client (console)
Reproducibility: always
Severity: minor
Priority: normal
Status: resolved
Operating System: Debian Testing
PHP Version: 5.1.6
Xdebug Version: 2.0.0rc2-dev
Resolution: not a bug
======================================================================
Date Submitted: 2006-10-18 16:20 CEST
Last Modified: 2006-10-18 16:43 CEST
======================================================================
Summary: coverage coverage inaccurate
Description:
Xdebug doesn't report execution of switch and try statements and class
constants. I'm not sure whether this is a feature or a bug and I couldn't
find the answer elsewhere.

  1 <?php
  2
  3 xdebug_start_code_coverage();
  4
  5 $action = '';
  6
  7 switch($action)
  8 {
  9 default:
 10 }
 11
 12 var_export(xdebug_get_code_coverage());
 13
 14 ?>

Line 7 is missing here
array (
  '/home/simon/switch_xdebug.php' =>
  array (
    5 => 1,
    9 => 1,
    10 => 1,
    12 => 1,
  ),
)

  1 <?php
  2
  3 xdebug_start_code_coverage();
  4
  5 try
  6 {
  7 throw new Exception();
  8 }
  9 catch(Exception $e) {}
 10
 11 var_export(xdebug_get_code_coverage());
 12
 13 ?>

Line 5 is missing here
array (
  '/home/simon/try_catch_xdebug.php' =>
  array (
    7 => 1,
    9 => 1,
    11 => 1,
  ),
)

  1 <?php
  2
  3 xdebug_start_code_coverage();
  4
  5 class foo
  6 {
  7 const MESSAGE = 'Hello World';
  8 }
  9
 10 echo foo::MESSAGE;
 11
 12 var_export(xdebug_get_code_coverage());
 13
 14 ?>

Line 7 is missing here
array (
  '/home/simon/const_xdebug.php' =>
  array (
    6 => 1,
    10 => 1,
    12 => 1,
  ),
)
======================================================================

----------------------------------------------------------------------
 derick - 2006-10-18 16:43 CEST
----------------------------------------------------------------------
Hello,

In all three cases, there is not a bug and it's simply how the Zend engine
internally works.

1. The switch statement is optimized out into a NOP (on line 7):

line # op fetch ext operands
-------------------------------------------------------------------------------
   5 0 EXT_STMT
         1 ASSIGN !0, ''
   7 2 NOP
   9 3 EXT_STMT
         4 JMP ->6

2. "try" is just a place holder for something, and is turned into a NOP
(on line 5):

line # op fetch ext operands
-------------------------------------------------------------------------------
   5 0 NOP
   7 1 EXT_STMT
         2 ZEND_FETCH_CLASS :0,
'Exception'

3. Class constants are part of the class definition, and do not take up
executable code. They are resolved at compile time, and are therefore not
in the code coverage.

However, I did find a different bug while analyzing your 3 examples. I
will file that as a new report myself though.

Thanks for submitting this issue!

Bug History
Date Modified Username Field Change
======================================================================
2006-10-18 16:20swestcott New Bug
2006-10-18 16:20swestcott Bug Monitored: swestcott
2006-10-18 16:43derick Bugnote Added: 0000477
2006-10-18 16:43derick Assigned To => derick
2006-10-18 16:43derick Resolution open => not a bug
2006-10-18 16:43derick Status new => resolved
======================================================================
Received on Wed Oct 18 2006 - 16:43:39 BST

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