Permalink
Browse files

Merged pull request #310

  • Loading branch information...
derickr committed Nov 18, 2017
2 parents f7a08bc + 0c08631 commit 9e5ab0c130bfa6cf4fc52185acdd8410a2ba56dc
View
@@ -56,7 +56,7 @@
#define MSG_NOSIGNAL 0
#endif
#define DEBUGCLIENT_VERSION "0.11.0"
#define DEBUGCLIENT_VERSION "0.12.0"
#define DEFAULT_PORT 9000
#define IPV4 4
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
while ((buffer = fd_read_line_delim(fd, &cxt, FD_RL_SOCKET, '\0', &length)) > 0) {
buffer = fd_read_line_delim(fd, &cxt, FD_RL_SOCKET, '\0', &length);
printf ("%s\n", buffer);
if (strstr(buffer, "<stream") == NULL)
if ((strstr(buffer, "<stream") == NULL) && (strstr(buffer, "<notify") == NULL))
{
/* The server requires a new command */
View
@@ -11,7 +11,7 @@ function dummy1(){
function dummy2(){
echo 'dummy2';
}
if($x)
if(false)
dummy1();
else
dummy2();
View
@@ -0,0 +1,5 @@
<?php
$foo = 42;
echo $bar;
echo $bar;
?>
View
@@ -0,0 +1,47 @@
--TEST--
Test for bug #990: DBGP: Add notification for notices, warnings and errors
--SKIPIF--
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--INI--
xdebug.remote_enable=1
--FILE--
<?php
require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug00990-001.inc');
$commands = array(
'step_into',
'step_into',
'feature_set -n notify_ok -v 1',
'step_into',
'detach'
);
dbgpRun( $data, $commands );
?>
--EXPECTF--
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" xdebug:language_version="" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
-> step_into -i 1
<?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="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
-> step_into -i 2
<?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="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3"></xdebug:message></response>
-> feature_set -i 3 -n notify_ok -v 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="notify_ok" success="1"></response>
-> 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"><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>
-> detach -i 5
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="detach" transaction_id="5" status="stopping" reason="ok"></response>
View
@@ -0,0 +1,4 @@
<?php
$foo = 42;
new MyClass;
?>
View
@@ -0,0 +1,47 @@
--TEST--
Test for bug #990: DBGP: Add notification for notices, warnings and errors
--SKIPIF--
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--INI--
xdebug.remote_enable=1
--FILE--
<?php
require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug00990-002.inc');
$commands = array(
'step_into',
'feature_set -n notify_ok -v 1',
'step_into',
'step_into',
'detach'
);
dbgpRun( $data, $commands );
?>
--EXPECTF--
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" xdebug:language_version="" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
-> step_into -i 1
<?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="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
-> feature_set -i 2 -n notify_ok -v 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>
-> step_into -i 3
<?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="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3"></xdebug:message></response>
-> 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"><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>
-> detach -i 5
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="detach" transaction_id="5" status="stopping" reason="ok"></response>
View
@@ -0,0 +1,4 @@
<?php
ini_set('html_errors', 1);
new MyClass;
?>
View
@@ -0,0 +1,47 @@
--TEST--
Test for bug #990: DBGP: Add notification for notices, warnings and errors
--SKIPIF--
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--INI--
xdebug.remote_enable=1
--FILE--
<?php
require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug00990-003.inc');
$commands = array(
'step_into',
'feature_set -n notify_ok -v 1',
'step_into',
'step_into',
'detach'
);
dbgpRun( $data, $commands );
?>
--EXPECTF--
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" xdebug:language_version="" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
-> step_into -i 1
<?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="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
-> feature_set -i 2 -n notify_ok -v 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>
-> step_into -i 3
<?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="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="3"></xdebug:message></response>
-> 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"><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>
-> detach -i 5
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="detach" transaction_id="5" status="stopping" reason="ok"></response>
@@ -107,6 +107,10 @@ function doRead( $conn )
{
$end = false;
}
if ( preg_match( '@<notify xmlns="urn.debugger_protocol_v1" xmlns:xdebug@', $read ) )
{
$end = false;
}
} while( !$end );
}
View
@@ -2475,6 +2475,7 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_op_array *op_array)
/* Remember error reporting level */
old_error_reporting = EG(error_reporting);
EG(error_reporting) = 0;
XG(context).inhibit_notifications = 1;
/* Check the condition */
if (zend_eval_string(extra_brk_info->condition, &retval, "xdebug conditional breakpoint" TSRMLS_CC) == SUCCESS) {
@@ -2484,6 +2485,7 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_op_array *op_array)
/* Restore error reporting level */
EG(error_reporting) = old_error_reporting;
XG(context).inhibit_notifications = 0;
}
if (break_ok && xdebug_handle_hit_value(extra_brk_info)) {
if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), file, lineno, XDEBUG_BREAK, NULL, 0, NULL)) {
View
@@ -42,6 +42,7 @@
#include "xdebug_hash.h"
#include "xdebug_llist.h"
#include "xdebug_mm.h"
#include "xdebug_stack.h"
#include "xdebug_var.h"
#include "xdebug_xml.h"
@@ -1213,6 +1214,11 @@ DBGP_FUNC(feature_get)
xdebug_xml_add_attribute(*retval, "supported", "1");
XDEBUG_STR_CASE_END
XDEBUG_STR_CASE("notify_ok")
xdebug_xml_add_text(*retval, xdebug_sprintf("%ld", XG(context).send_notifications));
xdebug_xml_add_attribute(*retval, "supported", "1");
XDEBUG_STR_CASE_END
XDEBUG_STR_CASE_DEFAULT
xdebug_xml_add_text(*retval, xdstrdup(lookup_cmd(CMD_OPTION('n')) ? "1" : "0"));
xdebug_xml_add_attribute(*retval, "supported", lookup_cmd(CMD_OPTION('n')) ? "1" : "0");
@@ -1272,6 +1278,10 @@ DBGP_FUNC(feature_set)
options->extended_properties = strtol(CMD_OPTION('v'), NULL, 10);
XDEBUG_STR_CASE_END
XDEBUG_STR_CASE("notify_ok")
XG(context).send_notifications = strtol(CMD_OPTION('v'), NULL, 10);
XDEBUG_STR_CASE_END
XDEBUG_STR_CASE_DEFAULT
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
XDEBUG_STR_CASE_DEFAULT_END
@@ -1394,7 +1404,13 @@ DBGP_FUNC(property_get)
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTENT);
}
} else {
if (add_variable_node(*retval, CMD_OPTION('n'), 1, 0, 0, options TSRMLS_CC) == FAILURE) {
int add_var_retval;
XG(context).inhibit_notifications = 1;
add_var_retval = add_variable_node(*retval, CMD_OPTION('n'), 1, 0, 0, options TSRMLS_CC);
XG(context).inhibit_notifications = 0;
if (add_var_retval) {
options->max_data = old_max_data;
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTENT);
}
@@ -2250,6 +2266,8 @@ int xdebug_dbgp_init(xdebug_con *context, int mode)
context->line_breakpoints = xdebug_llist_alloc((xdebug_llist_dtor) xdebug_llist_brk_dtor);
context->eval_id_lookup = xdebug_hash_alloc(64, (xdebug_hash_dtor) xdebug_hash_eval_info_dtor);
context->eval_id_sequence = 0;
context->send_notifications = 0;
context->inhibit_notifications = 0;
xdebug_dbgp_cmdloop(context, 1 TSRMLS_CC);
@@ -2439,6 +2457,49 @@ int xdebug_dbgp_stream_output(const char *string, unsigned int length TSRMLS_DC)
return -1;
}
int xdebug_dbgp_notification(xdebug_con *context, const char *file, long lineno, int type, char *type_string, char *message)
{
xdebug_xml_node *response, *error_container;
TSRMLS_FETCH();
response = xdebug_xml_node_init("notify");
xdebug_xml_add_attribute(response, "xmlns", "urn:debugger_protocol_v1");
xdebug_xml_add_attribute(response, "xmlns:xdebug", "http://xdebug.org/dbgp/xdebug");
xdebug_xml_add_attribute(response, "name", "error");
error_container = xdebug_xml_node_init("xdebug:message");
if (file) {
char *tmp_filename = (char*) file;
int tmp_lineno = lineno;
if (check_evaled_code(NULL, &tmp_filename, &tmp_lineno, 0 TSRMLS_CC)) {
xdebug_xml_add_attribute_ex(error_container, "filename", xdstrdup(tmp_filename), 1, 1);
} else {
xdebug_xml_add_attribute_ex(error_container, "filename", xdebug_path_to_url(file TSRMLS_CC), 0, 1);
}
}
if (lineno) {
xdebug_xml_add_attribute_ex(error_container, "lineno", xdebug_sprintf("%lu", lineno), 0, 1);
}
if (type_string) {
xdebug_xml_add_attribute_ex(error_container, "type_string", xdstrdup(type_string), 0, 1);
}
if (message) {
char *tmp_buf;
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);
return 1;
}
static char *create_eval_key_file(char *filename, int lineno)
{
return xdebug_sprintf("%s(%d) : eval()'d code", filename, lineno);
View
@@ -93,6 +93,7 @@ int xdebug_dbgp_deinit(xdebug_con *context);
int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const uint line, xdebug_llist *stack);
int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *code, char *message);
int xdebug_dbgp_stream_output(const char *string, unsigned int length TSRMLS_DC);
int xdebug_dbgp_notification(xdebug_con *context, const char *file, long lineno, int type, char *type_string, char *message TSRMLS_DC);
int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse);
char *xdebug_dbgp_get_revision(void);
@@ -102,6 +103,7 @@ char *xdebug_dbgp_get_revision(void);
xdebug_dbgp_error, \
xdebug_dbgp_breakpoint, \
xdebug_dbgp_stream_output, \
xdebug_dbgp_notification, \
xdebug_dbgp_register_eval_id, \
xdebug_dbgp_get_revision \
}
View
@@ -24,7 +24,7 @@
xdebug_remote_handler_info handlers[] = {
{ "dbgp", "DBGp - Common DeBuGger Protocol", xdebug_handler_dbgp },
{ 0, NULL, { NULL, NULL, NULL, NULL, NULL, NULL, NULL } }
{ 0, NULL, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } }
};
xdebug_remote_handler* xdebug_handler_get(char* mode)
View
@@ -70,6 +70,9 @@ struct _xdebug_con {
int do_finish;
int finish_level;
int finish_func_nr;
int send_notifications;
int inhibit_notifications;
};
#define XDEBUG_HIT_DISABLED 0
@@ -117,6 +120,9 @@ struct _xdebug_remote_handler {
/* Output redirection */
int (*remote_stream_output)(const char *string, unsigned int length TSRMLS_DC);
/* Notifications */
int (*remote_notification)(xdebug_con *h, const char *file, long lineno, int type, char *type_string, char *message TSRMLS_DC);
/* Eval ID registration and removal */
int (*register_eval_id)(xdebug_con *h, function_stack_entry *fse);
Oops, something went wrong.

0 comments on commit 9e5ab0c

Please sign in to comment.