Browse files

- Fix problem with debug_backtrace() reported by Stig. We weren't rep…

…orting

- 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.
  • Loading branch information...
1 parent 8d73650 commit 41e3f4f0c395d512efc71e437864dbedac901a23 @andigutmans andigutmans committed Jul 26, 2002
Showing with 18 additions and 35 deletions.
  1. +1 −8 Zend/zend.c
  2. +15 −27 Zend/zend_builtin_functions.c
  3. +1 −0 Zend/zend_compile.h
  4. +1 −0 Zend/zend_execute.c
View
9 Zend/zend.c
@@ -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)) {
View
42 Zend/zend_builtin_functions.c
@@ -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_";
- }
-
- ptr = ptr->prev_execute_data;
- if (!ptr) {
- zval_ptr_dtor(&stack_frame);
- break;
- }
-
- filename = ptr->function_state.function->op_array.filename;
+
+ filename = ptr->op_array->filename;
+ lineno = ptr->opline->lineno;
- if (!first_time) { /* Skip the first context which is debug_backtrace() itself */
+ 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);
- } else {
- first_time = 0;
}
-
- if (ptr->opline) {
- lineno = ptr->opline->lineno;
+ 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;
}
}
/* }}} */
View
1 Zend/zend_compile.h
@@ -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;
View
1 Zend/zend_execute.c
@@ -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;

0 comments on commit 41e3f4f

Please sign in to comment.