[xdebug-dev] xdebug xdebug/xdebug_handler_dbgp.c xdebug/xdebug_handler_dbgp.h xdebug/xdebug_hash.c xdebug/xdebug_hash.h xdebug/xdebug_mm.h xdebug/xdebug_var.c xdebug/xdebug_var.h - Implemented FR #131: XDebug needs to implement paged child object requests.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 23 Jan 2006 00:30:59 +0100

Date: Mon Jan 23 00:30:59 CET 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[4.00]
- Implemented FR #131: XDebug needs to implement paged child object requests.

Modified files:
           xdebug/xdebug_handler_dbgp.c (version: 1.78)
           xdebug/xdebug_handler_dbgp.h (version: 1.16)
           xdebug/xdebug_hash.c (version: 1.4)
           xdebug/xdebug_hash.h (version: 1.2)
           xdebug/xdebug_mm.h (version: 1.3)
           xdebug/xdebug_var.c (version: 1.64)
           xdebug/xdebug_var.h (version: 1.22)

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- xdebug/xdebug_handler_dbgp.c:1.77 Tue Jan 17 21:19:48 2006 GMT
+++ xdebug/xdebug_handler_dbgp.c Sun Jan 22 22:30:59 2006 GMT
@@ -508,25 +508,25 @@
         return NULL;
 }
 
-static xdebug_xml_node* get_symbol(char* name, int name_length TSRMLS_DC)
+static xdebug_xml_node* get_symbol(char* name, int name_length, xdebug_var_export_options *options TSRMLS_DC)
 {
         zval *retval;
 
         retval = get_symbol_contents_zval(name, name_length TSRMLS_CC);
         if (retval) {
- return get_zval_value_xml_node(name, retval);
+ return get_zval_value_xml_node(name, retval, options);
         }
 
         return NULL;
 }
 
-int get_symbol_contents(char* name, int name_length, xdebug_xml_node *node TSRMLS_DC)
+int get_symbol_contents(char* name, int name_length, xdebug_xml_node *node, xdebug_var_export_options *options TSRMLS_DC)
 {
         zval *retval;
 
         retval = get_symbol_contents_zval(name, name_length TSRMLS_CC);
         if (retval) {
- xdebug_var_export_xml_node(&retval, name, node, 1 TSRMLS_CC);
+ xdebug_var_export_xml_node(&retval, name, node, options, 1 TSRMLS_CC);
                 return 1;
         }
 
@@ -1040,11 +1040,14 @@
         zval ret_zval;
         int new_length;
         int res;
+ xdebug_var_export_options *options;
 
         if (!CMD_OPTION('-')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
         }
 
+ options = (xdebug_var_export_options*) context->options;
+
         /* base64 decode eval string */
         eval_string = xdebug_base64_decode(CMD_OPTION('-'), strlen(CMD_OPTION('-')), &new_length);
 
@@ -1056,7 +1059,7 @@
         if (res == FAILURE) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_EVALUATING_CODE);
         } else {
- ret_xml = get_zval_value_xml_node(NULL, &ret_zval);
+ ret_xml = get_zval_value_xml_node(NULL, &ret_zval, options);
                 xdebug_xml_add_child(*retval, ret_xml);
                 zval_dtor(&ret_zval);
         }
