Skip to content

Commit 4997492

Browse files
committed
phpdbg next command must step over function calls
This was broken in cf35dae. The fix is to try to better target the fix applied in that patch to only instances where we have left the current context and entered the previous context.
1 parent d1ccb5b commit 4997492

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,16 +1764,16 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
17641764
goto next;
17651765
}
17661766

1767-
/* not while in conditionals */
1768-
phpdbg_print_opline_ex(execute_data, 0);
1769-
17701767
/* perform seek operation */
17711768
if ((PHPDBG_G(flags) & PHPDBG_SEEK_MASK) && !(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
17721769
/* current address */
17731770
zend_ulong address = (zend_ulong) execute_data->opline;
17741771

17751772
if (PHPDBG_G(seek_ex) != execute_data) {
1776-
if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) {
1773+
if (PHPDBG_G(seek_ex)->prev_execute_data &&
1774+
phpdbg_user_execute_data(PHPDBG_G(seek_ex)->prev_execute_data) == execute_data &&
1775+
PHPDBG_G(flags) & PHPDBG_IS_STEPPING) {
1776+
phpdbg_print_opline_ex(execute_data, 0);
17771777
goto stepping;
17781778
}
17791779
goto next;
@@ -1819,6 +1819,9 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
18191819
}
18201820
}
18211821

1822+
/* not while in conditionals */
1823+
phpdbg_print_opline_ex(execute_data, 0);
1824+
18221825
if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) {
18231826
stepping:
18241827
PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;

sapi/phpdbg/tests/next_002.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Test next command step over functionality
3+
--PHPDBG--
4+
b 7
5+
r
6+
n
7+
q
8+
--EXPECTF--
9+
[Successful compilation of %s]
10+
prompt> [Breakpoint #0 added at %s:7]
11+
prompt> [Breakpoint #0 at %s:7, hits: 1]
12+
>00007: foo();
13+
00008: echo 1;
14+
00009:
15+
prompt> 0
16+
[L8 %s ECHO 1 %s]
17+
>00008: echo 1;
18+
00009:
19+
prompt>
20+
--FILE--
21+
<?php
22+
23+
function foo() {
24+
echo 0;
25+
}
26+
27+
foo();
28+
echo 1;

0 commit comments

Comments
 (0)