Skip to content

Commit

Permalink
Fixed issue #1660: Return breakpoints for methods don't break immedia…
Browse files Browse the repository at this point in the history
…tely
  • Loading branch information
derickr committed May 6, 2019
1 parent 7003f28 commit cbf9b60
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
49 changes: 49 additions & 0 deletions tests/bug01660.phpt
@@ -0,0 +1,49 @@
--TEST--
Test for bug #1660: Return breakpoints for methods don't break immediately
--SKIPIF--
<?php if (getenv("SKIP_DBGP_TESTS")) { exit("skip Excluding DBGp tests"); } ?>
--FILE--
<?php
require 'dbgp/dbgpclient.php';

$dir = dirname(__FILE__);
putenv("XDEBUG_TEST_DIR=$dir");

$filename = realpath( dirname(__FILE__) . '/bug01388-14-index.inc' );

$commands = array(
'feature_set -n resolved_breakpoints -v 1',
'breakpoint_set -t return -m SimpleClass::displayVar',
'run',
'context_get',
'property_get -n ::hello'
);

dbgpRunFile( $filename, $commands );
?>
--EXPECT--
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug01388-14-index.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>

-> feature_set -i 1 -n resolved_breakpoints -v 1
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>

-> breakpoint_set -i 2 -t return -m SimpleClass::displayVar
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="" resolved="unresolved"></response>

-> run -i 3
<?xml version="1.0" encoding="iso-8859-1"?>
<notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" name="breakpoint_resolved"><breakpoint type="return" resolved="resolved" function="SimpleClass::displayVar" state="enabled" hit_count="0" hit_value="0" id=""></breakpoint></notify>

<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file://bug01388-14-simpleclass.inc" lineno="8"></xdebug:message></response>

-> context_get -i 4
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="::" fullname="::" type="object" classname="SimpleClass" children="1" numchildren="1"><property name="::hello" fullname="::hello" type="string" size="5" facet="static public" encoding="base64"><![CDATA[SEVMTE8=]]></property></property></response>

-> property_get -i 5 -n ::hello
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="5"><property name="::hello" fullname="::hello" type="string" size="5" encoding="base64"><![CDATA[SEVMTE8=]]></property></response>
8 changes: 7 additions & 1 deletion xdebug.c
Expand Up @@ -1756,7 +1756,13 @@ static int handle_breakpoints(function_stack_entry *fse, int breakpoint_type)
* disabled AND handle_hit_value is happy */
if (!extra_brk_info->disabled && (extra_brk_info->function_break_type == breakpoint_type)) {
if (xdebug_handle_hit_value(extra_brk_info)) {
XG(context).do_break = 1;
if (fse->user_defined == XDEBUG_BUILT_IN || (breakpoint_type == XDEBUG_BREAKPOINT_TYPE_RETURN)) {
if (!XG(context).handler->remote_breakpoint(&(XG(context)), XG(stack), fse->filename, fse->lineno, XDEBUG_BREAK, NULL, 0, NULL)) {
return 0;
}
} else {
XG(context).do_break = 1;
}
}
}
}
Expand Down

0 comments on commit cbf9b60

Please sign in to comment.