xref: /PHP-5.6/sapi/phpdbg/phpdbg_bp.h (revision 49493a2d)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2016 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Authors: Felipe Pena <felipe@php.net>                                |
16    | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
17    | Authors: Bob Weinand <bwoebi@php.net>                                |
18    +----------------------------------------------------------------------+
19 */
20 
21 #ifndef PHPDBG_BP_H
22 #define PHPDBG_BP_H
23 
24 /* {{{ */
25 typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */
26 
27 /* {{{ breakpoint base structure */
28 #define phpdbg_breakbase(name) \
29 	int         id; \
30 	zend_uchar  type; \
31 	zend_ulong  hits; \
32 	zend_bool   disabled; \
33 	const char *name /* }}} */
34 
35 /* {{{ breakpoint base */
36 typedef struct _phpdbg_breakbase_t {
37 	phpdbg_breakbase(name);
38 } phpdbg_breakbase_t; /* }}} */
39 
40 /**
41  * Breakpoint file-based representation
42  */
43 typedef struct _phpdbg_breakfile_t {
44 	phpdbg_breakbase(filename);
45 	long        line;
46 } phpdbg_breakfile_t;
47 
48 /**
49  * Breakpoint symbol-based representation
50  */
51 typedef struct _phpdbg_breaksymbol_t {
52 	phpdbg_breakbase(symbol);
53 } phpdbg_breaksymbol_t;
54 
55 /**
56  * Breakpoint method based representation
57  */
58 typedef struct _phpdbg_breakmethod_t {
59 	phpdbg_breakbase(class_name);
60 	size_t      class_len;
61 	const char *func_name;
62 	size_t      func_len;
63 } phpdbg_breakmethod_t;
64 
65 /**
66  * Breakpoint opline num based representation
67  */
68 typedef struct _phpdbg_breakopline_t {
69 	phpdbg_breakbase(func_name);
70 	size_t      func_len;
71 	const char *class_name;
72 	size_t      class_len;
73 	zend_ulong  opline_num;
74 	zend_ulong  opline;
75 } phpdbg_breakopline_t;
76 
77 /**
78  * Breakpoint opline based representation
79  */
80 typedef struct _phpdbg_breakline_t {
81 	phpdbg_breakbase(name);
82 	zend_ulong opline;
83 	phpdbg_breakopline_t *base;
84 } phpdbg_breakline_t;
85 
86 /**
87  * Breakpoint opcode based representation
88  */
89 typedef struct _phpdbg_breakop_t {
90 	phpdbg_breakbase(name);
91 	zend_ulong hash;
92 } phpdbg_breakop_t;
93 
94 /**
95  * Breakpoint condition based representation
96  */
97 typedef struct _phpdbg_breakcond_t {
98 	phpdbg_breakbase(code);
99 	size_t          code_len;
100 	zend_bool       paramed;
101 	phpdbg_param_t  param;
102 	zend_ulong      hash;
103 	zend_op_array  *ops;
104 } phpdbg_breakcond_t;
105 
106 /* {{{ Opline breaks API */
107 PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC);
108 PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC);
109 PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC); /* }}} */
110 
111 /* {{{ Breakpoint Creation API */
112 PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, long lineno TSRMLS_DC);
113 PHPDBG_API void phpdbg_set_breakpoint_symbol(const char* func_name, size_t func_name_len TSRMLS_DC);
114 PHPDBG_API void phpdbg_set_breakpoint_method(const char* class_name, const char* func_name TSRMLS_DC);
115 PHPDBG_API void phpdbg_set_breakpoint_opcode(const char* opname, size_t opname_len TSRMLS_DC);
116 PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC);
117 PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC);
118 PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline TSRMLS_DC);
119 PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC);
120 PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC);
121 PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len TSRMLS_DC);
122 PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC); /* }}} */
123 
124 /* {{{ Breakpoint Detection API */
125 PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data* TSRMLS_DC); /* }}} */
126 
127 /* {{{ Misc Breakpoint API */
128 PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t* brake, zend_bool output TSRMLS_DC);
129 PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC);
130 PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t* brake TSRMLS_DC);
131 PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D);
132 PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D);
133 PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC);
134 PHPDBG_API void phpdbg_enable_breakpoints(TSRMLS_D);
135 PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id TSRMLS_DC);
136 PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id TSRMLS_DC);
137 PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D); /* }}} */
138 
139 /* {{{ Breakbase API */
140 PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC);
141 PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */
142 
143 /* {{{ Breakpoint Exportation API */
144 PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */
145 
146 #endif /* PHPDBG_BP_H */
147