cvs: ZendEngine2 / zend_default_classes.c

From: Date: Sat, 30 Aug 2003 18:58:40 +0000
Subject: cvs: ZendEngine2 / zend_default_classes.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1746@lists.php.net to get a copy of this message
helly Sat Aug 30 14:58:40 2003 EDT Modified files: /ZendEngine2 zend_default_classes.c Log: Add frame numer and finally display stack trace in the message. # # And voila - nice useable and helpfull exceptions in PHP. # Now we need to tell ppl 'anyway don't use them if possible'. # Index: ZendEngine2/zend_default_classes.c diff -u ZendEngine2/zend_default_classes.c:1.23 ZendEngine2/zend_default_classes.c:1.24 --- ZendEngine2/zend_default_classes.c:1.23 Sat Aug 30 14:28:24 2003 +++ ZendEngine2/zend_default_classes.c Sat Aug 30 14:58:40 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_default_classes.c,v 1.23 2003/08/30 18:28:24 helly Exp $ */ +/* $Id: zend_default_classes.c,v 1.24 2003/08/30 18:58:40 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -224,7 +224,7 @@ static int _build_trace_string(zval **frame, int num_args, va_list args, zend_hash_key *hash_key) { char *s_tmp, **str; - int *len; + int *len, *num; long line; HashTable *ht = Z_ARRVAL_PP(frame); zval **file, **tmp; @@ -232,6 +232,10 @@ str = va_arg(args, char**); len = va_arg(args, int*); + s_tmp = emalloc(Z_STRLEN_PP(file) + MAX_LENGTH_OF_LONG + 2 + 1); + sprintf(s_tmp, "#%d ", (*num)++); + TRACE_APPEND_STRL(s_tmp, strlen(s_tmp)); + efree(s_tmp); if (zend_hash_find(ht, "file", sizeof("file"), (void**)&file) == SUCCESS) { if (zend_hash_find(ht, "line", sizeof("line"), (void**)&tmp) == SUCCESS) { line = Z_LVAL_PP(tmp); @@ -261,10 +265,10 @@ { zval *trace; char *str = estrdup(""); - int len = 0; + int len = 0, 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, 2, &str, &len); + zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 2, &str, &len, &num); str[len] = '\0'; RETURN_STRINGL(str, len, 0); @@ -443,10 +447,31 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC) { if (instanceof_function(Z_OBJCE_P(exception), default_exception_ptr TSRMLS_CC)) { - zval *message = zend_read_property(default_exception_ptr, exception, "message", sizeof("message")-1, 1 TSRMLS_CC); - zval *file = zend_read_property(default_exception_ptr, exception, "file", sizeof("file")-1, 1 TSRMLS_CC); - zval *line = zend_read_property(default_exception_ptr, exception, "line", sizeof("line")-1, 1 TSRMLS_CC); - zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught exception '%s' with message '%s'", Z_OBJCE_P(exception)->name, Z_STRVAL_P(message)); + zend_fcall_info fci; + zval fname; + zval *str, *file, *line; + + file = zend_read_property(default_exception_ptr, exception, "file", sizeof("file")-1, 1 TSRMLS_CC); + line = zend_read_property(default_exception_ptr, exception, "line", sizeof("line")-1, 1 TSRMLS_CC); + + ZVAL_STRINGL(&fname, "tostring", sizeof("tostring")-1, 0); + + fci.size = sizeof(fci); + fci.function_table = &default_exception_ptr->function_table; + fci.function_name = &fname; + fci.symbol_table = NULL; + fci.object_pp = &exception; + fci.retval_ptr_ptr = &str; + fci.param_count = 0; + fci.params = NULL; + fci.no_separation = 1; + + zend_call_function(&fci, NULL TSRMLS_CC); + zval_ptr_dtor(&str); + + str = zend_read_property(default_exception_ptr, exception, "string", sizeof("string")-1, 1 TSRMLS_CC); + + zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n thrown", Z_STRVAL_P(str)); } else { zend_error(E_ERROR, "Uncaught exception '%s'", Z_OBJCE_P(exception)->name); }

« previous php.zend-engine.cvs (#1746) next »