View Issue Details

IDProjectCategoryView StatusLast Update
0000212Xdebug(No Category)public2006-10-18 16:43
ReporterswestcottAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version 
Target VersionFixed in Version 
Summary0000212: coverage coverage inaccurate
DescriptionXdebug 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,
  ),
)
Additional InformationPHP 5.1.6
Xdebug v2.0.0RC2-dev
TagsNo tags attached.
Operating SystemDebian Testing
PHP Version5.1.6

Activities

derick

2006-10-18 16:43

administrator   ~0000477

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!

Issue History

Date Modified Username Field Change
2006-10-18 16:20 swestcott New Issue
2006-10-18 16:43 derick Status new => resolved
2006-10-18 16:43 derick Resolution open => no change required
2006-10-18 16:43 derick Assigned To => derick
2006-10-18 16:43 derick Note Added: 0000477
2016-07-31 13:35 derick Category Debug client (console) => debugclient (debugging tool)
2016-07-31 13:35 derick Category debugclient (debugging tool) => (No Category)