@@ -1237,10 +1240,10 @@
 
 DBGP_FUNC(feature_get)
 {
- xdebug_dbgp_options *options;
+ xdebug_var_export_options *options;
         XDEBUG_STR_SWITCH_DECL;
 
- options = (xdebug_dbgp_options*) context->options;
+ options = (xdebug_var_export_options*) context->options;
 
         if (!CMD_OPTION('n')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
@@ -1302,6 +1305,11 @@
                         xdebug_xml_add_attribute(*retval, "supported", "1");
                 XDEBUG_STR_CASE_END
 
+ XDEBUG_STR_CASE("supports_postmortem")
+ xdebug_xml_add_text(*retval, xdstrdup("0"));
+ xdebug_xml_add_attribute(*retval, "supported", "1");
+ XDEBUG_STR_CASE_END
+
                 XDEBUG_STR_CASE("show_hidden")
                         xdebug_xml_add_text(*retval, xdebug_sprintf("%ld", options->show_hidden));
                         xdebug_xml_add_attribute(*retval, "supported", "1");
@@ -1315,10 +1323,10 @@
 
 DBGP_FUNC(feature_set)
 {
- xdebug_dbgp_options *options;
+ xdebug_var_export_options *options;
         XDEBUG_STR_SWITCH_DECL;
 
- options = (xdebug_dbgp_options*) context->options;
+ options = (xdebug_var_export_options*) context->options;
 
         if (!CMD_OPTION('n') || !CMD_OPTION('v')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
@@ -1380,14 +1388,14 @@
         }
 }
 
-static int add_variable_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null, int no_eval TSRMLS_DC)
+static int add_variable_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null, int no_eval, xdebug_var_export_options *options TSRMLS_DC)
 {
         xdebug_xml_node *contents;
         zval ret_zval;
         int res;
         HashTable *tmp_symbol_table;
 
- contents = get_symbol(name, name_length TSRMLS_CC);
+ contents = get_symbol(name, name_length, options TSRMLS_CC);
         if (!contents && !no_eval && XG(active_symbol_table)) {
                 char *varname = NULL;
                 if (var_only && name[0] != '$' && !strstr(name, "::$")) {
@@ -1399,7 +1407,7 @@
                 res = _xdebug_do_eval(varname ? varname : name, &ret_zval TSRMLS_CC);
                 EG(active_symbol_table) = tmp_symbol_table;
                 if (res != FAILURE && (!non_null || Z_TYPE_P(&ret_zval) != IS_NULL)) {
- contents = get_zval_value_xml_node(name, &ret_zval);
+ contents = get_zval_value_xml_node(name, &ret_zval, options);
                         zval_dtor(&ret_zval);
                 }
                 if (varname) {
@@ -1416,8 +1424,10 @@
 
 DBGP_FUNC(property_get)
 {
- int depth = -1;
- function_stack_entry *fse;
+ int depth = -1;
+ function_stack_entry *fse;
+ int old_max_data;
+ xdebug_var_export_options *options = (xdebug_var_export_options*) context->options;
 
         if (!CMD_OPTION('n')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
@@ -1437,7 +1447,19 @@
                 }
         }
 
- if (add_variable_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0, 0 TSRMLS_CC) == FAILURE) {
+ if (CMD_OPTION('p')) {
+ options->runtime.page = strtol(CMD_OPTION('p'), NULL, 10);
+ } else {
+ options->runtime.page = 0;
+ }
+
+ /* Override max data size if necessary */
+ old_max_data = options->max_data;
+ if (CMD_OPTION('m')) {
+ options->max_data= strtol(CMD_OPTION('m'), NULL, 10);
+ }
+ if (add_variable_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0, 0, options TSRMLS_CC) == FAILURE) {
+ options->max_data = old_max_data;
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTANT);
         }
 }
@@ -1498,14 +1520,14 @@
         }
 }
 
-static int add_variable_contents_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null, int no_eval TSRMLS_DC)
+static int add_variable_contents_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null, int no_eval, xdebug_var_export_options *options TSRMLS_DC)
 {
         int contents_found;
         zval ret_zval;
         int res;
         HashTable *tmp_symbol_table;
 
- contents_found = get_symbol_contents(name, name_length, node TSRMLS_CC);
+ contents_found = get_symbol_contents(name, name_length, node, options TSRMLS_CC);
         if (!contents_found && !no_eval) {
                 char *varname = NULL;
                 if (var_only && name[0] != '$' && !strstr(name, "::$")) {
@@ -1519,7 +1541,7 @@
                 if (res != FAILURE && (!non_null || Z_TYPE_P(&ret_zval) != IS_NULL)) {
                         zval *tmp_zval = &ret_zval;
                         
- xdebug_var_export_xml_node(&tmp_zval, name, node, 1 TSRMLS_CC);
+ xdebug_var_export_xml_node(&tmp_zval, name, node, options, 1 TSRMLS_CC);
                         contents_found = 1;
                         zval_dtor(&ret_zval);
                 }
@@ -1532,10 +1554,13 @@
         }
         return FAILURE;
 }
+
 DBGP_FUNC(property_value)
 {
- int depth = -1;
- function_stack_entry *fse;
+ int depth = -1;
+ function_stack_entry *fse;
+ int old_max_data;
+ xdebug_var_export_options *options = (xdebug_var_export_options*) context->options;
 
         if (!CMD_OPTION('n')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
@@ -1555,11 +1580,23 @@
                 }
         }
 
- if (add_variable_contents_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0, 0 TSRMLS_CC) == FAILURE) {
+ if (CMD_OPTION('p')) {
+ options->runtime.page = strtol(CMD_OPTION('p'), NULL, 10);
+ } else {
+ options->runtime.page = 0;
+ }
+
+ /* Override max data size if necessary */
+ old_max_data = options->max_data;
+ if (CMD_OPTION('m')) {
+ options->max_data = strtol(CMD_OPTION('m'), NULL, 10);
+ }
+ if (add_variable_contents_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0, 0, options TSRMLS_CC) == FAILURE) {
+ options->max_data = old_max_data;
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTANT);
         }
 }
