Skip to content

Commit cf35dae

Browse files
committed
phpdbg next command must stop when leaving function
1 parent 54d8053 commit cf35dae

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ PHP NEWS
6060

6161
- phpdbg:
6262
. Fixed bug #72996 (phpdbg_prompt.c undefined reference to DL_LOAD). (Nikita)
63+
. Fixed next command not stopping when leaving function. (Bob)
6364

6465
- Session:
6566
. Fixed bug #68015 (Session does not report invalid uid for files save handler).

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,12 +1541,18 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
15411541
goto next;
15421542
}
15431543

1544+
/* not while in conditionals */
1545+
phpdbg_print_opline_ex(execute_data, 0);
1546+
15441547
/* perform seek operation */
15451548
if ((PHPDBG_G(flags) & PHPDBG_SEEK_MASK) && !(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
15461549
/* current address */
15471550
zend_ulong address = (zend_ulong) execute_data->opline;
15481551

15491552
if (PHPDBG_G(seek_ex) != execute_data) {
1553+
if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) {
1554+
goto stepping;
1555+
}
15501556
goto next;
15511557
}
15521558

@@ -1590,10 +1596,8 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
15901596
}
15911597
}
15921598

1593-
/* not while in conditionals */
1594-
phpdbg_print_opline_ex(execute_data, 0);
1595-
15961599
if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) {
1600+
stepping:
15971601
PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;
15981602
DO_INTERACTIVE(1);
15991603
}

sapi/phpdbg/tests/next_001.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Test next command on function boundaries
3+
--PHPDBG--
4+
b 4
5+
r
6+
n
7+
8+
9+
q
10+
--EXPECTF--
11+
[Successful compilation of %s]
12+
prompt> [Breakpoint #0 added at %s:4]
13+
prompt> [Breakpoint #0 at %s:4, hits: 1]
14+
>00004: echo 0;
15+
00005: }
16+
00006:
17+
prompt> 0
18+
[L5 %s RETURN null %s]
19+
>00005: }
20+
00006:
21+
00007: foo();
22+
prompt> [L8 %s ECHO 1 %s]
23+
>00008: echo 1;
24+
00009:
25+
prompt> 1
26+
[L8 %s RETURN 1 %s]
27+
[Script ended normally]
28+
prompt>
29+
--FILE--
30+
<?php
31+
32+
function foo() {
33+
echo 0;
34+
}
35+
36+
foo();
37+
echo 1;

0 commit comments

Comments
 (0)