Skip to content

Commit 0488640

Browse files
committed
better output for disassembler
1 parent c8d408f commit 0488640

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

phpdbg_print.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
4242
switch (method->type) {
4343
case ZEND_USER_FUNCTION: {
4444
zend_op_array* op_array = &(method->op_array);
45-
45+
HashTable vars;
46+
4647
if (op_array) {
4748
zend_op *opline = &(op_array->opcodes[0]);
4849
zend_uint opcode = 0,
@@ -64,16 +65,21 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
6465
op_array->filename ? op_array->filename : "unknown");
6566
}
6667

67-
68+
zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
6869
do {
69-
const char *decode = phpdbg_decode_opcode(opline->opcode);
70+
char *decode = phpdbg_decode_opline(op_array, opline, &vars TSRMLS_CC);
7071
if (decode != NULL) {
7172
phpdbg_writeln(
72-
"\t\t#%lu\t%p %s", opline->lineno, opline, decode);
73+
"\t\t#%lu\t%p %-30s %s",
74+
opline->lineno,
75+
opline,
76+
phpdbg_decode_opcode(opline->opcode),
77+
decode);
7378
} else phpdbg_error("\tFailed to decode opline @ %ld", opline);
74-
79+
free(decode);
7580
opline++;
7681
} while (++opcode < end);
82+
zend_hash_destroy(&vars);
7783
}
7884
} break;
7985

phpdbg_prompt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint
10591059
return decode;
10601060
} /* }}} */
10611061

1062-
static inline char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC) /*{{{ */
1062+
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC) /*{{{ */
10631063
{
10641064
char *decode[3];
10651065

phpdbg_prompt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC);
2424
int phpdbg_interactive(TSRMLS_D);
2525
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC);
26+
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC);
2627
int phpdbg_compile(TSRMLS_D);
2728
void phpdbg_clean(zend_bool full TSRMLS_DC);
2829
void phpdbg_sigint_handler(int signo);

0 commit comments

Comments
 (0)