mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Simplify TMP var number decoding (without HashTable)
This commit is contained in:
parent
436b01e379
commit
001ecd3198
@ -27,7 +27,7 @@
|
||||
|
||||
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
||||
|
||||
static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type, HashTable *vars) /* {{{ */
|
||||
static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type) /* {{{ */
|
||||
{
|
||||
char *decode = NULL;
|
||||
|
||||
@ -39,18 +39,8 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t
|
||||
|
||||
case IS_VAR:
|
||||
case IS_TMP_VAR: {
|
||||
zend_ulong id = 0, *pid = NULL;
|
||||
if (vars != NULL) {
|
||||
if ((pid = zend_hash_index_find_ptr(vars, (zend_ulong) ops->vars - op->var))) {
|
||||
id = *pid;
|
||||
} else {
|
||||
id = zend_hash_num_elements(vars);
|
||||
zend_hash_index_update_mem(vars, (zend_ulong) ops->vars - op->var, &id, sizeof(zend_ulong));
|
||||
}
|
||||
}
|
||||
asprintf(&decode, "@" ZEND_ULONG_FMT, id);
|
||||
asprintf(&decode, "@%" PRIu32, EX_VAR_TO_NUM(op->var) - ops->last_var);
|
||||
} break;
|
||||
|
||||
case IS_CONST: {
|
||||
zval *literal = RT_CONSTANT(ops, *op);
|
||||
decode = phpdbg_short_zval_print(literal, 20);
|
||||
@ -59,7 +49,7 @@ 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, HashTable *vars) /*{{{ */
|
||||
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */
|
||||
{
|
||||
char *decode[4] = {NULL, NULL, NULL, NULL};
|
||||
|
||||
@ -79,7 +69,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
|
||||
break;
|
||||
|
||||
default:
|
||||
decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars);
|
||||
decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -110,7 +100,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
|
||||
break;
|
||||
|
||||
default:
|
||||
decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type, vars);
|
||||
decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -120,7 +110,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
|
||||
asprintf(&decode[2], "%" PRIu32, op->result.num);
|
||||
break;
|
||||
default:
|
||||
decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type, vars);
|
||||
decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -140,7 +130,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
|
||||
return decode[0];
|
||||
} /* }}} */
|
||||
|
||||
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags) /* {{{ */
|
||||
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 ||
|
||||
@ -149,7 +139,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
|
||||
(PHPDBG_G(oplog)))) {
|
||||
|
||||
zend_op *opline = (zend_op *) execute_data->opline;
|
||||
char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline, vars);
|
||||
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 */
|
||||
@ -187,7 +177,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
|
||||
|
||||
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags) /* {{{ */
|
||||
{
|
||||
phpdbg_print_opline_ex(execute_data, NULL, ignore_flags);
|
||||
phpdbg_print_opline_ex(execute_data, ignore_flags);
|
||||
} /* }}} */
|
||||
|
||||
const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
|
||||
|
@ -24,9 +24,9 @@
|
||||
#include "zend_types.h"
|
||||
|
||||
const char *phpdbg_decode_opcode(zend_uchar);
|
||||
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars);
|
||||
char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op);
|
||||
void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags);
|
||||
void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags);
|
||||
void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_flags);
|
||||
|
||||
typedef struct _phpdbg_oplog_entry phpdbg_oplog_entry;
|
||||
struct _phpdbg_oplog_entry {
|
||||
|
@ -55,7 +55,6 @@ 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]);
|
||||
@ -81,9 +80,8 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
|
||||
op_array->last);
|
||||
}
|
||||
|
||||
zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
|
||||
do {
|
||||
char *decode = phpdbg_decode_opline(op_array, opline, &vars);
|
||||
char *decode = phpdbg_decode_opline(op_array, opline);
|
||||
if (decode != NULL) {
|
||||
phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" opcode=\"%s\" op=\"%s\"", " L%-4u #%-5u %-23s %s",
|
||||
opline->lineno,
|
||||
@ -96,7 +94,6 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
|
||||
}
|
||||
opline++;
|
||||
} while (opcode++ < end);
|
||||
zend_hash_destroy(&vars);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -1418,9 +1418,6 @@ void phpdbg_clean(zend_bool full) /* {{{ */
|
||||
void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
|
||||
{
|
||||
zend_bool original_in_execution = PHPDBG_G(in_execution);
|
||||
HashTable vars;
|
||||
|
||||
zend_hash_init(&vars, execute_data->func->op_array.last, NULL, NULL, 0);
|
||||
|
||||
if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) && !(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) {
|
||||
zend_bailout();
|
||||
@ -1531,7 +1528,7 @@ ex_is_caught:
|
||||
}
|
||||
|
||||
/* not while in conditionals */
|
||||
phpdbg_print_opline_ex(execute_data, &vars, 0);
|
||||
phpdbg_print_opline_ex(execute_data, 0);
|
||||
|
||||
if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) {
|
||||
PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;
|
||||
@ -1581,7 +1578,6 @@ next:
|
||||
|
||||
if (PHPDBG_G(vmret) != 0) {
|
||||
if (PHPDBG_G(vmret) < 0) {
|
||||
zend_hash_destroy(&vars);
|
||||
PHPDBG_G(in_execution) = original_in_execution;
|
||||
return;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user