[xdebug-dev] xdebug xdebug/php_xdebug.h xdebug/xdebug.c - Added the xdebug_start_error_collection(), xdebug_stop_error_collection() and

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Wed, 15 Aug 2007 16:03:58 +0200

Date: Wed Aug 15 16:03:58 CEST 2007
User: Derick Rethans
Directory: xdebug

Log Message:
[3.00]
- Added the xdebug_start_error_collection(), xdebug_stop_error_collection() and
  xdebug_get_collected_errors() functions.

Modified files:
           xdebug/php_xdebug.h (version: 1.137)
           xdebug/xdebug.c (version: 1.405)

[FILE: /xdebug/php_xdebug.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- xdebug/php_xdebug.h:1.136 Sun Jul 29 13:04:48 2007 GMT
+++ xdebug/php_xdebug.h Wed Aug 15 12:03:58 2007 GMT
@@ -100,6 +100,11 @@
 PHP_FUNCTION(xdebug_stop_trace);
 PHP_FUNCTION(xdebug_get_tracefile_name);
 
+/* error collecting functions */
+PHP_FUNCTION(xdebug_start_error_collection);
+PHP_FUNCTION(xdebug_stop_error_collection);
+PHP_FUNCTION(xdebug_get_collected_errors);
+
 /* profiling functions */
 PHP_FUNCTION(xdebug_get_profiler_filename);
 PHP_FUNCTION(xdebug_dump_aggr_profiling_data);
@@ -162,6 +167,10 @@
         xdebug_hash *code_coverage_op_array_cache;
         unsigned int function_count;
 
+ /* used for collection errors */
+ zend_bool do_collect_errors;
+ xdebug_llist *collected_errors;
+
         /* superglobals */
         zend_bool dump_globals;
         zend_bool dump_once;

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.404
retrieving revision 1.405
diff -u -r1.404 -r1.405
--- xdebug/xdebug.c:1.404 Mon Aug 06 17:35:41 2007 GMT
+++ xdebug/xdebug.c Wed Aug 15 12:03:58 2007 GMT
@@ -138,6 +138,10 @@
 #endif
         PHP_FE(xdebug_time_index, NULL)
 
+ PHP_FE(xdebug_start_error_collection, NULL)
+ PHP_FE(xdebug_stop_error_collection, NULL)
+ PHP_FE(xdebug_get_collected_errors, NULL)
+
         PHP_FE(xdebug_start_code_coverage, NULL)
         PHP_FE(xdebug_stop_code_coverage, NULL)
         PHP_FE(xdebug_get_code_coverage, NULL)
@@ -639,6 +643,15 @@
         return SUCCESS;
 }
 
+static void xdebug_collected_error_dtor(void *dummy, void *elem)
+{
+ char *s = elem;
+
+ if (s) {
+ xdfree(s);
+ }
+}
+
 static void xdebug_used_var_dtor(void *dummy, void *elem)
 {
         char *s = elem;
@@ -724,6 +737,8 @@
         XG(function_count) = 0;
         XG(active_symbol_table) = NULL;
         XG(last_exception_trace) = NULL;
+ XG(do_collect_errors) = 0;
+ XG(collected_errors) = xdebug_llist_alloc(xdebug_collected_error_dtor);
         
         if (idekey && *idekey) {
                 if (XG(ide_key)) {
@@ -851,6 +866,8 @@
                 xdfree(XG(last_exception_trace));
         }
 
+ xdebug_llist_destroy(XG(collected_errors), NULL);
+
         /* Reset var_dump and set_time_limit to the original function */
         zend_hash_find(EG(function_table), "var_dump", 9, (void **)&orig);
         orig->internal_function.handler = XG(orig_var_dump_func);
@@ -2333,6 +2350,11 @@
                                 xdfree(printable_stack);
                         }
                 }
+ if (XG(do_collect_errors)) {
+ char *printable_stack;
+ printable_stack = get_printable_stack(PG(html_errors), error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
+ xdebug_llist_insert_next(XG(collected_errors), XDEBUG_LLIST_TAIL(XG(collected_errors)), printable_stack);
+ }
         }
 
         /* Start JIT if requested and not yet enabled */
@@ -2753,6 +2775,44 @@
         }
 }
 
+PHP_FUNCTION(xdebug_start_error_collection)
+{
+ if (XG(do_collect_errors) == 1) {
+ php_error(E_NOTICE, "Error collection was already started");
+ }
+ XG(do_collect_errors) = 1;
+}
+
+PHP_FUNCTION(xdebug_stop_error_collection)
+{
+ if (XG(do_collect_errors) == 0) {
+ php_error(E_NOTICE, "Error collection was not started");
+ }
+ XG(do_collect_errors) = 0;
+}
+
+PHP_FUNCTION(xdebug_get_collected_errors)
+{
+ xdebug_llist_element *le;
+ char *string;
+ zend_bool clear = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &clear) == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+ for (le = XDEBUG_LLIST_HEAD(XG(collected_errors)); le != NULL; le = XDEBUG_LLIST_NEXT(le)) {
+ string = XDEBUG_LLIST_VALP(le);
+ add_next_index_string(return_value, string, 1);
+ }
+
+ if (clear) {
+ xdebug_llist_destroy(XG(collected_errors), NULL);
+ XG(collected_errors) = xdebug_llist_alloc(xdebug_collected_error_dtor);
+ }
+}
+
 PHP_FUNCTION(xdebug_start_trace)
 {
         char *fname = NULL;
Received on Wed Aug 15 2007 - 16:04:39 BST

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