Skip to content
Browse files

- Implemented FR #131: XDebug needs to implement paged child object r…

…equests.

SVN Rev: 1812
  • Loading branch information...
1 parent f379ef8 commit 87dfa5d0e598f7b1ed18385c6d0dd9b9fee9ddc0 @derickr committed Jan 22, 2006
Showing with 201 additions and 104 deletions.
  1. +85 −44 xdebug_handler_dbgp.c
  2. +0 −8 xdebug_handler_dbgp.h
  3. +13 −1 xdebug_hash.c
  4. +2 −1 xdebug_hash.h
  5. +3 −0 xdebug_mm.h
  6. +82 −48 xdebug_var.c
  7. +16 −2 xdebug_var.h
View
129 xdebug_handler_dbgp.c
@@ -508,25 +508,25 @@ static zval* get_symbol_contents_zval(char* name, int name_length TSRMLS_DC)
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 @@ DBGP_FUNC(eval)
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 @@ DBGP_FUNC(eval)
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(source)
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 @@ DBGP_FUNC(feature_get)
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_get)
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 @@ DBGP_FUNC(typemap_get)
}
}
-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 @@ static int add_variable_node(xdebug_xml_node *node, char *name, int name_length,
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 @@ static int add_variable_node(xdebug_xml_node *node, char *name, int name_length,
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 @@ DBGP_FUNC(property_get)
}
}
- 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 @@ DBGP_FUNC(property_set)
}
}
-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 @@ static int add_variable_contents_node(xdebug_xml_node *node, char *name, int nam
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 @@ static int add_variable_contents_node(xdebug_xml_node *node, char *name, int nam
}
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,19 +1580,31 @@ DBGP_FUNC(property_value)
}
}
- 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;
xdebug_xml_node *node = (xdebug_xml_node *) xml;
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 void attach_used_var_with_contents(void *xml, xdebug_hash_element* he)
}
}
-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 @@ static int attach_context_vars(xdebug_xml_node *node, xdebug_dbgp_options *optio
/* 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,17 +1716,19 @@ DBGP_FUNC(context_names)
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'));
}
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 @@ int xdebug_dbgp_parse_option(xdebug_con *context, char* line, int flags, xdebug_
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_cmdloop(xdebug_con *context TSRMLS_DC)
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 @@ int xdebug_dbgp_init(xdebug_con *context, int mode)
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
View
8 xdebug_handler_dbgp.h
@@ -70,14 +70,6 @@ typedef struct xdebug_dbgp_cmd {
#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);
View
14 xdebug_hash.c
@@ -1,4 +1,4 @@
-/* $Id: xdebug_hash.c,v 1.3 2003-04-15 05:55:56 derick Exp $ */
+/* $Id: xdebug_hash.c,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(xdebug_hash *h, void *user, void (*cb)(void *, xdebug_has
}
}
+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;
View
3 xdebug_hash.h
@@ -1,4 +1,4 @@
-/* $Id: xdebug_hash.h,v 1.1 2002-09-30 05:56:23 derick Exp $ */
+/* $Id: xdebug_hash.h,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_add_or_update(xdebug_hash *h, char *str_key, unsigned int str_k
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)
View
3 xdebug_mm.h
@@ -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
View
130 xdebug_var.c
@@ -268,7 +268,7 @@ static int xdebug_array_element_export_xml(zval **zv, int num_args, va_list args
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 @@ static int xdebug_object_element_export_xml(zval **zv, int num_args, va_list arg
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 @@ static int xdebug_array_element_export_xml_node(zval **zv, int num_args, va_list
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 *);
-
- 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);
+ 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)
+ {
+ 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,39 +441,46 @@ static int xdebug_object_element_export_xml_node(zval **zv, int num_args, va_lis
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();
level = va_arg(args, int);
parent = va_arg(args, xdebug_xml_node*);
full_name = parent_name = va_arg(args, char *);
-
- 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);
+ 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)
+ {
+ 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 @@ void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node,
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 @@ void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node,
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 @@ void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node,
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 @@ void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node,
}
}
-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_node* get_zval_value_xml_node(char *name, zval *val)
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;
}
View
18 xdebug_var.h
@@ -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

0 comments on commit 87dfa5d

Please sign in to comment.
Something went wrong with that request. Please try again.