[xdebug-dev] xdebug xdebug/xdebug_code_coverage.c xdebug/xdebug_compat.h xdebug/xdebug_superglobals.c xdebug/xdebug_var.c - MFH: Fixed TSRM issues for PHP 5.2 and PHP 5.3. (Original patch by Elizabeth

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Sat, 28 Mar 2009 16:58:58 +0100

Date: Sat Mar 28 16:58:57 CET 2009
User: Derick Rethans
Directory: xdebug

Log Message:
[1.00]
- MFH: Fixed TSRM issues for PHP 5.2 and PHP 5.3. (Original patch by Elizabeth
  M. Smith).

Modified files:
           xdebug/xdebug_code_coverage.c (version: 1.32.2.14)
           xdebug/xdebug_compat.h (version: 1.7.2.2)
           xdebug/xdebug_superglobals.c (version: 1.24.2.4)
           xdebug/xdebug_var.c (version: 1.86.2.6)

[FILE: /xdebug/xdebug_code_coverage.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.32.2.13
retrieving revision 1.32.2.14
diff -u -r1.32.2.13 -r1.32.2.14
--- xdebug/xdebug_code_coverage.c:1.32.2.13 Sat Jan 24 19:02:21 2009 GMT
+++ xdebug/xdebug_code_coverage.c Sat Mar 28 14:58:57 2009 GMT
@@ -21,6 +21,7 @@
 #include "xdebug_set.h"
 #include "xdebug_var.h"
 #include "xdebug_code_coverage.h"
+#include "xdebug_compat.h"
 
 extern ZEND_DECLARE_MODULE_GLOBALS(xdebug);
 
@@ -268,10 +269,12 @@
         }
 }
 
-static int prefill_from_function_table(zend_op_array *opa, int num_args, va_list args, zend_hash_key *hash_key)
+static int prefill_from_function_table(zend_op_array *opa XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         char *new_filename;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         new_filename = va_arg(args, char*);
         if (opa->type == ZEND_USER_FUNCTION) {
@@ -284,9 +287,9 @@
 }
 
 #ifdef ZEND_ENGINE_2
-static int prefill_from_class_table(zend_class_entry **class_entry, int num_args, va_list args, zend_hash_key *hash_key)
+static int prefill_from_class_table(zend_class_entry **class_entry XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 #else
-static int prefill_from_class_table(zend_class_entry *class_entry, int num_args, va_list args, zend_hash_key *hash_key)
+static int prefill_from_class_table(zend_class_entry *class_entry XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 #endif
 {
         char *new_filename;
@@ -303,7 +306,7 @@
 #if PHP_MAJOR_VERSION >= 5
                 if (!(ce->ce_flags & ZEND_XDEBUG_VISITED)) {
                         ce->ce_flags |= ZEND_XDEBUG_VISITED;
- zend_hash_apply_with_arguments(&ce->function_table, (apply_func_args_t) prefill_from_function_table, 1, new_filename);
+ zend_hash_apply_with_arguments(&ce->function_table XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) prefill_from_function_table, 1, new_filename);
                 }
 #else
                 zend_hash_apply_with_arguments(&ce->function_table, (apply_func_args_t) prefill_from_function_table, 1, new_filename);
@@ -319,8 +322,8 @@
                 prefill_from_oparray(op_array->filename, op_array TSRMLS_CC);
         }
 
- zend_hash_apply_with_arguments(CG(function_table), (apply_func_args_t) prefill_from_function_table, 1, op_array->filename);
- zend_hash_apply_with_arguments(CG(class_table), (apply_func_args_t) prefill_from_class_table, 1, op_array->filename);
+ zend_hash_apply_with_arguments(CG(function_table) XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) prefill_from_function_table, 1, op_array->filename);
+ zend_hash_apply_with_arguments(CG(class_table) XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) prefill_from_class_table, 1, op_array->filename);
 }
 
 PHP_FUNCTION(xdebug_start_code_coverage)

