Skip to content

Commit 057f11c

Browse files
committed
extend userland api phpdbg_break function
1 parent 38ed8d8 commit 057f11c

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

phpdbg.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */
5454
zend_execute = phpdbg_execute_ex;
5555
#endif
5656

57+
REGISTER_LONG_CONSTANT("PHPDBG_EMPTY", EMPTY_PARAM, CONST_CS|CONST_PERSISTENT);
58+
REGISTER_LONG_CONSTANT("PHPDBG_ADDR", ADDR_PARAM, CONST_CS|CONST_PERSISTENT);
59+
REGISTER_LONG_CONSTANT("PHPDBG_FILE", FILE_PARAM, CONST_CS|CONST_PERSISTENT);
60+
REGISTER_LONG_CONSTANT("PHPDBG_METHOD", METHOD_PARAM, CONST_CS|CONST_PERSISTENT);
61+
REGISTER_LONG_CONSTANT("PHPDBG_NUMERIC", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT);
62+
REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT);
63+
5764
return SUCCESS;
5865
} /* }}} */
5966

@@ -127,11 +134,44 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
127134
return SUCCESS;
128135
} /* }}} */
129136

130-
/* {{{ proto void phpdbg_break(void)
137+
/* {{{ proto void phpdbg_break([string expression])
131138
instructs phpdbg to insert a breakpoint at the next opcode */
132139
static PHP_FUNCTION(phpdbg_break)
133140
{
134-
if (EG(current_execute_data) && EG(active_op_array)) {
141+
if (ZEND_NUM_ARGS() > 0) {
142+
long type;
143+
char *expr = NULL;
144+
zend_uint expr_len = 0;
145+
146+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) {
147+
return;
148+
}
149+
150+
switch (type) {
151+
case METHOD_PARAM:
152+
phpdbg_do_break_method(
153+
expr, expr_len TSRMLS_CC);
154+
break;
155+
156+
case FILE_PARAM:
157+
phpdbg_do_break_file(
158+
expr, expr_len TSRMLS_CC);
159+
break;
160+
161+
case NUMERIC_PARAM:
162+
phpdbg_do_break_lineno(
163+
expr, expr_len TSRMLS_CC);
164+
break;
165+
166+
case STR_PARAM:
167+
phpdbg_do_break_func(
168+
expr, expr_len TSRMLS_CC);
169+
break;
170+
171+
default: zend_error(
172+
E_WARNING, "unrecognized parameter type %d", type);
173+
}
174+
} else if (EG(current_execute_data) && EG(active_op_array)) {
135175
zend_ulong opline_num = (EG(current_execute_data)->opline -
136176
EG(active_op_array)->opcodes);
137177

0 commit comments

Comments
 (0)