Lines Matching refs:watch
135 #define HT_WATCH_HT(watch) HT_PTR_HT((watch)->addr.ptr) argument
220 phpdbg_watchpoint_t *watch; in phpdbg_check_for_watchpoint() local
227 watch = result->ptr; in phpdbg_check_for_watchpoint()
230 …undary(watch->addr.ptr) > (char *) addr || (char *) phpdbg_get_page_boundary(watch->addr.ptr) + ph… in phpdbg_check_for_watchpoint()
235 return watch; in phpdbg_check_for_watchpoint()
238 static void phpdbg_change_watchpoint_access(phpdbg_watchpoint_t *watch, int access) { in phpdbg_change_watchpoint_access() argument
239 void *page_addr = phpdbg_get_page_boundary(watch->addr.ptr); in phpdbg_change_watchpoint_access()
240 size_t size = phpdbg_get_total_page_size(watch->addr.ptr, watch->size); in phpdbg_change_watchpoint_access()
273 static inline void phpdbg_activate_watchpoint(phpdbg_watchpoint_t *watch) { in phpdbg_activate_watchpoint() argument
274 phpdbg_change_watchpoint_access(watch, PROT_READ); in phpdbg_activate_watchpoint()
277 static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch) { in phpdbg_deactivate_watchpoint() argument
278 phpdbg_change_watchpoint_access(watch, PROT_READ | PROT_WRITE); in phpdbg_deactivate_watchpoint()
336 static inline void phpdbg_store_watchpoint_btree(phpdbg_watchpoint_t *watch) { argument
338 …phpdbg_btree_result *res = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.…
339 ZEND_ASSERT(res == NULL || res->ptr == watch);
341 phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr, watch);
344 static inline void phpdbg_remove_watchpoint_btree(phpdbg_watchpoint_t *watch) { argument
345 phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr);
349 void phpdbg_set_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch) { argument
350 watch->addr.ptr = addr;
351 watch->size = size;
352 watch->ref = NULL;
353 watch->coll = NULL;
354 zend_hash_init(&watch->elements, 8, NULL, NULL, 0);
357 void phpdbg_set_zval_watchpoint(zval *zv, phpdbg_watchpoint_t *watch) { argument
358 phpdbg_set_addr_watchpoint(zv, sizeof(zval) - sizeof(uint32_t), watch);
359 watch->type = WATCH_ON_ZVAL;
362 void phpdbg_set_bucket_watchpoint(Bucket *bucket, phpdbg_watchpoint_t *watch) { argument
363 phpdbg_set_addr_watchpoint(bucket, sizeof(Bucket), watch);
364 watch->type = WATCH_ON_BUCKET;
367 void phpdbg_set_ht_watchpoint(HashTable *ht, phpdbg_watchpoint_t *watch) { argument
368 …g_set_addr_watchpoint(((char *) ht) + HT_WATCH_OFFSET, sizeof(HashTable) - HT_WATCH_OFFSET, watch);
369 watch->type = WATCH_ON_HASHTABLE;
372 void phpdbg_watch_backup_data(phpdbg_watchpoint_t *watch) { argument
373 switch (watch->type) {
377 memcpy(&watch->backup, watch->addr.ptr, watch->size);
380 if (watch->backup.str) {
381 zend_string_release(watch->backup.str);
383 …watch->backup.str = zend_string_init((char *) watch->addr.ptr + XtOffsetOf(zend_string, val) - XtO…
384 GC_MAKE_PERSISTENT_LOCAL(watch->backup.str);
387 memcpy((char *) &watch->backup + HT_WATCH_OFFSET, watch->addr.ptr, watch->size);
395 void phpdbg_delete_watch_collision(phpdbg_watchpoint_t *watch) { argument
397 if ((coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
398 zend_hash_index_del(&coll->parents, (zend_ulong) watch);
414 zend_hash_index_del(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref);
421 void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) { argument
424 ZEND_ASSERT(watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET);
425 if (Z_REFCOUNTED_P(watch->addr.zv)) {
426 if (Z_COUNTED_P(watch->addr.zv) == watch->ref) {
430 if (watch->ref != NULL) {
431 phpdbg_delete_watch_collision(watch);
434 watch->ref = Z_COUNTED_P(watch->addr.zv);
436 if (!(coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
439 phpdbg_set_addr_watchpoint(Z_COUNTED_P(watch->addr.zv), sizeof(uint32_t), &coll->ref);
445 if (Z_ISREF_P(watch->addr.zv)) {
446 phpdbg_set_zval_watchpoint(Z_REFVAL_P(watch->addr.zv), &coll->reference);
452 } else if (Z_TYPE_P(watch->addr.zv) == IS_STRING) {
454 …_addr_watchpoint(&Z_STRLEN_P(watch->addr.zv), XtOffsetOf(zend_string, val) - XtOffsetOf(zend_strin…
465 zend_hash_index_add_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref, coll);
467 zend_hash_index_add_ptr(&coll->parents, (zend_long) watch, watch);
468 } else if (Z_TYPE_P(watch->addr.zv) == IS_INDIRECT) {
469 if ((zend_refcounted *) Z_INDIRECT_P(watch->addr.zv) == watch->ref) {
473 if (watch->ref != NULL) {
474 phpdbg_delete_watch_collision(watch);
477 watch->ref = (zend_refcounted *) Z_INDIRECT_P(watch->addr.zv);
479 if (!(coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
481 phpdbg_set_zval_watchpoint(Z_INDIRECT_P(watch->addr.zv), &coll->ref);
489 zend_hash_index_add_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref, coll);
491 zend_hash_index_add_ptr(&coll->parents, (zend_long) watch, watch);
492 } else if (watch->ref) {
493 phpdbg_delete_watch_collision(watch);
494 watch->ref = NULL;
503 void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch);
506 phpdbg_watch_element *phpdbg_add_watch_element(phpdbg_watchpoint_t *watch, phpdbg_watch_element *el… argument
508 if ((res = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr)) == NULL) {
510 *mem = *watch;
511 watch = mem;
512 phpdbg_store_watchpoint_btree(watch);
513 if (watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) {
514 phpdbg_update_watch_ref(watch);
516 phpdbg_activate_watchpoint(watch);
517 phpdbg_watch_backup_data(watch);
520 watch = res->ptr;
521 if ((old_element = zend_hash_find_ptr(&watch->elements, element->str))) {
529 element->watch = watch;
530 zend_hash_add_ptr(&watch->elements, element->str, element);
540 phpdbg_watchpoint_t watch; local
541 phpdbg_set_bucket_watchpoint(bucket, &watch);
542 element = phpdbg_add_watch_element(&watch, element);
548 phpdbg_watchpoint_t watch; local
556 phpdbg_set_ht_watchpoint(ht, &watch);
557 return phpdbg_add_watch_element(&watch, element);
564 if (element->watch->addr.ptr == ptr) {
592 child->parent_container = HT_WATCH_HT(element->watch);
601 if (element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET) {
602 zv = element->watch->addr.zv;
638 ZEND_ASSERT(element->watch->type == WATCH_ON_HASHTABLE);
639 ZEND_HASH_FOREACH_KEY_VAL(HT_WATCH_HT(element->watch), idx, str, zv) {
646 if (element->watch->type == WATCH_ON_BUCKET) {
670 if (element->watch && element->watch->type == WATCH_ON_BUCKET) {
781 …ZEND_ASSERT(element->parent->watch->type == WATCH_ON_ZVAL || element->parent->watch->type == WATCH…
782 zv = element->parent->watch->addr.zv;
861 …memcpy(&element->backup, &element->watch->backup, /* element->watch->size */ sizeof(element->backu…
919 ZEND_ASSERT(element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET);
934 void phpdbg_update_watch_collision_elements(phpdbg_watchpoint_t *watch) { argument
938 ZEND_HASH_MAP_FOREACH_PTR(&watch->coll->parents, parent) {
949 void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch) { argument
952 phpdbg_remove_watchpoint_btree(watch);
953 phpdbg_deactivate_watchpoint(watch);
954 phpdbg_delete_watch_collision(watch);
956 if (watch->coll) {
957 phpdbg_update_watch_collision_elements(watch);
961 watch->elements.nNumOfElements++; /* dirty hack to avoid double free */
962 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
965 zend_hash_destroy(&watch->elements);
967 efree(watch);
973 if (element->watch) {
974 HashTable *elements = &element->watch->elements;
977 phpdbg_remove_watchpoint(element->watch);
983 zend_string *phpdbg_watchpoint_change_collision_name(phpdbg_watchpoint_t *watch) { argument
987 if (watch->coll) {
988 ZEND_HASH_MAP_FOREACH_PTR(&watch->coll->parents, parent) {
996 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
998 …if ((watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) && Z_TYPE(watch->backup.zv) >…
1011 void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) { argument
1015 if (watch->type == WATCH_ON_HASHTABLE) {
1020 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1022 …tree_result *res = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) HT_WATCH_HT(watch));
1025 ZEND_HASH_REVERSE_FOREACH_KEY_VAL(HT_WATCH_HT(watch), idx, str, zv) {
1035 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1049 if (watch->type == WATCH_ON_HASHDATA) {
1053 switch (watch->type) {
1055 comparePtr = &ZSTR_LEN(watch->backup.str);
1058 comparePtr = (char *) &watch->backup.ht + HT_WATCH_OFFSET;
1061 comparePtr = &watch->backup;
1063 if (!phpdbg_check_watch_diff(watch->type, comparePtr, watch->addr.ptr)) {
1066 if (watch->type == WATCH_ON_REFCOUNTED && !(PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS)) {
1067 phpdbg_watch_backup_data(watch);
1070 if (watch->type == WATCH_ON_BUCKET) {
1071 …if (watch->backup.bucket.key != watch->addr.bucket->key || (watch->backup.bucket.key != NULL && wa…
1075 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1084 phpdbg_remove_watchpoint(watch);
1088 phpdbg_remove_watchpoint_btree(watch);
1089 phpdbg_deactivate_watchpoint(watch);
1090 watch->addr.zv = new;
1091 phpdbg_store_watchpoint_btree(watch);
1092 phpdbg_activate_watchpoint(watch);
1094 if (!phpdbg_check_watch_diff(WATCH_ON_ZVAL, &watch->backup.bucket.val, watch->addr.ptr)) {
1095 phpdbg_watch_backup_data(watch);
1098 } else if (Z_TYPE_P(watch->addr.zv) == IS_UNDEF) {
1100 phpdbg_remove_watchpoint(watch);
1105 name = phpdbg_watchpoint_change_collision_name(watch);
1108 phpdbg_print_watch_diff(watch->type, name, comparePtr, watch->addr.ptr);
1112 if (watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) {
1114 phpdbg_update_watch_ref(watch);
1115 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1122 phpdbg_watch_backup_data(watch);
1128 phpdbg_watchpoint_t *watch; local
1134 watch = res->ptr;
1135 if ((char *) page < (char *) watch->addr.ptr + watch->size) {
1160 phpdbg_watchpoint_t *watch; local
1177 watch = res->ptr;
1178 phpdbg_check_watchpoint(watch);
1181 watch = res->ptr;
1182 if ((char *) page < (char *) watch->addr.ptr + watch->size) {
1183 phpdbg_check_watchpoint(watch);
1210 phpdbg_watchpoint_t *watch = result->ptr; local
1211 if (watch->type != WATCH_ON_HASHDATA) {
1212 phpdbg_remove_watchpoint(watch);
1216 phpdbg_watch_ht_info *hti = (phpdbg_watch_ht_info *) watch;
1220 phpdbg_remove_watchpoint(element->watch);
1230 phpdbg_watchpoint_t *watch = result->ptr; local
1231 if (watch->type == WATCH_ON_HASHTABLE) {
1232 phpdbg_remove_watchpoint(watch);
1339 …_G(watch_tmp) && Z_ISREF_P(PHPDBG_G(watch_tmp)->watch->addr.zv) && Z_REFVAL_P(PHPDBG_G(watch_tmp)-…