[xdebug-dev] xdebug xdebug/php_xdebug.h xdebug/xdebug.c xdebug/xdebug_code_coverage.c xdebug/xdebug_handler_dbgp.c xdebug/xdebug_handler_gdb.c xdebug/xdebug_var.c - Added support for PHP 5.3 and local variables for debugging.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Thu, 7 May 2009 21:11:46 +0200

Date: Thu May 7 21:11:46 CEST 2009
User: Derick Rethans
Directory: xdebug

Log Message:
[0.50]
- Added support for PHP 5.3 and local variables for debugging.
- Added code-coverage improvements related to not-fully parsed files.
- Fixed cases where private properties where shown for objects, but not
  accesible.

Modified files:
           xdebug/php_xdebug.h (version: 1.148)
           xdebug/xdebug.c (version: 1.446)
           xdebug/xdebug_code_coverage.c (version: 1.50)
           xdebug/xdebug_handler_dbgp.c (version: 1.136)
           xdebug/xdebug_handler_gdb.c (version: 1.90)
           xdebug/xdebug_var.c (version: 1.96)

[FILE: /xdebug/php_xdebug.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- xdebug/php_xdebug.h:1.147 Tue Apr 07 19:21:07 2009 GMT
+++ xdebug/php_xdebug.h Thu May 07 17:11:45 2009 GMT
@@ -64,13 +64,6 @@
 # define XG_MEMORY_PEAK_USAGE() AG(allocated_memory_peak)
 #endif
 
-#if PHP_VERSION_ID >= 50300
-# define XG_INIT_SYMBOL_TABLE // if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); }
-# define XG_INIT_SYMBOL_TABLE
-#else
-# define XG_INIT_SYMBOL_TABLE
-#endif
-
 PHP_MINIT_FUNCTION(xdebug);
 PHP_MSHUTDOWN_FUNCTION(xdebug);
 PHP_RINIT_FUNCTION(xdebug);
@@ -148,6 +141,7 @@
         double start_time;
         HashTable *active_symbol_table;
         zend_execute_data *active_execute_data;
+ zend_op_array *active_op_array;
         unsigned int prev_memory;
         char *file_link_format;
 

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.445
retrieving revision 1.446
diff -u -r1.445 -r1.446
--- xdebug/xdebug.c:1.445 Tue Apr 07 19:21:07 2009 GMT
+++ xdebug/xdebug.c Thu May 07 17:11:45 2009 GMT
@@ -1326,7 +1326,6 @@
 static void add_used_variables(function_stack_entry *fse, zend_op_array *op_array)
 {
         int i = 0;
- int j = op_array->size;
 
         if (!fse->used_vars) {
                 fse->used_vars = xdebug_llist_alloc(xdebug_used_var_dtor);
@@ -1339,8 +1338,14 @@
                 }
         }
 
+ /* gather used variables from compiled vars information */
+ while (i < op_array->last_var) {
+ xdebug_llist_insert_next(fse->used_vars, XDEBUG_LLIST_TAIL(fse->used_vars), xdstrdup(op_array->vars[i].name));
+ i++;
+ }
+
         /* opcode scanning time */
- while (i < j) {
+ while (i < op_array->size) {
                 char *cv = NULL;
                 int cv_len;
 
@@ -1579,7 +1584,6 @@
         function_nr = XG(function_count);
         trace_function_begin(fse, function_nr TSRMLS_CC);
 
- XG_INIT_SYMBOL_TABLE
         fse->symbol_table = EG(active_symbol_table);
         fse->execute_data = EG(current_execute_data);
 
@@ -1778,7 +1782,6 @@
         }
 
         tmp_ht = XG(active_symbol_table);
- XG_INIT_SYMBOL_TABLE
         XG(active_symbol_table) = EG(active_symbol_table);
         zvar = xdebug_get_php_symbol(name, strlen(name) + 1);
         XG(active_symbol_table) = tmp_ht;
@@ -2446,7 +2449,7 @@
         exception_class = PG(exception_class);
 #endif
         /* according to error handling mode, suppress error, throw exception or show it */
- if (error_handling != EH_NORMAL) {
+ if (error_handling != EH_NORMAL && EG(in_execution)) {
                 switch (type) {
                         case E_CORE_ERROR:
                         case E_COMPILE_ERROR:
@@ -2540,7 +2543,6 @@
                         return;
         }
 
- XG_INIT_SYMBOL_TABLE
         if (PG(track_errors) && EG(active_symbol_table)) {
                 zval *tmp;
 
@@ -2564,7 +2566,7 @@
         op_array = old_compile_file(file_handle, type TSRMLS_CC);
 
         if (op_array) {
- if (XG(do_code_coverage) && XG(code_coverage_unused)) {
+ if (XG(do_code_coverage) && XG(code_coverage_unused && op_array->done_pass_two)) {
                         xdebug_prefill_code_coverage(op_array TSRMLS_CC);
                 }
         }
@@ -2858,7 +2860,6 @@
         
         for (i = 0; i < argc; i++) {
                 if (Z_TYPE_PP(args[i]) == IS_STRING) {
- XG_INIT_SYMBOL_TABLE
                         XG(active_symbol_table) = EG(active_symbol_table);
                         debugzval = xdebug_get_php_symbol(Z_STRVAL_PP(args[i]), Z_STRLEN_PP(args[i]) + 1);
                         if (debugzval) {
@@ -2900,7 +2901,6 @@
         
         for (i = 0; i < argc; i++) {
                 if (Z_TYPE_PP(args[i]) == IS_STRING) {
- XG_INIT_SYMBOL_TABLE
                         XG(active_symbol_table) = EG(active_symbol_table);
                         debugzval = xdebug_get_php_symbol(Z_STRVAL_PP(args[i]), Z_STRLEN_PP(args[i]) + 1);
                         if (debugzval) {

[FILE: /xdebug/xdebug_code_coverage.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- xdebug/xdebug_code_coverage.c:1.49 Sat Mar 28 18:37:16 2009 GMT
+++ xdebug/xdebug_code_coverage.c Thu May 07 17:11:45 2009 GMT
@@ -118,7 +118,11 @@
 
         zend_op opcode = opa->opcodes[position];
         if (opcode.opcode == ZEND_JMP) {
+#ifdef ZEND_ENGINE_2
                 *jmp1 = ((long) opcode.op1.u.jmp_addr - (long) base_address) / sizeof(zend_op);
+#else
+ *jmp1 = opcode.op1.u.opline_num;
+#endif
                 return 1;
         } else if (
                 opcode.opcode == ZEND_JMPZ ||
@@ -127,7 +131,11 @@
                 opcode.opcode == ZEND_JMPNZ_EX
         ) {
                 *jmp1 = position + 1;
+#ifdef ZEND_ENGINE_2
                 *jmp2 = ((long) opcode.op2.u.jmp_addr - (long) base_address) / sizeof(zend_op);
+#else
+ *jmp2 = opcode.op1.u.opline_num;
+#endif
                 return 1;
         } else if (opcode.opcode == ZEND_JMPZNZ) {
                 *jmp1 = opcode.op2.u.opline_num;
@@ -153,8 +161,8 @@
 
 static void xdebug_analyse_branch(zend_op_array *opa, unsigned int position, xdebug_set *set)
 {
- long jump_pos1 = -1;
- long jump_pos2 = -1;
+ long jump_pos1;
+ long jump_pos2;
 
         /*(fprintf(stderr, "Branch analysis from position: %d\n", position);)*/
         /* First we see if the branch has been visited, if so we bail out. */
@@ -165,14 +173,16 @@
         xdebug_set_add(set, position);
         /*(fprintf(stderr, "XDEBUG Adding %d\n", position);)*/
         while (position < opa->last) {
+ jump_pos1 = -1;
+ jump_pos2 = -1;
 
                 /* See if we have a jump instruction */
                 if (xdebug_find_jump(opa, position, &jump_pos1, &jump_pos2)) {
- /*(fprintf(stderr, "XDEBUG Jump found. Position 1 = %d", jump_pos1);)*/
+ fprintf(stderr, "XDEBUG Jump found. Position 1 = %d", jump_pos1);
                         if (jump_pos2 != -1) {
- /*(fprintf(stderr, ", Position 2 = %d\n", jump_pos2);)*/
+ fprintf(stderr, ", Position 2 = %d\n", jump_pos2);
                         } else {
- /*(fprintf(stderr, "\n");)*/
+ fprintf(stderr, "\n");
                         }
                         xdebug_analyse_branch(opa, jump_pos1, set);
                         if (jump_pos2 != -1 && jump_pos2 <= opa->last) {

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- xdebug/xdebug_handler_dbgp.c:1.135 Mon Jan 05 16:24:34 2009 GMT
+++ xdebug/xdebug_handler_dbgp.c Thu May 07 17:11:45 2009 GMT
@@ -274,6 +274,45 @@
 #define XF_ST_ARRAY_INDEX_ASSOC 2
 #define XF_ST_OBJ_PROPERTY 3
 
+inline static HashTable *fetch_ht_from_zval(zval *z TSRMLS_DC)
+{
+ switch (Z_TYPE_P(z)) {
+ case IS_ARRAY:
+ return Z_ARRVAL_P(z);
+ break;
+ case IS_OBJECT:
+ return Z_OBJPROP_P(z);
+ break;
+ }
+ return NULL;
+}
+
+inline static char *fetch_classname_from_zval(zval *z, int *length TSRMLS_DC)
+{
+ char *name;
+ zend_uint name_len;
+
+ if (Z_TYPE_P(z) != IS_OBJECT) {
+ return NULL;
+ }
+
+ if (Z_OBJ_HT_P(z)->get_class_name == NULL ||
+ Z_OBJ_HT_P(z)->get_class_name(z, &name, &name_len, 0 TSRMLS_CC) != SUCCESS) {
+ zend_class_entry *ce;
+
+ ce = zend_get_class_entry(z TSRMLS_CC);
+ if (!ce) {
+ return NULL;
+ }
+
+ *length = ce->name_length;
+ return estrdup(ce->name);
+ }
+
+ *length = name_len;
+ return name;
+}
+
 static char* prepare_search_key(char *name, int *name_length, char *prefix, int prefix_length)
 {
         char *element;
@@ -306,6 +345,33 @@
 
         switch (type) {
                 case XF_ST_ROOT:
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
+ /* Check for compiled vars */
+ element = prepare_search_key(name, &element_length, "", 0);
+ if (XG(active_execute_data) && XG(active_op_array)) {
+ int i = 0;
+ ulong hash_value = zend_inline_hash_func(element, element_length + 1);
+ zend_op_array *opa = XG(active_op_array);
+ zval ***CVs = XG(active_execute_data)->CVs;
+
+ while (i < opa->last_var) {
+ if (opa->vars[i].hash_value == hash_value &&
+ opa->vars[i].name_len == element_length &&
+ strcmp(opa->vars[i].name, element) == 0)
+ {
+ if (CVs[i]) {
+ retval_p = *CVs[i];
+ goto cleanup;
+ }
+ }
+ i++;
+ }
+ }
+ free(element);
+#else
+ ht = XG(active_symbol_table);
+ /* break intentionally missing */
+#endif
                 case XF_ST_ARRAY_INDEX_ASSOC:
                         element = prepare_search_key(name, &name_length, "", 0);
 
@@ -364,158 +430,50 @@
         return retval_p;
 }
 
-inline static HashTable *fetch_ht_from_zval(zval *z TSRMLS_DC)
-{
- switch (Z_TYPE_P(z)) {
- case IS_ARRAY:
- return Z_ARRVAL_P(z);
- break;
- case IS_OBJECT:
- return Z_OBJPROP_P(z);
- break;
- }
- return NULL;
-}
-
-inline static char *fetch_classname_from_zval(zval *z, int *length TSRMLS_DC)
-{
- char *name;
- zend_uint name_len;
-
- if (Z_TYPE_P(z) != IS_OBJECT) {
- return NULL;
- }
-
- if (Z_OBJ_HT_P(z)->get_class_name == NULL ||
- Z_OBJ_HT_P(z)->get_class_name(z, &name, &name_len, 0 TSRMLS_CC) != SUCCESS) {
- zend_class_entry *ce;
-
- ce = zend_get_class_entry(z TSRMLS_CC);
- if (!ce) {
- return NULL;
- }
-
- *length = ce->name_length;
- return estrdup(ce->name);
- }
-
- *length = name_len;
- return name;
-}
-
 static zval* get_symbol_contents_zval(char* name, int name_length TSRMLS_DC)
 {
- HashTable *st = NULL;
+ HashTable *st = NULL;
+ int found = -1;
+ int state = 0;
+ char **p = &name;
+ char *keyword = NULL, *keyword_end = NULL;
+ int type = XF_ST_ROOT;
+ zval *retval = NULL;
+ char *current_classname = NULL;
+ int cc_length = 0;
+ char quotechar = 0;
 
- if (name[0] == '$') {
- /* This is a fullname property. Relying on eval is bad as it can bail
- * out, so we do it ourselves. */
- int found = -1;
- int state = 0;
- char **p = &name;
- char *keyword = NULL, *keyword_end = NULL;
- int type = XF_ST_ROOT;
- zval *retval = NULL;
- char *current_classname = NULL;
- int cc_length = 0;
- char quotechar = 0;
-
- /* Set the target table to the currently active scope */
- st = XG(active_symbol_table);
-
- do {
- if (*p[0] == '\0') {
- found = 0;
- } else {
- switch (state) {
- case 0:
- if (*p[0] == '$') {
- state = 1;
- keyword = *p + 1;
- break;
- }
- keyword = *p;
- /* break intentionally missing */
- case 1:
- if (*p[0] == '[') {
- keyword_end = *p;
- if (keyword) {
- retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
- if (current_classname) {
- efree(current_classname);
- }
- current_classname = NULL;
- if (retval) {
- st = fetch_ht_from_zval(retval TSRMLS_CC);
- }
- keyword = NULL;
- }
- state = 3;
- } else if (*p[0] == '-') {
- keyword_end = *p;
- if (keyword) {
- retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
- if (current_classname) {
- efree(current_classname);
- }
- current_classname = NULL;
- if (retval) {
- current_classname = fetch_classname_from_zval(retval, &cc_length TSRMLS_CC);
- st = fetch_ht_from_zval(retval TSRMLS_CC);
- }
- keyword = NULL;
- }
- state = 2;
- type = XF_ST_OBJ_PROPERTY;
- }
- break;
- case 2:
- if (*p[0] != '>') {
- keyword = *p;
- state = 1;
- }
- break;
- case 3:
- /* Associative arrays */
- if (*p[0] == '\'' || *p[0] == '"') {
- state = 4;
- keyword = *p + 1;
- quotechar = *p[0];
- type = XF_ST_ARRAY_INDEX_ASSOC;
- }
- /* Numerical index */
- if (*p[0] >= '0' && *p[0] <= '9') {
- state = 6;
- keyword = *p;
- type = XF_ST_ARRAY_INDEX_NUM;
- }
+ do {
+ if (*p[0] == '\0') {
+ found = 0;
+ } else {
+ switch (state) {
+ case 0:
+ if (*p[0] == '$') {
+ keyword = *p + 1;
                                                 break;
- case 4:
- if (*p[0] == quotechar) {
- quotechar = 0;
- state = 5;
- keyword_end = *p;
+ }
+ keyword = *p;
+ state = 1;
+ /* break intentionally missing */
+ case 1:
+ if (*p[0] == '[') {
+ keyword_end = *p;
+ if (keyword) {
                                                         retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
                                                         if (current_classname) {
                                                                 efree(current_classname);
                                                         }
                                                         current_classname = NULL;
                                                         if (retval) {
- current_classname = fetch_classname_from_zval(retval, &cc_length TSRMLS_CC);
                                                                 st = fetch_ht_from_zval(retval TSRMLS_CC);
                                                         }
                                                         keyword = NULL;
                                                 }
- break;
- case 5:
- if (*p[0] == ']') {
- state = 1;
- }
- break;
- case 6:
- if (*p[0] == ']') {
- state = 1;
- keyword_end = *p;
+ state = 3;
+ } else if (*p[0] == '-') {
+ keyword_end = *p;
+ if (keyword) {
                                                         retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
                                                         if (current_classname) {
                                                                 efree(current_classname);
@@ -527,40 +485,80 @@
                                                         }
                                                         keyword = NULL;
                                                 }
- break;
- }
- (*p)++;
- }
- } while (found < 0);
- if (keyword != NULL) {
- retval = fetch_zval_from_symbol_table(st, keyword, *p - keyword, type, current_classname, cc_length TSRMLS_CC);
- if (retval) {
- st = fetch_ht_from_zval(retval TSRMLS_CC);
- }
- }
- return retval;
- } else {
- zval **retval;
-
- st = XG(active_symbol_table);
- if (st && zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) {
- return *retval;
- }
-
- st = EG(active_op_array)->static_variables;
- if (st) {
- if (zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) {
- return *retval;
+ state = 2;
+ type = XF_ST_OBJ_PROPERTY;
+ }
+ break;
+ case 2:
+ if (*p[0] != '>') {
+ keyword = *p;
+ state = 1;
+ }
+ break;
+ case 3:
+ /* Associative arrays */
+ if (*p[0] == '\'' || *p[0] == '"') {
+ state = 4;
+ keyword = *p + 1;
+ quotechar = *p[0];
+ type = XF_ST_ARRAY_INDEX_ASSOC;
+ }
+ /* Numerical index */
+ if (*p[0] >= '0' && *p[0] <= '9') {
+ state = 6;
+ keyword = *p;
+ type = XF_ST_ARRAY_INDEX_NUM;
+ }
+ break;
+ case 4:
+ if (*p[0] == quotechar) {
+ quotechar = 0;
+ state = 5;
+ keyword_end = *p;
+ retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
+ if (current_classname) {
+ efree(current_classname);
+ }
+ current_classname = NULL;
+ if (retval) {
+ current_classname = fetch_classname_from_zval(retval, &cc_length TSRMLS_CC);
+ st = fetch_ht_from_zval(retval TSRMLS_CC);
+ }
+ keyword = NULL;
+ }
+ break;
+ case 5:
+ if (*p[0] == ']') {
+ state = 1;
+ }
+ break;
+ case 6:
+ if (*p[0] == ']') {
+ state = 1;
+ keyword_end = *p;
+ retval = fetch_zval_from_symbol_table(st, keyword, keyword_end - keyword, type, current_classname, cc_length TSRMLS_CC);
+ if (current_classname) {
+ efree(current_classname);
+ }
+ current_classname = NULL;
+ if (retval) {
+ current_classname = fetch_classname_from_zval(retval, &cc_length TSRMLS_CC);
+ st = fetch_ht_from_zval(retval TSRMLS_CC);
+ }
+ keyword = NULL;
+ }
+ break;
                         }
+ (*p)++;
                 }
-#if 0
- st = &EG(symbol_table);
- if (zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) {
- return *retval;
+ } while (found < 0);
+ if (keyword != NULL) {
+ retval = fetch_zval_from_symbol_table(st, keyword, *p - keyword, type, current_classname, cc_length TSRMLS_CC);
+ if (retval) {
+ st = fetch_ht_from_zval(retval TSRMLS_CC);
                 }
-#endif
         }
- return NULL;
+ return retval;
 }
 
 static xdebug_xml_node* get_symbol(char* name, int name_length, xdebug_var_export_options *options TSRMLS_DC)
@@ -1620,8 +1618,19 @@
         /* Set the symbol table corresponding with the requested stack depth */
         if (context_nr == 0) { /* locals */
                 if ((fse = xdebug_get_stack_frame(depth TSRMLS_CC))) {
- XG(active_symbol_table) = fse->symbol_table;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
+ function_stack_entry *old_fse = xdebug_get_stack_frame(depth - 1 TSRMLS_CC);
+
+ if (depth > 0) {
+ XG(active_execute_data) = old_fse->execute_data;
+ } else {
+ XG(active_execute_data) = EG(current_execute_data);
+ }
+#else
                         XG(active_execute_data) = fse->execute_data;
+#endif
+ XG(active_symbol_table) = fse->symbol_table;
+ XG(active_op_array) = fse->op_array;
                 } else {
                         RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_STACK_DEPTH_INVALID);
                 }
@@ -1644,6 +1653,7 @@
                 options->max_data = old_max_data;
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTANT);
         }
+ XG(active_op_array) = NULL;
 }
 
 DBGP_FUNC(property_set)
@@ -1680,8 +1690,19 @@
         /* Set the symbol table corresponding with the requested stack depth */
         if (context_nr == 0) { /* locals */
                 if ((fse = xdebug_get_stack_frame(depth TSRMLS_CC))) {
- XG(active_symbol_table) = fse->symbol_table;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
+ function_stack_entry *old_fse = xdebug_get_stack_frame(depth - 1 TSRMLS_CC);
+
+ if (depth > 0) {
+ XG(active_execute_data) = old_fse->execute_data;
+ } else {
+ XG(active_execute_data) = EG(current_execute_data);
+ }
+#else
                         XG(active_execute_data) = fse->execute_data;
+#endif
+ XG(active_symbol_table) = fse->symbol_table;
+ XG(active_op_array) = fse->op_array;
                 } else {
                         RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_STACK_DEPTH_INVALID);
                 }
@@ -1781,8 +1802,19 @@
 
         /* Set the symbol table corresponding with the requested stack depth */
         if ((fse = xdebug_get_stack_frame(depth TSRMLS_CC))) {
- XG(active_symbol_table) = fse->symbol_table;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
+ function_stack_entry *old_fse = xdebug_get_stack_frame(depth - 1 TSRMLS_CC);
+
+ if (depth > 0) {
+ XG(active_execute_data) = old_fse->execute_data;
+ } else {
+ XG(active_execute_data) = EG(current_execute_data);
+ }
+#else
                 XG(active_execute_data) = fse->execute_data;
+#endif
+ XG(active_symbol_table) = fse->symbol_table;
+ XG(active_op_array) = fse->op_array;
         } else {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_STACK_DEPTH_INVALID);
         }
@@ -1812,7 +1844,7 @@
         xdebug_xml_node *contents;
         TSRMLS_FETCH();
 
- contents = get_symbol(name, strlen(name) + 1, options TSRMLS_CC);
+ contents = get_symbol(name, strlen(name), options TSRMLS_CC);
         if (contents) {
                 xdebug_xml_add_child(node, contents);
         } else {
@@ -1853,8 +1885,19 @@
 
         /* Here the context_id is 0 */
         if ((fse = xdebug_get_stack_frame(depth TSRMLS_CC))) {
- XG(active_symbol_table) = fse->symbol_table;
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || PHP_MAJOR_VERSION >= 6
+ function_stack_entry *old_fse = xdebug_get_stack_frame(depth - 1 TSRMLS_CC);
+
+ if (depth > 0) {
+ XG(active_execute_data) = old_fse->execute_data;
+ } else {
+ XG(active_execute_data) = EG(current_execute_data);
+ }
+#else
                 XG(active_execute_data) = fse->execute_data;
+#endif
+ XG(active_symbol_table) = fse->symbol_table;
+ XG(active_op_array) = fse->op_array;
 
                 /* Only show vars when they are scanned */
                 if (fse->used_vars) {
@@ -1869,6 +1912,7 @@
 
                 XG(active_symbol_table) = NULL;
                 XG(active_execute_data) = NULL;
+ XG(active_op_array) = NULL;
                 return 0;
         }
         
@@ -2225,7 +2269,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.135 $";
+ return "$Revision: 1.136 $";
 }
 
 static int xdebug_dbgp_cmdloop(xdebug_con *context, int bail TSRMLS_DC)

[FILE: /xdebug/xdebug_handler_gdb.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- xdebug/xdebug_handler_gdb.c:1.89 Mon Jan 05 16:24:34 2009 GMT
+++ xdebug/xdebug_handler_gdb.c Thu May 07 17:11:45 2009 GMT
@@ -1031,7 +1031,6 @@
         zval *zvar;
         TSRMLS_FETCH();
 
- XG_INIT_SYMBOL_TABLE
         XG(active_symbol_table) = EG(active_symbol_table);
         zvar = xdebug_get_php_symbol(args->args[0], strlen(args->args[0]) + 1);
         if (zvar) {
@@ -1217,7 +1216,6 @@
         char *tmp;
         TSRMLS_FETCH();
         
- XG_INIT_SYMBOL_TABLE
         XG(active_symbol_table) = EG(active_symbol_table);
         tmp = show_local_vars(context, args, dump_used_var_with_contents);
         XG(active_symbol_table) = NULL;
@@ -1353,7 +1351,7 @@
 
 char *xdebug_gdb_get_revision(void)
 {
- return "$Revision: 1.89 $";
+ return "$Revision: 1.90 $";
 }
 
 int xdebug_gdb_init(xdebug_con *context, int mode)

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- xdebug/xdebug_var.c:1.95 Tue Mar 31 16:48:12 2009 GMT
+++ xdebug/xdebug_var.c Thu May 07 17:11:45 2009 GMT
@@ -100,18 +100,19 @@
         return NULL;
 }
 
-static char* xdebug_get_property_info(char *mangled_property, int mangled_len, char **property_name)
+static char* xdebug_get_property_info(char *mangled_property, int mangled_len, char **property_name, char **class_name)
 {
- char *prop_name, *class_name;
+ char *prop_name, *cls_name;
 
 #if PHP_VERSION_ID >= 50200
- zend_unmangle_property_name(mangled_property, mangled_len - 1, &class_name, &prop_name);
+ zend_unmangle_property_name(mangled_property, mangled_len - 1, &cls_name, &prop_name);
 #else
- zend_unmangle_property_name(mangled_property, &class_name, &prop_name);
+ zend_unmangle_property_name(mangled_property, &cls_name, &prop_name);
 #endif
         *property_name = prop_name;
- if (class_name) {
- if (class_name[0] == '*') {
+ *class_name = cls_name;
+ if (cls_name) {
+ if (cls_name[0] == '*') {
                         return "protected";
                 } else {
                         return "private";
@@ -216,7 +217,7 @@
         int level, debug_zval;
         xdebug_str *str;
         xdebug_var_export_options *options;
- char *prop_name, *modifier;
+ char *prop_name, *class_name, *modifier;
 #if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
 #endif
@@ -230,7 +231,7 @@
                 options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
         {
                 if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name, &class_name);
                         xdebug_str_add(str, xdebug_sprintf("%s $%s = ", modifier, prop_name), 1);
                 }
                 xdebug_var_export(zv, str, level + 2, debug_zval, options TSRMLS_CC);
@@ -466,14 +467,14 @@
 {
         int level;
         xdebug_str *str;
- char *prop_name, *modifier;
+ char *prop_name, *class_name, *modifier;
 
         level = va_arg(args, int);
         str = va_arg(args, struct xdebug_str*);
 
         xdebug_str_addl(str, "<var", 4, 0);
         if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name, &class_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);
@@ -638,7 +639,7 @@
         xdebug_xml_node *parent;
         xdebug_xml_node *node;
         xdebug_var_export_options *options;
- char *prop_name, *modifier;
+ char *prop_name, *modifier, *class_name, *prop_class_name;
         char *parent_name = NULL, *full_name = NULL;
 #if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
@@ -648,31 +649,37 @@
         parent = va_arg(args, xdebug_xml_node*);
         full_name = parent_name = va_arg(args, char *);
         options = va_arg(args, xdebug_var_export_options*);
+ class_name = va_arg(args, char *);
 
         if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
                 options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
         {
                 node = xdebug_xml_node_init("property");
-
+
                 if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name, &prop_class_name);
                         xdebug_xml_add_attribute(node, "name", prop_name);
- /* XXX static vars? */
 
- if (parent_name) {
- if (parent_name[0] != '$') {
- full_name = xdebug_sprintf("$%s->%s", parent_name, prop_name);
- } else {
- full_name = xdebug_sprintf("%s->%s", parent_name, prop_name);
+ if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) {
+ if (parent_name) {
+ if (parent_name[0] != '$') {
+ full_name = xdebug_sprintf("$%s->%s", parent_name, prop_name);
+ } else {
+ full_name = xdebug_sprintf("%s->%s", parent_name, prop_name);
+ }
+ xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
                                 }
- xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
                         }
                         xdebug_xml_add_attribute(node, "facet", modifier);
- }
- xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) *zv), 0, 1);
 
- xdebug_xml_add_child(parent, node);
- xdebug_var_export_xml_node(zv, full_name, node, options, level + 1 TSRMLS_CC);
+ xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) *zv), 0, 1);
+
+ xdebug_xml_add_child(parent, node);
+
+ if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) {
+ xdebug_var_export_xml_node(zv, full_name, node, options, level + 1 TSRMLS_CC);
+ }
+ }
         }
         options->runtime[level].current_element_nr++;
         return 0;
@@ -744,7 +751,6 @@
                         xdebug_xml_add_attribute(node, "children", (myht && zend_hash_num_elements(myht))?"1":"0");
                         Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
                         xdebug_xml_add_attribute_ex(node, "classname", xdstrdup(class_name), 0, 1);
- efree(class_name);
                         if (myht) {
                                 if (myht->nApplyCount < 1) {
                                         xdebug_xml_add_attribute_ex(node, "numchildren", xdebug_sprintf("%d", zend_hash_num_elements(myht)), 0, 1);
@@ -759,12 +765,13 @@
                                                         options->runtime[level].start_element_nr = 0;
                                                         options->runtime[level].end_element_nr = options->max_children;
                                                 }
- 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);
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export_xml_node, 5, level, node, name, options, class_name);
                                         }
                                 } else {
                                         xdebug_xml_add_attribute(node, "recursive", "1");
                                 }
                         }
+ efree(class_name);
                         break;
 
                 case IS_RESOURCE: {
@@ -864,7 +871,7 @@
         xdebug_str *str;
         xdebug_var_export_options *options;
         char *key;
- char *prop_name, *modifier;
+ char *prop_name, *class_name, *modifier;
 #if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
         TSRMLS_FETCH();
 #endif
@@ -881,7 +888,7 @@
 
                 key = hash_key->arKey;
                 if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name);
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name, &class_name);
                         xdebug_str_add(str, xdebug_sprintf("<i>%s</i> '%s' <font color='%s'>=&gt;</font> ", modifier, prop_name, COLOR_POINTER), 1);
                 }
                 xdebug_var_export_fancy(zv, str, level + 1, debug_zval, options TSRMLS_CC);
Received on Thu May 07 2009 - 21:11:51 BST

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