Ejemplo n.º 1
0
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *opline) /*{{{ */
{
	const char *opcode_name = phpdbg_decode_opcode(opline->opcode);
	uint32_t flags = zend_get_opcode_flags(opline->opcode);
	char *result, *decode[4] = {NULL, NULL, NULL, NULL};

	/* EX */
	switch (opline->opcode) {
	case ZEND_FAST_CALL:
		if (opline->extended_value == ZEND_FAST_CALL_FROM_FINALLY) {
			decode[0] = estrdup("FAST_CALL<FROM_FINALLY>");
		}
		break;
	case ZEND_FAST_RET:
		if (opline->extended_value != 0) {
			spprintf(&decode[0], 0, "FAST_RET<%s>",
				opline->extended_value == ZEND_FAST_RET_TO_CATCH ? "TO_CATCH" : "TO_FINALLY");
		}
		break;
	}

	/* OP1 */
	decode[1] = phpdbg_decode_input_op(
		ops, opline, opline->op1, opline->op1_type, ZEND_VM_OP1_FLAGS(flags));

	/* OP2 */
	decode[2] = phpdbg_decode_input_op(
		ops, opline, opline->op2, opline->op2_type, ZEND_VM_OP2_FLAGS(flags));

	/* RESULT */
	switch (opline->opcode) {
	case ZEND_CATCH:
		spprintf(&decode[3], 0, "%" PRIu32, opline->result.num);
		break;
	default:
		decode[3] = phpdbg_decode_op(ops, &opline->result, opline->result_type);
		break;
	}

	spprintf(&result, 0,
		"%-23s %-20s %-20s %-20s",
		decode[0] ? decode[0] : opcode_name,
		decode[1] ? decode[1] : "",
		decode[2] ? decode[2] : "",
		decode[3] ? decode[3] : "");

	if (decode[0])
		efree(decode[0]);
	if (decode[1])
		efree(decode[1]);
	if (decode[2])
		efree(decode[2]);
	if (decode[3])
		efree(decode[3]);

	return result;
} /* }}} */
Ejemplo n.º 2
0
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *opline) /*{{{ */
{
	const char *opcode_name = phpdbg_decode_opcode(opline->opcode);
	uint32_t flags = zend_get_opcode_flags(opline->opcode);
	char *result, *decode[4] = {NULL, NULL, NULL, NULL};

	/* OpcodeName */
	if (opline->extended_value) {
		spprintf(&decode[0], 0, "%s<%" PRIi32 ">", opcode_name, opline->extended_value);
	}

	/* OP1 */
	decode[1] = phpdbg_decode_input_op(
		ops, opline, opline->op1, opline->op1_type, ZEND_VM_OP1_FLAGS(flags));

	/* OP2 */
	decode[2] = phpdbg_decode_input_op(
		ops, opline, opline->op2, opline->op2_type, ZEND_VM_OP2_FLAGS(flags));

	/* RESULT */
	switch (opline->opcode) {
	case ZEND_CATCH:
		spprintf(&decode[3], 0, "%" PRIu32, opline->result.num);
		break;
	default:
		decode[3] = phpdbg_decode_op(ops, &opline->result, opline->result_type);
		break;
	}

	spprintf(&result, 0,
		"%-23s %-20s %-20s %-20s",
		decode[0] ? decode[0] : opcode_name,
		decode[1] ? decode[1] : "",
		decode[2] ? decode[2] : "",
		decode[3] ? decode[3] : "");

	if (decode[0])
		efree(decode[0]);
	if (decode[1])
		efree(decode[1]);
	if (decode[2])
		efree(decode[2]);
	if (decode[3])
		efree(decode[3]);

	return result;
} /* }}} */