Skip to content

Commit

Permalink
Merged pull request #114
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed May 19, 2014
2 parents da1d115 + be44a42 commit dd9235a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/bug01025.inc
@@ -0,0 +1,2 @@
<?php
?>
59 changes: 59 additions & 0 deletions tests/bug01025.phpt
@@ -0,0 +1,59 @@
--TEST--
Test for bug #1025: Xdebug does not reject wrong breakpoint types (-t)
--FILE--
<?php
require 'dbgp/dbgpclient.php';

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

$data = file_get_contents(dirname(__FILE__) . '/bug01025.inc');

$commands = array(
'step_into',
'breakpoint_set -t bakerstreet',
'breakpoint_set -t line -n 3',
'breakpoint_set -t conditional -n 3',
'breakpoint_set -t call -m strlen',
'breakpoint_set -t return -m strlen',
'breakpoint_set -t exception -x Exception',
'breakpoint_set -t watch',
);

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" 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-%d 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="3"></xdebug:message></response>

-> breakpoint_set -i 2 -t bakerstreet
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" status="break" reason="ok"><error code="3"><message><![CDATA[invalid or missing options]]></message></error></response>

-> breakpoint_set -i 3 -t line -n 3
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id=""></response>

-> breakpoint_set -i 4 -t conditional -n 3
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id=""></response>

-> breakpoint_set -i 5 -t call -m strlen
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id=""></response>

-> breakpoint_set -i 6 -t return -m strlen
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id=""></response>

-> breakpoint_set -i 7 -t exception -x Exception
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id=""></response>

-> breakpoint_set -i 8 -t watch
<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" status="break" reason="ok"><error code="201"><message><![CDATA[breakpoint type is not supported]]></message></error></response>
10 changes: 10 additions & 0 deletions xdebug_handler_dbgp.c
Expand Up @@ -1206,6 +1206,16 @@ DBGP_FUNC(breakpoint_set)
if (!CMD_OPTION('t')) {
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
} else {
if (
(strcmp(CMD_OPTION('t'), "line") != 0) &&
(strcmp(CMD_OPTION('t'), "conditional") != 0) &&
(strcmp(CMD_OPTION('t'), "call") != 0) &&
(strcmp(CMD_OPTION('t'), "return") != 0) &&
(strcmp(CMD_OPTION('t'), "exception") != 0) &&
(strcmp(CMD_OPTION('t'), "watch") != 0)
) {
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
}
brk_info->type = xdstrdup(CMD_OPTION('t'));
}

Expand Down

0 comments on commit dd9235a

Please sign in to comment.