$env['USE_ZEND_ALLOC'] = '0';
$env['ZEND_DONT_UNLOAD_MODULES'] = 1;
+ /* --vex-iropt-register-updates=allregs-at-mem-access is necessary for phpdbg watchpoint tests */
if (version_compare($valgrind_version, '3.3.0', '>=')) {
/* valgrind 3.3.0+ doesn't have --log-file-exactly option */
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file=$memcheck_filename $cmd";
+ $cmd = "valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-register-updates=allregs-at-mem-access --log-file=$memcheck_filename $cmd";
} else {
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
+ $cmd = "valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-register-updates=allregs-at-mem-access --log-file-exactly=$memcheck_filename $cmd";
}
} else {
static void phpdbg_free_watch(phpdbg_watchpoint_t *watch) {
zend_string_release(watch->str);
- zend_string_release(watch->name_in_parent);
+ zend_string_release(watch->name_in_parent);
}
static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch);
if (flags & PHPDBG_WATCH_IMPLICIT) {
zend_hash_del(&cur->implicit_watches, watch->str);
}
-
+
old->flags = watch->flags;
phpdbg_free_watch(watch);
efree(watch);
if (ref) { \
phpdbg_add_watch_collision(ref); \
} \
- phpdbg_free_watch(watch); \
- efree(watch); \
+ if (watch != old_watch) { \
+ phpdbg_free_watch(watch); \
+ efree(watch); \
+ } \
return (x); \
}
if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s was removed, removing watchpoint%s", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_RECURSIVE) ? " recursively" : "");
}
- if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
- phpdbg_delete_watchpoint_recursive(watch, 0);
- } else {
- zend_hash_del(&PHPDBG_G(watchpoints), watch->str);
- }
-
if ((result = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) watch->parent_container))) {
phpdbg_watch_ht_info *hti = result->ptr;
hti->dtor(orig_zv);
if (zend_hash_num_elements(&hti->watches) == 0) {
watch->parent_container->pDestructor = hti->dtor;
zend_hash_destroy(&hti->watches);
+ phpdbg_btree_delete(&PHPDBG_G(watch_HashTables), (zend_ulong) watch->parent_container);
efree(hti);
}
} else {
zval_ptr_dtor_wrapper(orig_zv);
}
+
+ if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
+ phpdbg_delete_watchpoint_recursive(watch, 0);
+ } else {
+ zend_hash_del(&PHPDBG_G(watchpoints), watch->str);
+ }
}
}
dump = malloc(MEMDUMP_SIZE(size));
dump->page = page;
dump->size = size;
+ dump->reenable_writing = 0;
memcpy(&dump->data, page, size);
phpdbg_remove_watchpoint(watch);
phpdbg_free_watch(watch);
+ efree(watch);
}
static void phpdbg_watch_mem_dtor(void *llist_data) {
--- /dev/null
+--TEST--
+Test simple recursive watchpoint
+--PHPDBG--
+b 3
+r
+w r $b
+c
+
+
+
+q
+--EXPECTF--
+[Successful compilation of %s]
+prompt> [Breakpoint #0 added at %s:3]
+prompt> [Breakpoint #0 at %s:3, hits: 1]
+>00003: $a = 1;
+ 00004: $b = [$a];
+ 00005:
+prompt> [Set recursive watchpoint on $b]
+prompt> [Breaking on watchpoint $b]
+Old value:
+New value: Array ([0] => 1)
+>00006: unset($b);
+ 00007: $b = 2;
+ 00008:
+prompt> [Breaking on watchpoint $b]
+Old value inaccessible or destroyed
+New value:
+>00007: $b = 2;
+ 00008:
+prompt> [Breaking on watchpoint $b]
+Old value:
+New value: 2
+>00007: $b = 2;
+ 00008:
+prompt> [$b was removed, removing watchpoint recursively]
+[Script ended normally]
+prompt>
+--FILE--
+<?php
+
+$a = 1;
+$b = [$a];
+
+unset($b);
+$b = 2;