com php-src: Improve phpdbg opcode dump: sapi/phpdbg/phpdbg_o pcode.c sapi/phpdbg/tests/commands/0102_print.t est
| From: | Nikita Popov | Date: | Sun, 24 May 2015 18:29:57 +0000 |
| Subject: | com php-src: Improve phpdbg opcode dump: sapi/phpdbg/phpdbg_o pcode.c sapi/phpdbg/tests/commands/0102_print.t est | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86899@lists.php.net to get a copy of this message | ||
Commit: a1ef8b418d88798d2e23b9a89f944c0dc52e0928
Author: Nikita Popov <nikic@php.net> Sun, 24 May 2015 20:27:30 +0200
Parents: fc8143f58a760df0c915d37afe65f6a15d52fc16
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a1ef8b418d88798d2e23b9a89f944c0dc52e0928
Log:
Improve phpdbg opcode dump
Don't show <unused>, just don't display anything instead.
Dump nums used in op1/op2/result, e.g. for SEND, RECV etc.
Split the switch into three parts, one for each operand.
Changed paths:
M sapi/phpdbg/phpdbg_opcode.c
M sapi/phpdbg/tests/commands/0102_print.test
Diff:
diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c
index 7dadc3f..0935e74 100644
--- a/sapi/phpdbg/phpdbg_opcode.c
+++ b/sapi/phpdbg/phpdbg_opcode.c
@@ -106,8 +106,7 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t
} break;
case IS_UNUSED:
- asprintf(&decode, "<unused>");
- break;
+ return NULL;
}
return decode;
} /* }}} */
@@ -116,43 +115,72 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars)
/*{
{
char *decode[4] = {NULL, NULL, NULL, NULL};
+ /* OP1 */
switch (op->opcode) {
case ZEND_JMP:
case ZEND_GOTO:
case ZEND_FAST_CALL:
asprintf(&decode[1], "J%ld", OP_JMP_ADDR(op, op->op1) - ops->opcodes);
- goto format;
+ break;
- case ZEND_JMPZNZ:
+ case ZEND_INIT_FCALL:
+ case ZEND_RECV:
+ case ZEND_RECV_INIT:
+ case ZEND_RECV_VARIADIC:
+ asprintf(&decode[1], "%" PRIu32, op->op1.num);
+ break;
+
+ default:
decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars);
+ break;
+ }
+
+ /* OP2 */
+ switch (op->opcode) {
+ /* TODO: ZEND_FAST_CALL, ZEND_FAST_RET op2 */
+ case ZEND_JMPZNZ:
asprintf(&decode[2], "J%u or J%" PRIu32, op->op2.opline_num,
op->extended_value);
- goto result;
+ break;
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
case ZEND_JMP_SET:
- decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars);
asprintf(&decode[2], "J%ld", OP_JMP_ADDR(op, op->op2) - ops->opcodes);
- goto result;
+ break;
- case ZEND_RECV_INIT:
- goto result;
+ 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:
+ asprintf(&decode[2], "%" PRIu32, op->op2.num);
+ break;
default:
- decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars);
decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type, vars);
-result:
+ break;
+ }
+
+ /* RESULT */
+ switch (op->opcode) {
+ case ZEND_CATCH:
+ asprintf(&decode[2], "%" PRIu32, op->result.num);
+ break;
+ default:
decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type, vars);
-format:
- asprintf(&decode[0],
- "%-20s %-20s %-20s",
- decode[1] ? decode[1] : "",
- decode[2] ? decode[2] : "",
- decode[3] ? decode[3] : "");
+ break;
}
+ asprintf(&decode[0],
+ "%-20s %-20s %-20s",
+ decode[1] ? decode[1] : "",
+ decode[2] ? decode[2] : "",
+ decode[3] ? decode[3] : "");
+
if (decode[1])
free(decode[1]);
if (decode[2])
diff --git a/sapi/phpdbg/tests/commands/0102_print.test b/sapi/phpdbg/tests/commands/0102_print.test
index 6ca60db..7078b13 100644
--- a/sapi/phpdbg/tests/commands/0102_print.test
+++ b/sapi/phpdbg/tests/commands/0102_print.test
@@ -6,14 +6,14 @@
#################################################
#[User Class: test (3 methods)]
#L%d-%d test::testMethod() %s - 0x%s + 1 ops
-# L%d #0 RETURN null <unused>
<unused>
+# L%d #0 RETURN null
#L%d-%d test::testPrivateMethod() %s - 0x%s + 1 ops
-# L%d #0 RETURN null <unused>
<unused>
+# L%d #0 RETURN null
#L%d-%d test::testProtectedMethod() %s - 0x%s + 1 ops
-# L%d #0 RETURN null <unused>
<unused>
+# L%d #0 RETURN null
#[User Method testMethod (1 ops)]
#L%d-%d test::testMethod() %s - 0x%s + 1 ops
-# L%d #0 RETURN null <unused>
<unused>
+# L%d #0 RETURN null
#################################################
<:
class test {