File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / zend_dtrace.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:35 2012 UTC (12 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    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: zend_dtrace.c,v 1.1.1.1 2012/05/29 12:34:35 misho Exp $ */
   20: 
   21: #include "zend.h"
   22: #include "zend_API.h"
   23: #include "zend_dtrace.h"
   24: 
   25: #ifdef HAVE_DTRACE
   26: /* PHP DTrace probes {{{ */
   27: static inline char *dtrace_get_executed_filename(TSRMLS_D)
   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;
   39: 	DTRACE_COMPILE_FILE_ENTRY(file_handle->opened_path, file_handle->filename);
   40: 	res = compile_file(file_handle, type TSRMLS_CC);
   41: 	DTRACE_COMPILE_FILE_RETURN(file_handle->opened_path, file_handle->filename);
   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;
   50: 	char *scope, *filename, *funcname, *classname;
   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: 		filename = dtrace_get_executed_filename(TSRMLS_C);
   62: 		classname = get_active_class_name(&scope TSRMLS_CC);
   63: 		funcname = get_active_function_name(TSRMLS_C);
   64: 		lineno = zend_get_executed_lineno(TSRMLS_C);
   65: 	}
   66: 
   67: 	if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
   68: 		DTRACE_EXECUTE_ENTRY(filename, lineno);
   69: 	}
   70: 
   71: 	if (DTRACE_FUNCTION_ENTRY_ENABLED() && funcname != NULL) {
   72: 		DTRACE_FUNCTION_ENTRY(funcname, filename, lineno, classname, scope);
   73: 	}
   74: 
   75: 	execute(op_array TSRMLS_CC);
   76: 
   77: 	if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) {
   78: 		DTRACE_FUNCTION_RETURN(funcname, filename, lineno, classname, scope);
   79: 	}
   80: 
   81: 	if (DTRACE_EXECUTE_RETURN_ENABLED()) {
   82: 		DTRACE_EXECUTE_RETURN(filename, lineno);
   83: 	}
   84: }
   85: 
   86: ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC)
   87: {
   88: 	int lineno;
   89: 	char *filename;
   90: 	if (DTRACE_EXECUTE_ENTRY_ENABLED() || DTRACE_EXECUTE_RETURN_ENABLED()) {
   91: 		filename = dtrace_get_executed_filename(TSRMLS_C);
   92: 		lineno = zend_get_executed_lineno(TSRMLS_C);
   93: 	}
   94: 
   95: 	if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
   96: 		DTRACE_EXECUTE_ENTRY(filename, lineno);
   97: 	}
   98: 
   99: 	execute_internal(execute_data_ptr, return_value_used TSRMLS_CC);
  100: 
  101: 	if (DTRACE_EXECUTE_RETURN_ENABLED()) {
  102: 		DTRACE_EXECUTE_RETURN(filename, lineno);
  103: 	}
  104: }
  105: 
  106: /* }}} */
  107: #endif /* HAVE_DTRACE */
  108: 

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