From 86a96f2cf1d6feb3682d600138c3b53cf65ff1b2 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 10 Nov 2015 19:13:54 +0300 Subject: Changed meaning of "op2" for ZEND_FREE, ZEND_FE_FREE, ZEND_FAST_CALL, ZEND_FAST_RET. Previously it was an instruction number. Now it's an index in op_array->try_cacth_array[]. --- sapi/phpdbg/phpdbg_opcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/phpdbg/phpdbg_opcode.c') diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 44170c8c9e..a792090275 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -121,7 +121,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */ case ZEND_FAST_CALL: case ZEND_FAST_RET: if (op->extended_value != 0) { - spprintf(&decode[2], 0, "J%" PRIu32, op->op2.opline_num); + spprintf(&decode[2], 0, "%" PRIu32, op->op2.num); } break; -- cgit v1.2.1 From af255c67ebe4bdd0b990ab23310969817d05188d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 21 Jan 2016 21:28:02 +0100 Subject: Make op1/op2 decoding in phpdbg more complete --- sapi/phpdbg/phpdbg_opcode.c | 110 ++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 64 deletions(-) (limited to 'sapi/phpdbg/phpdbg_opcode.c') diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 70dab12656..a0e78c8122 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -36,7 +36,8 @@ static inline const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ return "UNKNOWN"; } /* }}} */ -static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type) /* {{{ */ +static inline char *phpdbg_decode_op( + zend_op_array *ops, const znode_op *op, uint32_t type) /* {{{ */ { char *decode = NULL; @@ -62,91 +63,72 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t return decode; } /* }}} */ -char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */ +char *phpdbg_decode_input_op( + zend_op_array *ops, const zend_op *opline, znode_op op, zend_uchar op_type, + uint32_t flags) { + char *result = NULL; + if (op_type != IS_UNUSED) { + result = phpdbg_decode_op(ops, &op, op_type); + } else if (ZEND_VM_OP_JMP_ADDR == (flags & ZEND_VM_OP_MASK)) { + spprintf(&result, 0, "J%td", OP_JMP_ADDR(opline, op) - ops->opcodes); + } else if (ZEND_VM_OP_NUM == (flags & ZEND_VM_OP_MASK)) { + spprintf(&result, 0, "%" PRIu32, op.num); + } else if (ZEND_VM_OP_TRY_CATCH == (flags & ZEND_VM_OP_MASK)) { + if (opline->opcode != ZEND_FAST_RET || opline->extended_value) { + spprintf(&result, 0, "try-catch(%" PRIu32 ")", op.num); + } + } else if (ZEND_VM_OP_LIVE_RANGE == (flags & ZEND_VM_OP_MASK)) { + if (opline->extended_value & ZEND_FREE_ON_RETURN) { + spprintf(&result, 0, "live-range(%" PRIu32 ")", op.num); + } + } else if (ZEND_VM_OP_THIS == (flags & ZEND_VM_OP_MASK)) { + result = estrdup("THIS"); + } else if (ZEND_VM_OP_NEXT == (flags & ZEND_VM_OP_MASK)) { + result = estrdup("NEXT"); + } else if (ZEND_VM_OP_CLASS_FETCH == (flags & ZEND_VM_OP_MASK)) { + //zend_dump_class_fetch_type(op.num); + } else if (ZEND_VM_OP_CONSTRUCTOR == (flags & ZEND_VM_OP_MASK)) { + result = estrdup("CONSTRUCTOR"); + } + return result; +} + +char *phpdbg_decode_opline(zend_op_array *ops, zend_op *opline) /*{{{ */ { - const char *opcode_name = phpdbg_decode_opcode(op->opcode); + 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 (op->opcode) { + switch (opline->opcode) { case ZEND_FAST_CALL: - if (op->extended_value == ZEND_FAST_CALL_FROM_FINALLY) { + if (opline->extended_value == ZEND_FAST_CALL_FROM_FINALLY) { decode[0] = estrdup("FAST_CALL"); } break; case ZEND_FAST_RET: - if (op->extended_value != 0) { + if (opline->extended_value != 0) { spprintf(&decode[0], 0, "FAST_RET<%s>", - op->extended_value == ZEND_FAST_RET_TO_CATCH ? "TO_CATCH" : "TO_FINALLY"); + opline->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; - } + decode[1] = phpdbg_decode_input_op( + ops, opline, opline->op1, opline->op1_type, ZEND_VM_OP1_FLAGS(flags)); /* 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, "%" PRIu32, op->op2.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; - } + decode[2] = phpdbg_decode_input_op( + ops, opline, opline->op2, opline->op2_type, ZEND_VM_OP2_FLAGS(flags)); /* RESULT */ - switch (op->opcode) { + switch (opline->opcode) { case ZEND_CATCH: - spprintf(&decode[3], 0, "%" PRIu32, op->result.num); + spprintf(&decode[3], 0, "%" PRIu32, opline->result.num); break; default: - decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type); + decode[3] = phpdbg_decode_op(ops, &opline->result, opline->result_type); break; } -- cgit v1.2.1 From 2ae21abdf7b87ee95d76aca22e787408d7c766cf Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 25 May 2016 01:25:12 +0300 Subject: Fixed bug #72213 (Finally leaks on nested exceptions). Squashed commit of the following: commit 8461b0407fc9eab0869d43b84e6a92ba2fe06997 Author: Dmitry Stogov Date: Wed May 25 00:34:42 2016 +0300 Rmoved zend_try_catch_element.parent and walk through op_array.try_catch_array backward from the current try_cacth_offset. commit 0c71e249649bed178bfbef30bb3e63c57f07af05 Author: Dmitry Stogov Date: Wed May 25 00:04:53 2016 +0300 Move SAVE_OPLINE() to its original place commit 111432a4df738fcd65878a42f23194dc3c4983a2 Author: Dmitry Stogov Date: Wed May 25 00:01:10 2016 +0300 Separate the common part of ZEND_HANDLE_EXCEPTION and FAST_RET into zend_dispatch_try_catch_finally_helper. commit 4f21c06c2ec17819a708bc037f318784554a6ecd Author: Nikita Popov Date: Tue May 24 14:55:27 2016 +0200 Improve finally fix commit da5c7274997b8308e682b5bf280124e3a1483086 Author: Dmitry Stogov Date: Tue May 24 10:36:08 2016 +0300 Fixed Zend/tests/try/bug70228_3.phpt and Zend/tests/try/bug70228_4.phpt commit cfcedf2fb4f4fc1f7de9f7d53a3037fed7795f19 Author: Dmitry Stogov Date: Tue May 24 02:59:27 2016 +0300 Added test commit 4c6aa93d43da941eb4fda15b48154bfb104bdc04 Author: Dmitry Stogov Date: Tue May 24 00:38:20 2016 +0300 Added tests commit 8a8f4704b0eca2e460d42c1f253a363b0db8e510 Author: Dmitry Stogov Date: Mon May 23 23:27:34 2016 +0300 Fixed bug #72213 (Finally leaks on nested exceptions) --- sapi/phpdbg/phpdbg_opcode.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'sapi/phpdbg/phpdbg_opcode.c') diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 8bd7c4e50e..44119c9e51 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -74,7 +74,7 @@ char *phpdbg_decode_input_op( } else if (ZEND_VM_OP_NUM == (flags & ZEND_VM_OP_MASK)) { spprintf(&result, 0, "%" PRIu32, op.num); } else if (ZEND_VM_OP_TRY_CATCH == (flags & ZEND_VM_OP_MASK)) { - if (opline->opcode != ZEND_FAST_RET || opline->extended_value) { + if (op.num != (uint32_t)-1) { spprintf(&result, 0, "try-catch(%" PRIu32 ")", op.num); } } else if (ZEND_VM_OP_LIVE_RANGE == (flags & ZEND_VM_OP_MASK)) { @@ -99,21 +99,6 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *opline) /*{{{ */ 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"); - } - 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)); -- cgit v1.2.1