summaryrefslogtreecommitdiff
path: root/sapi/phpdbg
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-05-26 17:46:56 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-05-26 17:46:56 +0200
commitd2508ef94704b10332e2af2ed0c09d0012cffd69 (patch)
treedbd8a1d5057d383b407e38dc0f963d10de2cbe9f /sapi/phpdbg
parent31e410e0980e5c9272c4e4d00ef99c6b50fe0499 (diff)
parent9fad9addb5707efe96dc5b9eeea4e4f00816d1f6 (diff)
downloadphp-git-d2508ef94704b10332e2af2ed0c09d0012cffd69.tar.gz
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
Diffstat (limited to 'sapi/phpdbg')
-rw-r--r--sapi/phpdbg/phpdbg.c12
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c2
-rw-r--r--sapi/phpdbg/phpdbg_utils.c7
-rw-r--r--sapi/phpdbg/phpdbg_watch.c12
-rw-r--r--sapi/phpdbg/phpdbg_watch.h1
-rw-r--r--sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt2
6 files changed, 28 insertions, 8 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index ee2483c1fb..f9777c5adb 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1287,10 +1287,12 @@ php_stream *phpdbg_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *
if (!strncasecmp(path, "stdin", 6) && PHPDBG_G(stdin_file)) {
php_stream *stream = php_stream_fopen_from_fd(dup(fileno(PHPDBG_G(stdin_file))), "r", NULL);
#ifdef PHP_WIN32
- zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
- if (blocking_pipes) {
- convert_to_long(blocking_pipes);
- php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
+ if (context != NULL) {
+ zval *blocking_pipes = php_stream_context_get_option(context, "pipe", "blocking");
+ if (blocking_pipes) {
+ convert_to_long(blocking_pipes);
+ php_stream_set_option(stream, PHP_STREAM_OPTION_PIPE_BLOCKING, Z_LVAL_P(blocking_pipes), NULL);
+ }
}
#endif
return stream;
@@ -2005,6 +2007,8 @@ phpdbg_out:
phpdbg_out:
#endif
+ phpdbg_purge_watchpoint_tree();
+
if (first_command) {
free(first_command);
first_command = NULL;
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index 750628c800..61f17d1c0e 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -821,7 +821,7 @@ PHPDBG_API int phpdbg_ask_user_permission(const char *question) {
while (1) {
phpdbg_consume_stdin_line(buf);
- if (buf[1] == '\n' && (buf[0] == 'y' || buf[0] == 'n')) {
+ if ((buf[1] == '\n' || (buf[1] == '\r' && buf[2] == '\n')) && (buf[0] == 'y' || buf[0] == 'n')) {
if (buf[0] == 'y') {
return SUCCESS;
}
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index 548c9e96b1..699f45b76d 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -355,8 +355,11 @@ PHPDBG_API int phpdbg_get_terminal_height(void) /* {{{ */
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- lines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) {
+ lines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ } else {
+ lines = 40;
+ }
#elif defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ)
struct winsize w;
diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c
index 62fb65a67e..784ab3a999 100644
--- a/sapi/phpdbg/phpdbg_watch.c
+++ b/sapi/phpdbg/phpdbg_watch.c
@@ -1404,6 +1404,8 @@ void phpdbg_setup_watchpoints(void) {
zend_hash_init(PHPDBG_G(watchlist_mem), phpdbg_pagesize / (sizeof(Bucket) + sizeof(uint32_t)), NULL, NULL, 1);
PHPDBG_G(watchlist_mem_backup) = malloc(phpdbg_pagesize > sizeof(HashTable) ? phpdbg_pagesize : sizeof(HashTable));
zend_hash_init(PHPDBG_G(watchlist_mem_backup), phpdbg_pagesize / (sizeof(Bucket) + sizeof(uint32_t)), NULL, NULL, 1);
+
+ PHPDBG_G(watch_tmp) = NULL;
}
void phpdbg_destroy_watchpoints(void) {
@@ -1431,3 +1433,13 @@ void phpdbg_destroy_watchpoints(void) {
zend_hash_destroy(PHPDBG_G(watchlist_mem_backup));
free(PHPDBG_G(watchlist_mem_backup));
}
+
+void phpdbg_purge_watchpoint_tree(void) {
+ phpdbg_btree_position pos;
+ phpdbg_btree_result *res;
+
+ pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), 0, -1);
+ while ((res = phpdbg_btree_next(&pos))) {
+ phpdbg_deactivate_watchpoint(res->ptr);
+ }
+}
diff --git a/sapi/phpdbg/phpdbg_watch.h b/sapi/phpdbg/phpdbg_watch.h
index f7b3fddcc2..6782c38d54 100644
--- a/sapi/phpdbg/phpdbg_watch.h
+++ b/sapi/phpdbg/phpdbg_watch.h
@@ -117,6 +117,7 @@ typedef struct {
void phpdbg_setup_watchpoints(void);
void phpdbg_destroy_watchpoints(void);
+void phpdbg_purge_watchpoint_tree(void);
#ifndef _WIN32
int phpdbg_watchpoint_segfault_handler(siginfo_t *info, void *context);
diff --git a/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt b/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt
index 560fac35f8..ab6236a7fc 100644
--- a/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt
+++ b/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt
@@ -70,7 +70,7 @@ stream_wrapper_register('wrapper', StreamWrapper::class);
* Next, we include a PHP file that contains executable lines, via the stream
* wrapper.
*/
-$filename = __DIR__ . '/phpdbg_get_executable_stream_wrapper.inc';
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'phpdbg_get_executable_stream_wrapper.inc';
require 'wrapper://' . $filename;
/**