[FILE: /xdebug/xdebug_compat.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- xdebug/xdebug_compat.h:1.7.2.1 Tue Oct 09 19:58:10 2007 GMT
+++ xdebug/xdebug_compat.h Sat Mar 28 14:58:57 2009 GMT
@@ -56,4 +56,12 @@
 # define XDEBUG_IS_REF is_ref
 #endif
 
+#if defined(PHP_VERSION_ID) && PHP_VERSION_ID >= 50300 && ZTS
+# define XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC TSRMLS_DC
+# define XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC TSRMLS_CC
+#else
+# define XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC
+# define XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC
+#endif
+
 #endif

[FILE: /xdebug/xdebug_superglobals.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.24.2.3
retrieving revision 1.24.2.4
diff -u -r1.24.2.3 -r1.24.2.4
--- xdebug/xdebug_superglobals.c:1.24.2.3 Sun Dec 07 18:28:37 2008 GMT
+++ xdebug/xdebug_superglobals.c Sat Mar 28 14:58:57 2009 GMT
@@ -19,6 +19,7 @@
 #include "php_xdebug.h"
 #include "xdebug_private.h"
 #include "xdebug_var.h"
+#include "xdebug_compat.h"
 #include "xdebug_superglobals.h"
 #include "SAPI.h"
 
@@ -76,12 +77,12 @@
         }
 }
 
