diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-09-19 14:57:21 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-09-19 14:57:36 +0200 |
commit | 8eadde40cdb1817d23c6aca01df69596877f69a3 (patch) | |
tree | d9e7e61eb039157b1d994978dcb5f249a929d3e4 /sapi/phpdbg/phpdbg_prompt.c | |
parent | 2f7cc862d763bcd3ca09f1164df8cdec929b75b9 (diff) | |
download | php-git-8eadde40cdb1817d23c6aca01df69596877f69a3.tar.gz |
Fix leave and finish
Diffstat (limited to 'sapi/phpdbg/phpdbg_prompt.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 41d221f527..2e0f4903f8 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -565,11 +565,11 @@ PHPDBG_COMMAND(next) /* {{{ */ } /* }}} */ static void phpdbg_seek_to_end(void) /* {{{ */ { - const zend_op *opline = EG(current_execute_data)->opline; - const zend_op_array *op_array = &EG(current_execute_data)->func->op_array - 1; + const zend_op_array *op_array = &EG(current_execute_data)->func->op_array; + const zend_op *opline = op_array->opcodes; PHPDBG_G(seek_ex) = EG(current_execute_data); - while (++opline < op_array->opcodes + op_array->last) { + do { switch (opline->opcode) { case ZEND_RETURN: case ZEND_FAST_RET: @@ -580,7 +580,7 @@ static void phpdbg_seek_to_end(void) /* {{{ */ { zend_hash_index_update_ptr(&PHPDBG_G(seek), (zend_ulong) opline, (void *) opline); return; } - } + } while (++opline < op_array->opcodes + op_array->last); } /* }}} */ @@ -591,8 +591,12 @@ PHPDBG_COMMAND(finish) /* {{{ */ return SUCCESS; } - PHPDBG_G(flags) |= PHPDBG_IN_FINISH; phpdbg_seek_to_end(); + if (zend_hash_index_exists(&PHPDBG_G(seek), (zend_ulong) EG(current_execute_data)->opline)) { + zend_hash_clean(&PHPDBG_G(seek)); + } else { + PHPDBG_G(flags) |= PHPDBG_IN_FINISH; + } return PHPDBG_FINISH; } /* }}} */ @@ -604,10 +608,15 @@ PHPDBG_COMMAND(leave) /* {{{ */ return SUCCESS; } - PHPDBG_G(flags) |= PHPDBG_IN_LEAVE; phpdbg_seek_to_end(); - - return PHPDBG_LEAVE; + if (zend_hash_index_exists(&PHPDBG_G(seek), (zend_ulong) EG(current_execute_data)->opline)) { + zend_hash_clean(&PHPDBG_G(seek)); + phpdbg_notice("leave", "type=\"end\"", "Already at the end of the function"); + return SUCCESS; + } else { + PHPDBG_G(flags) |= PHPDBG_IN_LEAVE; + return PHPDBG_LEAVE; + } } /* }}} */ PHPDBG_COMMAND(frame) /* {{{ */ |