]> granicus.if.org Git - php/commitdiff
Show full stacktraces for exceptions in phpdbg
authorBob Weinand <bobwei9@hotmail.com>
Mon, 20 Apr 2015 12:12:47 +0000 (14:12 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Mon, 20 Apr 2015 12:12:47 +0000 (14:12 +0200)
sapi/phpdbg/phpdbg_prompt.c

index aa2b1b8b0f93bba0906bc43b7e76c3c0ab4af1ca..6dfc8a8c80785d29270301970a18d8d822dc6464 100644 (file)
@@ -555,27 +555,30 @@ static inline void phpdbg_handle_exception(void) /* }}} */
 {
        zend_fcall_info fci;
        zval trace;
+       zend_object *ex = EG(exception);
 
        /* get filename and linenumber before unsetting exception */
        const char *filename = zend_get_executed_filename();
        uint32_t lineno = zend_get_executed_lineno();
 
+       EG(exception) = NULL;
+
        /* call __toString */
        ZVAL_STRINGL(&fci.function_name, "__tostring", sizeof("__tostring") - 1);
        fci.size = sizeof(fci);
-       fci.function_table = &EG(exception)->ce->function_table;
+       fci.function_table = &ex->ce->function_table;
        fci.symbol_table = NULL;
-       fci.object = EG(exception);
+       fci.object = ex;
        fci.retval = &trace;
        fci.param_count = 0;
        fci.params = NULL;
        fci.no_separation = 1;
        if (zend_call_function(&fci, NULL) == SUCCESS) {
-               phpdbg_writeln("exception", "name=\"%s\" trace=\"%.*s\"", "Uncaught %s!\n%.*s", EG(exception)->ce->name->val, Z_STRLEN(trace), Z_STRVAL(trace));
+               phpdbg_writeln("exception", "name=\"%s\" trace=\"%.*s\"", "Uncaught %s!\n%.*s", ex->ce->name->val, Z_STRLEN(trace), Z_STRVAL(trace));
 
                zval_ptr_dtor(&trace);
        } else {
-               phpdbg_error("exception", "name=\"%s\"", "Uncaught %s!", EG(exception)->ce->name->val);
+               phpdbg_error("exception", "name=\"%s\"", "Uncaught %s!", ex->ce->name->val);
        }
 
        /* output useful information about address */
@@ -587,8 +590,7 @@ static inline void phpdbg_handle_exception(void) /* }}} */
                OBJ_RELEASE(EG(prev_exception));
                EG(prev_exception) = 0;
        }
-       OBJ_RELEASE(EG(exception));
-       EG(exception) = NULL;
+       OBJ_RELEASE(ex);
        EG(opline_before_exception) = NULL;
 } /* }}} */