-static void attach_used_var_with_contents(void *xml, xdebug_hash_element* he)
+static void attach_used_var_with_contents(void *xml, xdebug_hash_element* he, void *options)
 {
         char *name = (char*) he->ptr;
         char *full_name;
@@ -1567,7 +1604,7 @@
         xdebug_xml_node *contents;
         TSRMLS_FETCH();
 
- contents = get_symbol(name, strlen(name) + 1 TSRMLS_CC);
+ contents = get_symbol(name, strlen(name) + 1, options TSRMLS_CC);
         if (contents) {
                 xdebug_xml_add_child(node, contents);
         } else {
@@ -1585,7 +1622,7 @@
         }
 }
 
-static int attach_context_vars(xdebug_xml_node *node, xdebug_dbgp_options *options, long context_id, long depth, void (*func)(void *, xdebug_hash_element*) TSRMLS_DC)
+static int attach_context_vars(xdebug_xml_node *node, xdebug_var_export_options *options, long context_id, long depth, void (*func)(void *, xdebug_hash_element*, void*) TSRMLS_DC)
 {
         function_stack_entry *fse;
         xdebug_hash *ht;
@@ -1601,22 +1638,22 @@
 
                 /* Only show vars when they are scanned */
                 if (ht) {
- xdebug_hash_apply(ht, (void *) node, func);
+ xdebug_hash_apply_with_argument(ht, (void *) node, func, (void *) options);
                 }
 
 #ifdef ZEND_ENGINE_2
                 /* zend engine 2 does not give us $this, eval so we can get it */
- add_variable_node(node, "this", sizeof("this"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "this", sizeof("this"), 1, 1, 0, options TSRMLS_CC);
 #endif
                 if (options->show_hidden && context_id > 0) {
                         /* add supper globals */
- add_variable_node(node, "_ENV", sizeof("_ENV"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_GET", sizeof("_GET"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_POST", sizeof("_POST"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_COOKIE", sizeof("_COOKIE"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_REQUEST", sizeof("_REQUEST"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_FILES", sizeof("_FILES"), 1, 1, 0 TSRMLS_CC);
- add_variable_node(node, "_SERVER", sizeof("_SERVER"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_ENV", sizeof("_ENV"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_GET", sizeof("_GET"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_POST", sizeof("_POST"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_COOKIE", sizeof("_COOKIE"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_REQUEST", sizeof("_REQUEST"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_FILES", sizeof("_FILES"), 1, 1, 0, options TSRMLS_CC);
+ add_variable_node(node, "_SERVER", sizeof("_SERVER"), 1, 1, 0, options TSRMLS_CC);
                 }
 
                 XG(active_symbol_table) = NULL;
@@ -1679,10 +1716,10 @@
 
 DBGP_FUNC(context_get)
 {
- int res;
- int context_id = 0;
- int depth = 0;
- xdebug_dbgp_options *options = (xdebug_dbgp_options*) context->options;
+ int res;
+ int context_id = 0;
+ int depth = 0;
+ xdebug_var_export_options *options = (xdebug_var_export_options*) context->options;
         
         if (CMD_OPTION('c')) {
                 context_id = atol(CMD_OPTION('c'));
@@ -1690,6 +1727,8 @@
         if (CMD_OPTION('d')) {
                 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;
         
         res = attach_context_vars(*retval, options, context_id, depth, attach_used_var_with_contents TSRMLS_CC);
         switch (res) {
@@ -1908,7 +1947,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.77 $";
+ return "$Revision: 1.78 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
@@ -1938,7 +1977,7 @@
 
 int xdebug_dbgp_init(xdebug_con *context, int mode)
 {
- xdebug_dbgp_options *options;
+ xdebug_var_export_options *options;
         xdebug_xml_node *response, *child;
         TSRMLS_FETCH();
 
@@ -1997,12 +2036,14 @@
         xdebug_xml_node_dtor(response);
 /* }}} */
 
- context->options = xdmalloc(sizeof(xdebug_dbgp_options));
- options = (xdebug_dbgp_options*) context->options;
- options->max_children = 2048;
- options->max_data = 524288;
- options->max_depth = 16;
+ context->options = xdmalloc(sizeof(xdebug_var_export_options));
+ options = (xdebug_var_export_options*) context->options;
+ options->max_children = 32;
+ options->max_data = 1024;
+ options->max_depth = 1;
         options->show_hidden = 0;
+ options->runtime.page = 0;
+ options->runtime.current_element_nr = 0;
 
 /* {{{ Initialize auto globals in Zend Engine 2 */
 #ifdef ZEND_ENGINE_2

[FILE: /xdebug/xdebug_handler_dbgp.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- xdebug/xdebug_handler_dbgp.h:1.15 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_handler_dbgp.h Sun Jan 22 22:30:59 2006 GMT
@@ -70,14 +70,6 @@
 
 #define CMD_OPTION(opt) (opt == '-' ? args->value[26] : args->value[(opt) - 'a'])
 
-typedef struct xdebug_dbgp_options {
- int max_children;
- int max_data;
- int max_depth;
- int show_hidden;
-} xdebug_dbgp_options;
-
-
 int xdebug_dbgp_init(xdebug_con *context, int mode);
 int xdebug_dbgp_deinit(xdebug_con *context);
 int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const uint line, xdebug_llist *stack);

[FILE: /xdebug/xdebug_hash.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- xdebug/xdebug_hash.c:1.3 Tue Apr 15 03:55:56 2003 GMT
+++ xdebug/xdebug_hash.c Sun Jan 22 22:30:59 2006 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.3 2003/04/15 05:55:56 derick Exp $ */
+/* $Id: cvstemp,v 1.4 2006/01/22 23:30:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -230,6 +230,18 @@
          }
 }
 
+void xdebug_hash_apply_with_argument(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *, void *), void *argument)
+{
+ xdebug_llist_element *le;
+ int i;
+
+ for (i = 0; i < h->slots; ++i) {
+ for (le = XDEBUG_LLIST_HEAD(h->table[i]); le != NULL; le = XDEBUG_LLIST_NEXT(le)) {
+ cb(user, (xdebug_hash_element *) XDEBUG_LLIST_VALP(le), argument);
+ }
+ }
+}
+
 void xdebug_hash_destroy(xdebug_hash *h)
 {
         int i;

[FILE: /xdebug/xdebug_hash.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xdebug/xdebug_hash.h:1.1 Mon Sep 30 03:56:23 2002 GMT
+++ xdebug/xdebug_hash.h Sun Jan 22 22:30:59 2006 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.1 2002/09/30 05:56:23 derick Exp $ */
+/* $Id: cvstemp,v 1.2 2006/01/22 23:30:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -67,6 +67,7 @@
 int xdebug_hash_extended_delete(xdebug_hash *h, char *str_key, unsigned int str_key_len, unsigned long num_key);
 int xdebug_hash_extended_find(xdebug_hash *h, char *str_key, unsigned int str_key_len, unsigned long num_key, void **p);
 void xdebug_hash_apply(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *));
+void xdebug_hash_apply_with_argument(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_hash_element *, void *), void *argument);
 void xdebug_hash_destroy(xdebug_hash *h);
 
 #define xdebug_hash_find(h, key, key_len, p) xdebug_hash_extended_find(h, key, key_len, 0, p)

[FILE: /xdebug/xdebug_mm.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xdebug/xdebug_mm.h:1.2 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_mm.h Sun Jan 22 22:30:59 2006 GMT
@@ -26,12 +26,15 @@
 #define xdrealloc erealloc
 #define xdfree efree
 #define xdstrdup estrdup
+#define xdstrndup estrndup
 #else
+#include <string.h>
 #define xdmalloc malloc
 #define xdcalloc calloc
 #define xdrealloc realloc
 #define xdfree free
 #define xdstrdup strdup
+#define xdstrndup strndup
 #endif
 
 #endif

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- xdebug/xdebug_var.c:1.63 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_var.c Sun Jan 22 22:30:59 2006 GMT
@@ -268,7 +268,7 @@
                 xdebug_str_add(str, xdebug_sprintf(" name='%s'", hash_key->arKey), 1);
         }
         xdebug_str_add(str, xdebug_sprintf(" id='%p'>", *zv), 1);
- xdebug_var_export_xml(zv, str, level + 2 TSRMLS_CC);
+ xdebug_var_export_xml(zv, str, level + 1 TSRMLS_CC);
         xdebug_str_addl(str, "</var>", 6, 0);
         return 0;
 }
@@ -289,7 +289,7 @@
                 xdebug_str_add(str, xdebug_sprintf(" name='%s' facet='%s'", prop_name, modifier), 1);
         }
         xdebug_str_add(str, xdebug_sprintf(" id='%p'>", *zv), 1);
- xdebug_var_export_xml(zv, str, level + 2 TSRMLS_CC);
+ xdebug_var_export_xml(zv, str, level + 1 TSRMLS_CC);
         xdebug_str_addl(str, "</var>", 6, 0);
         return 0;
 }
@@ -395,37 +395,44 @@
         int level;
         xdebug_xml_node *parent;
         xdebug_xml_node *node;
+ xdebug_var_export_options *options;
         char *name = NULL, *parent_name = NULL, *full_name = NULL;
         TSRMLS_FETCH();
 
         level = va_arg(args, int);
         parent = va_arg(args, xdebug_xml_node*);
         parent_name = va_arg(args, char *);
+ options = va_arg(args, xdebug_var_export_options*);
 
- node = xdebug_xml_node_init("property");
-
- if (hash_key->nKeyLength != 0) {
- name = xdstrdup(hash_key->arKey);
- if (parent_name[0] != '$') {
- full_name = xdebug_sprintf("$%s['%s']", parent_name, name);
- } else {
- full_name = xdebug_sprintf("%s['%s']", parent_name, name);
- }
- } else {
- name = xdebug_sprintf("%ld", hash_key->h);
- if (parent_name[0] != '$') {
- full_name = xdebug_sprintf("$%s[%s]", parent_name, name);
+ if (options->runtime.current_element_nr >= options->runtime.start_element_nr &&
+ options->runtime.current_element_nr < options->runtime.end_element_nr)
+ {
+ node = xdebug_xml_node_init("property");
+
+ if (hash_key->nKeyLength != 0) {
+ name = xdstrdup(hash_key->arKey);
+ if (parent_name[0] != '$') {
+ full_name = xdebug_sprintf("$%s['%s']", parent_name, name);
+ } else {
+ full_name = xdebug_sprintf("%s['%s']", parent_name, name);
+ }
                 } else {
- full_name = xdebug_sprintf("%s[%s]", parent_name, name);
+ name = xdebug_sprintf("%ld", hash_key->h);
+ if (parent_name[0] != '$') {
+ full_name = xdebug_sprintf("$%s[%s]", parent_name, name);
+ } else {
+ full_name = xdebug_sprintf("%s[%s]", parent_name, name);
+ }
                 }
- }
 
- xdebug_xml_add_attribute_ex(node, "name", name, 0, 1);
- xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
- xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) *zv), 0, 1);
+ xdebug_xml_add_attribute_ex(node, "name", name, 0, 1);
+ xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
+ 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, level + 2 TSRMLS_CC);
+ 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++;
         return 0;
 }
 
@@ -434,6 +441,7 @@
         int level;
         xdebug_xml_node *parent;
         xdebug_xml_node *node;
+ xdebug_var_export_options *options;
         char *prop_name, *modifier;
         char *parent_name = NULL, *full_name = NULL;
         TSRMLS_FETCH();
@@ -441,32 +449,38 @@
         level = va_arg(args, int);
         parent = va_arg(args, xdebug_xml_node*);
         full_name = parent_name = va_arg(args, char *);
+ options = va_arg(args, xdebug_var_export_options*);
 
- node = xdebug_xml_node_init("property");
-
- if (hash_key->nKeyLength != 0) {
- modifier = xdebug_get_property_info(hash_key->arKey, &prop_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 (options->runtime.current_element_nr >= options->runtime.start_element_nr &&
+ options->runtime.current_element_nr < options->runtime.end_element_nr)
+ {
+ node = xdebug_xml_node_init("property");
+
+ if (hash_key->nKeyLength != 0) {
+ modifier = xdebug_get_property_info(hash_key->arKey, &prop_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);
+ }
+ 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(node, "facet", modifier);
- }
- xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) *zv), 0, 1);
+ 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, level + 2 TSRMLS_CC);
+ 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++;
         return 0;
 }
 
-void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, int level TSRMLS_DC)
+void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, xdebug_var_export_options *options, int level TSRMLS_DC)
 {
         HashTable *myht;
 #ifdef ZEND_ENGINE_2
@@ -496,7 +510,12 @@
 
                 case IS_STRING:
                         xdebug_xml_add_attribute(node, "type", "string");
- xdebug_xml_add_text_encode(node, xdstrdup(Z_STRVAL_PP(struc)));
+ if (options->max_data == 0 || Z_STRLEN_PP(struc) <= options->max_data) {
+ xdebug_xml_add_text_encode(node, xdstrdup(Z_STRVAL_PP(struc)));
+ } else {
+ xdebug_xml_add_text_encode(node, xdstrndup(Z_STRVAL_PP(struc), options->max_data));
+ }
+ xdebug_xml_add_attribute(node, "size", xdebug_sprintf("%d", Z_STRLEN_PP(struc)));
                         break;
 
                 case IS_ARRAY:
@@ -505,7 +524,19 @@
                         xdebug_xml_add_attribute(node, "children", myht->nNumOfElements > 0?"1":"0");
                         if (myht->nApplyCount < 1) {
                                 xdebug_xml_add_attribute_ex(node, "numchildren", xdebug_sprintf("%d", myht->nNumOfElements), 0, 1);
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export_xml_node, 3, level, node, name);
+ 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);
+ 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);
+ } else {
+ options->runtime.start_element_nr = 0;
+ options->runtime.end_element_nr = myht->nNumOfElements;
+ }
+ zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_array_element_export_xml_node, 4, level, node, name, options);
+ }
                         } else {
                                 xdebug_xml_add_attribute(node, "recursive", "1");
                         }
@@ -525,7 +556,10 @@
                         if (myht) {
                                 if (myht->nApplyCount < 1) {
                                         xdebug_xml_add_attribute_ex(node, "numchildren", xdebug_sprintf("%d", zend_hash_num_elements(myht)), 0, 1);
- zend_hash_apply_with_arguments(myht, (apply_func_args_t) xdebug_object_element_export_xml_node, 3, level, node, name);
+ if (level <= options->max_depth) {
+ options->runtime.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 {
                                         xdebug_xml_add_attribute(node, "recursive", "1");
                                 }
@@ -547,7 +581,7 @@
         }
 }
 
-xdebug_xml_node* get_zval_value_xml_node(char *name, zval *val)
+xdebug_xml_node* get_zval_value_xml_node(char *name, zval *val, xdebug_var_export_options *options)
 {
         xdebug_xml_node *node;
         char *full_name = NULL;
@@ -564,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, 1 TSRMLS_CC);
+ xdebug_var_export_xml_node(&val, name, node, options, 1 TSRMLS_CC);
 
         return node;
 }

[FILE: /xdebug/xdebug_var.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- xdebug/xdebug_var.h:1.21 Sun Jan 01 14:27:27 2006 GMT
+++ xdebug/xdebug_var.h Sun Jan 22 22:30:59 2006 GMT
@@ -25,19 +25,33 @@
 #ifndef __HAVE_XDEBUG_VAR_H__
 #define __HAVE_XDEBUG_VAR_H__
 
+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_export_options;
+
 zval* xdebug_get_php_symbol(char* name, int name_length);
 
 void xdebug_var_export(zval **struc, xdebug_str *str, int level, int debug_zval TSRMLS_DC);
 void xdebug_var_export_xml(zval **struc, xdebug_str *str, int level TSRMLS_DC);
 void xdebug_var_export_fancy(zval **struc, xdebug_str *str, int level, int debug_zval TSRMLS_DC);
-void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, int level TSRMLS_DC);
+void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, xdebug_var_export_options *options, int level TSRMLS_DC);
 
 char* xmlize(char *string, int len, int *newlen);
 char* error_type (int type);
 char* get_zval_value (zval *val, int debug_zval);
 char* get_zval_value_xml (char *name, zval *val);
 char* get_zval_value_fancy(char *name, zval *val, int *len, int debug_zval TSRMLS_DC);
-xdebug_xml_node* get_zval_value_xml_node (char *name, zval *val);
+xdebug_xml_node* get_zval_value_xml_node (char *name, zval *val, xdebug_var_export_options *options);
 char* show_fname(xdebug_func t, int html, int flags TSRMLS_DC);
 
 #endif
Received on Mon Jan 23 2006 - 00:31:03 GMT

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