diff options
author | Marcus Boerger <helly@php.net> | 2003-09-01 20:54:48 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2003-09-01 20:54:48 +0000 |
commit | d7fa986db8c11bfd55d85f96cd5fa1fd2467d801 (patch) | |
tree | 471eaf95f6ce3c122871c1b1349018613f1ade1e /Zend/zend_exceptions.c | |
parent | 0036ed90649a58c3dd4b07dd97269caef75e48dc (diff) | |
download | php-git-d7fa986db8c11bfd55d85f96cd5fa1fd2467d801.tar.gz |
Show {main} and prevent showing empty stack traces
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r-- | Zend/zend_exceptions.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 78f54c492d..cd6038431d 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -274,14 +274,19 @@ static int _build_trace_string(zval **frame, int num_args, va_list args, zend_ha ZEND_METHOD(exception, gettraceasstring) { zval *trace; - char *str = estrdup(""); - int len = 0, num = 0; + char *res = estrdup(""), **str = &res, *s_tmp; + int res_len = 0, *len = &res_len, num = 0; trace = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC); - zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, &str, &len, &num); + zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num); - str[len] = '\0'; - RETURN_STRINGL(str, len, 0); + s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1); + sprintf(s_tmp, "#%d {main}", num); + TRACE_APPEND_STRL(s_tmp, strlen(s_tmp)); + efree(s_tmp); + + res[res_len] = '\0'; + RETURN_STRINGL(res, res_len, 0); } /* }}} */ @@ -315,7 +320,7 @@ ZEND_METHOD(exception, tostring) str = emalloc(len); sprintf(str, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), - Z_STRVAL_P(trace)); + Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n"); len = strlen(str); /* We store the result in the private property string so we can access |