mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
- Fix problem with debug_backtrace() reported by Stig. We weren't reporting
- global function information because it wasn't available. We have to do - an additional assignment per-function call so that it'll be available. - Also don't define the global scope as function name _main_ but leave it - empty so that frameworks like Pear can decide what they want to do.
This commit is contained in:
parent
8d73650be2
commit
41e3f4f0c3
@ -813,13 +813,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
|
||||
zend_file_handle *file_handle;
|
||||
zend_op_array *orig_op_array = EG(active_op_array);
|
||||
zval *local_retval=NULL;
|
||||
zend_execute_data execute_data;
|
||||
|
||||
EX(prev_execute_data) = NULL;
|
||||
EG(current_execute_data) = &execute_data;
|
||||
EX(object) = NULL;
|
||||
EX(opline) = NULL;
|
||||
|
||||
|
||||
va_start(files, file_count);
|
||||
for (i=0; i<file_count; i++) {
|
||||
file_handle = va_arg(files, zend_file_handle *);
|
||||
@ -829,7 +823,6 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
|
||||
EG(active_op_array) = zend_compile_file(file_handle, ZEND_INCLUDE TSRMLS_CC);
|
||||
zend_destroy_file_handle(file_handle TSRMLS_CC);
|
||||
if (EG(active_op_array)) {
|
||||
EX(function_state).function = (zend_function *) EG(active_op_array);
|
||||
EG(return_value_ptr_ptr) = retval ? retval : &local_retval;
|
||||
zend_execute(EG(active_op_array) TSRMLS_CC);
|
||||
if (EG(exception)) {
|
||||
|
@ -1201,10 +1201,11 @@ ZEND_FUNCTION(debug_backtrace)
|
||||
char *class_name;
|
||||
zend_uint class_name_length;
|
||||
zval *stack_frame;
|
||||
zend_bool first_time = 1;
|
||||
|
||||
ptr = EG(current_execute_data);
|
||||
lineno = ptr->opline->lineno;
|
||||
|
||||
/* Skip debug_backtrace() itself */
|
||||
ptr = ptr->prev_execute_data;
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
@ -1222,35 +1223,22 @@ ZEND_FUNCTION(debug_backtrace)
|
||||
class_name = ptr->function_state.function->common.scope->name;
|
||||
}
|
||||
function_name = ptr->function_state.function->common.function_name;
|
||||
if (!function_name) {
|
||||
function_name = "_main_";
|
||||
|
||||
filename = ptr->op_array->filename;
|
||||
lineno = ptr->opline->lineno;
|
||||
|
||||
if (function_name) {
|
||||
add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
|
||||
}
|
||||
if (class_name) {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1);
|
||||
}
|
||||
add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
|
||||
add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno);
|
||||
/* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */
|
||||
add_next_index_zval(return_value, stack_frame);
|
||||
|
||||
ptr = ptr->prev_execute_data;
|
||||
if (!ptr) {
|
||||
zval_ptr_dtor(&stack_frame);
|
||||
break;
|
||||
}
|
||||
|
||||
filename = ptr->function_state.function->op_array.filename;
|
||||
|
||||
if (!first_time) { /* Skip the first context which is debug_backtrace() itself */
|
||||
add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
|
||||
if (class_name) {
|
||||
add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1);
|
||||
}
|
||||
add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
|
||||
add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno);
|
||||
/* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */
|
||||
|
||||
add_next_index_zval(return_value, stack_frame);
|
||||
} else {
|
||||
first_time = 0;
|
||||
}
|
||||
|
||||
if (ptr->opline) {
|
||||
lineno = ptr->opline->lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -188,6 +188,7 @@ typedef struct _zend_execute_data {
|
||||
zend_function_state function_state;
|
||||
zend_function *fbc; /* Function Being Called */
|
||||
zend_function *fbc_constructor;
|
||||
zend_op_array *op_array;
|
||||
zval *object;
|
||||
union _temp_variable *Ts;
|
||||
zend_bool original_in_execution;
|
||||
|
@ -1110,6 +1110,7 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC)
|
||||
EX(fbc) = NULL;
|
||||
EX(object) = NULL;
|
||||
EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable)*op_array->T);
|
||||
EX(op_array) = op_array;
|
||||
EX(original_in_execution) = EG(in_execution);
|
||||
EX(prev_execute_data) = EG(current_execute_data);
|
||||
EG(current_execute_data) = &execute_data;
|
||||
|
Loading…
Reference in New Issue
Block a user