Skip to content

Commit 2fa3479

Browse files
committed
Added conditional opline num support
1 parent bba7362 commit 2fa3479

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

phpdbg_bp.c

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
916916
zend_function *function = (zend_function*) execute_data->function_state.function;
917917

918918
switch (param->type) {
919+
case NUMERIC_FUNCTION_PARAM:
919920
case STR_PARAM: {
920921
/* function breakpoint */
921922

@@ -926,12 +927,12 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
926927
{
927928
const char *str = NULL;
928929
size_t len = 0L;
929-
zend_op_array *ops = (zend_op_array*)function;
930+
zend_op_array *ops = (zend_op_array*)function;
930931
str = ops->function_name ? ops->function_name : "main";
931932
len = strlen(str);
932933

933-
if (len == param->len) {
934-
return (memcmp(param->str, str, len) == SUCCESS);
934+
if (len == param->len && memcmp(param->str, str, len) == SUCCESS) {
935+
return param->type == STR_PARAM || execute_data->opline - ops->opcodes == param->num;
935936
}
936937
}
937938
} break;
@@ -948,6 +949,7 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
948949
}
949950
} break;
950951

952+
case NUMERIC_METHOD_PARAM:
951953
case METHOD_PARAM: {
952954
if (function->type != ZEND_USER_FUNCTION) {
953955
return 0;
@@ -957,18 +959,13 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
957959
zend_op_array *ops = (zend_op_array*) function;
958960

959961
if (ops->scope) {
960-
size_t lengths[2] = {
961-
strlen(param->method.class), ops->scope->name_length};
962-
if (lengths[0] == lengths[1]) {
963-
if (memcmp(param->method.class,
964-
ops->scope->name, lengths[0]) == SUCCESS) {
965-
lengths[0] = strlen(param->method.name);
966-
lengths[1] = strlen(ops->function_name);
967-
968-
if (lengths[0] == lengths[1]) {
969-
return (memcmp(param->method.name,
970-
ops->function_name, lengths[0]) == SUCCESS);
971-
}
962+
size_t lengths[2] = {strlen(param->method.class), ops->scope->name_length};
963+
if (lengths[0] == lengths[1] && memcmp(param->method.class, ops->scope->name, lengths[0]) == SUCCESS) {
964+
lengths[0] = strlen(param->method.name);
965+
lengths[1] = strlen(ops->function_name);
966+
967+
if (lengths[0] == lengths[1] && memcmp(param->method.name, ops->function_name, lengths[0]) == SUCCESS) {
968+
return param->type == METHOD_PARAM || (execute_data->opline - ops->opcodes) == param->num;
972969
}
973970
}
974971
}
@@ -1584,6 +1581,15 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
15841581
((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
15851582
break;
15861583

1584+
case NUMERIC_FUNCTION_PARAM:
1585+
phpdbg_writeln("#%d\t\tat %s#%ld if %s%s",
1586+
brake->id,
1587+
brake->param.str,
1588+
brake->param.num,
1589+
brake->code,
1590+
((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
1591+
break;
1592+
15871593
case METHOD_PARAM:
15881594
phpdbg_writeln("#%d\t\tat %s::%s if %s%s",
15891595
brake->id,
@@ -1593,6 +1599,16 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
15931599
((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
15941600
break;
15951601

1602+
case NUMERIC_METHOD_PARAM:
1603+
phpdbg_writeln("#%d\t\tat %s::%s#%ld if %s%s",
1604+
brake->id,
1605+
brake->param.method.class,
1606+
brake->param.method.name,
1607+
brake->param.num,
1608+
brake->code,
1609+
((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
1610+
break;
1611+
15961612
case FILE_PARAM:
15971613
phpdbg_writeln("#%d\t\tat %s:%lu if %s%s",
15981614
brake->id,

0 commit comments

Comments
 (0)