summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2007-10-11 01:03:19 +0000
committerMarcus Boerger <helly@php.net>2007-10-11 01:03:19 +0000
commit8ce1211a626c1e487f7b4b9407fc345cb22aa9c2 (patch)
tree903d9d5b6afa75085bd802adaceb5fdc00e966b5 /Zend
parent50250dff8c5e1e6d47b309dc904b180e42d54065 (diff)
downloadphp-git-8ce1211a626c1e487f7b4b9407fc345cb22aa9c2.tar.gz
- MFH debug object helper
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.c39
-rw-r--r--Zend/zend_object_handlers.c15
-rw-r--r--Zend/zend_object_handlers.h5
-rw-r--r--Zend/zend_operators.h3
4 files changed, 37 insertions, 25 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 1921b07a3f..e7767ceadf 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -317,7 +317,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC)
HashTable *properties = NULL;
char *class_name = NULL;
zend_uint clen;
-
+
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
@@ -367,10 +367,11 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
break;
case IS_OBJECT:
{
- HashTable *properties = NULL;
+ HashTable *properties;
char *class_name = NULL;
zend_uint clen;
-
+ int is_temp;
+
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
@@ -383,17 +384,19 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
if (class_name) {
efree(class_name);
}
- if (Z_OBJ_HANDLER_P(expr, get_properties)) {
- properties = Z_OBJPROP_P(expr);
+ if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
+ break;
}
- if (properties) {
- if (++properties->nApplyCount>1) {
- ZEND_PUTS_EX(" *RECURSION*");
- properties->nApplyCount--;
- return;
- }
- print_hash(write_func, properties, indent, 1 TSRMLS_CC);
+ if (++properties->nApplyCount>1) {
+ ZEND_PUTS_EX(" *RECURSION*");
properties->nApplyCount--;
+ return;
+ }
+ print_hash(write_func, properties, indent, 1 TSRMLS_CC);
+ properties->nApplyCount--;
+ if (is_temp) {
+ zend_hash_destroy(properties);
+ efree(properties);
}
break;
}
@@ -711,7 +714,7 @@ void zend_post_startup(TSRMLS_D)
short_tags_default = CG(short_tags);
ct_pass_ref_default = CG(allow_call_time_pass_reference);
extended_info_default = CG(extended_info);
-
+
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
free(compiler_globals->function_table);
free(compiler_globals->class_table);
@@ -839,7 +842,7 @@ void zend_deactivate_modules(TSRMLS_D)
} zend_end_try();
}
-void zend_call_destructors(TSRMLS_D)
+void zend_call_destructors(TSRMLS_D)
{
zend_try {
shutdown_destructors(TSRMLS_C);
@@ -1026,11 +1029,11 @@ ZEND_API void zend_error(int type, const char *format, ...)
orig_user_error_handler = EG(user_error_handler);
EG(user_error_handler) = NULL;
-
+
/* User error handler may include() additinal PHP files.
* If an error was generated during comilation PHP will compile
- * such scripts recursivly, but some CG() variables may be
- * inconsistent. */
+ * such scripts recursivly, but some CG() variables may be
+ * inconsistent. */
in_compilation = zend_is_compiling(TSRMLS_C);
if (in_compilation) {
@@ -1056,7 +1059,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
if (!EG(user_error_handler)) {
EG(user_error_handler) = orig_user_error_handler;
- }
+ }
else {
zval_ptr_dtor(&orig_user_error_handler);
}
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index e0260c1a65..b71df7c8ec 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -42,14 +42,14 @@
set, we call __set handler. If it fails, we do not change the array.
for both handlers above, when we are inside __get/__set, no further calls for
- __get/__set for this property of this object will be made, to prevent endless
+ __get/__set for this property of this object will be made, to prevent endless
recursion and enable accessors to change properties array.
if we have __call and method which is not part of the class function table is
called, we cal __call handler.
*/
-static HashTable *zend_std_get_properties(zval *object TSRMLS_DC)
+ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC)
{
zend_object *zobj;
zobj = Z_OBJ_P(object);
@@ -316,7 +316,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC)
#if DEBUG_OBJECT_HANDLERS
fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), Z_STRVAL_P(member));
-#endif
+#endif
/* make zend_get_property_info silent if we have getter - we may want to use it */
property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__get != NULL) TSRMLS_CC);
@@ -758,11 +758,11 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, char *method
zend_function *fbc;
char *lc_method_name;
zval *object = *object_ptr;
-
+
lc_method_name = do_alloca(method_len+1);
/* Create a zend_copy_str_tolower(dest, src, src_length); */
zend_str_tolower_copy(lc_method_name, method_name, method_len);
-
+
zobj = Z_OBJ_P(object);
if (zend_hash_find(&zobj->ce->function_table, lc_method_name, method_len+1, (void **)&fbc) == FAILURE) {
free_alloca(lc_method_name);
@@ -830,7 +830,7 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{
zval *method_name_ptr, *method_args_ptr;
zval *method_result_ptr = NULL;
zend_class_entry *ce = EG(scope);
-
+
ALLOC_ZVAL(method_args_ptr);
INIT_PZVAL(method_args_ptr);
array_init(method_args_ptr);
@@ -883,7 +883,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *f
callstatic_user_call->arg_info = NULL;
callstatic_user_call->num_args = 0;
callstatic_user_call->scope = ce;
- callstatic_user_call->fn_flags = ZEND_ACC_STATIC | ZEND_ACC_PUBLIC;
+ callstatic_user_call->fn_flags = ZEND_ACC_STATIC | ZEND_ACC_PUBLIC;
callstatic_user_call->function_name = estrndup(function_name_strval, function_name_strlen);
callstatic_user_call->pass_rest_by_reference = 0;
callstatic_user_call->return_reference = ZEND_RETURN_VALUE;
@@ -1202,6 +1202,7 @@ ZEND_API zend_object_handlers std_object_handlers = {
zend_std_compare_objects, /* compare_objects */
zend_std_cast_object_tostring, /* cast_object */
NULL, /* count_elements */
+ NULL, /* get_debug_info */
};
/*
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index 8c27ae6340..83dd72356c 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -80,6 +80,8 @@ typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_
/* Used to get hash of the properties of the object, as hash of zval's */
typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC);
+typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TSRMLS_DC);
+
/* Used to call methods */
/* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
@@ -132,6 +134,7 @@ struct _zend_object_handlers {
zend_object_compare_t compare_objects;
zend_object_cast_t cast_object;
zend_object_count_elements_t count_elements;
+ zend_object_get_debug_info_t get_debug_info;
};
extern ZEND_API zend_object_handlers std_object_handlers;
@@ -143,6 +146,8 @@ ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *pr
ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC);
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
+ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC);
+ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC);
ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index c20c57088c..f5c6251ca7 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -387,6 +387,7 @@ END_EXTERN_C()
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC)
#define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf
#define Z_RESVAL(zval) (zval).value.lval
+#define Z_OBJDEBUG(zval,is_tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&is_tmp TSRMLS_CC):(is_tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
@@ -401,6 +402,7 @@ END_EXTERN_C()
#define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*zval_p)
#define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*zval_p)
#define Z_OBJ_HANDLER_P(zval_p, h) Z_OBJ_HANDLER(*zval_p, h)
+#define Z_OBJDEBUG_P(zval_p,is_tmp) Z_OBJDEBUG(*zval_p,is_tmp)
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
@@ -415,6 +417,7 @@ END_EXTERN_C()
#define Z_OBJ_HANDLE_PP(zval_p) Z_OBJ_HANDLE(**zval_p)
#define Z_OBJ_HT_PP(zval_p) Z_OBJ_HT(**zval_p)
#define Z_OBJ_HANDLER_PP(zval_p, h) Z_OBJ_HANDLER(**zval_p, h)
+#define Z_OBJDEBUG_PP(zval_pp,is_tmp) Z_OBJDEBUG(**zval_pp,is_tmp)
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)