@@ -274,7 +274,8 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */
274
274
Z_STR (startfile ) = zend_string_init (startfilename , strlen (startfilename ), 0 );
275
275
276
276
zend_hash_internal_pointer_reset_ex (Z_ARRVAL (zbacktrace ), & position );
277
- tmp = zend_hash_get_current_data_ex (Z_ARRVAL (zbacktrace ), & position );
277
+
278
+ zval * function_name = NULL ;
278
279
while ((tmp = zend_hash_get_current_data_ex (Z_ARRVAL (zbacktrace ), & position ))) {
279
280
if (file ) { /* userland */
280
281
phpdbg_out ("frame #%d: " , i );
@@ -289,10 +290,18 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */
289
290
290
291
file = zend_hash_str_find (Z_ARRVAL_P (tmp ), ZEND_STRL ("file" ));
291
292
line = zend_hash_str_find (Z_ARRVAL_P (tmp ), ZEND_STRL ("line" ));
293
+ function_name = zend_hash_find (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_FUNCTION ));
294
+
292
295
zend_hash_move_forward_ex (Z_ARRVAL (zbacktrace ), & position );
293
296
}
294
297
295
- phpdbg_writeln ("frame #%d: {main} at %s:" ZEND_LONG_FMT , i , Z_STRVAL_P (file ), Z_LVAL_P (line ));
298
+ /* This is possible for fibers' start closure for example, which have a frame that doesn't contain the info
299
+ * of which location stated the fiber if that stack frame is already torn down. same behaviour with debug_backtrace(). */
300
+ if (file == NULL ) {
301
+ phpdbg_writeln (" => %s (internal function)" , Z_STRVAL_P (function_name ));
302
+ } else {
303
+ phpdbg_writeln ("frame #%d: {main} at %s:" ZEND_LONG_FMT , i , Z_STRVAL_P (file ), Z_LVAL_P (line ));
304
+ }
296
305
297
306
zval_ptr_dtor_nogc (& zbacktrace );
298
307
zend_string_release (Z_STR (startfile ));
0 commit comments