Index: php_xdebug.h =================================================================== RCS file: /repository/xdebug/php_xdebug.h,v retrieving revision 1.139 diff -u -p -r1.139 php_xdebug.h --- php_xdebug.h 11 Oct 2007 00:54:09 -0000 1.139 +++ php_xdebug.h 17 Apr 2008 02:08:17 -0000 @@ -166,6 +166,7 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug) xdebug_hash *code_coverage; zend_bool code_coverage_unused; zend_bool code_coverage_dead_code_analysis; + HashTable *code_coverage_exclude_paths; unsigned int function_count; int reserved_offset; Index: xdebug.c =================================================================== RCS file: /repository/xdebug/xdebug.c,v retrieving revision 1.423 diff -u -p -r1.423 xdebug.c --- xdebug.c 2 Apr 2008 14:46:55 -0000 1.423 +++ xdebug.c 17 Apr 2008 02:08:20 -0000 @@ -142,10 +142,11 @@ function_entry xdebug_functions[] = { 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) - PHP_FE(xdebug_get_function_count, NULL) + PHP_FE(xdebug_start_code_coverage, NULL) + PHP_FE(xdebug_stop_code_coverage, NULL) + PHP_FE(xdebug_code_coverage_exclude_paths, NULL) + PHP_FE(xdebug_get_code_coverage, NULL) + PHP_FE(xdebug_get_function_count, NULL) PHP_FE(xdebug_dump_superglobals, NULL) {NULL, NULL, NULL} @@ -336,13 +337,14 @@ PHP_INI_END() static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC) { - xg->stack = NULL; - xg->level = 0; - xg->do_trace = 0; - xg->trace_file = NULL; - xg->do_code_coverage = 0; - xg->breakpoint_count = 0; - xg->ide_key = NULL; + xg->stack = NULL; + xg->level = 0; + xg->do_trace = 0; + xg->trace_file = NULL; + xg->do_code_coverage = 0; + xg->breakpoint_count = 0; + xg->ide_key = NULL; + xg->code_coverage_exclude_paths = NULL; xdebug_llist_init(&xg->server, xdebug_superglobals_dump_dtor); xdebug_llist_init(&xg->get, xdebug_superglobals_dump_dtor); @@ -874,6 +876,11 @@ PHP_RSHUTDOWN_FUNCTION(xdebug) xdebug_hash_destroy(XG(code_coverage)); + if (XG(code_coverage_exclude_paths)) { + zend_hash_destroy(XG(code_coverage_exclude_paths)); + efree(XG(code_coverage_exclude_paths)); + } + if (XG(context.list.last_file)) { xdfree(XG(context).list.last_file); } Index: xdebug_code_coverage.c =================================================================== RCS file: /repository/xdebug/xdebug_code_coverage.c,v retrieving revision 1.43 diff -u -p -r1.43 xdebug_code_coverage.c --- xdebug_code_coverage.c 20 Mar 2008 16:51:09 -0000 1.43 +++ xdebug_code_coverage.c 17 Apr 2008 02:08:20 -0000 @@ -44,8 +44,23 @@ void xdebug_count_line(char *filename, i { xdebug_coverage_file *file; xdebug_coverage_line *line; + zval **excludes; char *sline; - + + if (XG(code_coverage_exclude_paths)) { + for (zend_hash_internal_pointer_reset(XG(code_coverage_exclude_paths)); + zend_hash_has_more_elements(XG(code_coverage_exclude_paths)) == SUCCESS; + zend_hash_move_forward(XG(code_coverage_exclude_paths))) { + + zend_hash_get_current_data(XG(code_coverage_exclude_paths), (void **)&excludes); + if (Z_TYPE_PP(excludes) == IS_STRING && Z_STRLEN_PP(excludes) > 0) { + if (strstr(filename, Z_STRVAL_PP(excludes))) { + return; + } + } + } + } + sline = xdebug_sprintf("%d", lineno); /* Check if the file already exists in the hash */ @@ -356,6 +371,22 @@ PHP_FUNCTION(xdebug_stop_code_coverage) } } +PHP_FUNCTION(xdebug_code_coverage_exclude_paths) +{ + zval *exclude_paths, *tmp; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &exclude_paths) == FAILURE) { + return; + } + if (XG(code_coverage_exclude_paths)) { + zend_hash_destroy(XG(code_coverage_exclude_paths)); + efree(XG(code_coverage_exclude_paths)); + } + ALLOC_HASHTABLE(XG(code_coverage_exclude_paths)); + zend_hash_init(XG(code_coverage_exclude_paths), zend_hash_num_elements(Z_ARRVAL_P(exclude_paths)), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(XG(code_coverage_exclude_paths), Z_ARRVAL_P(exclude_paths), (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); +} + static int xdebug_lineno_cmp(const void *a, const void *b TSRMLS_DC) { Index: xdebug_code_coverage.h =================================================================== RCS file: /repository/xdebug/xdebug_code_coverage.h,v retrieving revision 1.12 diff -u -p -r1.12 xdebug_code_coverage.h --- xdebug_code_coverage.h 11 Oct 2007 00:54:09 -0000 1.12 +++ xdebug_code_coverage.h 17 Apr 2008 02:08:20 -0000 @@ -42,6 +42,7 @@ void xdebug_prefill_code_coverage(zend_o PHP_FUNCTION(xdebug_start_code_coverage); PHP_FUNCTION(xdebug_stop_code_coverage); +PHP_FUNCTION(xdebug_code_coverage_exclude_paths); PHP_FUNCTION(xdebug_get_code_coverage); PHP_FUNCTION(xdebug_get_function_count);