Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sapi/phpdbg/phpdbg_bp.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,12 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */
zend_string_release(filename);
} break;

default: { /* do nothing */ } break;
default: {
phpdbg_asprintf(&new_str, "%sbreak %s\n", *str, conditional->code);
} break;
}
} else {
phpdbg_asprintf(&new_str, "%sbreak if %s\n", str, conditional->code);
phpdbg_asprintf(&new_str, "%sbreak if %s\n", *str, conditional->code);
}
} break;

Expand Down
25 changes: 24 additions & 1 deletion sapi/phpdbg/phpdbg_break.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,30 @@ const phpdbg_command_t phpdbg_break_commands[] = {

PHPDBG_BREAK(at) /* {{{ */
{
phpdbg_set_breakpoint_at(param);
switch (param->type) {
case NUMERIC_PARAM: {
if (!PHPDBG_G(exec)) {
phpdbg_error("inactive", "type=\"noexec\"", "Execution context not set!");
return FAILURE;
}

phpdbg_param_t new_param;
new_param = *(param);
new_param.file.name = phpdbg_current_file();
new_param.file.line = param->num;
new_param.len = strlen(phpdbg_current_file());
new_param.type = FILE_PARAM;

phpdbg_set_breakpoint_at(&new_param);

} break;

case FILE_PARAM: {
phpdbg_set_breakpoint_at(param);
} break;

phpdbg_default_switch_case();
}

return SUCCESS;
} /* }}} */
Expand Down
39 changes: 39 additions & 0 deletions sapi/phpdbg/tests/breakpoints_009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
Basic conditional breakpoint functionality
--PHPDBG--
b @ 3 if $i > 1
r
b @ 4 if $i > 2
info break
c
b @ 5 if $i > 10
c
q
--EXPECTF--
[Successful compilation of %s]
prompt> [Conditional breakpoint #0 added %s]
prompt> [Conditional breakpoint #0: at %s:3#3 %s at %s:3, hits: 1]
>00003: echo $i++;
00004: echo $i++;
00005: echo $i++;
prompt> [Conditional breakpoint #1 added %s]
prompt> ------------------------------------------------
Conditional Breakpoints:
#0%wat %s:3 if $i > 1
#1%wat %s:4 if $i > 2
prompt> 1
[Conditional breakpoint #1: at %s:4#4 %s at %s:4, hits: 1]
>00004: echo $i++;
00005: echo $i++;
00006: echo $i++;
prompt> [Conditional breakpoint #2 added %s]
prompt> 234
[Script ended normally]
prompt>
--FILE--
<?php
$i = 1;
echo $i++;
echo $i++;
echo $i++;
echo $i++;