Browse Source

Fix info vars with refs/indirects

pull/1428/head
Bob Weinand 11 years ago
parent
commit
acba295088
  1. 26
      sapi/phpdbg/phpdbg_info.c

26
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) {

Loading…
Cancel
Save