diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2016-07-11 23:28:14 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2016-07-11 23:58:20 +0200 |
commit | b00376884e00aa04614dd650e119aad653c1f16b (patch) | |
tree | 9531526edb549ef5eae6ada0d6a6969dfe085e46 /sapi/phpdbg/phpdbg_btree.c | |
parent | 1223f7f91b63d37c1282c05c0fab5a16bc83bbf1 (diff) | |
download | php-git-b00376884e00aa04614dd650e119aad653c1f16b.tar.gz |
Rewrite watchpoints to be much more stable
This mainly involves a separate abstraction layer for elements (e.g. $a->b) and watchpoints (on pointer of the Bucket for example).
Also better comparison handling (value backup vs. page dumps).
It is not yet finished (there are sometimes false positives announced and names not yet perfect), but the functionality is working and not crashing as far as I have tested.
Future scope is also relative watchpoints, e.g. "w $this->val expression()" which does not have the symbol tables as basis, but the value (in this example: return value of expression()) as basis.
Diffstat (limited to 'sapi/phpdbg/phpdbg_btree.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_btree.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/sapi/phpdbg/phpdbg_btree.c b/sapi/phpdbg/phpdbg_btree.c index 9e7dc86e8e..7e1937fc73 100644 --- a/sapi/phpdbg/phpdbg_btree.c +++ b/sapi/phpdbg/phpdbg_btree.c @@ -25,14 +25,17 @@ branch = branch->branches[!!(n)]; #ifdef _Win32 -# define emalloc malloc -# define efree free +# undef pemalloc +# undef pefree +# define pemalloc(size, persistent) malloc(size) +# define pefree(ptr, persistent) free(ptr) #endif /* depth in bits */ void phpdbg_btree_init(phpdbg_btree *tree, zend_ulong depth) { tree->depth = depth; tree->branch = NULL; + tree->persistent = 0; tree->count = 0; } @@ -157,7 +160,7 @@ int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr, } { - phpdbg_btree_branch *memory = *branch = emalloc((i + 2) * sizeof(phpdbg_btree_branch)); + phpdbg_btree_branch *memory = *branch = pemalloc((i + 2) * sizeof(phpdbg_btree_branch), tree->persistent); do { (*branch)->branches[!((idx >> i) % 2)] = NULL; branch = &(*branch)->branches[(idx >> i) % 2]; @@ -199,14 +202,14 @@ check_branch_existence: tree->count--; if (i_last_dual_branch == -1) { - efree(tree->branch); + pefree(tree->branch, tree->persistent); tree->branch = NULL; } else { if (last_dual_branch->branches[last_dual_branch_branch] == last_dual_branch + 1) { phpdbg_btree_branch *original_branch = last_dual_branch->branches[!last_dual_branch_branch]; memcpy(last_dual_branch + 1, last_dual_branch->branches[!last_dual_branch_branch], (i_last_dual_branch + 1) * sizeof(phpdbg_btree_branch)); - efree(last_dual_branch->branches[!last_dual_branch_branch]); + pefree(last_dual_branch->branches[!last_dual_branch_branch], tree->persistent); last_dual_branch->branches[!last_dual_branch_branch] = last_dual_branch + 1; branch = last_dual_branch->branches[!last_dual_branch_branch]; @@ -214,7 +217,7 @@ check_branch_existence: branch = (branch->branches[branch->branches[1] == ++original_branch] = last_dual_branch + i_last_dual_branch - i + 1); } } else { - efree(last_dual_branch->branches[last_dual_branch_branch]); + pefree(last_dual_branch->branches[last_dual_branch_branch], tree->persistent); } last_dual_branch->branches[last_dual_branch_branch] = NULL; @@ -223,6 +226,26 @@ check_branch_existence: return SUCCESS; } +void phpdbg_btree_clean_recursive(phpdbg_btree_branch *branch, zend_ulong depth, zend_bool persistent) { + phpdbg_btree_branch *start = branch; + while (depth--) { + zend_bool use_branch = branch + 1 == branch->branches[0]; + if (branch->branches[use_branch]) { + phpdbg_btree_clean_recursive(branch->branches[use_branch], depth, persistent); + } + } + + pefree(start, persistent); +} + +void phpdbg_btree_clean(phpdbg_btree *tree) { + if (tree->branch) { + phpdbg_btree_clean_recursive(tree->branch, tree->depth, tree->persistent); + tree->branch = NULL; + tree->count = 0; + } +} + void phpdbg_btree_branch_dump(phpdbg_btree_branch *branch, zend_ulong depth) { if (branch) { if (depth--) { |