Lines Matching refs:watch
127 #define HT_WATCH_HT(watch) HT_PTR_HT((watch)->addr.ptr) argument
221 phpdbg_watchpoint_t *watch; in phpdbg_check_for_watchpoint() local
228 watch = result->ptr; in phpdbg_check_for_watchpoint()
231 …undary(watch->addr.ptr) > (char *) addr || (char *) phpdbg_get_page_boundary(watch->addr.ptr) + ph… in phpdbg_check_for_watchpoint()
236 return watch; in phpdbg_check_for_watchpoint()
239 static void phpdbg_change_watchpoint_access(phpdbg_watchpoint_t *watch, int access) { in phpdbg_change_watchpoint_access() argument
241 …mprotect(phpdbg_get_page_boundary(watch->addr.ptr), phpdbg_get_total_page_size(watch->addr.ptr, wa… in phpdbg_change_watchpoint_access()
244 static inline void phpdbg_activate_watchpoint(phpdbg_watchpoint_t *watch) { in phpdbg_activate_watchpoint() argument
245 phpdbg_change_watchpoint_access(watch, PROT_READ); in phpdbg_activate_watchpoint()
248 static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch) { in phpdbg_deactivate_watchpoint() argument
249 phpdbg_change_watchpoint_access(watch, PROT_READ | PROT_WRITE); in phpdbg_deactivate_watchpoint()
281 static inline void phpdbg_store_watchpoint_btree(phpdbg_watchpoint_t *watch) { argument
283 …_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr)) == NULL || res->ptr == watc…
284 phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr, watch);
287 static inline void phpdbg_remove_watchpoint_btree(phpdbg_watchpoint_t *watch) { argument
288 phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr);
292 void phpdbg_set_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch) { argument
293 watch->addr.ptr = addr;
294 watch->size = size;
295 watch->ref = NULL;
296 watch->coll = NULL;
297 zend_hash_init(&watch->elements, 8, brml, NULL, 0);
300 void phpdbg_set_zval_watchpoint(zval *zv, phpdbg_watchpoint_t *watch) { argument
301 phpdbg_set_addr_watchpoint(zv, sizeof(zval) - sizeof(uint32_t), watch);
302 watch->type = WATCH_ON_ZVAL;
305 void phpdbg_set_bucket_watchpoint(Bucket *bucket, phpdbg_watchpoint_t *watch) { argument
306 phpdbg_set_addr_watchpoint(bucket, sizeof(Bucket), watch);
307 watch->type = WATCH_ON_BUCKET;
310 void phpdbg_set_ht_watchpoint(HashTable *ht, phpdbg_watchpoint_t *watch) { argument
311 …g_set_addr_watchpoint(((char *) ht) + HT_WATCH_OFFSET, sizeof(HashTable) - HT_WATCH_OFFSET, watch);
312 watch->type = WATCH_ON_HASHTABLE;
315 void phpdbg_watch_backup_data(phpdbg_watchpoint_t *watch) { argument
316 switch (watch->type) {
320 memcpy(&watch->backup, watch->addr.ptr, watch->size);
323 if (watch->backup.str) {
324 zend_string_release(watch->backup.str);
326 …watch->backup.str = zend_string_init((char *) watch->addr.ptr + XtOffsetOf(zend_string, val) - XtO…
327 GC_MAKE_PERSISTENT_LOCAL(watch->backup.str);
330 memcpy((char *) &watch->backup + HT_WATCH_OFFSET, watch->addr.ptr, watch->size);
338 void phpdbg_delete_watch_collision(phpdbg_watchpoint_t *watch) { argument
340 if ((coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
341 zend_hash_index_del(&coll->parents, (zend_ulong) watch);
357 zend_hash_index_del(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref);
364 void phpdbg_update_watch_ref(phpdbg_watchpoint_t *watch) { argument
367 ZEND_ASSERT(watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET);
368 if (Z_REFCOUNTED_P(watch->addr.zv)) {
369 if (Z_COUNTED_P(watch->addr.zv) == watch->ref) {
373 if (watch->ref != NULL) {
374 phpdbg_delete_watch_collision(watch);
377 watch->ref = Z_COUNTED_P(watch->addr.zv);
379 if (!(coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
382 phpdbg_set_addr_watchpoint(Z_COUNTED_P(watch->addr.zv), sizeof(uint32_t), &coll->ref);
388 if (Z_ISREF_P(watch->addr.zv)) {
389 phpdbg_set_zval_watchpoint(Z_REFVAL_P(watch->addr.zv), &coll->reference);
395 } else if (Z_TYPE_P(watch->addr.zv) == IS_STRING) {
397 …_addr_watchpoint(&Z_STRLEN_P(watch->addr.zv), XtOffsetOf(zend_string, val) - XtOffsetOf(zend_strin…
408 zend_hash_index_add_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref, coll);
410 zend_hash_index_add_ptr(&coll->parents, (zend_long) watch, watch);
411 } else if (Z_TYPE_P(watch->addr.zv) == IS_INDIRECT) {
412 if ((zend_refcounted *) Z_INDIRECT_P(watch->addr.zv) == watch->ref) {
416 if (watch->ref != NULL) {
417 phpdbg_delete_watch_collision(watch);
420 watch->ref = (zend_refcounted *) Z_INDIRECT_P(watch->addr.zv);
422 if (!(coll = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref))) {
424 phpdbg_set_zval_watchpoint(Z_INDIRECT_P(watch->addr.zv), &coll->ref);
432 zend_hash_index_add_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->ref, coll);
434 zend_hash_index_add_ptr(&coll->parents, (zend_long) watch, watch);
435 } else if (watch->ref) {
436 phpdbg_delete_watch_collision(watch);
437 watch->ref = NULL;
446 void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch);
449 phpdbg_watch_element *phpdbg_add_watch_element(phpdbg_watchpoint_t *watch, phpdbg_watch_element *el… argument
451 if ((res = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr)) == NULL) {
453 *mem = *watch;
454 watch = mem;
455 phpdbg_store_watchpoint_btree(watch);
456 if (watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) {
457 phpdbg_update_watch_ref(watch);
459 phpdbg_activate_watchpoint(watch);
460 phpdbg_watch_backup_data(watch);
463 watch = res->ptr;
464 if ((old_element = zend_hash_find_ptr(&watch->elements, element->str))) {
470 element->watch = watch;
471 zend_hash_add_ptr(&watch->elements, element->str, element);
481 phpdbg_watchpoint_t watch; local
482 phpdbg_set_bucket_watchpoint(bucket, &watch);
483 element = phpdbg_add_watch_element(&watch, element);
489 phpdbg_watchpoint_t watch; local
497 phpdbg_set_ht_watchpoint(ht, &watch);
498 return phpdbg_add_watch_element(&watch, element);
505 if (element->watch->addr.ptr == ptr) {
533 child->parent_container = HT_WATCH_HT(element->watch);
542 if (element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET) {
543 zv = element->watch->addr.zv;
579 ZEND_ASSERT(element->watch->type == WATCH_ON_HASHTABLE);
580 ZEND_HASH_FOREACH_KEY_VAL(HT_WATCH_HT(element->watch), idx, str, zv) {
587 if (element->watch->type == WATCH_ON_BUCKET) {
617 if (element->watch->type == WATCH_ON_BUCKET) {
728 …ZEND_ASSERT(element->parent->watch->type == WATCH_ON_ZVAL || element->parent->watch->type == WATCH…
729 zv = element->parent->watch->addr.zv;
808 …memcpy(&element->backup, &element->watch->backup, /* element->watch->size */ sizeof(element->backu…
866 ZEND_ASSERT(element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET);
881 void phpdbg_update_watch_collision_elements(phpdbg_watchpoint_t *watch) { argument
885 ZEND_HASH_FOREACH_PTR(&watch->coll->parents, parent) {
896 void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch) { argument
899 phpdbg_deactivate_watchpoint(watch);
900 phpdbg_remove_watchpoint_btree(watch);
901 phpdbg_delete_watch_collision(watch);
903 if (watch->coll) {
904 phpdbg_update_watch_collision_elements(watch);
908 watch->elements.nNumOfElements++; /* dirty hack to avoid double free */
909 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
912 zend_hash_destroy(&watch->elements);
914 efree(watch);
918 HashTable *elements = &element->watch->elements;
922 phpdbg_remove_watchpoint(element->watch);
927 zend_string *phpdbg_watchpoint_change_collision_name(phpdbg_watchpoint_t *watch) { argument
931 if (watch->coll) {
932 ZEND_HASH_FOREACH_PTR(&watch->coll->parents, parent) {
940 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
942 …if ((watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) && Z_TYPE(watch->backup.zv) >…
955 void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) { argument
959 if (watch->type == WATCH_ON_HASHTABLE) {
964 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
966 …tree_result *res = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) HT_WATCH_HT(watch));
969 ZEND_HASH_REVERSE_FOREACH_KEY_VAL(HT_WATCH_HT(watch), idx, str, zv) {
979 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
993 if (watch->type == WATCH_ON_HASHDATA) {
997 switch (watch->type) {
999 comparePtr = &ZSTR_LEN(watch->backup.str);
1002 comparePtr = (char *) &watch->backup.ht + HT_WATCH_OFFSET;
1005 comparePtr = &watch->backup;
1007 if (!phpdbg_check_watch_diff(watch->type, comparePtr, watch->addr.ptr)) {
1010 if (watch->type == WATCH_ON_REFCOUNTED && !(PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS)) {
1011 phpdbg_watch_backup_data(watch);
1014 if (watch->type == WATCH_ON_BUCKET) {
1015 …if (watch->backup.bucket.key != watch->addr.bucket->key || (watch->backup.bucket.key != NULL && wa…
1019 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
1028 phpdbg_remove_watchpoint(watch);
1032 phpdbg_deactivate_watchpoint(watch);
1033 phpdbg_remove_watchpoint_btree(watch);
1034 watch->addr.zv = new;
1035 phpdbg_store_watchpoint_btree(watch);
1036 phpdbg_activate_watchpoint(watch);
1038 if (!phpdbg_check_watch_diff(WATCH_ON_ZVAL, &watch->backup.bucket.val, watch->addr.ptr)) {
1039 phpdbg_watch_backup_data(watch);
1042 } else if (Z_TYPE_P(watch->addr.zv) == IS_UNDEF) {
1044 phpdbg_remove_watchpoint(watch);
1049 name = phpdbg_watchpoint_change_collision_name(watch);
1052 phpdbg_print_watch_diff(watch->type, name, comparePtr, watch->addr.ptr);
1056 if (watch->type == WATCH_ON_ZVAL || watch->type == WATCH_ON_BUCKET) {
1058 phpdbg_update_watch_ref(watch);
1059 ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
1066 phpdbg_watch_backup_data(watch);
1072 phpdbg_watchpoint_t *watch; local
1078 watch = res->ptr;
1079 if ((char *) page < (char *) watch->addr.ptr + watch->size) {
1090 phpdbg_watchpoint_t *watch; local
1107 watch = res->ptr;
1108 phpdbg_check_watchpoint(watch);
1111 watch = res->ptr;
1112 if ((char *) page < (char *) watch->addr.ptr + watch->size) {
1113 phpdbg_check_watchpoint(watch);
1140 phpdbg_watchpoint_t *watch = result->ptr; local
1141 if (watch->type != WATCH_ON_HASHDATA) {
1142 phpdbg_remove_watchpoint(watch);
1146 phpdbg_watch_ht_info *hti = (phpdbg_watch_ht_info *) watch;
1150 phpdbg_remove_watchpoint(element->watch);
1160 phpdbg_watchpoint_t *watch = result->ptr; local
1161 if (watch->type == WATCH_ON_HASHTABLE) {
1162 phpdbg_remove_watchpoint(watch);
1273 …_G(watch_tmp) && Z_ISREF_P(PHPDBG_G(watch_tmp)->watch->addr.zv) && Z_REFVAL_P(PHPDBG_G(watch_tmp)-…