[xdebug-dev] xdebug xdebug/php_xdebug.h xdebug/xdebug.c xdebug/xdebug_profiler.c xdebug/xdebug_var.c - Fixed compile failures with PHP 5.2

From: Jani Taskinen <sniper[@]php.net>
Date: Wed, 2 Aug 2006 14:06:55 +0200

Date: Wed Aug 2 14:06:55 CEST 2006
User: Jani Taskinen
Directory: xdebug

Log Message:
- Fixed compile failures with PHP 5.2
Modified files:
           xdebug/php_xdebug.h (version: 1.108)
           xdebug/xdebug.c (version: 1.321)
           xdebug/xdebug_profiler.c (version: 1.37)
           xdebug/xdebug_var.c (version: 1.72)

[FILE: /xdebug/php_xdebug.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- xdebug/php_xdebug.h:1.107 Fri Jun 30 06:57:27 2006 GMT
+++ xdebug/php_xdebug.h Wed Aug 02 10:06:55 2006 GMT
@@ -46,6 +46,20 @@
 #include "TSRM.h"
 #endif
 
+#if PHP_VERSION_ID >= 50200
+# define HAVE_PHP_MEMORY_USAGE 1
+# define XG_MEMORY_USAGE() zend_memory_usage(1)
+# define XG_MEMORY_PEAK_USAGE() zend_memory_peak_usage(1)
+#else
+# if MEMORY_LIMIT
+# define HAVE_PHP_MEMORY_USAGE 1
+# else
+# define HAVE_PHP_MEMORY_USAGE 0
+# endif
+# define XG_MEMORY_USAGE() AG(allocated_memory)
+# define XG_MEMORY_PEAK_USAGE() AG(allocated_memory_peak)
+#endif
+
 PHP_MINIT_FUNCTION(xdebug);
 PHP_MSHUTDOWN_FUNCTION(xdebug);
 PHP_RINIT_FUNCTION(xdebug);
@@ -91,7 +105,7 @@
 /* misc functions */
 PHP_FUNCTION(xdebug_dump_superglobals);
 PHP_FUNCTION(xdebug_set_error_handler);
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
 PHP_FUNCTION(xdebug_memory_usage);
 PHP_FUNCTION(xdebug_peak_memory_usage);
 #endif

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.320
retrieving revision 1.321
diff -u -r1.320 -r1.321
--- xdebug/xdebug.c:1.320 Fri Jun 30 05:44:04 2006 GMT
+++ xdebug/xdebug.c Wed Aug 02 10:06:55 2006 GMT
@@ -148,7 +148,7 @@
         PHP_FE(xdebug_dump_aggr_profiling_data, NULL)
         PHP_FE(xdebug_clear_aggr_profiling_data, NULL)
 
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
         PHP_FE(xdebug_memory_usage, NULL)
         PHP_FE(xdebug_peak_memory_usage, NULL)
 #endif
@@ -966,9 +966,9 @@
         if (!tmp->filename && XDEBUG_LLIST_TAIL(XG(stack)) && XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))) ) {
                 tmp->filename = xdstrdup(((function_stack_entry*) XDEBUG_LLIST_VALP(XDEBUG_LLIST_TAIL(XG(stack))))->filename);
         }
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
         tmp->prev_memory = XG(prev_memory);
- tmp->memory = AG(allocated_memory);
+ tmp->memory = XG_MEMORY_USAGE();
         XG(prev_memory) = tmp->memory;
 #else
         tmp->memory = 0;
@@ -1049,7 +1049,7 @@
                         xae.call_count = 0;
                         xae.time_own = 0;
                         xae.time_inclusive = 0;
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                         xae.mem_used = 0;
 #endif
                         xae.call_list = NULL;
@@ -1573,7 +1573,7 @@
                                         php_printf("<tr><td bgcolor='#ddddff' align='center'>%d</td><td bgcolor='#ddddff'>%s(", i->level, tmp_name);
                                 } else {
                                         php_printf("%10.4f ", i->time - XG(start_time));
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                                         php_printf("%10ld ", i->memory);
 #endif
                                         php_printf("%3d. %s(", i->level, tmp_name);
@@ -1778,8 +1778,8 @@
         } else if (whence == 1) { /* end */
                 xdebug_str_add(&str, "1\t", 0);
                 xdebug_str_add(&str, xdebug_sprintf("%f\t", xdebug_get_utime() - XG(start_time)), 1);
-#if MEMORY_LIMIT
- xdebug_str_add(&str, xdebug_sprintf("%lu\n", AG(allocated_memory)), 1);
+#if HAVE_PHP_MEMORY_USAGE
+ xdebug_str_add(&str, xdebug_sprintf("%lu\n", XG_MEMORY_USAGE()), 1);
 #endif
         }
 
