[xdebug-dev] xdebug xdebug/xdebug.c - Made the code coverage a bit more accurate.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 28 Aug 2006 21:53:33 +0200

Date: Mon Aug 28 21:53:32 CEST 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[1.50]
- Made the code coverage a bit more accurate.

Modified files:
           xdebug/xdebug.c (version: 1.331)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -r1.330 -r1.331
--- xdebug/xdebug.c:1.330 Wed Aug 23 20:58:14 2006 GMT
+++ xdebug/xdebug.c Mon Aug 28 17:53:32 2006 GMT
@@ -92,24 +92,6 @@
 
 #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 0)
 int (*old_exit_handler)(ZEND_OPCODE_HANDLER_ARGS);
-
-static int (*old_jmp_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_jmpz_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_identical_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_not_identical_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_equal_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_not_equal_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_smaller_handler)(ZEND_OPCODE_HANDLER_ARGS);
-static int (*old_is_smaller_or_equal_handler)(ZEND_OPCODE_HANDLER_ARGS);
-
-static int xdebug_jmp_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_jmpz_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_identical_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_not_identical_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_equal_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_not_equal_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_smaller_handler(ZEND_OPCODE_HANDLER_ARGS);
-static int xdebug_is_smaller_or_equal_handler(ZEND_OPCODE_HANDLER_ARGS);
 #endif
 
 #ifdef ZEND_ENGINE_2
@@ -459,6 +441,10 @@
 #ifdef ZEND_ENGINE_2
 /* Needed for code coverage as Zend doesn't always add EXT_STMT when expected */
 # if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1) || PHP_MAJOR_VERSION >= 6
