Lines Matching refs:watch
46 phpdbg_watchpoint_t *watch; in phpdbg_check_for_watchpoint() local
53 watch = result->ptr; in phpdbg_check_for_watchpoint()
56 …oundary(watch->addr.ptr) > (char *)addr || (char *)phpdbg_get_page_boundary(watch->addr.ptr) + php… in phpdbg_check_for_watchpoint()
61 return watch; in phpdbg_check_for_watchpoint()
64 static void phpdbg_change_watchpoint_access(phpdbg_watchpoint_t *watch, int access TSRMLS_DC) { in phpdbg_change_watchpoint_access() argument
68 …m = mprotect(phpdbg_get_page_boundary(watch->addr.ptr), phpdbg_get_total_page_size(watch->addr.ptr… in phpdbg_change_watchpoint_access()
71 static inline void phpdbg_activate_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_activate_watchpoint()
72 phpdbg_change_watchpoint_access(watch, PROT_READ TSRMLS_CC); in phpdbg_activate_watchpoint()
75 static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_deactivate_watchpoint()
76 phpdbg_change_watchpoint_access(watch, PROT_READ | PROT_WRITE TSRMLS_CC); in phpdbg_deactivate_watchpoint()
79 static inline void phpdbg_store_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_store_watchpoint()
80 phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr, watch); in phpdbg_store_watchpoint()
83 static inline void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_remove_watchpoint()
84 phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr); in phpdbg_remove_watchpoint()
87 void phpdbg_create_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch) { in phpdbg_create_addr_watchpoint() argument
88 watch->addr.ptr = addr; in phpdbg_create_addr_watchpoint()
89 watch->size = size; in phpdbg_create_addr_watchpoint()
92 void phpdbg_create_zval_watchpoint(zval *zv, phpdbg_watchpoint_t *watch) { in phpdbg_create_zval_watchpoint() argument
93 phpdbg_create_addr_watchpoint(zv, sizeof(zval), watch); in phpdbg_create_zval_watchpoint()
94 watch->type = WATCH_ON_ZVAL; in phpdbg_create_zval_watchpoint()
97 void phpdbg_create_ht_watchpoint(HashTable *ht, phpdbg_watchpoint_t *watch) { in phpdbg_create_ht_watchpoint() argument
98 phpdbg_create_addr_watchpoint(ht, sizeof(HashTable), watch); in phpdbg_create_ht_watchpoint()
99 watch->type = WATCH_ON_HASHTABLE; in phpdbg_create_ht_watchpoint()
104 static int phpdbg_create_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_create_watchpoint()
105 watch->flags |= PHPDBG_WATCH_SIMPLE; in phpdbg_create_watchpoint()
107 phpdbg_store_watchpoint(watch TSRMLS_CC); in phpdbg_create_watchpoint()
108 …zend_hash_add(&PHPDBG_G(watchpoints), watch->str, watch->str_len, &watch, sizeof(phpdbg_watchpoint… in phpdbg_create_watchpoint()
110 if (watch->type == WATCH_ON_ZVAL) { in phpdbg_create_watchpoint()
111 …phpdbg_btree_insert(&PHPDBG_G(watch_HashTables), (zend_ulong)watch->parent_container, watch->paren… in phpdbg_create_watchpoint()
112 watch->parent_container->pDestructor = (dtor_func_t)phpdbg_watch_HashTable_dtor; in phpdbg_create_watchpoint()
115 phpdbg_activate_watchpoint(watch TSRMLS_CC); in phpdbg_create_watchpoint()
120 static int phpdbg_create_array_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_create_array_watchpoint()
123 switch (Z_TYPE_P(watch->addr.zv)) { in phpdbg_create_array_watchpoint()
125 ht = Z_ARRVAL_P(watch->addr.zv); in phpdbg_create_array_watchpoint()
128 ht = Z_OBJPROP_P(watch->addr.zv); in phpdbg_create_array_watchpoint()
134 phpdbg_create_ht_watchpoint(ht, watch); in phpdbg_create_array_watchpoint()
136 phpdbg_create_watchpoint(watch TSRMLS_CC); in phpdbg_create_array_watchpoint()
148 static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) { in phpdbg_create_recursive_watchpoint()
151 if (watch->type != WATCH_ON_ZVAL) { in phpdbg_create_recursive_watchpoint()
155 watch->flags |= PHPDBG_WATCH_RECURSIVE; in phpdbg_create_recursive_watchpoint()
156 phpdbg_create_watchpoint(watch TSRMLS_CC); in phpdbg_create_recursive_watchpoint()
158 switch (Z_TYPE_P(watch->addr.zv)) { in phpdbg_create_recursive_watchpoint()
160 ht = Z_ARRVAL_P(watch->addr.zv); in phpdbg_create_recursive_watchpoint()
163 ht = Z_OBJPROP_P(watch->addr.zv); in phpdbg_create_recursive_watchpoint()
180 new_watch->parent = watch; in phpdbg_create_recursive_watchpoint()
193 … (int)watch->str_len, watch->str, Z_TYPE_P(watch->addr.zv) == IS_ARRAY?"[":"->", phpdbg_get_proper… in phpdbg_create_recursive_watchpoint()
203 new_watch->parent = watch; in phpdbg_create_recursive_watchpoint()
204 new_watch->parent_container = watch->parent_container; in phpdbg_create_recursive_watchpoint()
205 new_watch->name_in_parent = zend_strndup(watch->name_in_parent, watch->name_in_parent_len); in phpdbg_create_recursive_watchpoint()
206 new_watch->name_in_parent_len = watch->name_in_parent_len; in phpdbg_create_recursive_watchpoint()
208 new_watch->str_len = asprintf(&new_watch->str, "%.*s[]", (int)watch->str_len, watch->str); in phpdbg_create_recursive_watchpoint()
218 static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_bool user_request TS… in phpdbg_delete_watchpoint_recursive() argument
219 …if (watch->type == WATCH_ON_HASHTABLE || (watch->type == WATCH_ON_ZVAL && (Z_TYPE_P(watch->addr.zv… in phpdbg_delete_watchpoint_recursive()
223 if (watch->type == WATCH_ON_HASHTABLE && user_request) { in phpdbg_delete_watchpoint_recursive()
231 ht = watch->addr.ht; in phpdbg_delete_watchpoint_recursive()
239 …watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY?"[":"->",… in phpdbg_delete_watchpoint_recursive()
241 …%li%s", (int)watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_AR… in phpdbg_delete_watchpoint_recursive()
249 switch (Z_TYPE_P(watch->addr.zv)) { in phpdbg_delete_watchpoint_recursive()
251 ht = Z_ARRVAL_P(watch->addr.zv); in phpdbg_delete_watchpoint_recursive()
254 ht = Z_OBJPROP_P(watch->addr.zv); in phpdbg_delete_watchpoint_recursive()
264 return zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); in phpdbg_delete_watchpoint_recursive()
269 phpdbg_watchpoint_t *watch; in phpdbg_delete_watchpoint() local
276 watch = result->ptr; in phpdbg_delete_watchpoint()
278 if (watch->flags & PHPDBG_WATCH_RECURSIVE) { in phpdbg_delete_watchpoint()
279 ret = phpdbg_delete_watchpoint_recursive(watch, 1 TSRMLS_CC); in phpdbg_delete_watchpoint()
281 ret = zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); in phpdbg_delete_watchpoint()
337 phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); in phpdbg_watchpoint_parse_input() local
338 watch->flags = 0; in phpdbg_watchpoint_parse_input()
341 watch->str = malloc(i + Z_STRLEN_P(key) + 2); in phpdbg_watchpoint_parse_input()
342 …watch->str_len = sprintf(watch->str, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P… in phpdbg_watchpoint_parse_input()
344 watch->name_in_parent = zend_strndup(last_index, index_len); in phpdbg_watchpoint_parse_input()
345 watch->name_in_parent_len = index_len; in phpdbg_watchpoint_parse_input()
346 watch->parent_container = parent; in phpdbg_watchpoint_parse_input()
347 phpdbg_create_zval_watchpoint(*zv, watch); in phpdbg_watchpoint_parse_input()
349 ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; in phpdbg_watchpoint_parse_input()
370 phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t)); in phpdbg_watchpoint_parse_input() local
371 watch->flags = 0; in phpdbg_watchpoint_parse_input()
372 watch->str = zend_strndup(input, len); in phpdbg_watchpoint_parse_input()
373 watch->str_len = len; in phpdbg_watchpoint_parse_input()
374 watch->name_in_parent = zend_strndup(last_index, index_len); in phpdbg_watchpoint_parse_input()
375 watch->name_in_parent_len = index_len; in phpdbg_watchpoint_parse_input()
376 watch->parent_container = parent; in phpdbg_watchpoint_parse_input()
377 phpdbg_create_zval_watchpoint(*zv, watch); in phpdbg_watchpoint_parse_input()
379 ret = callback(watch TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE; in phpdbg_watchpoint_parse_input()
472 phpdbg_watchpoint_t *watch = result->ptr; in phpdbg_watch_HashTable_dtor() local
476 …phpdbg_notice("%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, (watch->… in phpdbg_watch_HashTable_dtor()
478 if (watch->flags & PHPDBG_WATCH_RECURSIVE) { in phpdbg_watch_HashTable_dtor()
479 phpdbg_delete_watchpoint_recursive(watch, 0 TSRMLS_CC); in phpdbg_watch_HashTable_dtor()
481 zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); in phpdbg_watch_HashTable_dtor()
510 phpdbg_watchpoint_t *watch; local
513 watch = phpdbg_check_for_watchpoint(
521 if (watch == NULL) {
525 page = phpdbg_get_page_boundary(watch->addr.ptr);
526 size = phpdbg_get_total_page_size(watch->addr.ptr, watch->size);
547 phpdbg_watchpoint_t *watch = *(phpdbg_watchpoint_t **)pDest; local
550 phpdbg_deactivate_watchpoint(watch TSRMLS_CC);
551 phpdbg_remove_watchpoint(watch TSRMLS_CC);
553 free(watch->str);
554 free(watch->name_in_parent);
555 efree(watch);
596 phpdbg_watchpoint_t *watch = result->ptr, *htwatch; local
597 void *oldPtr = (char *)&dump->data + ((size_t)watch->addr.ptr - (size_t)dump->page);
600 …if ((size_t)watch->addr.ptr < (size_t)dump->page || (size_t)watch->addr.ptr + watch->size > (size_…
605 …if (zend_hash_find(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len + 1, …
606 if (watch->type == WATCH_ON_HASHTABLE) {
619 if (curTest != watch->addr.ptr) {
620 phpdbg_deactivate_watchpoint(watch TSRMLS_CC);
621 phpdbg_remove_watchpoint(watch TSRMLS_CC);
622 watch->addr.ptr = curTest;
623 phpdbg_store_watchpoint(watch TSRMLS_CC);
624 phpdbg_activate_watchpoint(watch TSRMLS_CC);
631 if (memcmp(oldPtr, watch->addr.ptr, watch->size) != SUCCESS) {
632 … & PHPDBG_SHOW_REFCOUNTS || (watch->type == WATCH_ON_ZVAL && memcmp(oldPtr, watch->addr.zv, sizeof…
634 && !watch->addr.ht->inconsistent
636 && zend_hash_num_elements((HashTable *)oldPtr) != zend_hash_num_elements(watch->addr.ht))) {
639 phpdbg_notice("Breaking on watchpoint %s", watch->str);
642 switch (watch->type) {
644 …dPtr)->refcount__gc != watch->addr.zv->refcount__gc && !zend_symtable_exists(watch->parent_contain…
645 int show_value = memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value));
646 …w_ref = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc || ((zval *)oldPtr)->is_ref…
663 phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str);
664 zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
677 zend_print_flat_zval_r(watch->addr.zv TSRMLS_CC);
681 …phpdbg_writeln("New refcount: %d; New is_ref: %d", watch->addr.zv->refcount__gc, watch->addr.zv->i…
684 …watch->addr.zv) == IS_ARRAY && Z_ARRVAL_P(watch->addr.zv) != Z_ARRVAL_P((zval *)oldPtr)) || (Z_TYP…
686 if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
687 phpdbg_create_recursive_watchpoint(watch TSRMLS_CC);
691 …ARRAY || Z_ARRVAL_P(watch->addr.zv) == Z_ARRVAL_P((zval *)oldPtr)) && (Z_TYPE_P((zval *)oldPtr) !=…
706 if (watch->addr.ht->inconsistent) {
707 phpdbg_notice("Watchpoint %s was unset, removing watchpoint", watch->str);
708 zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
716 …elementDiff = zend_hash_num_elements((HashTable *)oldPtr) - zend_hash_num_elements(watch->addr.ht);
724 if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
725 phpdbg_create_recursive_watchpoint(watch TSRMLS_CC);
729 if (((HashTable *)oldPtr)->pInternalPointer != watch->addr.ht->pInternalPointer) {
765 phpdbg_watchpoint_t **watch; local
768 zend_hash_get_current_data_ex(&PHPDBG_G(watchpoints), (void**) &watch, &position) == SUCCESS;
770 phpdbg_writeln("%.*s", (int)(*watch)->str_len, (*watch)->str);
781 phpdbg_watchpoint_t *watch = result->ptr; local
783 if ((size_t)watch->addr.ptr + watch->size > (size_t)ptr) {
784 zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);