1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 7 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2018 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 /* {{{ defines */ 25 #define PHPDBG_BREAK_FILE 0 26 #define PHPDBG_BREAK_FILE_PENDING 1 27 #define PHPDBG_BREAK_SYM 2 28 #define PHPDBG_BREAK_OPLINE 3 29 #define PHPDBG_BREAK_METHOD 4 30 #define PHPDBG_BREAK_COND 5 31 #define PHPDBG_BREAK_OPCODE 6 32 #define PHPDBG_BREAK_FUNCTION_OPLINE 7 33 #define PHPDBG_BREAK_METHOD_OPLINE 8 34 #define PHPDBG_BREAK_FILE_OPLINE 9 35 #define PHPDBG_BREAK_MAP 10 36 #define PHPDBG_BREAK_TABLES 11 /* }}} */ 37 38 /* {{{ */ 39 typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */ 40 41 /* {{{ breakpoint base structure */ 42 #define phpdbg_breakbase(name) \ 43 int id; \ 44 zend_uchar type; \ 45 zend_ulong hits; \ 46 zend_bool disabled; \ 47 const char *name /* }}} */ 48 49 /* {{{ breakpoint base */ 50 typedef struct _phpdbg_breakbase_t { 51 phpdbg_breakbase(name); 52 } phpdbg_breakbase_t; /* }}} */ 53 54 /** 55 * Breakpoint file-based representation 56 */ 57 typedef struct _phpdbg_breakfile_t { 58 phpdbg_breakbase(filename); 59 long line; 60 } phpdbg_breakfile_t; 61 62 /** 63 * Breakpoint symbol-based representation 64 */ 65 typedef struct _phpdbg_breaksymbol_t { 66 phpdbg_breakbase(symbol); 67 } phpdbg_breaksymbol_t; 68 69 /** 70 * Breakpoint method based representation 71 */ 72 typedef struct _phpdbg_breakmethod_t { 73 phpdbg_breakbase(class_name); 74 size_t class_len; 75 const char *func_name; 76 size_t func_len; 77 } phpdbg_breakmethod_t; 78 79 /** 80 * Breakpoint opline num based representation 81 */ 82 typedef struct _phpdbg_breakopline_t { 83 phpdbg_breakbase(func_name); 84 size_t func_len; 85 const char *class_name; 86 size_t class_len; 87 zend_ulong opline_num; 88 zend_ulong opline; 89 } phpdbg_breakopline_t; 90 91 /** 92 * Breakpoint opline based representation 93 */ 94 typedef struct _phpdbg_breakline_t { 95 phpdbg_breakbase(name); 96 zend_ulong opline; 97 phpdbg_breakopline_t *base; 98 } phpdbg_breakline_t; 99 100 /** 101 * Breakpoint opcode based representation 102 */ 103 typedef struct _phpdbg_breakop_t { 104 phpdbg_breakbase(name); 105 zend_ulong hash; 106 } phpdbg_breakop_t; 107 108 /** 109 * Breakpoint condition based representation 110 */ 111 typedef struct _phpdbg_breakcond_t { 112 phpdbg_breakbase(code); 113 size_t code_len; 114 zend_bool paramed; 115 phpdbg_param_t param; 116 zend_ulong hash; 117 zend_op_array *ops; 118 } phpdbg_breakcond_t; 119 120 /* {{{ Resolving breaks API */ 121 PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array); 122 PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array); 123 PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break); 124 PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint32_t filelen, zend_string *cur, HashTable *fileht); 125 PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file); /* }}} */ 126 127 /* {{{ Breakpoint Creation API */ 128 PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, size_t path_len, long lineno); 129 PHPDBG_API void phpdbg_set_breakpoint_symbol(const char* func_name, size_t func_name_len); 130 PHPDBG_API void phpdbg_set_breakpoint_method(const char* class_name, const char* func_name); 131 PHPDBG_API void phpdbg_set_breakpoint_opcode(const char* opname, size_t opname_len); 132 PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline); 133 PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline); 134 PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline); 135 PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline); 136 PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline); 137 PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len); 138 PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param); /* }}} */ 139 140 /* {{{ Breakpoint Detection API */ 141 PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data*); /* }}} */ 142 143 /* {{{ Misc Breakpoint API */ 144 PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t* brake, zend_bool output); 145 PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type); 146 PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t* brake); 147 PHPDBG_API void phpdbg_reset_breakpoints(void); 148 PHPDBG_API void phpdbg_clear_breakpoints(void); 149 PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num); 150 PHPDBG_API void phpdbg_enable_breakpoints(void); 151 PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id); 152 PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id); 153 PHPDBG_API void phpdbg_disable_breakpoints(void); /* }}} */ 154 155 /* {{{ Breakbase API */ 156 PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id); 157 PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey); /* }}} */ 158 159 /* {{{ Breakpoint Exportation API */ 160 PHPDBG_API void phpdbg_export_breakpoints(FILE *handle); 161 PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str); /* }}} */ 162 163 #endif /* PHPDBG_BP_H */ 164