Esempio n. 1
0
int vld_dump_zval (zval val)
{
	switch (val.type) {
		case IS_NULL:           return vld_dump_zval_null (val.value);
		case IS_LONG:           return vld_dump_zval_long (val.value);
		case IS_DOUBLE:         return vld_dump_zval_double (val.value);
		case IS_STRING:         return vld_dump_zval_string (val.value);
		case IS_ARRAY:          return vld_dump_zval_array (val.value);
		case IS_OBJECT:         return vld_dump_zval_object (val.value);
		case IS_BOOL:           return vld_dump_zval_bool (val.value);
		case IS_RESOURCE:       return vld_dump_zval_resource (val.value);
		case IS_CONSTANT:       return vld_dump_zval_constant (val.value);
		case IS_CONSTANT_ARRAY: return vld_dump_zval_constant_array (val.value);
#if PHP_VERSION_ID >= 60000
		case IS_UNICODE:        return vld_dump_zval_unicode (val.value);
#endif
	}
	return vld_printf(stderr, "<unknown>");
}
Esempio n. 2
0
int vld_dump_zval (zval val)
{
#if PHP_VERSION_ID >= 70000
	switch (val.u1.v.type) {
#else
	switch (val.type) {
#endif
		case IS_NULL:           return vld_dump_zval_null (val.value);
		case IS_LONG:           return vld_dump_zval_long (val.value);
		case IS_DOUBLE:         return vld_dump_zval_double (val.value);
		case IS_STRING:         return vld_dump_zval_string (val.value);
		case IS_ARRAY:          return vld_dump_zval_array (val.value);
		case IS_OBJECT:         return vld_dump_zval_object (val.value);
		case IS_RESOURCE:       return vld_dump_zval_resource (val.value);
		case IS_CONSTANT:       return vld_dump_zval_constant (val.value);
#if PHP_VERSION_ID >= 50600
		case IS_CONSTANT_AST:   return vld_dump_zval_constant_ast (val.value);
#else
		case IS_CONSTANT_ARRAY: return vld_dump_zval_constant_array (val.value);
#endif
#if PHP_VERSION_ID >= 70000
		case IS_UNDEF:          return vld_dump_zval_undef (val.value);
		case IS_FALSE:          return vld_dump_zval_false (val.value);
		case IS_TRUE:           return vld_dump_zval_true (val.value);
		case IS_REFERENCE:      return vld_dump_zval_reference (val.value);
		case IS_CALLABLE:       return vld_dump_zval_callable (val.value);
		case IS_INDIRECT:       return vld_dump_zval_indirect (val.value);
		case IS_PTR:            return vld_dump_zval_ptr (val.value);
#else
		case IS_BOOL:           return vld_dump_zval_bool (val.value);
#endif
	}
	return vld_printf(stderr, "<unknown>");
}


int vld_dump_znode (int *print_sep, unsigned int node_type, VLD_ZNODE node, unsigned int base_address, zend_op_array *op_array, int opline TSRMLS_DC)
{
	int len = 0;

	if (node_type != IS_UNUSED && print_sep) {
		if (*print_sep) {
			len += vld_printf (stderr, ", ");
		}
		*print_sep = 1;
	}
	switch (node_type) {
		case IS_UNUSED:
			VLD_PRINT(3, " IS_UNUSED ");
			break;
		case IS_CONST: /* 1 */
#if PHP_VERSION_ID >= 70000
			VLD_PRINT1(3, " IS_CONST (%d) ", VLD_ZNODE_ELEM(node, var) / sizeof(zval));
#else
			VLD_PRINT1(3, " IS_CONST (%d) ", VLD_ZNODE_ELEM(node, var) / sizeof(temp_variable));
#endif
#if PHP_VERSION_ID >= 70000
			vld_dump_zval(*RT_CONSTANT_EX(op_array->literals, node));
#else
# if PHP_VERSION_ID >= 50399
			vld_dump_zval(*node.zv);
# else
			vld_dump_zval(node.u.constant);
# endif
#endif
			break;
#if defined(ZEND_ENGINE_2) || defined(ZEND_ENGINE_3)
		case IS_TMP_VAR: /* 2 */
			VLD_PRINT(3, " IS_TMP_VAR ");
			len += vld_printf (stderr, "~%d", VAR_NUM(VLD_ZNODE_ELEM(node, var)));
			break;
		case IS_VAR: /* 4 */
			VLD_PRINT(3, " IS_VAR ");
			len += vld_printf (stderr, "$%d", VAR_NUM(VLD_ZNODE_ELEM(node, var)));
			break;
#if (PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1)
		case IS_CV:  /* 16 */
			VLD_PRINT(3, " IS_CV ");
#if PHP_VERSION_ID >= 70000
			len += vld_printf (stderr, "!%d", (VLD_ZNODE_ELEM(node, var)-sizeof(zend_execute_data)) / sizeof(zval));
#else
			len += vld_printf (stderr, "!%d", VLD_ZNODE_ELEM(node, var));
#endif
			break;
#endif
		case VLD_IS_OPNUM:
#if PHP_VERSION_ID >= 70000
			len += vld_printf (stderr, "->%d", VLD_ZNODE_JMP_LINE(node, opline, base_address));
#else
			len += vld_printf (stderr, "->%d", VLD_ZNODE_ELEM(node, opline_num));
#endif
			break;
		case VLD_IS_OPLINE:
#if PHP_VERSION_ID >= 70000
			len += vld_printf (stderr, "->%d", VLD_ZNODE_JMP_LINE(node, opline, base_address));
#else
			len += vld_printf (stderr, "->%d", (VLD_ZNODE_ELEM(node, opline_num) - base_address) / sizeof(zend_op));
#endif
			break;
		case VLD_IS_CLASS:
			len += vld_printf (stderr, ":%d", VAR_NUM(VLD_ZNODE_ELEM(node, var)));
			break;
#else /* ZEND_ENGINE_1 */
		case IS_TMP_VAR: /* 2 */
			len += vld_printf (stderr, "~%d", node.u.var);
			break;
		case IS_VAR: /* 4 */
			len += vld_printf (stderr, "$%d", node.u.var);
			break;           
		case VLD_IS_OPNUM:
		case VLD_IS_OPLINE:
			len += vld_printf (stderr, "->%d", node.u.opline_num);
			break;
		case VLD_IS_CLASS:
			len += vld_printf (stderr, ":%d", node.u.var);
			break;
#endif
		default:
			return 0;
	}
	return len;
}