-static int dump_hash_elem_va(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
+static int dump_hash_elem_va(void *pDest XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int html;
         char *name;
         xdebug_str *str;
-#ifdef ZTS
+#if defined(ZTS) && (!defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300)
         void ***tsrm_ls;
 #endif
 
@@ -89,7 +90,7 @@
         html = va_arg(args, int);
         str = va_arg(args, xdebug_str *);
 
-#ifdef ZTS
+#if defined(ZTS) && (!defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300)
         tsrm_ls = va_arg(args, void ***);
 #endif
 
@@ -133,13 +134,11 @@
         while (elem != NULL) {
                 if (ht && (*((char *) (elem->ptr)) == '*')) {
 
-#ifdef ZTS
-#define X_DUMP_ARGS 4
+#if defined(ZTS) && (!defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300)
+ zend_hash_apply_with_arguments(ht, dump_hash_elem_va, 4, name, html, str TSRMLS_CC);
 #else
-#define X_DUMP_ARGS 3
+ zend_hash_apply_with_arguments(ht TSRMLS_CC, dump_hash_elem_va, 3, name, html, str);
 #endif
-
- zend_hash_apply_with_arguments(ht, dump_hash_elem_va, X_DUMP_ARGS, name, html, str TSRMLS_CC);
                 } else if (ht && zend_hash_find(ht, elem->ptr, strlen(elem->ptr) + 1, (void **) &z) == SUCCESS) {
                         dump_hash_elem(*z, name, 0, elem->ptr, html, str TSRMLS_CC);
                 } else if(XG(dump_undefined)) {

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.86.2.5
retrieving revision 1.86.2.6
diff -u -r1.86.2.5 -r1.86.2.6
--- xdebug/xdebug_var.c:1.86.2.5 Tue Mar 04 10:24:07 2008 GMT
+++ xdebug/xdebug_var.c Sat Mar 28 14:58:57 2009 GMT
@@ -173,12 +173,14 @@
 ** Normal variable printing routines
 */
 
-static int xdebug_array_element_export(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_array_element_export(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level, debug_zval;
         xdebug_str *str;
         xdebug_var_export_options *options;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -216,13 +218,15 @@
         return 0;
 }
 
-static int xdebug_object_element_export(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_object_element_export(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level, debug_zval;
         xdebug_str *str;
         xdebug_var_export_options *options;
         char *prop_name, *modifier;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -296,7 +300,7 @@
                                         options->runtime[level].start_element_nr = 0;
                                         options->runtime[level].end_element_nr = options->max_children;
 
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export, 4, level, str, debug_zval, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_array_element_export, 4, level, str, debug_zval, options);
                                         /* Remove the ", " at the end of the string */
                                         if (myht->nNumOfElements > 0) {
                                                 xdebug_str_chop(str, 2);
@@ -319,7 +323,7 @@
                                         options->runtime[level].start_element_nr = 0;
                                         options->runtime[level].end_element_nr = options->max_children;
 
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export, 4, level, str, debug_zval, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export, 4, level, str, debug_zval, options);
                                         /* Remove the ", " at the end of the string */
                                         if (myht->nNumOfElements > 0) {
                                                 xdebug_str_chop(str, 2);
@@ -441,11 +445,13 @@
 ** XML variable printing routines
 */
 
-static int xdebug_array_element_export_xml(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_array_element_export_xml(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level;
         xdebug_str *str;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -462,12 +468,14 @@
         return 0;
 }
 
-static int xdebug_object_element_export_xml(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_object_element_export_xml(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level;
         xdebug_str *str;
         char *prop_name, *modifier;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -523,7 +531,7 @@
                         myht = Z_ARRVAL_PP(struc);
                         if (myht->nApplyCount < 1) {
                                 xdebug_str_addl(str, "<array>", 7, 0);
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export_xml, 2, level, str);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_array_element_export_xml, 2, level, str);
                                 xdebug_str_addl(str, "</array>", 8, 0);
                         } else {
                                 xdebug_str_addl(str, "<array hidden='true' recursive='true'/>", 39, 0);
@@ -534,7 +542,7 @@
                         myht = Z_OBJPROP_PP(struc);
                         if (myht->nApplyCount < 1) {
                                 xdebug_str_add(str, xdebug_sprintf("<object class='%s'>", Z_OBJCE_PP(struc)->name), 1);
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export_xml, 2, level, str);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export_xml, 2, level, str);
                                 xdebug_str_addl(str, "</object>", 9, 0);
                         } else {
                                 xdebug_str_addl(str, "<object hidden='true' recursive='true'/>", 40, 0);
@@ -579,14 +587,16 @@
 ** XML node printing routines
 */
 
-static int xdebug_array_element_export_xml_node(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_array_element_export_xml_node(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level;
         xdebug_xml_node *parent;
         xdebug_xml_node *node;
         xdebug_var_export_options *options;
         char *name = NULL, *parent_name = NULL, *full_name = NULL;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         parent = va_arg(args, xdebug_xml_node*);
@@ -631,7 +641,7 @@
         return 0;
 }
 
-static int xdebug_object_element_export_xml_node(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_object_element_export_xml_node(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level;
         xdebug_xml_node *parent;
@@ -639,7 +649,9 @@
         xdebug_var_export_options *options;
         char *prop_name, *modifier;
         char *parent_name = NULL, *full_name = NULL;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         parent = va_arg(args, xdebug_xml_node*);
@@ -730,7 +742,7 @@
                                                 options->runtime[level].start_element_nr = 0;
                                                 options->runtime[level].end_element_nr = options->max_children;
                                         }
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export_xml_node, 4, level, node, name, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_array_element_export_xml_node, 4, level, node, name, options);
                                 }
                         } else {
                                 xdebug_xml_add_attribute(node, "recursive", "1");
@@ -762,7 +774,7 @@
                                                         options->runtime[level].start_element_nr = 0;
                                                         options->runtime[level].end_element_nr = options->max_children;
                                                 }
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export_xml_node, 4, level, node, name, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export_xml_node, 4, level, node, name, options);
                                         }
                                 } else {
                                         xdebug_xml_add_attribute(node, "recursive", "1");
@@ -822,13 +834,15 @@
 #define COLOR_OBJECT "#8f5902"
 #define COLOR_RESOURCE "#2e3436"
 
-static int xdebug_array_element_export_fancy(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_array_element_export_fancy(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level, debug_zval, newlen;
         char *tmp_str;
         xdebug_str *str;
         xdebug_var_export_options *options;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -859,14 +873,16 @@
         return 0;
 }
 
-static int xdebug_object_element_export_fancy(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
+static int xdebug_object_element_export_fancy(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
         int level, debug_zval;
         xdebug_str *str;
         xdebug_var_export_options *options;
         char *key;
         char *prop_name, *modifier;
+#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
+#endif
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
@@ -950,7 +966,7 @@
                                                 options->runtime[level].start_element_nr = 0;
                                                 options->runtime[level].end_element_nr = options->max_children;
 
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export_fancy, 4, level, str, debug_zval, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_array_element_export_fancy, 4, level, str, debug_zval, options);
                                         } else {
                                                 xdebug_str_add(str, xdebug_sprintf("%*s", (level * 4) - 2, ""), 1);
                                                 xdebug_str_add(str, xdebug_sprintf("<i><font color='%s'>empty</font></i>\n", COLOR_EMPTY), 1);
@@ -979,7 +995,7 @@
                                         options->runtime[level].start_element_nr = 0;
                                         options->runtime[level].end_element_nr = options->max_children;
 
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export_fancy, 4, level, str, debug_zval, options);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export_fancy, 4, level, str, debug_zval, options);
                                 } else {
                                         xdebug_str_add(str, xdebug_sprintf("%*s", (level * 4) - 2, ""), 1);
                                         xdebug_str_add(str, xdebug_sprintf("...\n"), 1);
Received on Sat Mar 28 2009 - 16:58:59 GMT

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