Permalink
Browse files

Add a error-specific class to stack traces.

  • Loading branch information...
1 parent b59d6ea commit aa1b5c41c400a079e709cb85fe1df11b79b9e6cf @derickr committed Mar 2, 2012
View
@@ -10,7 +10,7 @@ throw new Exception("<MARK>");
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'Exception' with message '&lt;MARK&gt;' in <a style='color: black' href='xdebug://%sbug00305.php@2'>%sbug00305.php</a> on line <i>2</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: &lt;MARK&gt; in <a style='color: black' href='xdebug://%sbug00305.php@2'>%sbug00305.php</a> on line <i>2</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
View
@@ -21,14 +21,14 @@ throw new MyException();
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Array to string conversion in %sbug00340.php on line <i>11</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00340.php' bgcolor='#eeeeec'>../bug00340.php<b>:</b>0</td></tr>
</table></font>
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'MyException' with message 'Array' in %sbug00340.php on line <i>11</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> MyException: Array in %sbug00340.php on line <i>11</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
View
@@ -19,21 +19,21 @@ throw new Exception('Uncaught exception');
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: Caught exception in %sbug00635.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00635.php' bgcolor='#eeeeec'>../bug00635.php<b>:</b>0</td></tr>
</table></font>
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: Uncaught exception in %sbug00635.php on line <i>9</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>%f</td><td bgcolor='#eeeeec' align='right'>%d</td><td bgcolor='#eeeeec'>{main}( )</td><td title='%sbug00635.php' bgcolor='#eeeeec'>../bug00635.php<b>:</b>0</td></tr>
</table></font>
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'Exception' with message 'Uncaught exception' in %sbug00635.php on line <i>9</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: Uncaught exception in %sbug00635.php on line <i>9</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
@@ -30,7 +30,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_0.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
@@ -30,7 +30,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_1.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
@@ -33,7 +33,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_2.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
@@ -33,7 +33,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_3.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
@@ -33,7 +33,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_4.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
@@ -33,7 +33,7 @@ foo( $a );
?>
--EXPECTF--
<br />
-<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
+<font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function poo() in /%s/stacktrace_html_4_novar.php on line <i>4</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<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>
View
@@ -1083,7 +1083,7 @@ static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC)
}
if (PG(display_errors)) {
xdebug_str tmp_str = { 0, 0, NULL };
- xdebug_append_error_head(&tmp_str, PG(html_errors) TSRMLS_CC);
+ xdebug_append_error_head(&tmp_str, PG(html_errors), "exception" TSRMLS_CC);
xdebug_str_add(&tmp_str, exception_trace, 0);
xdebug_append_error_footer(&tmp_str, PG(html_errors) TSRMLS_CC);
View
@@ -67,7 +67,7 @@ static char* ansi_formats[10] = {
#endif
static char* html_formats[12] = {
- "<br />\n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n",
+ "<br />\n<font size='1'><table class='xdebug-error xe-%s' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n",
"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in %s on line <i>%d</i></th></tr>\n",
#if HAVE_PHP_MEMORY_USAGE
"<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",
@@ -246,11 +246,15 @@ static int create_file_link(char **filename, const char *error_filename, int err
return fname.l;
}
-void xdebug_append_error_head(xdebug_str *str, int html TSRMLS_DC)
+void xdebug_append_error_head(xdebug_str *str, int html, char *error_type_str TSRMLS_DC)
{
char **formats = select_formats(html TSRMLS_CC);
-
- xdebug_str_add(str, formats[0], 0);
+
+ if (html) {
+ xdebug_str_add(str, xdebug_sprintf(formats[0], error_type_str), 1);
+ } else {
+ xdebug_str_add(str, formats[0], 0);
+ }
}
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)
@@ -437,22 +441,27 @@ 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, const char *error_type_str, 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 TSRMLS_DC)
{
char *prepend_string;
char *append_string;
+ char *error_type_str = xdebug_error_type(error_type);
+ char *error_type_str_simple = xdebug_error_type_simple(error_type);
xdebug_str str = {0, 0, NULL};
prepend_string = INI_STR("error_prepend_string");
append_string = INI_STR("error_append_string");
xdebug_str_add(&str, prepend_string ? prepend_string : "", 0);
- xdebug_append_error_head(&str, html TSRMLS_CC);
+ 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);
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);
+ xdfree(error_type_str);
+ xdfree(error_type_str_simple);
+
return str.d;
}
@@ -614,7 +623,7 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
strncpy(tmp_buf, buffer, p - buffer );
/* Append error */
- xdebug_append_error_head(&str, PG(html_errors) TSRMLS_CC);
+ xdebug_append_error_head(&str, PG(html_errors), "uncaught-exception" TSRMLS_CC);
xdebug_append_error_description(&str, PG(html_errors), error_type_str, tmp_buf, error_filename, error_lineno TSRMLS_CC);
xdebug_append_printable_stack(&str, PG(html_errors) TSRMLS_CC);
xdebug_str_add(&str, XG(last_exception_trace), 0);
@@ -624,14 +633,14 @@ 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), error_type_str, buffer, error_filename, error_lineno TSRMLS_CC);
+ printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno TSRMLS_CC);
php_output_error(printable_stack TSRMLS_CC);
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);
+ printable_stack = get_printable_stack(PG(html_errors), type, buffer, error_filename, error_lineno TSRMLS_CC);
xdebug_llist_insert_next(XG(collected_errors), XDEBUG_LLIST_TAIL(XG(collected_errors)), printable_stack);
}
}
@@ -747,9 +756,9 @@ PHP_FUNCTION(xdebug_print_function_stack)
i = xdebug_get_stack_frame(0 TSRMLS_CC);
if (message) {
- tmp = get_printable_stack(PG(html_errors), "Xdebug", message, i->filename, i->lineno TSRMLS_CC);
+ tmp = get_printable_stack(PG(html_errors), 0, message, i->filename, i->lineno TSRMLS_CC);
} else {
- tmp = get_printable_stack(PG(html_errors), "Xdebug", "user triggered", i->filename, i->lineno TSRMLS_CC);
+ tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno TSRMLS_CC);
}
php_printf("%s", tmp);
xdfree(tmp);
@@ -764,7 +773,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), "Xdebug", "user triggered", i->filename, i->lineno TSRMLS_CC);
+ tmp = get_printable_stack(PG(html_errors), 0, "user triggered", i->filename, i->lineno TSRMLS_CC);
RETVAL_STRING(tmp, 1);
xdfree(tmp);
}
View
@@ -22,7 +22,7 @@
#include "xdebug_str.h"
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 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);
void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC);
void xdebug_append_error_footer(xdebug_str *str, int html TSRMLS_DC);
View
@@ -31,6 +31,51 @@
ZEND_EXTERN_MODULE_GLOBALS(xdebug)
+char* xdebug_error_type_simple(int type)
+{
+ switch (type) {
+ case E_ERROR:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ return xdstrdup("fatal-error");
+ break;
+#if PHP_VERSION_ID >= 50200
+ case E_RECOVERABLE_ERROR:
+ return xdstrdup("catchable-fatal-error");
+ break;
+#endif
+ case E_WARNING:
+ case E_CORE_WARNING:
+ case E_COMPILE_WARNING:
+ case E_USER_WARNING:
+ return xdstrdup("warning");
+ break;
+ case E_PARSE:
+ return xdstrdup("parse-error");
+ break;
+ case E_NOTICE:
+ case E_USER_NOTICE:
+ return xdstrdup("notice");
+ break;
+ case E_STRICT:
+ return xdstrdup("strict-standards");
+ break;
+#if PHP_VERSION_ID >= 50300
+ case E_DEPRECATED:
+ case E_USER_DEPRECATED:
+ return xdstrdup("deprecated");
+ break;
+#endif
+ case 0:
+ return xdstrdup("xdebug");
+ break;
+ default:
+ return xdstrdup("unknown-error");
+ break;
+ }
+}
+
char* xdebug_error_type(int type)
{
switch (type) {
@@ -67,6 +112,9 @@ char* xdebug_error_type(int type)
return xdstrdup("Deprecated");
break;
#endif
+ case 0:
+ return xdstrdup("Xdebug");
+ break;
default:
return xdstrdup("Unknown error");
break;
View
@@ -64,6 +64,7 @@ void xdebug_var_export_fancy(zval **struc, xdebug_str *str, int level, int debug
void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, xdebug_var_export_options *options, int level TSRMLS_DC);
char* xdebug_xmlize(char *string, int len, int *newlen);
+char* xdebug_error_type_simple(int type);
char* xdebug_error_type(int type);
zval *xdebug_get_zval(zend_execute_data *zdata, int node_type, XDEBUG_ZNODE *node, temp_variable *Ts, int *is_var);
char* xdebug_get_zval_value(zval *val, int debug_zval, xdebug_var_export_options *options);

0 comments on commit aa1b5c4

Please sign in to comment.