[xdebug-dev] svn: /xdebug/trunk/ tests/bug00566-1.phpt tests/bug00566-2.phpt xdebug.c

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 19 Apr 2010 13:08:17 +0000

derick Mon, 19 Apr 2010 13:08:17 +0000

Revision: http://svn.xdebug.org/cgi-bin/viewvc.cgi?view=rev&revision=3262&root=xdebug

Log:
Fixed bug #566: Xdebug crashes when using conditional breakpoints.

Changed paths:
    A xdebug/trunk/tests/bug00566-1.phpt
    A xdebug/trunk/tests/bug00566-2.phpt
    U xdebug/trunk/xdebug.c

Added: xdebug/trunk/tests/bug00566-1.phpt
===================================================================
--- xdebug/trunk/tests/bug00566-1.phpt (rev 0)
+++ xdebug/trunk/tests/bug00566-1.phpt 2010-04-19 13:08:17 UTC (rev 3262)
@@ -0,0 +1,51 @@
+--TEST--
+Test for bug #566: Xdebug crashes when using conditional breakpoints [1]
+--INI--
+xdebug.collect_params=4
+xdebug.collect_return=1
+xdebug.collect_assignments=0
+--FILE--
+<?php
+$tf = xdebug_start_trace('%s'. uniqid('xdt', TRUE));
+function loadMod( $module )
+{
+ strlen( $module );
+ $module .= 's';
+ strlen( $module );
+}
+
+function loadFoo( $test )
+{
+ strlen( $test );
+ $test .= 's';
+ strlen( $test );
+}
+
+loadFoo( 'view' );
+loadMod( 'test' );
+loadMod( 'view' );
+
+xdebug_stop_trace();
+echo file_get_contents($tf);
+unlink($tf);
+?>
+--EXPECTF--
+TRACE START [%d-%d-%d %d:%d:%d]
+%w%f %w%d -> loadFoo($test = 'view') %sbug00566-1.php:17
+%w%f %w%d -> strlen('view') %sbug00566-1.php:12
+ >=> 4
+%w%f %w%d -> strlen('views') %sbug00566-1.php:14
+ >=> 5
+%w%f %w%d -> loadMod($module = 'test') %sbug00566-1.php:18
+%w%f %w%d -> strlen('test') %sbug00566-1.php:5
+ >=> 4
+%w%f %w%d -> strlen('tests') %sbug00566-1.php:7
+ >=> 5
+%w%f %w%d -> loadMod($module = 'view') %sbug00566-1.php:19
+%w%f %w%d -> strlen('view') %sbug00566-1.php:5
+ >=> 4
+%w%f %w%d -> strlen('views') %sbug00566-1.php:7
+ >=> 5
+%w%f %w%d -> xdebug_stop_trace() %sbug00566-1.php:21
+%w%f %w%d
+TRACE END [%d-%d-%d %d:%d:%d]

Added: xdebug/trunk/tests/bug00566-2.phpt
===================================================================
--- xdebug/trunk/tests/bug00566-2.phpt (rev 0)
+++ xdebug/trunk/tests/bug00566-2.phpt 2010-04-19 13:08:17 UTC (rev 3262)
@@ -0,0 +1,63 @@
+--TEST--
+Test for bug #566: Xdebug crashes when using conditional breakpoints [2]
+--INI--
+xdebug.collect_params=4
+xdebug.collect_return=1
+xdebug.collect_assignments=0
+--FILE--
+<?php
+require 'dbgp/dbgpclient.php';
+$data = <<<'NOWDOC'
+<?php
+
+function loadMod( $module )
+{
+ strlen( $module );
+ $module .= 's';
+ strlen( $module );
+}
+
+function loadFoo( $test )
+{
+ strlen( $test );
+ $test .= 's';
+ strlen( $test );
+}
+
+loadFoo( 'view' );
+loadMod( 'test' );
+loadMod( 'view' );
+NOWDOC;
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -f file:///tmp/xdebug-dbgp-test.php -n 7 -t conditional -- JG1vZHVsZSA9PSB2aWV3cw==',
+ 'run',
+ 'context_get',
+ 'detach'
+);
+
+dbgpRun( $data, $commands );
+--EXPECT--
+<?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-2010 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 -f file:///tmp/xdebug-dbgp-test.php -n 7 -t conditional -- JG1vZHVsZSA9PSB2aWV3cw==
+<?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" id=""></response>
+
+-> run -i 3
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="7"></xdebug:message></response>
+
+-> context_get -i 4
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="module" fullname="$module" address="" type="string" size="5" encoding="base64"><![CDATA[dmlld3M=]]></property></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>

Modified: xdebug/trunk/xdebug.c
===================================================================
--- xdebug/trunk/xdebug.c 2010-04-15 11:47:15 UTC (rev 3261)
+++ xdebug/trunk/xdebug.c 2010-04-19 13:08:17 UTC (rev 3262)
@@ -1075,6 +1075,12 @@
         xdebug_llist_element *le;
         int eval_id = 0;

+ /* if we're in a ZEND_EXT_STMT, we ignore this function call as it's likely
+ that it's just being called to check for breakpoints with conditions */
+ if (edata && edata->opline && edata->opline->opcode == ZEND_EXT_STMT) {
+ xdebug_old_execute(op_array TSRMLS_CC);
+ return;
+ }

         if (XG(no_exec) == 1) {
                 php_printf("DEBUG SESSION ENDED");
Received on Mon Apr 19 2010 - 14:08:17 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST