From cdd72cfda77b5770a10e57399c12c0e4f4360937 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Thu, 21 Nov 2013 19:47:31 +0000 Subject: [PATCH] housekeeping, moving stuff to appropriate units --- phpdbg.c | 6 ++++++ phpdbg_opcode.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ phpdbg_opcode.h | 2 ++ phpdbg_prompt.c | 51 +------------------------------------------------ phpdbg_prompt.h | 24 ++++++++++++----------- 5 files changed, 69 insertions(+), 61 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 6b219fa756..d417a89158 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -434,6 +434,12 @@ static void phpdbg_welcome(zend_bool cleaning TSRMLS_DC) /* {{{ */ } } /* }}} */ +static inline void phpdbg_sigint_handler(int signo) /* {{{ */ +{ + TSRMLS_FETCH(); + PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; +} /* }}} */ + int main(int argc, char **argv) /* {{{ */ { sapi_module_struct *phpdbg = &phpdbg_sapi_module; diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c index 727f5e4c3d..9fa357c4fa 100644 --- a/phpdbg_opcode.c +++ b/phpdbg_opcode.c @@ -17,9 +17,13 @@ +----------------------------------------------------------------------+ */ +#include "phpdbg.h" #include "zend_vm_opcodes.h" #include "zend_compile.h" #include "phpdbg_opcode.h" +#include "phpdbg_utils.h" + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */ { @@ -133,6 +137,49 @@ format: return decode[0]; } /* }}} */ +void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ +{ + /* force out a line while stepping so the user knows what is happening */ + if (ignore_flags || + (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || + (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) || + (PHPDBG_G(oplog)))) { + + zend_op *opline = execute_data->opline; + char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC); + + if (ignore_flags || + (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || + (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) { + /* output line info */ + 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), "#%- 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); + } + } +} /* }}} */ + +void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ +{ + phpdbg_print_opline_ex(execute_data, NULL, ignore_flags TSRMLS_CC); +} /* }}} */ + const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */ { #define CASE(s) case s: return #s diff --git a/phpdbg_opcode.h b/phpdbg_opcode.h index 83c0ac5add..dfa443a064 100644 --- a/phpdbg_opcode.h +++ b/phpdbg_opcode.h @@ -24,5 +24,7 @@ const char *phpdbg_decode_opcode(zend_uchar); char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC); +void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC); +void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC); #endif /* PHPDBG_OPCODE_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 860183b101..85222e8c5d 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -34,7 +34,7 @@ #include "phpdbg_cmd.h" /* {{{ command declarations */ -static const phpdbg_command_t phpdbg_prompt_commands[] = { +const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(exec, "set execution context", 'e', NULL, 1), PHPDBG_COMMAND_D(compile, "attempt compilation", 'c', NULL, 0), PHPDBG_COMMAND_D(step, "step through execution", 's', NULL, 1), @@ -1025,49 +1025,6 @@ out: return ret; } /* }}} */ -void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ -{ - /* force out a line while stepping so the user knows what is happening */ - if (ignore_flags || - (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || - (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) || - (PHPDBG_G(oplog)))) { - - zend_op *opline = execute_data->opline; - char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC); - - if (ignore_flags || - (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || - (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) { - /* output line info */ - 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), "#%- 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); - } - } -} /* }}} */ - -void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC) /* {{{ */ -{ - phpdbg_print_opline_ex(execute_data, NULL, ignore_flags TSRMLS_CC); -} /* }}} */ - void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ { /* this is implicitly required */ @@ -1084,12 +1041,6 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */ } } /* }}} */ -void phpdbg_sigint_handler(int signo) -{ - TSRMLS_FETCH(); - PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; -} - static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */ { #if PHP_VERSION_ID >= 50500 diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h index a410cc4ec4..89623d0835 100644 --- a/phpdbg_prompt.h +++ b/phpdbg_prompt.h @@ -20,21 +20,13 @@ #ifndef PHPDBG_PROMPT_H #define PHPDBG_PROMPT_H +/* {{{ */ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC); int phpdbg_interactive(TSRMLS_D); -void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags TSRMLS_DC); -char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRMLS_DC); int phpdbg_compile(TSRMLS_D); -void phpdbg_clean(zend_bool full TSRMLS_DC); -void phpdbg_sigint_handler(int signo); +void phpdbg_clean(zend_bool full TSRMLS_DC); /* }}} */ -#if PHP_VERSION_ID >= 50500 -void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC); -#else -void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC); -#endif - -/* {{{ */ +/* {{{ phpdbg command handlers */ PHPDBG_COMMAND(exec); PHPDBG_COMMAND(compile); PHPDBG_COMMAND(step); @@ -59,4 +51,14 @@ PHPDBG_COMMAND(oplog); PHPDBG_COMMAND(register); PHPDBG_COMMAND(quit); /* }}} */ +/* {{{ prompt commands */ +extern const phpdbg_command_t phpdbg_prompt_commands[]; /* }}} */ + +/* {{{ */ +#if PHP_VERSION_ID >= 50500 +void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC); +#else +void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC); +#endif /* }}} */ + #endif /* PHPDBG_PROMPT_H */ -- 2.50.1