File php-phpdbg-fix-next-command.patch of Package php8

Source: https://github.com/devnexen/php-src/commit/f1191beb7e2fea21c9510d695de61a738ed35e3a.patch

From f1191beb7e2fea21c9510d695de61a738ed35e3a Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Wed, 3 Jul 2024 20:19:35 +0100
Subject: [PATCH] Fix bug #80006: fix next command on next line.

original PR GH-6031
---
 NEWS                            |  1 +
 sapi/phpdbg/phpdbg_prompt.c     |  4 +++-
 sapi/phpdbg/tests/bug80006.phpt | 26 ++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 sapi/phpdbg/tests/bug80006.phpt

#diff --git a/NEWS b/NEWS
#index f33c3842df40e..f90c7625a2dc0 100644
#--- a/NEWS
#+++ b/NEWS
#@@ -27,6 +27,7 @@ PHP                                                                        NEWS
# - PHPDBG:
#   . Fixed bug GH-14596 (crashes with ASAN and ZEND_RC_DEBUG=1).
#     (David Carlier)
#+  . Fixed bug 80006 (next command on function calls). (ebernhardson)
# 
# - Shmop:
#    . Fixed bug GH-14537 (shmop Windows 11 crashes the process). (nielsdos)
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index 994ac829b0a5e..5b99ecabe8565 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -1728,7 +1728,9 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
 			zend_ulong address = (zend_ulong) execute_data->opline;
 
 			if (PHPDBG_G(seek_ex) != execute_data) {
-				if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) {
+				if (PHPDBG_G(seek_ex)->prev_execute_data &&
+				    phpdbg_user_execute_data(PHPDBG_G(seek_ex)->prev_execute_data) == execute_data &&
+				    PHPDBG_G(flags) & PHPDBG_IS_STEPPING) {
 					goto stepping;
 				}
 				goto next;
diff --git a/sapi/phpdbg/tests/bug80006.phpt b/sapi/phpdbg/tests/bug80006.phpt
new file mode 100644
index 0000000000000..108c30dd1ea8c
--- /dev/null
+++ b/sapi/phpdbg/tests/bug80006.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test next command step over functionality
+--PHPDBG--
+b 7
+r
+n
+q
+--EXPECTF--
+[Successful compilation of %s]
+prompt> [Breakpoint #0 added at %s:7]
+prompt> [Breakpoint #0 at %s:7, hits: 1]
+>00007: foo();
+ 00008: echo 1;
+ 00009: 
+prompt> 0>00008: echo 1;
+ 00009: 
+prompt> 
+--FILE--
+<?php
+
+function foo() {
+	echo 0;
+}
+
+foo();
+echo 1;
openSUSE Build Service is sponsored by