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