Fix #73927: phpdbg fails with windows error prompt at "watch array"

We expect zvals, so we should request zvals.

We also suppress spurious watchpoint removal notices.
This commit is contained in:
Christoph M. Becker 2020-05-27 18:26:32 +02:00
parent 461135009c
commit af4a9bf1bf
4 changed files with 57 additions and 7 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ PHP NEWS
- phpdbg: - phpdbg:
. Fixed bug #73926 (phpdbg will not accept input on restart execution). (cmb) . Fixed bug #73926 (phpdbg will not accept input on restart execution). (cmb)
. Fixed bug #73927 (phpdbg fails with windows error prompt at "watch array").
(cmb)
. Fixed several mostly Windows related phpdbg bugs. (cmb) . Fixed several mostly Windows related phpdbg bugs. (cmb)
11 Jun 2020, PHP 7.4.7 11 Jun 2020, PHP 7.4.7

View File

@ -473,11 +473,7 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
if (new_index && index_len == 0) { if (new_index && index_len == 0) {
zend_ulong numkey; zend_ulong numkey;
zend_string *strkey; zend_string *strkey;
ZEND_HASH_FOREACH_KEY_PTR(parent, numkey, strkey, zv) { ZEND_HASH_FOREACH_KEY_VAL_IND(parent, numkey, strkey, zv) {
while (Z_TYPE_P(zv) == IS_INDIRECT) {
zv = Z_INDIRECT_P(zv);
}
if (i == len || (i == len - 1 && input[len - 1] == ']')) { if (i == len || (i == len - 1 && input[len - 1] == ']')) {
char *key, *propkey; char *key, *propkey;
size_t namelen, keylen; size_t namelen, keylen;

View File

@ -713,8 +713,9 @@ void phpdbg_automatic_dequeue_free(phpdbg_watch_element *element) {
child = child->child; child = child->child;
} }
PHPDBG_G(watchpoint_hit) = 1; PHPDBG_G(watchpoint_hit) = 1;
phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s has been removed, removing watchpoint%s", (int) ZSTR_LEN(child->str), ZSTR_VAL(child->str), (child->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursively" : ""); if (zend_hash_index_del(&PHPDBG_G(watch_elements), child->id) == SUCCESS) {
zend_hash_index_del(&PHPDBG_G(watch_elements), child->id); phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s has been removed, removing watchpoint%s", (int) ZSTR_LEN(child->str), ZSTR_VAL(child->str), (child->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursively" : "");
}
phpdbg_free_watch_element_tree(element); phpdbg_free_watch_element_tree(element);
} }

View File

@ -0,0 +1,51 @@
--TEST--
Bug #73927 (phpdbg fails with windows error prompt at "watch array")
--PHPDBG--
b 19
r
c
w $value
w $lower[]
q
--EXPECTF--
[Successful compilation of %s]
prompt> [Breakpoint #0 added at %s:%d]
prompt> [Breakpoint #0 at %s:%d, hits: 1]
>00019: if ($value < 100) {
00020: $lower[] = $value;
00021: } else {
prompt> [Breakpoint #0 at %s:%d, hits: 2]
>00019: if ($value < 100) {
00020: $lower[] = $value;
00021: } else {
prompt> [Added watchpoint #0 for $value]
prompt> [Added watchpoint #1 for $lower[0]]
prompt> [$lower[0] has been removed, removing watchpoint]
[$value has been removed, removing watchpoint]
--FILE--
<?php
// Generate some mock data
$example = [1, 23, 23423, 256436, 3463, 4363, 457];
foreach (range(1, 1000) as $val) {
$example[] = mt_rand(1, 10000);
}
// Stuff to debug
function doCoolStuff($value)
{
$value++;
return mt_rand(1, 1000);
}
$lower = [];
foreach ($example as $key => $value) {
if ($value < 100) {
$lower[] = $value;
} else {
doCoolStuff($value);
}
}
?>