root/Zend/zend_dtrace.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dtrace_get_executed_filename
  2. dtrace_compile_file
  3. dtrace_execute_ex
  4. dtrace_execute_internal

   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 {{{ */
  27 static inline const 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, (char *)file_handle->filename);
  40         res = compile_file(file_handle, type TSRMLS_CC);
  41         DTRACE_COMPILE_FILE_RETURN(file_handle->opened_path, (char *)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_ex(zend_execute_data *execute_data TSRMLS_DC)
  48 {
  49         int lineno;
  50         const 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                 classname = get_active_class_name(&scope TSRMLS_CC);
  62                 funcname = get_active_function_name(TSRMLS_C);
  63         }
  64 
  65         if (DTRACE_EXECUTE_ENTRY_ENABLED()) {
  66                 DTRACE_EXECUTE_ENTRY((char *)filename, lineno);
  67         }
  68 
  69         if (DTRACE_FUNCTION_ENTRY_ENABLED() && funcname != NULL) {
  70                 DTRACE_FUNCTION_ENTRY((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
  71         }
  72 
  73         execute_ex(execute_data TSRMLS_CC);
  74 
  75         if (DTRACE_FUNCTION_RETURN_ENABLED() && funcname != NULL) {
  76                 DTRACE_FUNCTION_RETURN((char *)funcname, (char *)filename, lineno, (char *)classname, (char *)scope);
  77         }
  78 
  79         if (DTRACE_EXECUTE_RETURN_ENABLED()) {
  80                 DTRACE_EXECUTE_RETURN((char *)filename, lineno);
  81         }
  82 }
  83 
  84 ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC)
  85 {
  86         int lineno;
  87         const char *filename;
  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()) {
  94                 DTRACE_EXECUTE_ENTRY((char *)filename, lineno);
  95         }
  96 
  97         execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC);
  98 
  99         if (DTRACE_EXECUTE_RETURN_ENABLED()) {
 100                 DTRACE_EXECUTE_RETURN((char *)filename, lineno);
 101         }
 102 }
 103 
 104 /* }}} */
 105 #endif /* HAVE_DTRACE */
 106 

/* [<][>][^][v][top][bottom][index][help] */