File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 2020#include "zend_observer.h"
2121#include "zend_smart_str.h"
2222#include "ext/standard/php_var.h"
23+ #include "zend_generators.h"
2324
2425static zend_observer_fcall_handlers observer_fcall_init (zend_execute_data * execute_data );
2526
@@ -163,6 +164,11 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data)
163164 zend_execute_data * ex = execute_data ;
164165 php_printf ("%*s<!--\n" , 2 * ZT_G (observer_nesting_depth ), "" );
165166 do {
167+ if (UNEXPECTED (!ex -> func )) {
168+ ex = zend_generator_check_placeholder_frame (ex );
169+ ZEND_ASSERT (ex -> func );
170+ }
171+
166172 zend_function * fbc = ex -> func ;
167173 int indent = 2 * ZT_G (observer_nesting_depth ) + 4 ;
168174 if (fbc -> common .function_name ) {
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-16514: Nested generator in zend_test observer
3+ --EXTENSIONS--
4+ zend_test
5+ --INI--
6+ zend_test.observer.enabled=1
7+ zend_test.observer.show_init_backtrace=1
8+ --FILE--
9+ <?php
10+
11+ class Foo {
12+ public function __destruct () {
13+ debug_print_backtrace ();
14+ }
15+ }
16+ function bar () {
17+ yield from foo ();
18+ }
19+ function foo () {
20+ $ foo = new Foo ();
21+ yield ;
22+ }
23+ $ gen = bar ();
24+ foreach ($ gen as $ dummy );
25+
26+ ?>
27+ --EXPECTF--
28+ <!-- init '%sgh16514.php' -->
29+ <!--
30+ {main} %sgh16514.php
31+ -->
32+ <!-- init bar() -->
33+ <!--
34+ bar()
35+ {main} %sgh16514.php
36+ -->
37+ <!-- init foo() -->
38+ <!--
39+ foo()
40+ bar()
41+ {main} %sgh16514.php
42+ -->
43+ <!-- init Foo::__destruct() -->
44+ <!--
45+ Foo::__destruct()
46+ bar()
47+ {main} %sgh16514.php
48+ -->
49+ <!-- init debug_print_backtrace() -->
50+ <!--
51+ debug_print_backtrace()
52+ Foo::__destruct()
53+ bar()
54+ {main} %sgh16514.php
55+ -->
56+ #0 %s(%d): Foo->__destruct()
57+ #1 %s(%d): bar()
You can’t perform that action at this time.
0 commit comments