Permalink
Browse files

Do not add stack trace to notifications

  • Loading branch information...
derickr committed Nov 18, 2017
1 parent cee063c commit 0c086314ece8928fd3d361f4c2cca16999c20392
Showing with 29 additions and 26 deletions.
  1. +1 −1 tests/bug00990-001.phpt
  2. +1 −4 tests/bug00990-002.phpt
  3. +1 −4 tests/bug00990-003.phpt
  4. +7 −9 xdebug_handler_dbgp.c
  5. +18 −8 xdebug_stack.c
  6. +1 −0 xdebug_stack.h
View
@@ -37,7 +37,7 @@ dbgpRun( $data, $commands );
-> step_into -i 4
<?xml version="1.0" encoding="iso-8859-1"?>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error" encoding="base64"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Notice"><![CDATA[Undefined variable: bar]]></xdebug:message><![CDATA[Ck5vdGljZTogVW5kZWZpbmVkIHZhcmlhYmxlOiBiYXIgaW4gL3RtcC94ZGVidWctZGJncC10ZXN0LnBocCBvbi%s]]></notify>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Notice"><![CDATA[Undefined variable: bar]]></xdebug:message></notify>
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="4"></xdebug:message></response>
View
@@ -37,10 +37,7 @@ dbgpRun( $data, $commands );
-> step_into -i 4
<?xml version="1.0" encoding="iso-8859-1"?>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error" encoding="base64"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Fatal error"><![CDATA[Uncaught Error: Class 'MyClass' not found in /tmp/xdebug-dbgp-test.php:3
Stack trace:
#0 {main}
thrown]]></xdebug:message><![CDATA[CkZhdGFsIGVycm9yOiBVbmNhdWdodCBFcnJvcjogQ2xhc3MgJ015Q2xhc3MnIG5vdCBmb3VuZCBpbiAvdG1wL3hkZWJ1Zy1kYmdwLXRlc3QucGhwIG9uIGxpbmUgMwoKRXJyb3I6IENsYXNzICdNeUNsYXNzJyBub3QgZm91bmQgaW4gL3RtcC94ZGVidWctZGJncC10ZXN0LnBocC%s]]></notify>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Fatal error"><![CDATA[Uncaught Error: Class 'MyClass' not found]]></xdebug:message></notify>
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>
View
@@ -37,10 +37,7 @@ dbgpRun( $data, $commands );
-> step_into -i 4
<?xml version="1.0" encoding="iso-8859-1"?>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error" encoding="base64"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Fatal error"><![CDATA[Uncaught Error: Class 'MyClass' not found in /tmp/xdebug-dbgp-test.php:3
Stack trace:
#0 {main}
thrown]]></xdebug:message><![CDATA[PGJyIC8+Cjxmb250IHNpemU9JzEnPjx0YWJsZSBjbGFzcz0neGRlYnVnLWVycm9yIHhlLXVuY2F1Z2h0LWV4Y2VwdGlvbicgZGlyPSdsdHInIGJvcmRlcj0nMScgY2VsbHNwYWNpbmc9JzAnIGNlbGxwYWRkaW5nPScxJz4KPHRyPjx0aCBhbGlnbj0nbGVmdCcgYmdjb2xvcj0nI2Y1NzkwMCcgY29sc3Bhbj0iNSI+PHNwYW4gc3R5bGU9J2JhY2tncm91bmQtY29sb3I6ICNjYzAwMDA7IGNvbG9yOiAjZmNlOTRmOyBmb250LXNpemU6IHgtbGFyZ2U7Jz4oICEgKTwvc3Bhbj4gRmF0YWwgZXJyb3I6IFVuY2F1Z2h0IEVycm9yOiBDbGFzcyAnTXlDbGFzcycgbm90IGZvdW5kIGluIC90bXAveGRlYnVnLWRiZ3AtdGVzdC5waHAgb24gbGluZSA8aT4zPC9pPjwvdGg+PC90cj4KPHRyPjx0aCBhbGlnbj0nbGVmdCcgYmdjb2xvcj0nI2Y1NzkwMCcgY29sc3Bhbj0iNSI+PHNwYW4gc3R5bGU9J2JhY2tncm91bmQtY29sb3I6ICNjYzAwMDA7IGNvbG9yOiAjZmNlOTRmOyBmb250LXNpemU6IHgtbGFyZ2U7Jz4oICEgKTwvc3Bhbj4gRXJyb3I6IENsYXNzICdNeUNsYXNzJyBub3QgZm91bmQgaW4gL3RtcC94ZGVidWctZGJncC10ZXN0LnBocCBvbi%s]]></notify>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" name="error"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3" type_string="Fatal error"><![CDATA[Uncaught Error: Class 'MyClass' not found]]></xdebug:message></notify>
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>
View
@@ -2484,17 +2484,15 @@ int xdebug_dbgp_notification(xdebug_con *context, const char *file, long lineno,
xdebug_xml_add_attribute_ex(error_container, "type_string", xdstrdup(type_string), 0, 1);
}
if (message) {
xdebug_xml_add_text(error_container, xdstrdup(message));
}
xdebug_xml_add_child(response, error_container);
/* Collate full message for the CDATA section */
{
char *stack_message;
char *tmp_buf;
stack_message = xdebug_handle_stack_trace(type, type_string, file, lineno, message);
xdebug_xml_add_text_encode(response, stack_message);
if (type == E_ERROR && ((tmp_buf = xdebug_strip_php_stack_trace(message)) != NULL)) {
xdebug_xml_add_text(error_container, tmp_buf);
} else {
xdebug_xml_add_text(error_container, xdstrdup(message));
}
}
xdebug_xml_add_child(response, error_container);
send_message(context, response TSRMLS_CC);
xdebug_xml_node_dtor(response);
View
@@ -619,15 +619,11 @@ static void php_output_error(const char *error TSRMLS_DC)
php_printf("%s", error);
}
char *xdebug_handle_stack_trace(int type, char *error_type_str, const char *error_filename, const uint error_lineno, char *buffer TSRMLS_DC)
char *xdebug_strip_php_stack_trace(char *buffer)
{
char *printable_stack;
/* We need to see if we have an uncaught exception fatal error now */
if (type == E_ERROR && strncmp(buffer, "Uncaught ", 9) == 0) {
xdebug_str str = XDEBUG_STR_INITIALIZER;
char *tmp_buf, *p;
char *tmp_buf, *p;
if (strncmp(buffer, "Uncaught ", 9) == 0) {
/* find first new line */
p = strchr(buffer, '\n');
if (!p) {
@@ -641,7 +637,21 @@ char *xdebug_handle_stack_trace(int type, char *error_type_str, const char *erro
}
/* Create new buffer */
tmp_buf = calloc(p - buffer + 1, 1);
strncpy(tmp_buf, buffer, p - buffer );
strncpy(tmp_buf, buffer, p - buffer);
return tmp_buf;
}
return NULL;
}
char *xdebug_handle_stack_trace(int type, char *error_type_str, const char *error_filename, const uint error_lineno, char *buffer TSRMLS_DC)
{
char *printable_stack;
char *tmp_buf;
/* We need to see if we have an uncaught exception fatal error now */
if (type == E_ERROR && ((tmp_buf = xdebug_strip_php_stack_trace(buffer)) != NULL)) {
xdebug_str str = XDEBUG_STR_INITIALIZER;
/* Append error */
xdebug_append_error_head(&str, PG(html_errors), "uncaught-exception" TSRMLS_CC);
View
@@ -29,6 +29,7 @@ void xdebug_append_error_description(xdebug_str *str, int html, const char *erro
void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC);
void xdebug_append_error_footer(xdebug_str *str, int html TSRMLS_DC);
void xdebug_log_stack(const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC);
char *xdebug_strip_php_stack_trace(char *buffer);
char *xdebug_handle_stack_trace(int type, char *error_type_str, const char *error_filename, const uint error_lineno, char *buffer TSRMLS_DC);
void xdebug_do_jit(TSRMLS_D);
int xdebug_handle_hit_value(xdebug_brk_info *brk_info);

0 comments on commit 0c08631

Please sign in to comment.