Skip to content

Commit 5f10e84

Browse files
committed
Shrink phpdbg opcode dump output a bit more
1 parent 0381c1b commit 5f10e84

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

sapi/phpdbg/phpdbg_opcode.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,15 @@
2727

2828
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
2929

30-
static inline uint32_t phpdbg_decode_literal(zend_op_array *ops, zval *literal) /* {{{ */
31-
{
32-
int iter = 0;
33-
34-
while (iter < ops->last_literal) {
35-
if (literal == &ops->literals[iter]) {
36-
return iter;
37-
}
38-
iter++;
39-
}
40-
41-
return 0;
42-
} /* }}} */
43-
4430
static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type, HashTable *vars) /* {{{ */
4531
{
4632
char *decode = NULL;
4733

4834
switch (type &~ EXT_TYPE_UNUSED) {
49-
case IS_CV:
50-
asprintf(&decode, "$%s", ops->vars[EX_VAR_TO_NUM(op->var)]->val);
51-
break;
35+
case IS_CV: {
36+
zend_string *var = ops->vars[EX_VAR_TO_NUM(op->var)];
37+
asprintf(&decode, "$%.*s%c", var->len <= 19 ? (int) var->len : 18, var->val, var->len <= 19 ? 0 : '+');
38+
} break;
5239

5340
case IS_VAR:
5441
case IS_TMP_VAR: {

sapi/phpdbg/phpdbg_print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
8585
do {
8686
char *decode = phpdbg_decode_opline(op_array, opline, &vars);
8787
if (decode != NULL) {
88-
phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" opcode=\"%s\" op=\"%s\"", " L%-5u #%-5u %-36s %s",
88+
phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" opcode=\"%s\" op=\"%s\"", " L%-4u #%-5u %-23s %s",
8989
opline->lineno,
9090
opcode,
91-
phpdbg_decode_opcode(opline->opcode),
91+
phpdbg_decode_opcode(opline->opcode) + 5, /* remove ZEND_ prefix */
9292
decode);
9393
free(decode);
9494
} else {

0 commit comments

Comments
 (0)