Skip to content

Commit d2508ef

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Enable phpdbg tests on AppVeyor Make phpdbg test portable Fix several mostly Windows related phpdbg bugs Fix #73926: phpdbg will not accept input on restart execution
2 parents 31e410e + 9fad9ad commit d2508ef

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

appveyor/test_task.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\en_US.aff" (
8989
mkdir %LOCALAPPDATA%\enchant\hunspell
9090
copy %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\* %LOCALAPPDATA%\enchant\hunspell
9191

92+
set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_OBJ_DIR%\Release
93+
if "%THREAD_SAFE%" equ "1" set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%_TS
94+
set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%\phpdbg.exe
95+
9296
mkdir c:\tests_tmp
9397

9498
set TEST_PHP_JUNIT=c:\junit.out.xml

sapi/phpdbg/phpdbg.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,10 +1287,12 @@ php_stream *phpdbg_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *
12871287
if (!strncasecmp(path, "stdin", 6) && PHPDBG_G(stdin_file)) {
12881288
php_stream *stream = php_stream_fopen_from_fd(dup(fileno(PHPDBG_G(stdin_file))), "r", NULL);
12891289
#ifdef PHP_WIN32
1290-
zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
1291-
if (blocking_pipes) {
1292-
convert_to_long(blocking_pipes);
1293-
php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
1290+
if (context != NULL) {
1291+
zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
1292+
if (blocking_pipes) {
1293+
convert_to_long(blocking_pipes);
1294+
php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
1295+
}
12941296
}
12951297
#endif
12961298
return stream;
@@ -2005,6 +2007,8 @@ int main(int argc, char **argv) /* {{{ */
20052007
phpdbg_out:
20062008
#endif
20072009

2010+
phpdbg_purge_watchpoint_tree();
2011+
20082012
if (first_command) {
20092013
free(first_command);
20102014
first_command = NULL;

sapi/phpdbg/phpdbg_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ PHPDBG_API int phpdbg_ask_user_permission(const char *question) {
821821

822822
while (1) {
823823
phpdbg_consume_stdin_line(buf);
824-
if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) {
824+
if ((buf[1] == '\n' || (buf[1] == '\r' && buf[2] == '\n')) && (buf[0] == 'y' || buf[0] == 'n')) {
825825
if (buf[0] == 'y') {
826826
return SUCCESS;
827827
}

sapi/phpdbg/phpdbg_utils.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,11 @@ PHPDBG_API int phpdbg_get_terminal_height(void) /* {{{ */
355355
#ifdef _WIN32
356356
CONSOLE_SCREEN_BUFFER_INFO csbi;
357357

358-
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
359-
lines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
358+
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
359+
lines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
360+
} else {
361+
lines = 40;
362+
}
360363
#elif defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ)
361364
struct winsize w;
362365

sapi/phpdbg/phpdbg_watch.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,8 @@ void phpdbg_setup_watchpoints(void) {
14041404
zend_hash_init(PHPDBG_G(watchlist_mem), phpdbg_pagesize / (sizeof(Bucket) + sizeof(uint32_t)), NULL, NULL, 1);
14051405
PHPDBG_G(watchlist_mem_backup) = malloc(phpdbg_pagesize > sizeof(HashTable) ? phpdbg_pagesize : sizeof(HashTable));
14061406
zend_hash_init(PHPDBG_G(watchlist_mem_backup), phpdbg_pagesize / (sizeof(Bucket) + sizeof(uint32_t)), NULL, NULL, 1);
1407+
1408+
PHPDBG_G(watch_tmp) = NULL;
14071409
}
14081410

14091411
void phpdbg_destroy_watchpoints(void) {
@@ -1431,3 +1433,13 @@ void phpdbg_destroy_watchpoints(void) {
14311433
zend_hash_destroy(PHPDBG_G(watchlist_mem_backup));
14321434
free(PHPDBG_G(watchlist_mem_backup));
14331435
}
1436+
1437+
void phpdbg_purge_watchpoint_tree(void) {
1438+
phpdbg_btree_position pos;
1439+
phpdbg_btree_result *res;
1440+
1441+
pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), 0, -1);
1442+
while ((res = phpdbg_btree_next(&pos))) {
1443+
phpdbg_deactivate_watchpoint(res->ptr);
1444+
}
1445+
}

sapi/phpdbg/phpdbg_watch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ typedef struct {
117117

118118
void phpdbg_setup_watchpoints(void);
119119
void phpdbg_destroy_watchpoints(void);
120+
void phpdbg_purge_watchpoint_tree(void);
120121

121122
#ifndef _WIN32
122123
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context);

sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ stream_wrapper_register('wrapper', StreamWrapper::class);
7070
* Next, we include a PHP file that contains executable lines, via the stream
7171
* wrapper.
7272
*/
73-
$filename = __DIR__ . '/phpdbg_get_executable_stream_wrapper.inc';
73+
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'phpdbg_get_executable_stream_wrapper.inc';
7474
require 'wrapper://' . $filename;
7575

7676
/**

0 commit comments

Comments
 (0)