xref: /PHP-8.0/Zend/zend_vm_trace_lines.h (revision a60cdcf0)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 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: Dmitry Stogov <dmitry@php.net>                              |
16    +----------------------------------------------------------------------+
17 */
18 
19 #include "zend_sort.h"
20 
21 #define VM_TRACE(op)     zend_vm_trace(execute_data, opline);
22 #define VM_TRACE_START() zend_vm_trace_init();
23 #define VM_TRACE_END()   zend_vm_trace_finish();
24 
25 static FILE *vm_trace_file;
26 
zend_vm_trace(const zend_execute_data * execute_data,const zend_op * opline)27 static void zend_vm_trace(const zend_execute_data *execute_data, const zend_op *opline)
28 {
29 	if (EX(func) && EX(func)->op_array.filename) {
30 		fprintf(vm_trace_file, "%s:%d\n", ZSTR_VAL(EX(func)->op_array.filename), opline->lineno);
31 	}
32 }
33 
zend_vm_trace_finish(void)34 static void zend_vm_trace_finish(void)
35 {
36 	fclose(vm_trace_file);
37 }
38 
zend_vm_trace_init(void)39 static void zend_vm_trace_init(void)
40 {
41 	vm_trace_file = fopen("zend_vm_trace.log", "w+");
42 }
43