コード例 #1
0
ファイル: phpdbg_opcode.c プロジェクト: lllito/php-src
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags) /* {{{ */
{
	/* force out a line while stepping so the user knows what is happening */
	if (ignore_flags ||
		(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
		(PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ||
		(PHPDBG_G(oplog)))) {

		zend_op *opline = (zend_op *) execute_data->opline;
		char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline, vars);

		if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
			/* output line info */
			phpdbg_notice("opline", "line=\"%u\" opline=\"%p\" opcode=\"%s\" op=\"%s\" file=\"%s\"", "L%-5u %16p %-30s %s %s",
			   opline->lineno,
			   opline,
			   phpdbg_decode_opcode(opline->opcode),
			   decode,
			   execute_data->func->op_array.filename ? execute_data->func->op_array.filename->val : "unknown");
		}

		if (!ignore_flags && PHPDBG_G(oplog)) {
			phpdbg_log_ex(fileno(PHPDBG_G(oplog)), "L%-5u %16p %-30s %s %s",
				opline->lineno,
				opline,
				phpdbg_decode_opcode(opline->opcode),
				decode,
				execute_data->func->op_array.filename ? execute_data->func->op_array.filename->val : "unknown");
		}

		if (decode) {
			free(decode);
		}
	}
} /* }}} */
コード例 #2
0
ファイル: phpdbg_opcode.c プロジェクト: 13572293130/php-src
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;
} /* }}} */
コード例 #3
0
ファイル: phpdbg_opcode.c プロジェクト: artasoftkey/php-src
void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_flags) /* {{{ */
{
	/* force out a line while stepping so the user knows what is happening */
	if (ignore_flags ||
		(!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) ||
		(PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ||
		(PHPDBG_G(oplog)))) {

		zend_op *opline = (zend_op *) execute_data->opline;
		char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline);

		if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
			/* output line info */
			phpdbg_notice("opline", "line=\"%u\" opline=\"%p\" opcode=\"%s\" op=\"%s\" file=\"%s\"", "L%-5u %16p %-30s %s %s",
			   opline->lineno,
			   opline,
			   phpdbg_decode_opcode(opline->opcode),
			   decode,
			   execute_data->func->op_array.filename ? ZSTR_VAL(execute_data->func->op_array.filename) : "unknown");
		}

		if (!ignore_flags && PHPDBG_G(oplog)) {
			phpdbg_log_ex(fileno(PHPDBG_G(oplog)), "L%-5u %16p %-30s %s %s",
				opline->lineno,
				opline,
				phpdbg_decode_opcode(opline->opcode),
				decode,
				execute_data->func->op_array.filename ? ZSTR_VAL(execute_data->func->op_array.filename) : "unknown");
		}

		if (decode) {
			free(decode);
		}
	}

	if (PHPDBG_G(oplog_list)) {
		phpdbg_oplog_entry *cur = zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry));
		cur->op = (zend_op *) execute_data->opline;
		cur->op_array = &execute_data->func->op_array;
		cur->next = NULL;
		PHPDBG_G(oplog_cur)->next = cur;
		PHPDBG_G(oplog_cur) = cur;
	}
} /* }}} */
コード例 #4
0
ファイル: phpdbg_print.c プロジェクト: AmesianX/php-src
static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
{
	switch (method->type) {
		case ZEND_USER_FUNCTION: {
			zend_op_array* op_array = &(method->op_array);
			HashTable vars;

			if (op_array) {
				zend_op *opline = &(op_array->opcodes[0]);
				uint32_t opcode = 0,
				end = op_array->last-1;

				if (method->common.scope) {
					phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" method=\"%s::%s\" file=\"%s\"", "\tL%d-%d %s::%s() %s",
						op_array->line_start,
						op_array->line_end,
						method->common.scope->name->val,
						method->common.function_name->val,
						op_array->filename ? op_array->filename->val : "unknown");
				} else {
					phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" function=\"%s\" file=\"%s\"", "\tL%d-%d %s() %s",
						method->common.function_name ? op_array->line_start : 0,
						method->common.function_name ? op_array->line_end : 0,
						method->common.function_name ? method->common.function_name->val : "{main}",
						op_array->filename ? op_array->filename->val : "unknown");
				}

				zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
				do {
					char *decode = phpdbg_decode_opline(op_array, opline, &vars);
					if (decode != NULL) {
						phpdbg_writeln("print", "line=\"%u\" opline=\"%p\" opcode=\"%s\" op=\"%s\"", "\t\tL%u\t%p %-30s %s",
							opline->lineno,
							opline,
							phpdbg_decode_opcode(opline->opcode),
							decode);
						free(decode);
					} else {
						phpdbg_error("print", "type=\"decodefailure\" opline=\"%16p\"", "\tFailed to decode opline %16p", opline);
					}
					opline++;
				} while (opcode++ < end);
				zend_hash_destroy(&vars);
			}
		} break;

		default: {
			if (method->common.scope) {
				phpdbg_writeln("printoplineinfo", "type=\"Internal\" method=\"%s::%s\"", "\tInternal %s::%s()", method->common.scope->name->val, method->common.function_name->val);
			} else {
				phpdbg_writeln("printoplineinfo", "type=\"Internal\" function=\"%s\"", "\tInternal %s()", method->common.function_name->val);
			}
		}
	}
} /* }}} */
コード例 #5
0
ファイル: phpdbg_opcode.c プロジェクト: AxiosCros/php-src
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;
} /* }}} */
コード例 #6
0
ファイル: phpdbg_opcode.c プロジェクト: Sobak/php-src
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */
{
	const char *opcode_name = phpdbg_decode_opcode(op->opcode);
	char *result, *decode[4] = {NULL, NULL, NULL, NULL};

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

	/* OP1 */
	switch (op->opcode) {
	case ZEND_JMP:
	case ZEND_FAST_CALL:
		spprintf(&decode[1], 0, "J%td", OP_JMP_ADDR(op, op->op1) - ops->opcodes);
		break;

	case ZEND_INIT_FCALL:
	case ZEND_RECV:
	case ZEND_RECV_INIT:
	case ZEND_RECV_VARIADIC:
		spprintf(&decode[1], 0, "%" PRIu32, op->op1.num);
		break;

	default:
		decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type);
		break;
	}

	/* OP2 */
	switch (op->opcode) {
	case ZEND_JMPZNZ:
		spprintf(&decode[2], 0, "J%td or J%td",
			OP_JMP_ADDR(op, op->op2) - ops->opcodes,
			ZEND_OFFSET_TO_OPLINE(op, op->extended_value) - ops->opcodes);
		break;

	case ZEND_JMPZ:
	case ZEND_JMPNZ:
	case ZEND_JMPZ_EX:
	case ZEND_JMPNZ_EX:
	case ZEND_JMP_SET:
	case ZEND_ASSERT_CHECK:
		spprintf(&decode[2], 0, "J%td", OP_JMP_ADDR(op, op->op2) - ops->opcodes);
		break;

	case ZEND_FAST_CALL:
	case ZEND_FAST_RET:
		if (op->extended_value != 0) {
			spprintf(&decode[2], 0, "J%" PRIu32, op->op2.opline_num);
		}
		break;

	case ZEND_SEND_VAL:
	case ZEND_SEND_VAL_EX:
	case ZEND_SEND_VAR:
	case ZEND_SEND_VAR_NO_REF:
	case ZEND_SEND_REF:
	case ZEND_SEND_VAR_EX:
	case ZEND_SEND_USER:
		spprintf(&decode[2], 0, "%" PRIu32, op->op2.num);
		break;

	default:
		decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type);
		break;
	}

	/* RESULT */
	switch (op->opcode) {
	case ZEND_CATCH:
		spprintf(&decode[3], 0, "%" PRIu32, op->result.num);
		break;
	default:
		decode[3] = phpdbg_decode_op(ops, &op->result, op->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;
} /* }}} */