@@ -1947,9 +1947,13 @@
                 case E_COMPILE_ERROR:
                 case E_USER_ERROR:
                         EG(exit_status) = 255;
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                         /* restore memory limit */
+# if PHP_VERSION_ID >= 50200
+ zend_set_memory_limit(PG(memory_limit));
+# else
                         AG(memory_limit) = PG(memory_limit);
+# endif
 #endif
                         zend_bailout();
                         return;
@@ -2420,8 +2424,8 @@
         if (XG(trace_file)) {
                 u_time = xdebug_get_utime();
                 fprintf(XG(trace_file), "%10.4f ", u_time - XG(start_time));
-#if MEMORY_LIMIT
- fprintf(XG(trace_file), "%10u", AG(allocated_memory));
+#if HAVE_PHP_MEMORY_USAGE
+ fprintf(XG(trace_file), "%10u", XG_MEMORY_USAGE());
 #else
                 fprintf(XG(trace_file), "%10u", 0);
 #endif
@@ -2496,15 +2500,15 @@
         RETURN_TRUE;
 }
 
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
 PHP_FUNCTION(xdebug_memory_usage)
 {
- RETURN_LONG(AG(allocated_memory));
+ RETURN_LONG(XG_MEMORY_USAGE());
 }
 
 PHP_FUNCTION(xdebug_peak_memory_usage)
 {
- RETURN_LONG(AG(allocated_memory_peak));
+ RETURN_LONG(XG_MEMORY_PEAK_USAGE());
 }
 #endif
 

[FILE: /xdebug/xdebug_profiler.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- xdebug/xdebug_profiler.c:1.36 Thu May 04 07:55:31 2006 GMT
+++ xdebug/xdebug_profiler.c Wed Aug 02 10:06:55 2006 GMT
@@ -94,7 +94,7 @@
                 fprintf(XG(profile_file), "\n==== NEW PROFILING FILE ==============================================\n");
         }
         XG(profile_filename) = estrdup(filename);
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
         fprintf(XG(profile_file), "version: 0.9.6\ncmd: %s\npart: 1\n\nevents: Time Memory\n\n", script_name);
 #else
         fprintf(XG(profile_file), "version: 0.9.6\ncmd: %s\npart: 1\n\nevents: Time\n\n", script_name);
@@ -139,8 +139,8 @@
 {
         fse->profile.time = 0;
         fse->profile.mark = xdebug_get_utime();
-#if MEMORY_LIMIT
- fse->profile.memory = AG(allocated_memory);
+#if HAVE_PHP_MEMORY_USAGE
+ fse->profile.memory = XG_MEMORY_USAGE();
 #endif
 }
 
@@ -176,8 +176,8 @@
                 ce->time_taken = fse->profile.time;
                 ce->lineno = fse->lineno;
                 ce->user_defined = fse->user_defined;
-#if MEMORY_LIMIT
- ce->mem_used = fse->profile.memory - AG(allocated_memory);
+#if HAVE_PHP_MEMORY_USAGE
+ ce->mem_used = fse->profile.memory - XG_MEMORY_USAGE();
 #endif
 
                 xdebug_llist_insert_next(fse->prev->profile.call_list, NULL, ce);
@@ -196,8 +196,8 @@
         xdfree(tmp_name);
 
         if (fse->function.function && strcmp(fse->function.function, "{main}") == 0) {
-#if MEMORY_LIMIT
- fprintf(XG(profile_file), "\nsummary: %lu %u\n\n", (unsigned long) (fse->profile.time * 10000000), AG(allocated_memory));
+#if HAVE_PHP_MEMORY_USAGE
+ fprintf(XG(profile_file), "\nsummary: %lu %u\n\n", (unsigned long) (fse->profile.time * 10000000), XG_MEMORY_USAGE());
 #else
                 fprintf(XG(profile_file), "\nsummary: %lu\n\n", (unsigned long) (fse->profile.time * 10000000));
 #endif
@@ -215,12 +215,12 @@
         {
                 xdebug_call_entry *call_entry = XDEBUG_LLIST_VALP(le);
                 fse->profile.time -= call_entry->time_taken;
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                 fse->memory -= call_entry->mem_used;
 #endif
         }
-#if MEMORY_LIMIT
- fprintf(XG(profile_file), "%d %lu %ld\n", default_lineno, (unsigned long) (fse->profile.time * 10000000), (AG(allocated_memory) - fse->profile.memory) < 0 ? 0 : (AG(allocated_memory) - fse->profile.memory));
+#if HAVE_PHP_MEMORY_USAGE
+ fprintf(XG(profile_file), "%d %lu %ld\n", default_lineno, (unsigned long) (fse->profile.time * 10000000), (XG_MEMORY_USAGE() - fse->profile.memory) < 0 ? 0 : (XG_MEMORY_USAGE() - fse->profile.memory));
 #else
         fprintf(XG(profile_file), "%d %lu\n", default_lineno, (unsigned long) (fse->profile.time * 10000000));
 #endif
@@ -228,7 +228,7 @@
         /* update aggregate data */
         if (XG(profiler_aggregate)) {
                 fse->aggr_entry->time_own += fse->profile.time;
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                 fse->aggr_entry->mem_used += fse->memory;
 #endif
         }
@@ -245,7 +245,7 @@
                 }
                 
                 fprintf(XG(profile_file), "calls=1 0 0\n");
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                 fprintf(XG(profile_file), "%d %lu %ld\n", call_entry->lineno, (unsigned long) (call_entry->time_taken * 10000000), call_entry->mem_used < 0 ? 0 : call_entry->mem_used);
 #else
                 fprintf(XG(profile_file), "%d %lu\n", call_entry->lineno, (unsigned long) (call_entry->time_taken * 10000000));
