Permalink
Browse files

Merged pull request #382

  • Loading branch information...
derickr committed Nov 19, 2017
2 parents 907cef1 + 669a81c commit e4f9c54e32fc39fc9c0692b8dc4d531f91b3c92a
View
@@ -150,6 +150,7 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug)
function_stack_entry *active_fse;
unsigned int prev_memory;
char *file_link_format;
char *filename_format;
zend_bool force_display_errors;
zend_long force_error_reporting;
zend_long halt_level;
View
@@ -4,6 +4,7 @@ Test for bug #305: xdebug exception handler doesn't properly handle special char
html_errors=1
xdebug.default_enable=1
xdebug.file_link_format=xdebug://%f@%l
xdebug.filename_format=
--FILE--
<?php
throw new Exception("<MARK>");
View
@@ -4,6 +4,7 @@ Test for bug #340: Segfault while throwing an Exception
xdebug.default_enable=1
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.dump.GET=
xdebug.dump.SERVER=
--FILE--
View
@@ -5,6 +5,7 @@ html_errors=1
xdebug.show_exception_trace=1
xdebug.default_enable=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.dump.SERVER=
xdebug.show_local_vars=0
--FILE--
View
@@ -6,6 +6,7 @@ docref_ext=.php
html_errors=1
xdebug.default_enable=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_error_trace=0
--FILE--
<?php
View
@@ -6,6 +6,7 @@ docref_ext=.php
html_errors=1
xdebug.default_enable=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.collect_params=0
--FILE--
<?php
View
@@ -5,6 +5,7 @@ html_errors=1
xdebug.default_enable=1
xdebug.collect_params=3
xdebug.file_link_format=
xdebug.filename_format=
--FILE--
<?php
assert(0, "TEST&TEST");
@@ -6,6 +6,7 @@ xdebug.default_enable=1
html_errors=1
xdebug.overload_var_dump=0
xdebug.file_link_format=xdebug://%f@%l
xdebug.filename_format=
xdebug.auto_trace=0
xdebug.collect_assignments=1
xdebug.collect_return=1
@@ -4,6 +4,7 @@ Test for xdebug_print_function_stack() without description (HTML)
xdebug.cli_color=0
xdebug.collect_params=3
xdebug.file_link_format=
xdebug.filename_format=
html_errors=1
--FILE--
<?php
View
@@ -7,6 +7,7 @@ xdebug.scream=0
error_reporting(E_ALL);
html_errors=1
xdebug.file_link_format=xdebug://%f@%l
xdebug.filename_format=
xdebug.force_error_reporting=0
--FILE--
<?php
@@ -12,6 +12,7 @@ xdebug.collect_params=0
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -12,6 +12,7 @@ xdebug.collect_params=1
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -15,6 +15,7 @@ xdebug.collect_params=2
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -15,6 +15,7 @@ xdebug.collect_params=3
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -15,6 +15,7 @@ xdebug.collect_params=4
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -15,6 +15,7 @@ xdebug.collect_params=4
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -15,6 +15,7 @@ xdebug.collect_params=5
xdebug.collect_return=0
html_errors=1
xdebug.file_link_format=
xdebug.filename_format=
xdebug.show_local_vars=0
xdebug.show_error_trace=1
--FILE--
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
@@ -13,6 +13,7 @@ xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
html_errors=1
xdebug.filename_format=
--FILE--
<?php
function foo( $a, ...$b )
View
@@ -708,6 +708,70 @@ int xdebug_format_file_link(char **filename, const char *error_filename, int err
return fname.l;
}
int xdebug_format_filename(char **formatted_name, char *fmt, char *filename TSRMLS_DC)
{
xdebug_str fname = XDEBUG_STR_INITIALIZER;
char *name, *parent, *ancester, *full = filename;
xdebug_arg *parts = (xdebug_arg*) xdmalloc(sizeof(xdebug_arg));
char *slash = xdebug_sprintf("%c", DEFAULT_SLASH);
char *format = fmt && fmt[0] ? fmt : "...%s%n"; /* If the format is empty, we use the default */
/* Create pointers for the format chars */
xdebug_arg_init(parts);
xdebug_explode(slash, filename, parts, -1);
name = parts->args[parts->c - 1];
parent = parts->c > 1 ?
xdebug_join(slash, parts, parts->c - 2, parts->c - 1) :
xdstrdup(name);
ancester = parts->c > 2 ?
xdebug_join(slash, parts, parts->c - 3, parts->c - 1) :
xdstrdup(parent);
/* Make sure that we at least output an empty string */
xdebug_str_addl(&fname, "", 0, 0);
while (*format)
{
if (*format != '%') {
xdebug_str_addl(&fname, (char *) format, 1, 0);
} else {
format++;
switch (*format)
{
case 'n': /* filename */
xdebug_str_add(&fname, xdebug_sprintf("%s", name), 1);
break;
case 'p': /* parent */
xdebug_str_add(&fname, xdebug_sprintf("%s", parent), 1);
break;
case 'a': /* ancester */
xdebug_str_add(&fname, xdebug_sprintf("%s", ancester), 1);
break;
case 'f': /* full path */
xdebug_str_add(&fname, xdebug_sprintf("%s", full), 1);
break;
case 's': /* slash */
xdebug_str_add(&fname, xdebug_sprintf("%c", DEFAULT_SLASH), 1);
break;
case '%': /* literal % */
xdebug_str_addl(&fname, "%", 1, 0);
break;
}
}
format++;
}
xdfree(slash);
xdfree(ancester);
xdfree(parent);
xdebug_arg_dtor(parts);
*formatted_name = fname.d;
return fname.l;
}
void xdebug_open_log(TSRMLS_D)
{
/* initialize remote log file */
View
@@ -63,6 +63,7 @@ char *xdebug_path_from_url(const char *fileurl TSRMLS_DC);
FILE *xdebug_fopen(char *fname, char *mode, char *extension, char **new_fname);
int xdebug_format_output_filename(char **filename, char *format, char *script_name);
int xdebug_format_file_link(char **filename, const char *error_filename, int error_lineno TSRMLS_DC);
int xdebug_format_filename(char **formatted_name, char *format, char *filename TSRMLS_DC);
void xdebug_open_log(TSRMLS_D);
void xdebug_close_log(TSRMLS_D);
View
@@ -318,6 +318,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("xdebug.default_enable", "1", PHP_INI_ALL, OnUpdateBool, default_enable, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.extended_info", "1", PHP_INI_SYSTEM, OnUpdateBool, extended_info, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.file_link_format", "", PHP_INI_ALL, OnUpdateString, file_link_format, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.filename_format", "", PHP_INI_ALL, OnUpdateString, filename_format, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.force_display_errors", "0", PHP_INI_SYSTEM, OnUpdateBool, force_display_errors, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.force_error_reporting", "0", PHP_INI_SYSTEM, OnUpdateLong, force_error_reporting, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.halt_level", "0", PHP_INI_ALL, OnUpdateLong, halt_level, zend_xdebug_globals, xdebug_globals)
View
@@ -67,12 +67,12 @@ static char* html_formats[13] = {
"<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>\n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>\n",
"<tr><td bgcolor='#eeeeec' align='center'>%d</td><td bgcolor='#eeeeec' align='center'>%.4F</td><td bgcolor='#eeeeec' align='right'>%ld</td><td bgcolor='#eeeeec'>%s( ",
"<font color='#00bb00'>'%s'</font>",
" )</td><td title='%s' bgcolor='#eeeeec'>...%s<b>:</b>%d</td></tr>\n",
" )</td><td title='%s' bgcolor='#eeeeec'>%s<b>:</b>%d</td></tr>\n",
"<tr><th align='left' colspan='5' bgcolor='#e9b96e'>Variables in local scope (#%d)</th></tr>\n",
"</table></font>\n",
"<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s&nbsp;=</pre></td><td colspan='3' bgcolor='#eeeeec'>%s</td></tr>\n",
"<tr><td colspan='2' align='right' bgcolor='#eeeeec' valign='top'><pre>$%s&nbsp;=</pre></td><td colspan='3' bgcolor='#eeeeec' valign='top'><i>Undefined</i></td></tr>\n",
" )</td><td title='%s' bgcolor='#eeeeec'><a style='color: black' href='%s'>...%s<b>:</b>%d</a></td></tr>\n",
" )</td><td title='%s' bgcolor='#eeeeec'><a style='color: black' href='%s'>%s<b>:</b>%d</a></td></tr>\n",
"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in <a style='color: black' href='%s'>%s</a> on line <i>%d</i></th></tr>\n",
"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SCREAM: Error suppression ignored for</th></tr>\n"
};
@@ -439,18 +439,20 @@ void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC)
}
if (html) {
char *formatted_filename;
xdebug_format_filename(&formatted_filename, XG(filename_format), i->filename);
if (strlen(XG(file_link_format)) > 0) {
char *just_filename = strrchr(i->filename, DEFAULT_SLASH);
char *file_link;
xdebug_format_file_link(&file_link, i->filename, i->lineno TSRMLS_CC);
xdebug_str_add(str, xdebug_sprintf(formats[10], i->filename, file_link, just_filename, i->lineno), 1);
xdebug_str_add(str, xdebug_sprintf(formats[10], i->filename, file_link, formatted_filename, i->lineno), 1);
xdfree(file_link);
} else {
char *just_filename = strrchr(i->filename, DEFAULT_SLASH);
xdebug_str_add(str, xdebug_sprintf(formats[5], i->filename, just_filename, i->lineno), 1);
xdebug_str_add(str, xdebug_sprintf(formats[5], i->filename, formatted_filename, i->lineno), 1);
}
xdfree(formatted_filename);
} else {
xdebug_str_add(str, xdebug_sprintf(formats[5], i->filename, i->lineno), 1);
}

0 comments on commit e4f9c54

Please sign in to comment.