Permalink
Browse files

- Added dumping of superglobals (patch by Harald Radi <phanto@php.net>).

SVN Rev: 597
  • Loading branch information...
1 parent 6d414e8 commit d63d7ee610ee95b4f9f654e624f605c1f7f9836e @derickr derickr committed Feb 20, 2003
Showing with 364 additions and 9 deletions.
  1. +14 −0 php_xdebug.h
  2. +98 −2 xdebug.c
  3. +14 −2 xdebug.dsp
  4. +14 −4 xdebug_llist.c
  5. +3 −1 xdebug_llist.h
  6. +184 −0 xdebug_superglobals.c
  7. +37 −0 xdebug_superglobals.h
View
@@ -77,6 +77,7 @@ PHP_FUNCTION(xdebug_start_trace);
PHP_FUNCTION(xdebug_stop_trace);
PHP_FUNCTION(xdebug_get_function_trace);
PHP_FUNCTION(xdebug_dump_function_trace);
+PHP_FUNCTION(xdebug_dump_superglobals);
PHP_FUNCTION(xdebug_set_error_handler);
@@ -173,6 +174,19 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug)
char *output_dir;
int auto_profile_mode;
+ /* superglobals */
+ zend_bool dump_once;
+ zend_bool dump_undefined;
+ zend_bool dumped;
+ xdebug_llist server;
+ xdebug_llist get;
+ xdebug_llist post;
+ xdebug_llist cookie;
+ xdebug_llist files;
+ xdebug_llist env;
+ xdebug_llist request;
+ xdebug_llist session;
+
/* remote settings */
zend_bool remote_enable; /* 0 */
int remote_port; /* 17869 */
View
100 xdebug.c
@@ -14,6 +14,7 @@
+----------------------------------------------------------------------+
| Authors: Derick Rethans <d.rethans@jdimedia.nl> |
| Ilia Alshanetsky <ilia@prohost.org> |
+ | Harald Radi <harald.radi@nme.at> |
+----------------------------------------------------------------------+
*/
@@ -51,6 +52,7 @@
#include "xdebug_llist.h"
#include "xdebug_var.h"
#include "xdebug_profiler.h"
+#include "xdebug_superglobals.h"
#include "usefulstuff.h"
#include "php_xdebug.h"
@@ -89,6 +91,7 @@ function_entry xdebug_functions[] = {
PHP_FE(xdebug_stop_profiling, NULL)
PHP_FE(xdebug_dump_function_profile, NULL)
PHP_FE(xdebug_get_function_profile, NULL)
+ PHP_FE(xdebug_dump_superglobals, NULL)
#if MEMORY_LIMIT
PHP_FE(xdebug_memory_usage, NULL)
#endif
@@ -117,6 +120,46 @@ ZEND_DECLARE_MODULE_GLOBALS(xdebug)
ZEND_GET_MODULE(xdebug)
#endif
+static PHP_INI_MH(OnUpdateServer)
+{
+ DUMP_TOK(server);
+}
+
+static PHP_INI_MH(OnUpdateGet)
+{
+ DUMP_TOK(get);
+}
+
+static PHP_INI_MH(OnUpdatePost)
+{
+ DUMP_TOK(post);
+}
+
+static PHP_INI_MH(OnUpdateCookie)
+{
+ DUMP_TOK(cookie);
+}
+
+static PHP_INI_MH(OnUpdateFiles)
+{
+ DUMP_TOK(files);
+}
+
+static PHP_INI_MH(OnUpdateEnv)
+{
+ DUMP_TOK(env);
+}
+
+static PHP_INI_MH(OnUpdateRequest)
+{
+ DUMP_TOK(request);
+}
+
+static PHP_INI_MH(OnUpdateSession)
+{
+ DUMP_TOK(session);
+}
+
static PHP_INI_MH(OnUpdateDebugMode)
{
if (!new_value) {
@@ -144,6 +187,18 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.manual_url", "http://www.php.net", PHP_INI_ALL, OnUpdateString, manual_url, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.output_dir", "/tmp", PHP_INI_SYSTEM, OnUpdateString, output_dir, zend_xdebug_globals, xdebug_globals)
+ /* Dump superglobals settings */
+ STD_PHP_INI_BOOLEAN("xdebug.dump_once", "1", PHP_INI_ALL, OnUpdateBool, dump_once, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_BOOLEAN("xdebug.dump_undefined", "0", PHP_INI_ALL, OnUpdateBool, dump_undefined, zend_xdebug_globals, xdebug_globals)
+ PHP_INI_ENTRY("xdebug.dump.SERVER", NULL, PHP_INI_ALL, OnUpdateServer)
+ PHP_INI_ENTRY("xdebug.dump.GET", NULL, PHP_INI_ALL, OnUpdateGet)
+ PHP_INI_ENTRY("xdebug.dump.POST", NULL, PHP_INI_ALL, OnUpdatePost)
+ PHP_INI_ENTRY("xdebug.dump.COOKIE", NULL, PHP_INI_ALL, OnUpdateCookie)
+ PHP_INI_ENTRY("xdebug.dump.FILES", NULL, PHP_INI_ALL, OnUpdateFiles)
+ PHP_INI_ENTRY("xdebug.dump.ENV", NULL, PHP_INI_ALL, OnUpdateEnv)
+ PHP_INI_ENTRY("xdebug.dump.REQUEST", NULL, PHP_INI_ALL, OnUpdateRequest)
+ PHP_INI_ENTRY("xdebug.dump.SESSION", NULL, PHP_INI_ALL, OnUpdateSession)
+
/* Remote debugger settings */
STD_PHP_INI_BOOLEAN("xdebug.remote_enable", "0", PHP_INI_SYSTEM, OnUpdateBool, remote_enable, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.remote_port", "17869", PHP_INI_ALL, OnUpdateInt, remote_port, zend_xdebug_globals, xdebug_globals)
@@ -170,7 +225,7 @@ static double get_utime()
return 0;
}
-static void php_xdebug_init_globals (zend_xdebug_globals *xg)
+static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC)
{
xg->stack = NULL;
xg->level = 0;
@@ -180,11 +235,32 @@ static void php_xdebug_init_globals (zend_xdebug_globals *xg)
xg->total_execution_time = 0;
xg->total_compiling_time = 0;
xg->error_handler = 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);
+}
+
+static void php_xdebug_shutdown_globals (zend_xdebug_globals *xg TSRMLS_DC)
+{
+ xdebug_llist_empty(&xg->server, NULL);
+ xdebug_llist_empty(&xg->get, NULL);
+ xdebug_llist_empty(&xg->post, NULL);
+ xdebug_llist_empty(&xg->cookie, NULL);
+ xdebug_llist_empty(&xg->files, NULL);
+ xdebug_llist_empty(&xg->env, NULL);
+ xdebug_llist_empty(&xg->request, NULL);
+ xdebug_llist_empty(&xg->session, NULL);
}
PHP_MINIT_FUNCTION(xdebug)
{
- ZEND_INIT_MODULE_GLOBALS(xdebug, php_xdebug_init_globals, NULL);
+ ZEND_INIT_MODULE_GLOBALS(xdebug, php_xdebug_init_globals, php_xdebug_shutdown_globals);
REGISTER_INI_ENTRIES();
old_compile_file = zend_compile_file;
@@ -305,6 +381,9 @@ PHP_RINIT_FUNCTION(xdebug)
XG(context).do_next = 0;
XG(context).do_finish = 0;
+ /* Initialize dump superglobals */
+ XG(dumped) = 0;
+
return SUCCESS;
}
@@ -765,6 +844,8 @@ static inline void print_stack (int html, const char *error_type_str, char *buff
}
}
+ dump_superglobals(html, PG(log_errors) && !is_cli TSRMLS_CC);
+
if (html) {
php_printf ("</table>\n");
}
@@ -1261,6 +1342,21 @@ PHP_FUNCTION(xdebug_get_function_trace)
}
}
+PHP_FUNCTION(xdebug_dump_superglobals)
+{
+ int is_cli = (strcmp ("cli", sapi_module.name) == 0);
+ int html = PG(html_errors);
+
+ if (html) {
+ php_printf("<table border='1' cellspacing='0'>\n");
+ }
+
+ dump_superglobals(html , PG(log_errors) && !is_cli TSRMLS_CC);
+
+ if (html) {
+ php_printf("</table>\n");
+ }
+}
#if MEMORY_LIMIT
PHP_FUNCTION(xdebug_memory_usage)
View
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XDEBUG_EXPORTS" /YX /FD /c
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XDEBUG_EXPORTS" /D "MEMORY_LIMIT" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D "WIN32" /D "COMPILE_DL_XDEBUG" /D ZTS=1 /D HAVE_XDEBUG=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "HAVE_EXECUTE_DATA_PTR" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XDEBUG_EXPORTS" /YX /FD /GZ /c
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XDEBUG_EXPORTS" /D "MEMORY_LIMIT" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "COMPILE_DL_XDEBUG" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XDEBUG=1 /D "HAVE_EXECUTE_DATA_PTR" /YX /FD /GZ /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -127,6 +127,10 @@ SOURCE=.\xdebug_llist.c
# End Source File
# Begin Source File
+SOURCE=.\xdebug_superglobals.c
+# End Source File
+# Begin Source File
+
SOURCE=.\xdebug_profiler.c
# End Source File
# Begin Source File
@@ -171,6 +175,14 @@ SOURCE=.\xdebug_llist.h
# End Source File
# Begin Source File
+SOURCE=.\xdebug_profiler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\xdebug_superglobals.h
+# End Source File
+# Begin Source File
+
SOURCE=.\xdebug_var.h
# End Source File
# End Group
View
@@ -1,4 +1,4 @@
-/* $Id: xdebug_llist.c,v 1.3 2002-11-15 14:12:05 derick Exp $ */
+/* $Id: xdebug_llist.c,v 1.4 2003-02-20 14:30:54 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
@@ -29,12 +29,17 @@ xdebug_llist *xdebug_llist_alloc(xdebug_llist_dtor dtor)
xdebug_llist *l;
l = malloc(sizeof(xdebug_llist));
+ xdebug_llist_init(l, dtor);
+
+ return l;
+}
+
+void xdebug_llist_init(xdebug_llist *l, xdebug_llist_dtor dtor)
+{
l->size = 0;
l->dtor = dtor;
l->head = NULL;
l->tail = NULL;
-
- return l;
}
int xdebug_llist_insert_next(xdebug_llist *l, xdebug_llist_element *e, const void *p)
@@ -163,11 +168,16 @@ size_t xdebug_llist_count(xdebug_llist *l)
return l->size;
}
-void xdebug_llist_destroy(xdebug_llist *l, void *user)
+void xdebug_llist_empty(xdebug_llist *l, void *user)
{
while (xdebug_llist_count(l) > 0) {
xdebug_llist_remove(l, XDEBUG_LLIST_TAIL(l), user);
}
+}
+
+void xdebug_llist_destroy(xdebug_llist *l, void *user)
+{
+ xdebug_llist_empty(l, user);
free (l);
l = NULL;
View
@@ -1,4 +1,4 @@
-/* $Id: xdebug_llist.h,v 1.3 2002-11-27 22:39:22 ilia Exp $ */
+/* $Id: xdebug_llist.h,v 1.4 2003-02-20 14:30:54 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
@@ -44,12 +44,14 @@ typedef struct _xdebug_llist {
} xdebug_llist;
xdebug_llist *xdebug_llist_alloc(xdebug_llist_dtor dtor);
+void xdebug_llist_init(xdebug_llist *l, xdebug_llist_dtor dtor);
int xdebug_llist_insert_next(xdebug_llist *l, xdebug_llist_element *e, const void *p);
int xdebug_llist_insert_prev(xdebug_llist *l, xdebug_llist_element *e, const void *p);
int xdebug_llist_remove(xdebug_llist *l, xdebug_llist_element *e, void *user);
int xdebug_llist_remove_next(xdebug_llist *l, xdebug_llist_element *e, void *user);
xdebug_llist_element *xdebug_llist_jump(xdebug_llist *l, int where, int pos);
size_t xdebug_llist_count(xdebug_llist *l);
+void xdebug_llist_empty(xdebug_llist *l, void *user);
void xdebug_llist_destroy(xdebug_llist *l, void *user);
#if !defined(LIST_HEAD)
Oops, something went wrong.

0 comments on commit d63d7ee

Please sign in to comment.