diff --git a/tests/print_function_stack-no-description-001.phpt b/tests/print_function_stack-no-description-001.phpt new file mode 100644 index 000000000..8adccedbf --- /dev/null +++ b/tests/print_function_stack-no-description-001.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test for xdebug_print_function_stack() without description +--INI-- +xdebug.cli_color=0 +xdebug.collect_params=3 +html_errors=0 +--FILE-- + +--EXPECTF-- +Call Stack: +%w%f %w%d 1. {main}() %sprint_function_stack-no-description-001.php:0 +%w%f %w%d 2. bar() %sprint_function_stack-no-description-001.php:12 +%w%f %w%d 3. foo(1, 3, 'foo', 'bar') %sprint_function_stack-no-description-001.php:9 +%w%f %w%d 4. xdebug_print_function_stack('test message', 1) %sprint_function_stack-no-description-001.php:4 diff --git a/tests/print_function_stack-no-description-002.phpt b/tests/print_function_stack-no-description-002.phpt new file mode 100644 index 000000000..ba06f70e2 --- /dev/null +++ b/tests/print_function_stack-no-description-002.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test for xdebug_print_function_stack() without description (CLI colour) +--INI-- +xdebug.cli_color=2 +xdebug.collect_params=3 +html_errors=0 +--FILE-- + +--EXPECTF-- +Call Stack: +%w%f %w%d 1. {main}() %sprint_function_stack-no-description-002.php:0 +%w%f %w%d 2. bar() %sprint_function_stack-no-description-002.php:12 +%w%f %w%d 3. foo(1, 3, 'foo', 'bar') %sprint_function_stack-no-description-002.php:9 +%w%f %w%d 4. xdebug_print_function_stack('test message', 1) %sprint_function_stack-no-description-002.php:4 diff --git a/tests/print_function_stack-no-description-003.phpt b/tests/print_function_stack-no-description-003.phpt new file mode 100644 index 000000000..4005de46a --- /dev/null +++ b/tests/print_function_stack-no-description-003.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test for xdebug_print_function_stack() without description (HTML) +--INI-- +xdebug.cli_color=0 +xdebug.collect_params=3 +xdebug.file_link_format= +html_errors=1 +--FILE-- + +--EXPECTF-- +
+ + + + + + + +
Call Stack
#TimeMemoryFunctionLocation
1%f%d{main}( )../print_function_stack-no-description-003.php:0
2%f%dbar( )../print_function_stack-no-description-003.php:12
3%f%dfoo( 1, 3, 'foo', 'bar' )../print_function_stack-no-description-003.php:9
4%f%dxdebug_print_function_stack +( 'test message', 1 )../print_function_stack-no-description-003.php:4
diff --git a/xdebug.c b/xdebug.c index fe8671c47..0ed76ef08 100644 --- a/xdebug.c +++ b/xdebug.c @@ -705,6 +705,8 @@ PHP_MINIT_FUNCTION(xdebug) REGISTER_LONG_CONSTANT("XDEBUG_CC_UNUSED", XDEBUG_CC_OPTION_UNUSED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XDEBUG_CC_DEAD_CODE", XDEBUG_CC_OPTION_DEAD_CODE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XDEBUG_STACK_NO_DESC", XDEBUG_STACK_NO_DESC, CONST_CS | CONST_PERSISTENT); + XG(breakpoint_count) = 0; XG(output_is_tty) = OUTPUT_NOT_CHECKED; diff --git a/xdebug_stack.c b/xdebug_stack.c index e55b6f05b..7e5728c6f 100644 --- a/xdebug_stack.c +++ b/xdebug_stack.c @@ -456,7 +456,7 @@ void xdebug_append_error_footer(xdebug_str *str, int html TSRMLS_DC) xdebug_str_add(str, formats[7], 0); } -static char *get_printable_stack(int html, int error_type, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC) +static char *get_printable_stack(int html, int error_type, char *buffer, const char *error_filename, const int error_lineno, int include_decription TSRMLS_DC) { char *prepend_string; char *append_string; @@ -469,7 +469,9 @@ static char *get_printable_stack(int html, int error_type, char *buffer, const c xdebug_str_add(&str, prepend_string ? prepend_string : "", 0); xdebug_append_error_head(&str, html, error_type_str_simple TSRMLS_CC); - xdebug_append_error_description(&str, html, error_type_str, buffer, error_filename, error_lineno TSRMLS_CC); + if (include_decription) { + xdebug_append_error_description(&str, html, error_type_str, buffer, error_filename, error_lineno TSRMLS_CC); + } xdebug_append_printable_stack(&str, html TSRMLS_CC); xdebug_append_error_footer(&str, html TSRMLS_CC); xdebug_str_add(&str, append_string ? append_string : "", 0); @@ -660,7 +662,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line xdfree(str.d); free(tmp_buf); } else { - printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno TSRMLS_CC); + printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno, 1 TSRMLS_CC); if (XG(do_collect_errors) && (type != E_ERROR) && (type != E_COMPILE_ERROR) && (type != E_USER_ERROR)) { xdebug_llist_insert_next(XG(collected_errors), XDEBUG_LLIST_TAIL(XG(collected_errors)), printable_stack); } else { @@ -670,7 +672,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line } } else if (XG(do_collect_errors)) { char *printable_stack; - printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno TSRMLS_CC); + printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno, 1 TSRMLS_CC); xdebug_llist_insert_next(XG(collected_errors), XDEBUG_LLIST_TAIL(XG(collected_errors)), printable_stack); } } @@ -775,7 +777,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line } } -/* {{{ proto array xdebug_print_function_stack([string message]) +/* {{{ proto array xdebug_print_function_stack([string message [, int options]) Displays a stack trace */ PHP_FUNCTION(xdebug_print_function_stack) { @@ -783,16 +785,17 @@ PHP_FUNCTION(xdebug_print_function_stack) int message_len; function_stack_entry *i; char *tmp; + long options = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &message, &message_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", &message, &message_len, &options) == FAILURE) { return; } i = xdebug_get_stack_frame(0 TSRMLS_CC); if (message) { - tmp = get_printable_stack(PG(html_errors), 0, message, i->filename, i->lineno TSRMLS_CC); + tmp = get_printable_stack(PG(html_errors), 0, message, i->filename, i->lineno, !(options & XDEBUG_STACK_NO_DESC) TSRMLS_CC); } else { - tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno TSRMLS_CC); + tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno, !(options & XDEBUG_STACK_NO_DESC) TSRMLS_CC); } php_printf("%s", tmp); xdfree(tmp); @@ -807,7 +810,7 @@ PHP_FUNCTION(xdebug_get_formatted_function_stack) char *tmp; i = xdebug_get_stack_frame(0 TSRMLS_CC); - tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno TSRMLS_CC); + tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno, 1 TSRMLS_CC); RETVAL_STRING(tmp, 1); xdfree(tmp); } diff --git a/xdebug_stack.h b/xdebug_stack.h index 9feb398f4..ef0515a01 100644 --- a/xdebug_stack.h +++ b/xdebug_stack.h @@ -21,6 +21,8 @@ #include "xdebug_str.h" +#define XDEBUG_STACK_NO_DESC 0x01 + function_stack_entry *xdebug_add_stack_frame(zend_execute_data *zdata, zend_op_array *op_array, int type TSRMLS_DC); void xdebug_append_error_head(xdebug_str *str, int html, char *error_type_str TSRMLS_DC); void xdebug_append_error_description(xdebug_str *str, int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC);