com php-src: Fix info vars with refs/indirects: sapi/phpdbg/php dbg_info.c
| From: | Bob Weinand | Date: | Mon, 20 Jul 2015 16:00:43 +0000 |
| Subject: | com php-src: Fix info vars with refs/indirects: sapi/phpdbg/php dbg_info.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88052@lists.php.net to get a copy of this message | ||
Commit: acba2950886cbc39a1b6caecdaa22ad4f62412d8
Author: Bob Weinand <bobwei9@hotmail.com> Mon, 20 Jul 2015 02:18:50 +0200
Parents: 22c7c1189aae36ac51fe45bf33ee0b196cb5e755
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=acba2950886cbc39a1b6caecdaa22ad4f62412d8
Log:
Fix info vars with refs/indirects
Changed paths:
M sapi/phpdbg/phpdbg_info.c
Diff:
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index 1f78ac9...51e12b7 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -153,7 +153,9 @@ PHPDBG_INFO(constants) /* {{{ */
return SUCCESS;
} /* }}} */
-static int phpdbg_arm_auto_global(zend_auto_global *auto_global) {
+static int phpdbg_arm_auto_global(zval *ptrzv) {
+ zend_auto_global *auto_global = Z_PTR_P(ptrzv);
+
if (auto_global->armed) {
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
phpdbg_notice("variableinfo", "unreachable=\"%.*s\"", "Cannot
show information about superglobal variable %.*s", ZSTR_LEN(auto_global->name),
ZSTR_VAL(auto_global->name));
@@ -204,9 +206,9 @@ static int phpdbg_print_symbols(zend_bool show_globals) {
if (ops->function_name) {
if (ops->scope) {
- phpdbg_notice("variableinfo", "method=\"%s::%s\"
num=\"%d\"", "Variables in %s::%s() (%d)", ops->scope->name,
ops->function_name, zend_hash_num_elements(&vars));
+ phpdbg_notice("variableinfo", "method=\"%s::%s\"
num=\"%d\"", "Variables in %s::%s() (%d)", ops->scope->name->val,
ops->function_name->val, zend_hash_num_elements(&vars));
} else {
- phpdbg_notice("variableinfo", "function=\"%s\"
num=\"%d\"", "Variables in %s() (%d)", ops->function_name,
zend_hash_num_elements(&vars));
+ phpdbg_notice("variableinfo", "function=\"%s\"
num=\"%d\"", "Variables in %s() (%d)", ZSTR_VAL(ops->function_name),
zend_hash_num_elements(&vars));
}
} else {
if (ops->filename) {
@@ -221,8 +223,9 @@ static int phpdbg_print_symbols(zend_bool show_globals) {
phpdbg_out("Address Refs Type Variable\n");
ZEND_HASH_FOREACH_STR_KEY_VAL(&vars, var, data) {
phpdbg_try_access {
-#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_P(data), zend_zval_type_name(data), Z_ISREF_P(data) ? "&":
"", ZSTR_LEN(var), ZSTR_VAL(var), ##__VA_ARGS__)
-
+ const char *isref = "";
+#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_REFCOUNTED_P(data) ? Z_REFCOUNT_P(data) : 1, zend_zval_type_name(data), isref,
ZSTR_LEN(var), ZSTR_VAL(var), ##__VA_ARGS__)
+retry_switch:
switch (Z_TYPE_P(data)) {
case IS_RESOURCE:
phpdbg_try_access {
@@ -258,6 +261,13 @@ static int phpdbg_print_symbols(zend_bool show_globals) {
case IS_DOUBLE:
VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)",
Z_DVAL_P(data));
break;
+ case IS_REFERENCE:
+ isref = "&";
+ data = Z_REFVAL_P(data);
+ goto retry_switch;
+ case IS_INDIRECT:
+ data = Z_INDIRECT_P(data);
+ goto retry_switch;
default:
VARIABLEINFO("", "");
}
@@ -290,13 +300,13 @@ PHPDBG_INFO(literal) /* {{{ */
zend_bool in_executor = PHPDBG_G(in_execution) && EG(current_execute_data) &&
EG(current_execute_data)->func;
if (in_executor || PHPDBG_G(ops)) {
zend_op_array *ops = in_executor ? &EG(current_execute_data)->func->op_array :
PHPDBG_G(ops);
- int literal = 0, count = ops->last_literal-1;
+ int literal = 0, count = ops->last_literal - 1;
if (ops->function_name) {
if (ops->scope) {
- phpdbg_notice("literalinfo", "method=\"%s::%s\"
num=\"%d\"", "Literal Constants in %s::%s() (%d)", ops->scope->name,
ops->function_name, count);
+ phpdbg_notice("literalinfo", "method=\"%s::%s\"
num=\"%d\"", "Literal Constants in %s::%s() (%d)",
ops->scope->name->val, ops->function_name->val, count);
} else {
- phpdbg_notice("literalinfo", "function=\"%s\"
num=\"%d\"", "Literal Constants in %s() (%d)", ops->function_name,
count);
+ phpdbg_notice("literalinfo", "function=\"%s\"
num=\"%d\"", "Literal Constants in %s() (%d)",
ops->function_name->val, count);
}
} else {
if (ops->filename) {