+
+#define XDEBUG_SET_OPCODE_OVERRIDE(f,oc) \
+ zend_set_user_opcode_handler(oc, xdebug_##f##_handler);
+
 #define XDEBUG_OPCODE_OVERRIDE(f) static int xdebug_##f##_handler(ZEND_OPCODE_HANDLER_ARGS) \
 { \
         if (XG(do_code_coverage)) { \
@@ -479,7 +465,13 @@
         return ZEND_USER_OPCODE_DISPATCH; \
 }
 #else
-#define XDEBUG_OPCODE_OVERRIDE(f) static int xdebug_##f##_handler(ZEND_OPCODE_HANDLER_ARGS) \
+#define XDEBUG_SET_OPCODE_OVERRIDE(f,oc) \
+ old_##f##_handler = zend_opcode_handlers[oc]; \
+ zend_opcode_handlers[oc] = xdebug_##f##_handler; \
+
+#define XDEBUG_OPCODE_OVERRIDE(f) \
+static int (*old_##f##_handler)(ZEND_OPCODE_HANDLER_ARGS); \
+static int xdebug_##f##_handler(ZEND_OPCODE_HANDLER_ARGS) \
 { \
         if (XG(do_code_coverage)) { \
                 zend_op *cur_opcode; \
@@ -498,6 +490,7 @@
         return old_##f##_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \
 }
 #endif
+
 XDEBUG_OPCODE_OVERRIDE(jmp)
 XDEBUG_OPCODE_OVERRIDE(jmpz)
 XDEBUG_OPCODE_OVERRIDE(is_identical)
@@ -506,6 +499,9 @@
 XDEBUG_OPCODE_OVERRIDE(is_not_equal)
 XDEBUG_OPCODE_OVERRIDE(is_smaller)
 XDEBUG_OPCODE_OVERRIDE(is_smaller_or_equal)
+XDEBUG_OPCODE_OVERRIDE(assign)
+XDEBUG_OPCODE_OVERRIDE(add_array_element)
+XDEBUG_OPCODE_OVERRIDE(return)
 #endif
 
 
@@ -538,39 +534,18 @@
         new_error_cb = xdebug_error_cb;
 
         /* Overload the "exit" opcode */
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 0)
- old_exit_handler = zend_opcode_handlers[ZEND_EXIT];
- zend_opcode_handlers[ZEND_EXIT] = xdebug_exit_handler;
-
- old_jmp_handler = zend_opcode_handlers[ZEND_JMP];
- old_jmpz_handler = zend_opcode_handlers[ZEND_JMPZ];
- old_is_identical_handler = zend_opcode_handlers[ZEND_IS_IDENTICAL];
- old_is_not_identical_handler = zend_opcode_handlers[ZEND_IS_NOT_IDENTICAL];
- old_is_equal_handler = zend_opcode_handlers[ZEND_IS_EQUAL];
- old_is_not_equal_handler = zend_opcode_handlers[ZEND_IS_NOT_EQUAL];
- old_is_smaller_handler = zend_opcode_handlers[ZEND_IS_SMALLER];
- old_is_smaller_or_equal_handler = zend_opcode_handlers[ZEND_IS_SMALLER_OR_EQUAL];
-
- zend_opcode_handlers[ZEND_JMP] = xdebug_jmp_handler;
- zend_opcode_handlers[ZEND_JMPZ] = xdebug_jmpz_handler;
- zend_opcode_handlers[ZEND_IS_IDENTICAL] = xdebug_is_identical_handler;
- zend_opcode_handlers[ZEND_IS_NOT_IDENTICAL] = xdebug_is_not_identical_handler;
- zend_opcode_handlers[ZEND_IS_EQUAL] = xdebug_is_equal_handler;
- zend_opcode_handlers[ZEND_IS_NOT_EQUAL] = xdebug_is_not_equal_handler;
- zend_opcode_handlers[ZEND_IS_SMALLER] = xdebug_is_smaller_handler;
- zend_opcode_handlers[ZEND_IS_SMALLER_OR_EQUAL] = xdebug_is_smaller_or_equal_handler;
-#endif
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1) || PHP_MAJOR_VERSION >= 6
- zend_set_user_opcode_handler(ZEND_EXIT, xdebug_exit_handler);
- zend_set_user_opcode_handler(ZEND_JMP, xdebug_jmp_handler);
- zend_set_user_opcode_handler(ZEND_JMPZ, xdebug_jmpz_handler);
- zend_set_user_opcode_handler(ZEND_IS_IDENTICAL, xdebug_is_identical_handler);
- zend_set_user_opcode_handler(ZEND_IS_NOT_IDENTICAL, xdebug_is_not_identical_handler);
- zend_set_user_opcode_handler(ZEND_IS_EQUAL, xdebug_is_equal_handler);
- zend_set_user_opcode_handler(ZEND_IS_NOT_EQUAL, xdebug_is_not_equal_handler);
- zend_set_user_opcode_handler(ZEND_IS_SMALLER, xdebug_is_smaller_handler);
- zend_set_user_opcode_handler(ZEND_IS_SMALLER_OR_EQUAL, xdebug_is_smaller_or_equal_handler);
-#endif
+ XDEBUG_SET_OPCODE_OVERRIDE(exit, ZEND_EXIT);
+ XDEBUG_SET_OPCODE_OVERRIDE(jmp, ZEND_JMP);
+ XDEBUG_SET_OPCODE_OVERRIDE(jmpz, ZEND_JMPZ);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_identical, ZEND_IS_IDENTICAL);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_not_identical, ZEND_IS_NOT_IDENTICAL);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_equal, ZEND_IS_EQUAL);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_not_equal, ZEND_IS_NOT_EQUAL);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_smaller, ZEND_IS_SMALLER);
+ XDEBUG_SET_OPCODE_OVERRIDE(is_smaller_or_equal, ZEND_IS_SMALLER_OR_EQUAL);
+ XDEBUG_SET_OPCODE_OVERRIDE(assign, ZEND_ASSIGN);
+ XDEBUG_SET_OPCODE_OVERRIDE(add_array_element, ZEND_ADD_ARRAY_ELEMENT);
+ XDEBUG_SET_OPCODE_OVERRIDE(return, ZEND_RETURN);
 
         if (zend_xdebug_initialised == 0) {
                 zend_error(E_WARNING, "Xdebug MUST be loaded as a Zend extension");
Received on Mon Aug 28 2006 - 21:53:39 BST

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