@@ -274,13 +274,13 @@
 
         fprintf(fp, "fl=%s\n", xae->filename);
         fprintf(fp, "fn=%s\n", xae->function);
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
         fprintf(fp, "%d %lu %ld\n", 0, (unsigned long) (xae->time_own * 10000000), (xae->mem_used < 0) ? 0 : xae->mem_used);
 #else
         fprintf(fp, "%d %lu\n", 0, (unsigned long) (xae->time_own * 10000000));
 #endif
         if (strcmp(xae->function, "{main}") == 0) {
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                 fprintf(fp, "\nsummary: %lu %u\n\n", (unsigned long) (xae->time_inclusive * 10000000), (xae->mem_used));
 #else
                 fprintf(fp, "\nsummary: %lu\n\n", (unsigned long) (xae->time_inclusive * 10000000), (xae->mem_used));
@@ -293,7 +293,7 @@
                 while (zend_hash_get_current_data(xae->call_list, (void**)&xae_call) == SUCCESS) {
                         fprintf(fp, "cfn=%s\n", (*xae_call)->function);
                         fprintf(fp, "calls=%d 0 0\n", (*xae_call)->call_count);
-#if MEMORY_LIMIT
+#if HAVE_PHP_MEMORY_USAGE
                         fprintf(fp, "%d %lu %ld\n", (*xae_call)->lineno, (unsigned long) ((*xae_call)->time_inclusive * 10000000), (*xae_call)->mem_used < 0 ? 0 : (*xae_call)->mem_used);
 #else
                         fprintf(fp, "%d %lu\n", (*xae_call)->lineno, (unsigned long) ((*xae_call)->time_inclusive * 10000000));

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- xdebug/xdebug_var.c:1.71 Sat May 27 18:06:57 2006 GMT
+++ xdebug/xdebug_var.c Wed Aug 02 10:06:55 2006 GMT
@@ -39,7 +39,7 @@
                 case E_USER_ERROR:
                         return xdstrdup("Fatal error");
                         break;
-#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION >= 6
+#if PHP_VERSION_ID >= 50200
                 case E_RECOVERABLE_ERROR:
                         return xdstrdup("Catchable fatal error");
                         break;
@@ -96,12 +96,16 @@
         return NULL;
 }
 
-static char* xdebug_get_property_info(char *mangled_property, char **property_name)
+static char* xdebug_get_property_info(char *mangled_property, int mangled_len, char **property_name)
 {
 #ifdef ZEND_ENGINE_2
         char *prop_name, *class_name;
 
+#if PHP_VERSION_ID >= 50200
+ zend_unmangle_property_name(mangled_property, mangled_len - 1, &class_name, &prop_name);
+#else
         zend_unmangle_property_name(mangled_property, &class_name, &prop_name);
+#endif
         *property_name = prop_name;
         if (class_name) {
                 if (class_name[0] == '*') {
@@ -168,7 +172,7 @@
         debug_zval = va_arg(args, int);
 
         if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
                 xdebug_str_add(str, xdebug_sprintf("%s $%s = ", modifier, prop_name), 1);
         }
         xdebug_var_export(zv, str, level + 2, debug_zval TSRMLS_CC);
@@ -300,7 +304,7 @@
 
         xdebug_str_addl(str, "<var", 4, 0);
         if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
                 xdebug_str_add(str, xdebug_sprintf(" name='%s' facet='%s'", prop_name, modifier), 1);
         }
         xdebug_str_add(str, xdebug_sprintf(" id='%p'>", *zv), 1);
@@ -478,7 +482,7 @@
                 node = xdebug_xml_node_init("property");
                 
                 if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
                         xdebug_xml_add_attribute(node, "name", prop_name);
                         /* XXX static vars? */
 
@@ -683,7 +687,7 @@
 
         key = hash_key->arKey;
         if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
                 xdebug_str_add(str, xdebug_sprintf("<i>%s</i> '%s' <font color='%s'>=&gt;</font> ", modifier, prop_name, DGREY), 1);
         }
         xdebug_var_export_fancy(zv, str, level + 2, debug_zval TSRMLS_CC);
Received on Wed Aug 02 2006 - 14:09:18 BST

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