-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdebug.c
More file actions
141 lines (118 loc) · 4.16 KB
/
Copy pathsdebug.c
File metadata and controls
141 lines (118 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* sdebug extension for PHP */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php_sdebug.h"
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.remote_enable", "0", PHP_INI_ALL, OnUpdateLong, remote_enable, zend_sdebug_globals, sdebug_globals)
STD_PHP_INI_ENTRY("xdebug.remote_host", "127.0.0.1", PHP_INI_ALL, OnUpdateString, remote_host, zend_sdebug_globals, sdebug_globals)
STD_PHP_INI_ENTRY("xdebug.remote_port", "9000", PHP_INI_ALL, OnUpdateLong, remote_port, zend_sdebug_globals, sdebug_globals)
PHP_INI_END()
PHP_MINIT_FUNCTION(sdebug)
{
REGISTER_INI_ENTRIES();
SG(sockfd) = 0;
SG(status) = DBGP_STATUS_STARTING;
SG(lastcmd) = (char *)malloc(MAX_CMD_NAME_LEN + 1);
SG(transaction_id) = (char *)malloc(MAX_CMD_NAME_LEN + 1);
SG(do_step) = 0;
SG(breakpoint_list) = (HashTable *)malloc(sizeof(HashTable));
zend_hash_init(SG(breakpoint_list), 16, NULL, ZVAL_PTR_DTOR, 0);
return SUCCESS;
}
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(sdebug)
{
CG(compiler_options) = CG(compiler_options) | (ZEND_COMPILE_EXTENDED_INFO);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(sdebug)
{
php_info_print_table_start();
php_info_print_table_header(2, "sdebug support", "enabled");
php_info_print_table_end();
}
/* }}} */
/* {{{ sdebug_functions[]
*/
static const zend_function_entry sdebug_functions[] = {
PHP_FE_END
};
/* }}} */
/* {{{ sdebug_module_entry
*/
zend_module_entry sdebug_module_entry = {
STANDARD_MODULE_HEADER,
"sdebug", /* Extension name */
sdebug_functions, /* zend_function_entry */
PHP_MINIT(sdebug), /* PHP_MINIT - Module initialization */
NULL, /* PHP_MSHUTDOWN - Module shutdown */
PHP_RINIT(sdebug), /* PHP_RINIT - Request initialization */
NULL, /* PHP_RSHUTDOWN - Request shutdown */
PHP_MINFO(sdebug), /* PHP_MINFO - Module info */
PHP_SDEBUG_VERSION, /* Version */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifndef ZEND_EXT_API
# ifdef ZEND_WIN32
# define ZEND_EXT_API __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__ >= 4
# define ZEND_EXT_API __attribute__ ((visibility("default")))
# else
# define ZEND_EXT_API
# endif
#endif
static int sdebug_zend_startup(zend_extension *extension)
{
return zend_startup_module(&sdebug_module_entry);
}
void sdebug_statement_call(zend_execute_data *frame)
{
int lineno;
char *filename;
zend_op_array *op_array = &frame->func->op_array;
lineno = EG(current_execute_data)->opline->lineno;
filename = (char*) ZSTR_VAL(op_array->filename);
if (SG(remote_enable)) {
if (!SG(sockfd)) {
dbgp_init(filename);
}
if (SG(do_step)) {
SG(do_step) = 0;
dbgp_breakpoint_handler(filename, lineno, BREAKPOINT_TYPE_STEP);
return;
}
if (SG(breakpoint_list)->nNumUsed) {
char key[strlen(filename) + 8];
sprintf((char *)key, "%s:%d", filename, lineno);
if (zend_hash_str_exists(SG(breakpoint_list), key, strlen(key))) {
dbgp_breakpoint_handler(filename, lineno, BREAKPOINT_TYPE_BREAK);
}
}
}
}
ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, (char*) ZEND_EXTENSION_BUILD_ID };
ZEND_EXT_API zend_extension zend_extension_entry = {
(char*) "Sdebug",
(char*) PHP_SDEBUG_VERSION,
(char*) "mabu233",
(char*) PHP_SDEBUG_URL,
(char*) "",
sdebug_zend_startup,
NULL,
NULL, /* activate_func_t */
NULL, /* deactivate_func_t */
NULL, /* message_handler_func_t */
NULL, /* op_array_handler_func_t */
sdebug_statement_call, /* statement_handler_func_t */
NULL, /* fcall_begin_handler_func_t */
NULL, /* fcall_end_handler_func_t */
NULL, /* op_array_ctor_func_t */
NULL, /* op_array_dtor_func_t */
STANDARD_ZEND_EXTENSION_PROPERTIES
};