From: Bob Weinand Date: Mon, 20 Oct 2014 14:05:37 +0000 (+0200) Subject: Add values of scalars to info vars/globals X-Git-Tag: php-5.6.3RC1~51^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c6b356f637c1677a4f1b6f946fb899c2769aea5;p=php Add values of scalars to info vars/globals --- diff --git a/phpdbg_info.c b/phpdbg_info.c index fee8368ab6..e7857e1ff5 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -173,7 +173,7 @@ static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) { } if (zend_hash_num_elements(&vars)) { - phpdbg_out("Address\t\tRefs\tType\t\tVariable"); + phpdbg_out("Address Refs Type Variable\n"); for (zend_hash_internal_pointer_reset_ex(&vars, &pos); zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS; zend_hash_move_forward_ex(&vars, &pos)) { @@ -184,23 +184,42 @@ static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) { phpdbg_try_access { if (!(invalid_data = !*data)) { -#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%s\" " attrs, "%p\t%d\t(%s)\n%s$%s", *data, Z_REFCOUNT_PP(data), zend_zval_type_name(*data), Z_ISREF_PP(data) ? "&": "", var, ##__VA_ARGS__) - - if (Z_TYPE_PP(data) == IS_RESOURCE) { - phpdbg_try_access { - int type; - VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", zend_list_find(Z_RESVAL_PP(data), &type) ? zend_rsrc_list_get_rsrc_type(type TSRMLS_CC) : "unknown"); - } phpdbg_catch_access { - VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n"); - } phpdbg_end_try_access(); - } else if (Z_TYPE_PP(data) == IS_OBJECT) { - phpdbg_try_access { - VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_PP(data)->name); - } phpdbg_catch_access { - VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n"); - } phpdbg_end_try_access(); - } else { - VARIABLEINFO("", ""); +#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%s\" " attrs, "%-18p %-7d %-9s %s$%s" msg, *data, Z_REFCOUNT_PP(data), zend_zval_type_name(*data), Z_ISREF_PP(data) ? "&": "", var, ##__VA_ARGS__) + + switch (Z_TYPE_PP(data)) { + case IS_RESOURCE: + phpdbg_try_access { + int type; + VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", zend_list_find(Z_RESVAL_PP(data), &type) ? zend_rsrc_list_get_rsrc_type(type TSRMLS_CC) : "unknown"); + } phpdbg_catch_access { + VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n"); + } phpdbg_end_try_access(); + break; + case IS_OBJECT: + phpdbg_try_access { + VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_PP(data)->name); + } phpdbg_catch_access { + VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n"); + } phpdbg_end_try_access(); + break; + case IS_STRING: + phpdbg_try_access { + VARIABLEINFO("length=\"%d\" value=\"%.*s%s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN_PP(data), Z_STRLEN_PP(data) < 255 ? Z_STRLEN_PP(data) : 255, Z_STRVAL_PP(data), Z_STRLEN_PP(data) > 255 ? "..." : ""); + } phpdbg_catch_access { + VARIABLEINFO("", ""); + } phpdbg_end_try_access(); + break; + case IS_BOOL: + VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL_PP(data) ? "true" : "false"); + break; + case IS_LONG: + VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL_PP(data)); + break; + case IS_DOUBLE: + VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL_PP(data)); + break; + default: + VARIABLEINFO("", ""); } } } phpdbg_end_try_access(); diff --git a/xml.md b/xml.md index 7871b31376..0675634257 100644 --- a/xml.md +++ b/xml.md @@ -268,6 +268,8 @@ info (subcommands) - refstatus: empty if the zval is not a reference - class: the class the object in the zval is an instance of - resource: the type of the resource in the zval + - value: the value of primitive types (scalars) => string/int/bool/double + - length: if string, then the length of that string ### literal ###