com php-src: some work on opline output, incomplete: phpdbg_prompt.c

From: Date: Thu, 21 Nov 2013 11:16:14 +0000
Subject: com php-src: some work on opline output, incomplete: phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74733@lists.php.net to get a copy of this message
Commit: ed8f64cc801a2ad33bfdbd447d2d719db0442f8e Author: krakjoe <joe.watkins@live.co.uk> Thu, 21 Nov 2013 11:16:14 +0000 Parents: f68fee50548094280a76e556bb5d6afec86dd225 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ed8f64cc801a2ad33bfdbd447d2d719db0442f8e Log: some work on opline output, incomplete Changed paths: M phpdbg_prompt.c Diff: diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 8ccea7d..29577b0 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -610,6 +610,9 @@ PHPDBG_COMMAND(print) /* {{{ */ PHPDBG_COMMAND(info) /* {{{ */ { + phpdbg_error( + "No information command selected !"); + return SUCCESS; } /* }}} */ @@ -780,8 +783,11 @@ PHPDBG_COMMAND(oplog) /* {{{ */ fclose( PHPDBG_G(oplog)); } else { - phpdbg_error("No oplog currently open"); + phpdbg_error("No oplog currently open !"); } + } else { + phpdbg_error( + "No action taken !"); } break; @@ -1019,6 +1025,55 @@ out: return ret; } /* }}} */ +static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint type TSRMLS_DC) /* {{{ */ +{ + char *decode = NULL; + switch (type) { + case IS_CV: + asprintf(&decode, "$%s", ops->vars[op->var].name); + break; + + case IS_TMP_VAR: /* this address is wrong */ + asprintf(&decode, "T%p", ops->vars - op->var); + break; + + case IS_VAR: /* this address is wrong */ + asprintf(&decode, "%p", ops->vars - op->var); + break; + + case IS_CONST: + asprintf(&decode, "<constant>"); + break; + + case IS_UNUSED: + asprintf(&decode, "<unused>"); + break; + } + return decode; +} /* }}} */ + +static inline char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op TSRMLS_DC) /*{{{ */ +{ + char *decode[3]; + + decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type TSRMLS_CC); + decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type TSRMLS_CC); + + switch (op->opcode) { + default: asprintf( + &decode[0], "%-20s %-20s", + decode[1], decode[2] + ); + } + + if (decode[1]) + free(decode[1]); + if (decode[2]) + free(decode[2]); + + return decode[0]; +} /* }}} */ + void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ { /* force out a line while stepping so the user knows what is happening */ @@ -1028,25 +1083,32 @@ void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags (PHPDBG_G(oplog)))) { zend_op *opline = execute_data->opline; - + char *decode = phpdbg_decode_opline(execute_data->op_array, opline TSRMLS_CC); + if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) { /* output line info */ - phpdbg_notice("#%lu %p %s %s", + phpdbg_notice("#%- 5lu %16p %30s %s %s", opline->lineno, opline, phpdbg_decode_opcode(opline->opcode), + decode, execute_data->op_array->filename ? execute_data->op_array->filename : "unknown"); } if (!ignore_flags && PHPDBG_G(oplog)) { - phpdbg_log_ex(PHPDBG_G(oplog), "#%lu %p %s %s", + phpdbg_log_ex(PHPDBG_G(oplog), "#%- 5lu %16p %30s %s %s", opline->lineno, opline, phpdbg_decode_opcode(opline->opcode), + decode, execute_data->op_array->filename ? execute_data->op_array->filename : "unknown"); } + + if (decode) { + free(decode); + } } } /* }}} */

« previous php.cvs (#74733) next »