Lines Matching refs:element
500 void phpdbg_recurse_watch_element(phpdbg_watch_element *element);
501 void phpdbg_remove_watch_element_recursively(phpdbg_watch_element *element);
502 void phpdbg_free_watch_element(phpdbg_watch_element *element);
504 void phpdbg_watch_parent_ht(phpdbg_watch_element *element);
506 …atch_element *phpdbg_add_watch_element(phpdbg_watchpoint_t *watch, phpdbg_watch_element *element) { argument
521 if ((old_element = zend_hash_find_ptr(&watch->elements, element->str))) {
522 if (element != old_element) {
523 phpdbg_free_watch_element(element);
529 element->watch = watch;
530 zend_hash_add_ptr(&watch->elements, element->str, element);
532 if (element->flags & PHPDBG_WATCH_RECURSIVE) {
533 phpdbg_recurse_watch_element(element);
536 return element;
539 phpdbg_watch_element *phpdbg_add_bucket_watch_element(Bucket *bucket, phpdbg_watch_element *element… argument
542 element = phpdbg_add_watch_element(&watch, element);
543 phpdbg_watch_parent_ht(element);
544 return element;
547 phpdbg_watch_element *phpdbg_add_ht_watch_element(zval *zv, phpdbg_watch_element *element) { argument
555 element->flags |= Z_TYPE_P(zv) == IS_ARRAY ? PHPDBG_WATCH_ARRAY : PHPDBG_WATCH_OBJECT;
557 return phpdbg_add_watch_element(&watch, element);
560 bool phpdbg_is_recursively_watched(void *ptr, phpdbg_watch_element *element) { argument
561 phpdbg_watch_element *next = element;
563 element = next;
564 if (element->watch->addr.ptr == ptr) {
567 next = element->parent;
568 } while (!(element->flags & PHPDBG_WATCH_RECURSIVE_ROOT));
573 void phpdbg_add_recursive_watch_from_ht(phpdbg_watch_element *element, zend_long idx, zend_string *… argument
575 if (phpdbg_is_recursively_watched(zv, element)) {
582 …r = strpprintf(0, (element->flags & PHPDBG_WATCH_ARRAY) ? "%.*s[%s]" : "%.*s->%s", (int) ZSTR_LEN(…
584 …f(0, (element->flags & PHPDBG_WATCH_ARRAY) ? "%.*s[" ZEND_LONG_FMT "]" : "%.*s->" ZEND_LONG_FMT, (…
590 child->parent = element;
592 child->parent_container = HT_WATCH_HT(element->watch);
593 zend_hash_add_ptr(&element->child_container, child->str, child);
597 void phpdbg_recurse_watch_element(phpdbg_watch_element *element) { argument
601 if (element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET) {
602 zv = element->watch->addr.zv;
608 if (element->child) {
609 phpdbg_remove_watch_element_recursively(element->child);
613 || phpdbg_is_recursively_watched(HT_WATCH_OFFSET + (char *) HT_FROM_ZVP(zv), element)) {
614 if (element->child) {
615 phpdbg_free_watch_element(element->child);
616 element->child = NULL;
621 if (element->child) {
622 child = element->child;
626 child->str = strpprintf(0, "%.*s[]", (int) ZSTR_LEN(element->str), ZSTR_VAL(element->str));
628 child->parent = element;
630 element->child = child;
634 } else if (zend_hash_num_elements(&element->child_container) == 0) {
638 ZEND_ASSERT(element->watch->type == WATCH_ON_HASHTABLE);
639 ZEND_HASH_FOREACH_KEY_VAL(HT_WATCH_HT(element->watch), idx, str, zv) {
640 phpdbg_add_recursive_watch_from_ht(element, idx, str, zv);
645 void phpdbg_watch_parent_ht(phpdbg_watch_element *element) { argument
646 if (element->watch->type == WATCH_ON_BUCKET) {
649 ZEND_ASSERT(element->parent_container);
650 …if (!(res = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) element->parent_container)…
652 hti->ht = element->parent_container;
665 zend_hash_add_ptr(&hti->watches, element->name_in_parent, element);
669 void phpdbg_unwatch_parent_ht(phpdbg_watch_element *element) { argument
670 if (element->watch && element->watch->type == WATCH_ON_BUCKET) {
671 …phpdbg_btree_result *res = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) element->pa…
672 ZEND_ASSERT(element->parent_container);
683 zend_hash_del(&hti->watches, element->name_in_parent);
692 void phpdbg_dissociate_watch_element(phpdbg_watch_element *element, phpdbg_watch_element *until);
693 void phpdbg_free_watch_element_tree(phpdbg_watch_element *element);
695 void phpdbg_queue_element_for_recreation(phpdbg_watch_element *element) { argument
699 if ((prev = zend_hash_find_ptr(&PHPDBG_G(watch_recreation), element->str))) {
702 if (child == element) {
708 zend_hash_update_ptr(&PHPDBG_G(watch_recreation), element->str, element);
711 phpdbg_dissociate_watch_element(element, prev);
713 if (!element->parent) {
715 zend_hash_index_add_empty_element(&PHPDBG_G(watch_free), (zend_ulong) element->parent_container);
719 bool phpdbg_try_re_adding_watch_element(zval *parent, phpdbg_watch_element *element) { argument
725 } else if (element->flags & (PHPDBG_WATCH_ARRAY | PHPDBG_WATCH_OBJECT)) {
727 char *oldPtr = ((char *) &element->backup.ht) + HT_WATCH_OFFSET;
729 phpdbg_print_watch_diff(WATCH_ON_HASHTABLE, element->str, oldPtr, htPtr);
732 phpdbg_add_ht_watch_element(parent, element);
733 } else if ((zv = zend_symtable_find(ht, element->name_in_parent))) {
734 if (element->flags & PHPDBG_WATCH_IMPLICIT) {
744 if (!phpdbg_try_re_adding_watch_element(next, element->child)) {
747 } else if (phpdbg_check_watch_diff(WATCH_ON_ZVAL, &element->backup.zv, zv)) {
748 phpdbg_print_watch_diff(WATCH_ON_ZVAL, element->str, &element->backup.zv, zv);
751 element->parent_container = ht;
752 phpdbg_add_bucket_watch_element((Bucket *) zv, element);
753 phpdbg_watch_parent_ht(element);
761 void phpdbg_automatic_dequeue_free(phpdbg_watch_element *element) { argument
762 phpdbg_watch_element *child = element;
770 phpdbg_free_watch_element_tree(element);
774 phpdbg_watch_element *element; local
776 ZEND_HASH_MAP_FOREACH_PTR(&PHPDBG_G(watch_recreation), element) {
777 …ZEND_ASSERT(element->flags & (PHPDBG_WATCH_IMPLICIT | PHPDBG_WATCH_RECURSIVE_ROOT | PHPDBG_WATCH_S…
778 …if (element->parent || zend_hash_index_find(&PHPDBG_G(watch_free), (zend_ulong) element->parent_co…
780 if (element->parent) {
781 …ZEND_ASSERT(element->parent->watch->type == WATCH_ON_ZVAL || element->parent->watch->type == WATCH…
782 zv = element->parent->watch->addr.zv;
788 ZVAL_ARR(zv, element->parent_container);
790 if (!phpdbg_try_re_adding_watch_element(zv, element)) {
791 phpdbg_automatic_dequeue_free(element);
794 phpdbg_automatic_dequeue_free(element);
803 void phpdbg_clean_watch_element(phpdbg_watch_element *element);
805 void phpdbg_free_watch_element(phpdbg_watch_element *element) { argument
806 zend_string_release(element->str);
807 if (element->name_in_parent) {
808 zend_string_release(element->name_in_parent);
810 efree(element);
814 void phpdbg_remove_watch_element_recursively(phpdbg_watch_element *element) { argument
815 if (element->child) {
816 phpdbg_remove_watch_element_recursively(element->child);
817 phpdbg_free_watch_element(element->child);
818 element->child = NULL;
819 } else if (element->flags & (PHPDBG_WATCH_ARRAY | PHPDBG_WATCH_OBJECT)) {
821 ZEND_HASH_MAP_FOREACH_PTR(&element->child_container, child) {
825 zend_hash_destroy(&element->child_container);
828 phpdbg_clean_watch_element(element);
832 void phpdbg_remove_watch_element(phpdbg_watch_element *element) { argument
833 phpdbg_watch_element *parent = element->parent, *child = element->child;
851 if (element->flags & PHPDBG_WATCH_RECURSIVE_ROOT) {
852 phpdbg_remove_watch_element_recursively(element);
854 phpdbg_clean_watch_element(element);
856 zend_hash_index_del(&PHPDBG_G(watch_elements), element->id);
857 phpdbg_free_watch_element(element);
860 void phpdbg_backup_watch_element(phpdbg_watch_element *element) { argument
861 …memcpy(&element->backup, &element->watch->backup, /* element->watch->size */ sizeof(element->backu…
865 void phpdbg_dissociate_watch_element(phpdbg_watch_element *element, phpdbg_watch_element *until) { argument
866 phpdbg_watch_element *child = element;
867 …ZEND_ASSERT((element->flags & (PHPDBG_WATCH_RECURSIVE_ROOT | PHPDBG_WATCH_RECURSIVE)) != PHPDBG_WA…
869 if (element->flags & PHPDBG_WATCH_RECURSIVE_ROOT) {
870 phpdbg_backup_watch_element(element);
871 phpdbg_remove_watch_element_recursively(element);
889 if (element->child == NULL) {
890 phpdbg_backup_watch_element(element);
892 phpdbg_clean_watch_element(element);
896 void phpdbg_free_watch_element_tree(phpdbg_watch_element *element) { argument
897 phpdbg_watch_element *parent = element->parent, *child = element->child;
909 phpdbg_free_watch_element(element);
912 void phpdbg_update_watch_element_watch(phpdbg_watch_element *element) { argument
913 if (element->flags & PHPDBG_WATCH_IMPLICIT) {
914 phpdbg_watch_element *child = element->child;
919 ZEND_ASSERT(element->watch->type == WATCH_ON_ZVAL || element->watch->type == WATCH_ON_BUCKET);
920 phpdbg_queue_element_for_recreation(element);
921 } else if (element->flags & (PHPDBG_WATCH_RECURSIVE_ROOT | PHPDBG_WATCH_SIMPLE)) {
922 phpdbg_queue_element_for_recreation(element);
923 } else if (element->flags & PHPDBG_WATCH_RECURSIVE) {
924 phpdbg_remove_watch_element_recursively(element);
925 if (element->parent->flags & (PHPDBG_WATCH_OBJECT | PHPDBG_WATCH_ARRAY)) {
926 zend_hash_del(&element->parent->child_container, element->str);
928 element->parent->child = NULL;
930 phpdbg_free_watch_element(element);
936 phpdbg_watch_element *element; local
942 ZEND_HASH_MAP_FOREACH_PTR(&parent->elements, element) {
943 phpdbg_update_watch_element_watch(element);
950 phpdbg_watch_element *element; local
962 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
963 phpdbg_update_watch_element_watch(element);
970 void phpdbg_clean_watch_element(phpdbg_watch_element *element) { argument
971 phpdbg_unwatch_parent_ht(element);
973 if (element->watch) {
974 HashTable *elements = &element->watch->elements;
975 zend_hash_del(elements, element->str);
977 phpdbg_remove_watchpoint(element->watch);
985 phpdbg_watch_element *element; local
996 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
997 if (element->flags & PHPDBG_WATCH_IMPLICIT) {
999 phpdbg_update_watch_element_watch(element->child);
1003 name = element->str;
1016 phpdbg_watch_element *element; local
1020 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1021 if (element->flags & PHPDBG_WATCH_RECURSIVE) {
1035 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1036 if (element->flags & PHPDBG_WATCH_RECURSIVE) {
1037 phpdbg_add_recursive_watch_from_ht(element, idx, str, zv);
1072 phpdbg_watch_element *element = NULL; local
1075 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1079 ZEND_ASSERT(element); /* elements must be non-empty */
1080 new = zend_symtable_find(element->parent_container, element->name_in_parent);
1113 phpdbg_watch_element *element; local
1115 ZEND_HASH_MAP_FOREACH_PTR(&watch->elements, element) {
1116 if (element->flags & PHPDBG_WATCH_RECURSIVE) {
1117 phpdbg_recurse_watch_element(element);
1215 phpdbg_watch_element *element; local
1218 ZEND_HASH_MAP_FOREACH_PTR(&hti->watches, element) {
1220 phpdbg_remove_watchpoint(element->watch);
1246 phpdbg_watch_element *element; local
1248 ZEND_HASH_FOREACH_PTR(&PHPDBG_G(watch_elements), element) {
1249 …) ZSTR_LEN(element->str), ZSTR_VAL(element->str), (element->flags & (PHPDBG_WATCH_ARRAY|PHPDBG_WAT…
1253 static int phpdbg_create_simple_watchpoint(zval *zv, phpdbg_watch_element *element) { argument
1254 element->flags = PHPDBG_WATCH_SIMPLE;
1255 phpdbg_add_bucket_watch_element((Bucket *) zv, element);
1259 static int phpdbg_create_array_watchpoint(zval *zv, phpdbg_watch_element *element) { argument
1271 str = strpprintf(0, "%.*s[]", (int) ZSTR_LEN(element->str), ZSTR_VAL(element->str));
1272 zend_string_release(element->str);
1273 element->str = str;
1274 element->flags = PHPDBG_WATCH_IMPLICIT;
1275 phpdbg_add_bucket_watch_element((Bucket *) orig_zv, element);
1276 element->child = new;
1280 new->parent = element;
1285 static int phpdbg_create_recursive_watchpoint(zval *zv, phpdbg_watch_element *element) { argument
1286 element->flags = PHPDBG_WATCH_RECURSIVE | PHPDBG_WATCH_RECURSIVE_ROOT;
1287 element->child = NULL;
1288 phpdbg_add_bucket_watch_element((Bucket *) zv, element);
1296 phpdbg_watch_element *element = ecalloc(1, sizeof(phpdbg_watch_element)); local
1297 element->str = zend_string_init(name, namelen, 0);
1298 element->name_in_parent = zend_string_init(key, keylen, 0);
1299 element->parent_container = parent;
1300 element->parent = PHPDBG_G(watch_tmp);
1301 element->child = NULL;
1303 ret = info->callback(zv, element);
1309 phpdbg_remove_watch_element(element);
1312 PHPDBG_G(watch_tmp)->child = element;
1315 if (element->child) {
1316 element = element->child;
1320 zend_hash_next_index_insert_ptr(&PHPDBG_G(watch_elements), element);
1321 element->id = PHPDBG_G(watch_elements).nNextFreeElement - 1;
1323 … for %.*s", (element->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursive" : "", element->id, (int)…
1336 phpdbg_watch_element *element; local
1345 element = ecalloc(1, sizeof(phpdbg_watch_element));
1346 element->flags = PHPDBG_WATCH_IMPLICIT;
1347 element->str = zend_string_copy(info->str);
1348 element->name_in_parent = zend_string_init(key, keylen, 0);
1349 element->parent_container = parent;
1350 element->parent = PHPDBG_G(watch_tmp);
1351 element = phpdbg_add_bucket_watch_element((Bucket *) zv, element);
1357 PHPDBG_G(watch_tmp)->child = element;
1359 PHPDBG_G(watch_tmp) = element;
1393 phpdbg_watch_element *element; local
1396 if ((element = zend_hash_index_find_ptr(&PHPDBG_G(watch_elements), param->num))) {
1397 phpdbg_remove_watch_element(element);
1507 phpdbg_watch_element *element; local
1510 ZEND_HASH_MAP_FOREACH_PTR(&PHPDBG_G(watch_recreation), element) {
1511 phpdbg_automatic_dequeue_free(element);