Date: Sun Oct 8 00:02:47 CEST 2006
User: Derick Rethans
Directory: xdebug
Log Message:
[3.00]
- Namespace protected super global dumping functions.
- Refactored stack trace dumping code to return by string for better
control over when things are printed.
Modified files:
xdebug/xdebug.c (version: 1.351)
xdebug/xdebug_superglobals.c (version: 1.20)
xdebug/xdebug_superglobals.h (version: 1.7)
[FILE: /xdebug/xdebug.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.350
retrieving revision 1.351
diff -u -r1.350 -r1.351
--- xdebug/xdebug.c:1.350 Fri Oct 06 12:23:03 2006 GMT
+++ xdebug/xdebug.c Sat Oct 07 20:02:47 2006 GMT
@@ -340,14 +340,14 @@
xg->breakpoint_count = 0;
xg->ide_key = NULL;
- xdebug_llist_init(&xg->server, dump_dtor);
- xdebug_llist_init(&xg->get, dump_dtor);
- xdebug_llist_init(&xg->post, dump_dtor);
- xdebug_llist_init(&xg->cookie, dump_dtor);
- xdebug_llist_init(&xg->files, dump_dtor);
- xdebug_llist_init(&xg->env, dump_dtor);
- xdebug_llist_init(&xg->request, dump_dtor);
- xdebug_llist_init(&xg->session, dump_dtor);
+ xdebug_llist_init(&xg->server, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->get, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->post, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->cookie, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->files, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->env, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->request, xdebug_superglobals_dump_dtor);
+ xdebug_llist_init(&xg->session, xdebug_superglobals_dump_dtor);
}
static void php_xdebug_shutdown_globals (zend_xdebug_globals *xg TSRMLS_DC)
@@ -1538,7 +1538,7 @@
"<tr><td bgcolor='#eeeeec'>$%s</td><td colspan='4' bgcolor='#eeeeec' colspan='2'><i>Undefined</i></td></tr>\n"
};
-static void dump_used_var_with_contents(void *htmlq, xdebug_hash_element* he)
+static void dump_used_var_with_contents(void *htmlq, xdebug_hash_element* he, void *argument)
{
int html = *(int *)htmlq;
int len;
@@ -1547,6 +1547,7 @@
char *name = (char*) he->ptr;
HashTable *tmp_ht;
char **formats;
+ xdebug_str *str = (xdebug_str *) argument;
TSRMLS_FETCH();
if (!he->ptr) {
@@ -1576,9 +1577,9 @@
}
if (contents) {
- php_printf(formats[8], name, contents);
+ xdebug_str_add(str, xdebug_sprintf(formats[8], name, contents), 1);
} else {
- php_printf(formats[9], name);
+ xdebug_str_add(str, xdebug_sprintf(formats[9], name), 1);;
}
xdfree(contents);
@@ -1624,17 +1625,19 @@
xdebug_str_add(&log_buffer, xdebug_sprintf(") %s:%d", i->filename, i->lineno), 1);
php_log_err(log_buffer.d TSRMLS_CC);
+ xdebug_str_free(&log_buffer);
}
}
}
-static void print_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno, int log_only TSRMLS_DC)
+static char* get_printable_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno, int log_only TSRMLS_DC)
{
char *error_format, *error_string;
xdebug_llist_element *le;
function_stack_entry *i;
int len, dummy;
char **formats;
+ xdebug_str str = {0, 0, NULL};
log_stack(error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
@@ -1648,14 +1651,14 @@
formats = text_formats;
}
- php_printf(formats[0]);
+ xdebug_str_add(&str, formats[0], 0);
- php_printf(formats[1], error_type_str, buffer, error_filename, error_lineno);
+ xdebug_str_add(&str, xdebug_sprintf(formats[1], error_type_str, buffer, error_filename, error_lineno), 1);
if (XG(stack) && XG(stack)->size) {
i = XDEBUG_LLIST_VALP(XDEBUG_LLIST_HEAD(XG(stack)));
- php_printf(formats[2]);
+ xdebug_str_add(&str, formats[2], 0);
for (le = XDEBUG_LLIST_HEAD(XG(stack)); le != NULL; le = XDEBUG_LLIST_NEXT(le))
{
@@ -1667,15 +1670,15 @@
tmp_name = show_fname(i->function, html, 0 TSRMLS_CC);
if (html) {
#if HAVE_PHP_MEMORY_USAGE
- php_printf(formats[3], i->level, i->time - XG(start_time), i->memory, tmp_name);
+ xdebug_str_add(&str, xdebug_sprintf(formats[3], i->level, i->time - XG(start_time), i->memory, tmp_name), 1);
#else
- php_printf(formats[3], i->level, i->time - XG(start_time), tmp_name);
+ xdebug_str_add(&str, xdebug_sprintf(formats[3], i->level, i->time - XG(start_time), tmp_name), 1);
#endif
} else {
#if HAVE_PHP_MEMORY_USAGE
- php_printf(formats[3], i->time - XG(start_time), i->memory, i->level, tmp_name);
+ xdebug_str_add(&str, xdebug_sprintf(formats[3], i->time - XG(start_time), i->memory, i->level, tmp_name), 1);
#else
- php_printf(formats[3], i->time - XG(start_time), i->level, tmp_name);
+ xdebug_str_add(&str, xdebug_sprintf(formats[3], i->time - XG(start_time), i->level, tmp_name), 1);
#endif
}
xdfree(tmp_name);
@@ -1685,32 +1688,32 @@
char *tmp_varname, *tmp_value, *tmp_fancy_value;
if (c) {
- php_printf(", ");
+ xdebug_str_addl(&str, ", ", 2, 0);
} else {
c = 1;
}
tmp_varname = i->var[j].name ? xdebug_sprintf("$%s = ", i->var[j].name) : xdstrdup("");
if (html) {
tmp_fancy_value = get_zval_synopsis_fancy(tmp_varname, i->var[j].addr, &len, 0, NULL TSRMLS_CC);
- php_printf("%s", tmp_fancy_value);
+ xdebug_str_add(&str, xdebug_sprintf("%s", tmp_fancy_value), 1);
xdfree(tmp_fancy_value);
} else {
tmp_value = get_zval_synopsis(i->var[j].addr, 0, NULL);
- php_printf("%s%s", tmp_varname, tmp_value);
+ xdebug_str_add(&str, xdebug_sprintf("%s%s", tmp_varname, tmp_value), 1);
xdfree(tmp_value);
}
xdfree(tmp_varname);
}
if (i->include_filename) {
- php_printf(formats[4], i->include_filename);
+ xdebug_str_add(&str, xdebug_sprintf(formats[4], i->include_filename), 1);
}
- php_printf(formats[5], i->filename, i->lineno);
+ xdebug_str_add(&str, xdebug_sprintf(formats[5], i->filename, i->lineno), 1);
}
if (XG(dump_globals)) {
- dump_superglobals(html TSRMLS_CC);
+ xdebug_str_add(&str, xdebug_get_printable_superglobals(html TSRMLS_CC), 1);
}
if (XG(show_local_vars) && XG(stack) && XDEBUG_LLIST_TAIL(XG(stack))) {
@@ -1722,13 +1725,23 @@
scope_nr--;
}
if (i->used_vars && i->used_vars->size) {
- php_printf(formats[6], scope_nr);
- xdebug_hash_apply(i->used_vars, (void*) &html, dump_used_var_with_contents);
+ xdebug_str_add(&str, xdebug_sprintf(formats[6], scope_nr), 1);
+ xdebug_hash_apply_with_argument(i->used_vars, (void*) &html, dump_used_var_with_contents, (void *) &str);
}
}
- php_printf(formats[7]);
+ xdebug_str_add(&str, formats[7], 0);
}
+ return str.d;
+}
+
+static void print_stack(int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno, int log_only TSRMLS_DC)
+{
+ char *printable_stack;
+
+ printable_stack = get_printable_stack(html, error_type_str, buffer, error_filename, error_lineno, log_only TSRMLS_CC);
+ php_printf("%s", printable_stack);
+ xdfree(printable_stack);
}
static char* return_trace_stack_retval(function_stack_entry* i, zval* retval TSRMLS_DC)
[FILE: /xdebug/xdebug_superglobals.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- xdebug/xdebug_superglobals.c:1.19 Fri Oct 06 12:23:03 2006 GMT
+++ xdebug/xdebug_superglobals.c Sat Oct 07 20:02:47 2006 GMT
@@ -24,21 +24,21 @@
extern ZEND_DECLARE_MODULE_GLOBALS(xdebug);
-void dump_dtor(void *user, void *ptr)
+void xdebug_superglobals_dump_dtor(void *user, void *ptr)
{
free(ptr);
}
-static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html TSRMLS_DC)
+static void dump_hash_elem(zval *z, char *name, long index, char *elem, int html, xdebug_str *str TSRMLS_DC)
{
char buffer[1024];
int len;
if (html) {
if (elem) {
- php_printf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s['%s'] =</pre></td>", name, elem);
+ xdebug_str_add(str, xdebug_sprintf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s['%s'] =</pre></td>", name, elem), 1);
} else {
- php_printf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s[%ld] =</pre></td>", name, index);
+ xdebug_str_add(str, xdebug_sprintf("<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s[%ld] =</pre></td>", name, index), 1);
}
}
@@ -48,31 +48,32 @@
if (html) {
val = get_zval_value_fancy(NULL, z, &len, 0, NULL TSRMLS_CC);
#if HAVE_PHP_MEMORY_USAGE
- php_printf("<td colspan='3' bgcolor='#eeeeec'>");
+ xdebug_str_add(str, xdebug_sprintf("<td colspan='3' bgcolor='#eeeeec'>"), 1);
#else
- php_printf("<td colspan='2' bgcolor='#eeeeec'>");
+ xdebug_str_add(str, xdebug_sprintf("<td colspan='2' bgcolor='#eeeeec'>"), 1);
#endif
- PHPWRITE(val, len);
- php_printf("</td>");
+ xdebug_str_addl(str, val, len, 0);
+ xdebug_str_add(str, "</td>", 0);
} else {
val = get_zval_value(z, 0, NULL);
- printf("\n $%s['%s'] = %s", name, elem, val);
+ xdebug_str_add(str, xdebug_sprintf("\n $%s['%s'] = %s", name, elem, val), 1);
}
+ xdfree(val);
} else {
/* not found */
if (html) {
#if HAVE_PHP_MEMORY_USAGE
- php_printf("<td colspan='3' bgcolor='#eeeeec'><i>undefined</i></td>");
+ xdebug_str_add(str, "<td colspan='3' bgcolor='#eeeeec'><i>undefined</i></td>", 0);
#else
- php_printf("<td colspan='2' bgcolor='#eeeeec'><i>undefined</i></td>");
+ xdebug_str_add(str, "<td colspan='2' bgcolor='#eeeeec'><i>undefined</i></td>", 0);
#endif
} else {
- printf("\n $%s['%s'] is undefined", name, elem);
+ xdebug_str_add(str, xdebug_sprintf("\n $%s['%s'] is undefined", name, elem), 1);
}
}
if (html) {
- php_printf("</tr>\n");
+ xdebug_str_add(str, "</tr>\n", 0);
}
}
@@ -80,27 +81,29 @@
{
int html;
char *name;
+ xdebug_str *str;
#ifdef ZTS
void ***tsrm_ls;
#endif
name = va_arg(args, char *);
html = va_arg(args, int);
+ str = va_arg(args, xdebug_str *);
#ifdef ZTS
tsrm_ls = va_arg(args, void ***);
#endif
if (hash_key->nKeyLength == 0) {
- dump_hash_elem(*((zval **) pDest), name, hash_key->h, NULL, html TSRMLS_CC);
+ dump_hash_elem(*((zval **) pDest), name, hash_key->h, NULL, html, str TSRMLS_CC);
} else {
- dump_hash_elem(*((zval **) pDest), name, 0, hash_key->arKey, html TSRMLS_CC);
+ dump_hash_elem(*((zval **) pDest), name, 0, hash_key->arKey, html, str TSRMLS_CC);
}
return SUCCESS;
}
-static void dump_hash(xdebug_llist *l, char *name, int name_len, int html TSRMLS_DC)
+static void dump_hash(xdebug_llist *l, char *name, int name_len, int html, xdebug_str *str TSRMLS_DC)
{
zval **z;
HashTable *ht;
@@ -118,12 +121,12 @@
if (html) {
#if HAVE_PHP_MEMORY_USAGE
- php_printf("<tr><th colspan='5' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name);
+ xdebug_str_add(str, xdebug_sprintf("<tr><th colspan='5' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name), 1);
#else
- php_printf("<tr><th colspan='4' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name);
+ xdebug_str_add(str, xdebug_sprintf("<tr><th colspan='4' align='left' bgcolor='#e9b96e'>Dump <i>$%s</i></th></tr>\n", name), 1);
#endif
} else {
- printf("\nDump $%s", name);
+ xdebug_str_add(str, xdebug_sprintf("\nDump $%s", name), 1);
}
elem = XDEBUG_LLIST_HEAD(l);
@@ -132,41 +135,45 @@
if (ht && (*((char *) (elem->ptr)) == '*')) {
#ifdef ZTS
-#define X_DUMP_ARGS 3
+#define X_DUMP_ARGS 4
#else
-#define X_DUMP_ARGS 2
+#define X_DUMP_ARGS 3
#endif
- zend_hash_apply_with_arguments(ht, dump_hash_elem_va, X_DUMP_ARGS, name, html TSRMLS_CC);
+ zend_hash_apply_with_arguments(ht, dump_hash_elem_va, X_DUMP_ARGS, name, html, str TSRMLS_CC);
} else if (ht && zend_hash_find(ht, elem->ptr, strlen(elem->ptr) + 1, (void **) &z) == SUCCESS) {
- dump_hash_elem(*z, name, 0, elem->ptr, html TSRMLS_CC);
+ dump_hash_elem(*z, name, 0, elem->ptr, html, str TSRMLS_CC);
} else if(XG(dump_undefined)) {
- dump_hash_elem(NULL, name, 0, elem->ptr, html TSRMLS_CC);
+ dump_hash_elem(NULL, name, 0, elem->ptr, html, str TSRMLS_CC);
}
elem = XDEBUG_LLIST_NEXT(elem);
}
}
-void dump_superglobals(int html TSRMLS_DC)
+char* xdebug_get_printable_superglobals(int html TSRMLS_DC)
{
+ xdebug_str str = {0, 0, NULL};
+
if (XG(dump_once) && XG(dumped)) {
return;
}
XG(dumped) = 1;
- dump_hash(&XG(server), "_SERVER", 8, html TSRMLS_CC);
- dump_hash(&XG(get), "_GET", 5, html TSRMLS_CC);
- dump_hash(&XG(post), "_POST", 6, html TSRMLS_CC);
- dump_hash(&XG(cookie), "_COOKIE", 8, html TSRMLS_CC);
- dump_hash(&XG(files), "_FILES", 7, html TSRMLS_CC);
- dump_hash(&XG(env), "_ENV", 5, html TSRMLS_CC);
- dump_hash(&XG(session), "_SESSION", 9, html TSRMLS_CC);
- dump_hash(&XG(request), "_REQUEST", 9, html TSRMLS_CC);
+ dump_hash(&XG(server), "_SERVER", 8, html, &str TSRMLS_CC);
+ dump_hash(&XG(get), "_GET", 5, html, &str TSRMLS_CC);
+ dump_hash(&XG(post), "_POST", 6, html, &str TSRMLS_CC);
+ dump_hash(&XG(cookie), "_COOKIE", 8, html, &str TSRMLS_CC);
+ dump_hash(&XG(files), "_FILES", 7, html, &str TSRMLS_CC);
+ dump_hash(&XG(env), "_ENV", 5, html, &str TSRMLS_CC);
+ dump_hash(&XG(session), "_SESSION", 9, html, &str TSRMLS_CC);
+ dump_hash(&XG(request), "_REQUEST", 9, html, &str TSRMLS_CC);
+
+ return str.d;
}
-void dump_tok(xdebug_llist *l, char *str)
+void xdebug_superglobals_dump_tok(xdebug_llist *l, char *str)
{
char *tok, *sep = ",";
@@ -200,7 +207,7 @@
php_printf("<table border='1' cellspacing='0'>\n");
}
- dump_superglobals(html TSRMLS_CC);
+ php_printf("%s", xdebug_get_printable_superglobals(html TSRMLS_CC));
if (html) {
php_printf("</table>\n");
[FILE: /xdebug/xdebug_superglobals.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- xdebug/xdebug_superglobals.h:1.6 Fri Oct 06 12:23:03 2006 GMT
+++ xdebug/xdebug_superglobals.h Sat Oct 07 20:02:47 2006 GMT
@@ -21,15 +21,15 @@
#include "php.h"
-void dump_dtor(void *, void*);
-void dump_superglobals(int html TSRMLS_DC);
-void dump_tok(xdebug_llist *l, char *str);
+void xdebug_superglobals_dump_dtor(void *, void*);
+char *xdebug_get_printable_superglobals(int html TSRMLS_DC);
+void xdebug_superglobals_dump_tok(xdebug_llist *l, char *str);
#define DUMP_TOK(__llist) \
xdebug_llist_empty(&XG(__llist), NULL); \
if (new_value && *new_value) { \
char *str = estrndup(new_value, new_value_length); \
- dump_tok(&XG(__llist), str); \
+ xdebug_superglobals_dump_tok(&XG(__llist), str); \
efree(str); \
} \
return SUCCESS;
Received on Sun Oct 08 2006 - 00:02:52 BST
This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST