Permalink
Browse files

Fixed bug #886: Use the same file system protocol for file located in…

…side PHAR in both directions
  • Loading branch information...
1 parent 8368fd0 commit 1857b36d490d14b97e70a39bcb6e7afcc1d8020a @derickr committed Dec 23, 2012
Showing with 80 additions and 4 deletions.
  1. +5 −0 tests/bug00886.inc
  2. BIN tests/bug00886.phar
  3. +74 −0 tests/bug00886.phpt
  4. +1 −1 usefulstuff.c
  5. +0 −3 xdebug_handler_dbgp.c
View
@@ -0,0 +1,5 @@
+<?php
+$DIR = getenv("XDEBUG_TEST_DIR");
+include "phar://$DIR/bug00886.phar/file1.php";
+function1( "Derick" );
+?>
View
Binary file not shown.
View
@@ -0,0 +1,74 @@
+--TEST--
+Test for bug #886: Use the same file system protocol for file located inside PHAR in both directions
+--FILE--
+<?php
+xdebug_start_trace( "/tmp/trace.log" );
+require 'dbgp/dbgpclient.php';
+
+$dir = dirname(__FILE__);
+putenv("XDEBUG_TEST_DIR=$dir");
+$data = file_get_contents(dirname(__FILE__) . '/bug00886.inc');
+
+$commands = array(
+ 'step_into',
+ 'step_into',
+ 'step_into',
+ 'stack_get',
+ 'step_into',
+ "breakpoint_set -t line -f phar://{$dir}/bug00886.phar/file1.php -n 4",
+ 'run',
+ "source -f phar://{$dir}/bug00886.phar/file1.php",
+ 'step_into',
+ 'stack_get',
+ '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" 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-2012 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>
+
+-> 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="phar://%s/tests/bug00886.phar/file1.php" lineno="2"></xdebug:message></response>
+
+-> stack_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="stack_get" transaction_id="4"><stack where="include" level="0" type="file" filename="phar://%s/tests/bug00886.phar/file1.php" lineno="2"></stack><stack where="{main}" level="1" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="3"></stack></response>
+
+-> step_into -i 5
+<?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="5" status="break" reason="ok"><xdebug:message filename="phar://%s/tests/bug00886.phar/file2.php" lineno="2"></xdebug:message></response>
+
+-> breakpoint_set -i 6 -t line -f phar://%s/tests/bug00886.phar/file1.php -n 4
+<?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>
+
+-> run -i 7
+<?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="7" status="break" reason="ok"><xdebug:message filename="phar://%s/tests/bug00886.phar/file1.php" lineno="4"></xdebug:message></response>
+
+-> source -i 8 -f phar://%s/tests/bug00886.phar/file1.php
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="source" transaction_id="8" encoding="base64"><![CDATA[PD9waHAKaW5jbHVkZSAnZmlsZTIucGhwJzsKCmZ1bmN0aW9uIGZ1bmN0aW9uMSggJGZvbyApCnsKCWVjaG8gc3RybGVuKCAkZm9vICksICJcbiI7CglmdW5jdGlvbjIoICRmb28gKTsKfQo/Pgo=]]></response>
+
+-> step_into -i 9
+<?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="9" status="break" reason="ok"><xdebug:message filename="phar://%s/tests/bug00886.phar/file1.php" lineno="10"></xdebug:message></response>
+
+-> stack_get -i 10
+<?xml version="1.0" encoding="iso-8859-1"?>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="10"><stack where="include" level="0" type="file" filename="phar://%s/tests/bug00886.phar/file1.php" lineno="10"></stack><stack where="{main}" level="1" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="3"></stack></response>
+
+-> detach -i 11
+<?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="11" status="stopping" reason="ok"></response>
View
@@ -337,7 +337,7 @@ char *xdebug_path_to_url(const char *fileurl TSRMLS_DC)
if (strncmp(fileurl, "phar://", 7) == 0) {
/* ignore, phar is cool */
- tmp = xdebug_sprintf("dbgp://%s", fileurl);
+ tmp = xdstrdup(fileurl);
} else if (fileurl[0] != '/' && fileurl[0] != '\\' && fileurl[1] != ':') {
/* convert relative paths */
cwd_state new_state;
@@ -779,9 +779,6 @@ static char* return_eval_source(char *id, int begin, int end TSRMLS_DC)
static char* return_source(char *filename, int begin, int end TSRMLS_DC)
{
if (strncmp(filename, "dbgp://", 7) == 0) {
- if (strncmp(filename, "dbgp://phar://", 14) == 0) {
- return return_file_source(filename + 7, begin, end TSRMLS_CC);
- }
return return_eval_source(filename + 7, begin, end TSRMLS_CC);
} else {
return return_file_source(filename, begin, end TSRMLS_CC);

0 comments on commit 1857b36

Please sign in to comment.