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