@@ -245,12 +245,10 @@ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */
245
245
246
246
void phpdbg_dump_backtrace (size_t num ) /* {{{ */
247
247
{
248
- HashPosition position ;
249
248
zval zbacktrace ;
250
249
zval * tmp ;
251
- zval startline , startfile ;
252
- const char * startfilename ;
253
- zval * file = & startfile , * line = & startline ;
250
+ zend_string * file = NULL ;
251
+ zend_long line = 0 ;
254
252
int i = 0 , limit = num ;
255
253
256
254
PHPDBG_OUTPUT_BACKUP ();
@@ -269,42 +267,39 @@ void phpdbg_dump_backtrace(size_t num) /* {{{ */
269
267
return ;
270
268
} phpdbg_end_try_access ();
271
269
272
- Z_LVAL (startline ) = zend_get_executed_lineno ();
273
- startfilename = zend_get_executed_filename ();
274
- Z_STR (startfile ) = zend_string_init (startfilename , strlen (startfilename ), 0 );
275
-
276
- zend_hash_internal_pointer_reset_ex (Z_ARRVAL (zbacktrace ), & position );
270
+ line = zend_get_executed_lineno ();
271
+ file = zend_get_executed_filename_ex ();
277
272
278
273
zval * function_name = NULL ;
279
- while (( tmp = zend_hash_get_current_data_ex ( Z_ARRVAL (zbacktrace ), & position )) ) {
274
+ ZEND_HASH_FOREACH_VAL ( Z_ARRVAL (zbacktrace ), tmp ) {
280
275
if (file ) { /* userland */
281
276
phpdbg_out ("frame #%d: " , i );
282
277
phpdbg_dump_prototype (tmp );
283
- phpdbg_out (" at %s:" ZEND_LONG_FMT "\n" , Z_STRVAL_P (file ), Z_LVAL_P ( line ) );
278
+ phpdbg_out (" at %s:" ZEND_LONG_FMT "\n" , ZSTR_VAL (file ), line );
284
279
i ++ ;
285
280
} else {
286
281
phpdbg_out (" => " );
287
282
phpdbg_dump_prototype (tmp );
288
283
phpdbg_out (" (internal function)\n" );
289
284
}
290
285
291
- file = zend_hash_find (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_FILE ));
292
- line = zend_hash_find (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_LINE ));
286
+ file = zend_hash_find_ptr (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_FILE ));
287
+ zval * line_zv = zend_hash_find (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_LINE ));
288
+ if (line_zv ) {
289
+ line = Z_LVAL_P (line_zv );
290
+ }
293
291
function_name = zend_hash_find (Z_ARRVAL_P (tmp ), ZSTR_KNOWN (ZEND_STR_FUNCTION ));
294
-
295
- zend_hash_move_forward_ex (Z_ARRVAL (zbacktrace ), & position );
296
- }
292
+ } ZEND_HASH_FOREACH_END ();
297
293
298
294
/* This is possible for fibers' start closure for example, which have a frame that doesn't contain the info
299
295
* of which location stated the fiber if that stack frame is already torn down. same behaviour with debug_backtrace(). */
300
296
if (file == NULL ) {
301
297
phpdbg_writeln (" => %s (internal function)" , Z_STRVAL_P (function_name ));
302
298
} else {
303
- phpdbg_writeln ("frame #%d: {main} at %s:" ZEND_LONG_FMT , i , Z_STRVAL_P (file ), Z_LVAL_P ( line ) );
299
+ phpdbg_writeln ("frame #%d: {main} at %s:" ZEND_LONG_FMT , i , ZSTR_VAL (file ), line );
304
300
}
305
301
306
302
zval_ptr_dtor_nogc (& zbacktrace );
307
- zend_string_release (Z_STR (startfile ));
308
303
309
304
PHPDBG_OUTPUT_BACKUP_RESTORE ();
310
305
} /* }}} */
0 commit comments