]> granicus.if.org Git - php/commitdiff
- Fix problem with debug_backtrace() reported by Stig. We weren't reporting
authorAndi Gutmans <andi@php.net>
Fri, 26 Jul 2002 10:38:25 +0000 (10:38 +0000)
committerAndi Gutmans <andi@php.net>
Fri, 26 Jul 2002 10:38:25 +0000 (10:38 +0000)
- 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.

Zend/zend.c
Zend/zend_builtin_functions.c
Zend/zend_compile.h
Zend/zend_execute.c

index a3d8d070695e1bc9b247fe6395f734e43c2b6a82..8871ce00e8546d2fbd19d1601433263320474593 100644 (file)
@@ -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)) {
index 946bf008f285bff0efabab4b2753138da9275c96..b826c5499194502ceab8fcc0e2c6bc6915e98f30 100644 (file)
@@ -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;
        }
 }
 /* }}} */
index b51d576ff113ec29caa3fb6b5ed5ecd244f6e8f9..cb007bf779484fb01f3056c4ee91e791790c0ca8 100644 (file)
@@ -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;
index fca3ff2a36dbb91d0d81d4979b12fc4998be20be..af50e25725e351c41f9d2b22792a2bc1d5b920b6 100644 (file)
@@ -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;