Annotation of embedaddon/php/Zend/zend_dtrace.c, revision 1.1.1.2

1.1       misho       1: /*
                      2:    +----------------------------------------------------------------------+
                      3:    | Zend Engine                                                          |
                      4:    +----------------------------------------------------------------------+
                      5:    | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
                      6:    +----------------------------------------------------------------------+
                      7:    | This source file is subject to version 2.00 of the Zend license,     |
                      8:    | that is bundled with this package in the file LICENSE, and is        |
                      9:    | available through the world-wide-web at the following url:           |
                     10:    | http://www.zend.com/license/2_00.txt.                                |
                     11:    | If you did not receive a copy of the Zend license and are unable to  |
                     12:    | obtain it through the world-wide-web, please send a note to          |
                     13:    | license@zend.com so we can mail you a copy immediately.              |
                     14:    +----------------------------------------------------------------------+
                     15:    | Authors: David Soria Parra <david.soriaparra@sun.com>                |
                     16:    +----------------------------------------------------------------------+
                     17: */
                     18: 
                     19: /* $Id: $ */
                     20: 
                     21: #include "zend.h"
                     22: #include "zend_API.h"
                     23: #include "zend_dtrace.h"
                     24: 
                     25: #ifdef HAVE_DTRACE
                     26: /* PHP DTrace probes {{{ */
1.1.1.2 ! misho      27: static inline const char *dtrace_get_executed_filename(TSRMLS_D)
1.1       misho      28: {
                     29:        if (EG(current_execute_data) && EG(current_execute_data)->op_array) {
                     30:                return EG(current_execute_data)->op_array->filename;
                     31:        } else {
                     32:                return zend_get_executed_filename(TSRMLS_C);
                     33:        }
                     34: }
                     35: 
                     36: ZEND_API zend_op_array *dtrace_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC)
                     37: {
                     38:        zend_op_array *res;
1.1.1.2 ! misho      39:        DTRACE_COMPILE_FILE_ENTRY(file_handle->opened_path, (char *)file_handle->filename);
1.1       misho      40:        res = compile_file(file_handle, type TSRMLS_CC);
1.1.1.2 ! misho      41:        DTRACE_COMPILE_FILE_RETURN(file_handle->opened_path, (char *)file_handle->filename);
1.1       misho      42: 
                     43:        return res;
                     44: }
                     45: 
                     46: /* We wrap the execute function to have fire the execute-entry/return and function-entry/return probes */
                     47: ZEND_API void dtrace_execute(zend_op_array *op_array TSRMLS_DC)
                     48: {
                     49:        int lineno;
1.1.1.2 ! misho      50:        const char *scope, *filename, *funcname, *classname;
1.1       misho      51:        scope = filename = funcname = classname = NULL;
                     52: 
                     53:        /* we need filename and lineno for both execute and function probes */
                     54:        if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()
                     55:                || DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) {
                     56:                filename = dtrace_get_executed_filename(TSRMLS_C);
                     57:                lineno = zend_get_executed_lineno(TSRMLS_C);
                     58:        }
                     59: 
                     60:        if (DTRACE_FUNCTION_ENTRY_ENABLED() || DTRACE_FUNCTION_RETURN_ENABLED()) {
                     61:                classname = get_active_class_name(&scope TSRMLS_CC);
                     62:                funcname = get_active_function_name(TSRMLS_C);
                     63:        }
                     64: 
                     65:        if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
1.1.1.2 ! misho      66:                DTRACE_EXECUTE_ENTRY((char *)filename, lineno);
1.1       misho      67:        }
                     68: 
                     69:        if (DTRACE_FUNCTION_ENTRY_ENABLED() && funcname != NULL) {
1.1.1.2 ! misho      70:                DTRACE_FUNCTION_ENTRY((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
1.1       misho      71:        }
                     72: 
                     73:        execute(op_array TSRMLS_CC);
                     74: 
                     75:        if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) {
1.1.1.2 ! misho      76:                DTRACE_FUNCTION_RETURN((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
1.1       misho      77:        }
                     78: 
                     79:        if (DTRACE_EXECUTE_RETURN_ENABLED()) {
1.1.1.2 ! misho      80:                DTRACE_EXECUTE_RETURN((char *)filename, lineno);
1.1       misho      81:        }
                     82: }
                     83: 
                     84: ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC)
                     85: {
                     86:        int lineno;
1.1.1.2 ! misho      87:        const char *filename;
1.1       misho      88:        if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()) {
                     89:                filename = dtrace_get_executed_filename(TSRMLS_C);
                     90:                lineno = zend_get_executed_lineno(TSRMLS_C);
                     91:        }
                     92: 
                     93:        if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
1.1.1.2 ! misho      94:                DTRACE_EXECUTE_ENTRY((char *)filename, lineno);
1.1       misho      95:        }
                     96: 
                     97:        execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
                     98: 
                     99:        if (DTRACE_EXECUTE_RETURN_ENABLED()) {
1.1.1.2 ! misho     100:                DTRACE_EXECUTE_RETURN((char *)filename, lineno);
1.1       misho     101:        }
                    102: }
                    103: 
                    104: /* }}} */
                    105: #endif /* HAVE_DTRACE */
                    106: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>