[xdebug-dev] xdebug xdebug/xdebug_handler_dbgp.c xdebug/xdebug_var.c xdebug/xdebug_var.h - Implemented correct paging behavior in case max_depth is greater than 1.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Tue, 24 Jan 2006 22:12:06 +0100

Date: Tue Jan 24 22:12:06 CET 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[0.75]
- Implemented correct paging behavior in case max_depth is greater than 1.

Modified files:
           xdebug/xdebug_handler_dbgp.c (version: 1.79)
           xdebug/xdebug_var.c (version: 1.65)
           xdebug/xdebug_var.h (version: 1.23)

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- xdebug/xdebug_handler_dbgp.c:1.78 Sun Jan 22 22:30:59 2006 GMT
+++ xdebug/xdebug_handler_dbgp.c Tue Jan 24 20:12:06 2006 GMT
@@ -1349,7 +1349,16 @@
                 XDEBUG_STR_CASE_END
 
                 XDEBUG_STR_CASE("max_depth")
+ int i;
                         options->max_depth = strtol(CMD_OPTION('v'), NULL, 10);
+
+ /* Reallocating page structure */
+ xdfree(options->runtime);
+ options->runtime = (xdebug_var_runtime_page*) xdmalloc(options->max_depth * sizeof(xdebug_var_runtime_page));
+ for (i = 0; i < options->max_depth; i++) {
+ options->runtime[i].page = 0;
+ options->runtime[i].current_element_nr = 0;
+ }
                 XDEBUG_STR_CASE_END
 
                 XDEBUG_STR_CASE("show_hidden")
@@ -1448,9 +1457,9 @@
         }
 
         if (CMD_OPTION('p')) {
- options->runtime.page = strtol(CMD_OPTION('p'), NULL, 10);
+ options->runtime[0].page = strtol(CMD_OPTION('p'), NULL, 10);
         } else {
- options->runtime.page = 0;
+ options->runtime[0].page = 0;
         }
 
         /* Override max data size if necessary */
@@ -1581,9 +1590,9 @@
         }
 
         if (CMD_OPTION('p')) {
- options->runtime.page = strtol(CMD_OPTION('p'), NULL, 10);
+ options->runtime[0].page = strtol(CMD_OPTION('p'), NULL, 10);
         } else {
- options->runtime.page = 0;
+ options->runtime[0].page = 0;
         }
 
         /* Override max data size if necessary */
@@ -1728,7 +1737,7 @@
                 depth = atol(CMD_OPTION('d'));
         }
         /* Always reset to page = 0, as it might have been modified by property_get or property_value */
- options->runtime.page = 0;
+ options->runtime[0].page = 0;
         
         res = attach_context_vars(*retval, options, context_id, depth, attach_used_var_with_contents TSRMLS_CC);
         switch (res) {
@@ -1947,7 +1956,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.78 $";
+ return "$Revision: 1.79 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
@@ -1979,6 +1988,7 @@
 {
         xdebug_var_export_options *options;
         xdebug_xml_node *response, *child;
+ int i;
         TSRMLS_FETCH();
 
         /* initialize our status information */
@@ -2042,8 +2052,11 @@
         options->max_data = 1024;
         options->max_depth = 1;
         options->show_hidden = 0;
- options->runtime.page = 0;
- options->runtime.current_element_nr = 0;
+ options->runtime = (xdebug_var_runtime_page*) xdmalloc(options->max_depth * sizeof(xdebug_var_runtime_page));
+ for (i = 0; i < options->max_depth; i++) {
+ options->runtime[i].page = 0;
+ options->runtime[i].current_element_nr = 0;
+ }
 
 /* {{{ Initialize auto globals in Zend Engine 2 */
 #ifdef ZEND_ENGINE_2
@@ -2069,7 +2082,8 @@
 
 int xdebug_dbgp_deinit(xdebug_con *context)
 {
- xdebug_xml_node *response;
+ xdebug_xml_node *response;
+ xdebug_var_export_options *options;
         TSRMLS_FETCH();
 
         XG(status) = DBGP_STATUS_STOPPED;
@@ -2095,6 +2109,8 @@
                 XG(stdio).php_header_write = NULL;
         }
 
+ options = (xdebug_var_export_options*) context->options;
+ xdfree(options->runtime);
         xdfree(context->options);
         xdebug_hash_destroy(context->function_breakpoints);
         xdebug_hash_destroy(context->class_breakpoints);

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- xdebug/xdebug_var.c:1.64 Sun Jan 22 22:30:59 2006 GMT
+++ xdebug/xdebug_var.c Tue Jan 24 20:12:06 2006 GMT
@@ -404,8 +404,8 @@
         parent_name = va_arg(args, char *);
         options = va_arg(args, xdebug_var_export_options*);
 
- if (options->runtime.current_element_nr >= options->runtime.start_element_nr &&
- options->runtime.current_element_nr < options->runtime.end_element_nr)
+ 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");
                 
@@ -432,7 +432,7 @@
                 xdebug_xml_add_child(parent, node);
                 xdebug_var_export_xml_node(zv, full_name, node, options, level + 1 TSRMLS_CC);
         }
- options->runtime.current_element_nr++;
+ options->runtime[level].current_element_nr++;
         return 0;
 }
 
