Improve fiber backtraces

The start/resume/throw execute_data is now attached as the prev_execute_data to the bottom frame of the fiber stack when the fiber is running.
This commit is contained in:
Aaron Piotrowski 2021-04-26 11:16:54 -05:00
parent f3465e6740
commit 810fb59f66
No known key found for this signature in database
GPG key ID: ADD1EF783EDE9EEB
13 changed files with 262 additions and 4 deletions

View file

@ -6790,6 +6790,7 @@ ZEND_METHOD(ReflectionFiber, getTrace)
{
zend_fiber *fiber = (zend_fiber *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj);
zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
zend_execute_data *prev_execute_data;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
@ -6798,6 +6799,9 @@ ZEND_METHOD(ReflectionFiber, getTrace)
REFLECTION_CHECK_VALID_FIBER(fiber);
prev_execute_data = fiber->stack_bottom->prev_execute_data;
fiber->stack_bottom->prev_execute_data = NULL;
if (EG(current_fiber) != fiber) {
// No need to replace current execute data if within the current fiber.
EG(current_execute_data) = fiber->execute_data;
@ -6806,6 +6810,7 @@ ZEND_METHOD(ReflectionFiber, getTrace)
zend_fetch_debug_backtrace(return_value, 0, options, 0);
EG(current_execute_data) = execute_data; // Restore original execute data.
fiber->stack_bottom->prev_execute_data = prev_execute_data; // Restore prev execute data on fiber stack.
}
ZEND_METHOD(ReflectionFiber, getExecutingLine)