]> granicus.if.org Git - php/commitdiff
backtrace
authorkrakjoe <joe.watkins@live.co.uk>
Sun, 10 Nov 2013 15:49:35 +0000 (15:49 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Sun, 10 Nov 2013 15:49:35 +0000 (15:49 +0000)
phpdbg_prompt.c

index 50a7fef922b290397ece1ba1b5347b270cdf2c12..387ce74fd575e513d246937badcf59847e735919 100644 (file)
@@ -142,12 +142,28 @@ static PHPDBG_COMMAND(eval) { /* {{{ */
 
 static PHPDBG_COMMAND(back) { /* {{{ */
     if (EG(in_execution)) {
-        const zend_execute_data *current = EG(current_execute_data);
-        if (current) {
-            do {
-                printf("%d\n", current->opline->opcode);
-            } while ((current = current->prev_execute_data));
+        zval zbacktrace;
+        zval **tmp;
+        HashPosition position;
+        int i = 0;
+        int limit = (expr != NULL) ? atoi(expr) : 0;
+        
+        zend_fetch_debug_backtrace(
+            &zbacktrace, 0, 0, limit TSRMLS_CC);
+        
+        for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
+             zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == SUCCESS;
+             zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position)) {
+             if (i++) {
+                printf(",\n");
+             }
+             zend_print_flat_zval_r(*tmp TSRMLS_CC);
         }
+        
+        printf("\n");
+        
+        zval_dtor(&zbacktrace);
+        
         return SUCCESS;
     } else {
         printf("Not executing !\n");