void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ { zend_execute_data *execute_data = PHPDBG_FRAME(num)?PHPDBG_FRAME(execute_data):EG(current_execute_data); int i = 0; if (PHPDBG_FRAME(num) == frame) { phpdbg_notice("frame", "id=\"%d\"", "Already in frame #%d", frame); return; } phpdbg_try_access { while (execute_data) { if (i++ == frame) { break; } do { execute_data = execute_data->prev_execute_data; } while (execute_data && execute_data->opline == NULL); } } phpdbg_catch_access { phpdbg_error("signalsegv", "", "Couldn't switch frames, invalid data source"); return; } phpdbg_end_try_access(); if (execute_data == NULL) { phpdbg_error("frame", "type=\"maxnum\" id=\"%d\"", "No frame #%d", frame); return; } phpdbg_restore_frame(TSRMLS_C); if (frame > 0) { PHPDBG_FRAME(num) = frame; /* backup things and jump back */ PHPDBG_FRAME(execute_data) = EG(current_execute_data); EG(current_execute_data) = execute_data; EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); PHPDBG_FRAME(execute_data)->original_return_value = EG(return_value_ptr_ptr); EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); EG(active_symbol_table) = PHPDBG_EX(symbol_table); EG(This) = PHPDBG_EX(current_this); EG(scope) = PHPDBG_EX(current_scope); EG(called_scope) = PHPDBG_EX(current_called_scope); } phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame); phpdbg_list_file( zend_get_executed_filename(TSRMLS_C), 3, zend_get_executed_lineno(TSRMLS_C)-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC ); } /* }}} */
void phpdbg_restore_frame(void) /* {{{ */ { if (PHPDBG_FRAME(num) == 0) { return; } PHPDBG_FRAME(num) = 0; /* move things back */ EG(current_execute_data) = PHPDBG_FRAME(execute_data); EG(scope) = PHPDBG_EX(func)->op_array.scope; } /* }}} */
void phpdbg_switch_frame(int frame) /* {{{ */ { zend_execute_data *execute_data = PHPDBG_FRAME(num)?PHPDBG_FRAME(execute_data):EG(current_execute_data); int i = 0; if (PHPDBG_FRAME(num) == frame) { phpdbg_notice("frame", "id=\"%d\"", "Already in frame #%d", frame); return; } phpdbg_try_access { while (execute_data) { if (i++ == frame) { break; } do { execute_data = execute_data->prev_execute_data; } while (execute_data && execute_data->opline == NULL); } } phpdbg_catch_access { phpdbg_error("signalsegv", "", "Couldn't switch frames, invalid data source"); return; } phpdbg_end_try_access(); if (execute_data == NULL) { phpdbg_error("frame", "type=\"maxnum\" id=\"%d\"", "No frame #%d", frame); return; } phpdbg_restore_frame(); if (frame > 0) { PHPDBG_FRAME(num) = frame; /* backup things and jump back */ PHPDBG_FRAME(execute_data) = EG(current_execute_data); EG(current_execute_data) = execute_data; EG(scope) = PHPDBG_EX(func)->op_array.scope; } phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame); { const char *file_chr = zend_get_executed_filename(); zend_string *file = zend_string_init(file_chr, strlen(file_chr), 0); phpdbg_list_file(file, 3, zend_get_executed_lineno() - 1, zend_get_executed_lineno()); efree(file); } } /* }}} */
void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ { if (PHPDBG_FRAME(num) == 0) { return; } PHPDBG_FRAME(num) = 0; /* move things back */ EG(current_execute_data) = PHPDBG_FRAME(execute_data); EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); EG(active_symbol_table) = PHPDBG_EX(symbol_table); EG(This) = PHPDBG_EX(current_this); EG(scope) = PHPDBG_EX(current_scope); EG(called_scope) = PHPDBG_EX(current_called_scope); } /* }}} */