@@ -451,8 +451,8 @@
         full_name = parent_name = va_arg(args, char *);
         options = va_arg(args, xdebug_var_export_options*);
 
- if (options->runtime.current_element_nr >= options->runtime.start_element_nr &&
- options->runtime.current_element_nr < options->runtime.end_element_nr)
+ 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");
                 
@@ -476,7 +476,7 @@
                 xdebug_xml_add_child(parent, node);
                 xdebug_var_export_xml_node(zv, full_name, node, options, level + 1 TSRMLS_CC);
         }
- options->runtime.current_element_nr++;
+ options->runtime[level].current_element_nr++;
         return 0;
 }
 
@@ -525,15 +525,15 @@
                         if (myht->nApplyCount < 1) {
                                 xdebug_xml_add_attribute_ex(node, "numchildren", xdebug_sprintf("%d", myht->nNumOfElements), 0, 1);
                                 if (level <= options->max_depth) {
- options->runtime.current_element_nr = 0;
- if (myht->nNumOfElements > options->max_children) {
- xdebug_xml_add_attribute_ex(node, "page", xdebug_sprintf("%d", options->runtime.page), 0, 1);
+ options->runtime[level].current_element_nr = 0;
+ if (level == 0 && myht->nNumOfElements > options->max_children) {
+ xdebug_xml_add_attribute_ex(node, "page", xdebug_sprintf("%d", options->runtime[level].page), 0, 1);
                                                 xdebug_xml_add_attribute_ex(node, "pagesize", xdebug_sprintf("%d", options->max_children), 0, 1);
- options->runtime.start_element_nr = options->max_children * options->runtime.page;
- options->runtime.end_element_nr = options->max_children * (options->runtime.page + 1);
+ options->runtime[level].start_element_nr = options->max_children * options->runtime[level].page;
+ options->runtime[level].end_element_nr = options->max_children * (options->runtime[level].page + 1);
                                         } else {
- options->runtime.start_element_nr = 0;
- options->runtime.end_element_nr = myht->nNumOfElements;
+ 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);
                                 }
@@ -557,7 +557,7 @@
                                 if (myht->nApplyCount < 1) {
                                         xdebug_xml_add_attribute_ex(node, "numchildren", xdebug_sprintf("%d", zend_hash_num_elements(myht)), 0, 1);
                                         if (level <= options->max_depth) {
- options->runtime.current_element_nr = 0;
+ options->runtime[level].current_element_nr = 0;
                                                 zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export_xml_node, 4, level, node, name, options);
                                         }
                                 } else {
@@ -598,7 +598,7 @@
                 xdebug_xml_add_attribute_ex(node, "fullname", xdstrdup(full_name), 0, 1);
         }
         xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) val), 0, 1);
- xdebug_var_export_xml_node(&val, name, node, options, 1 TSRMLS_CC);
+ xdebug_var_export_xml_node(&val, name, node, options, 0 TSRMLS_CC);
 
         return node;
 }

[FILE: /xdebug/xdebug_var.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- xdebug/xdebug_var.h:1.22 Sun Jan 22 22:30:59 2006 GMT
+++ xdebug/xdebug_var.h Tue Jan 24 20:12:06 2006 GMT
@@ -25,18 +25,20 @@
 #ifndef __HAVE_XDEBUG_VAR_H__
 #define __HAVE_XDEBUG_VAR_H__
 
+typedef struct
+{
+ int page; /* The number of the page to retrieve */
+ int current_element_nr;
+ int start_element_nr;
+ int end_element_nr;
+} xdebug_var_runtime_page;
+
 typedef struct xdebug_var_export_options {
         int max_children;
         int max_data;
         int max_depth;
         int show_hidden;
- struct
- {
- int page; /* The number of the page to retrieve */
- int current_element_nr;
- int start_element_nr;
- int end_element_nr;
- } runtime;
+ xdebug_var_runtime_page *runtime;
 } xdebug_var_export_options;
 
 zval* xdebug_get_php_symbol(char* name, int name_length);
Received on Tue Jan 24 2006 - 22:12:16 GMT

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