}
} /* }}} */
+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;
+----------------------------------------------------------------------+
*/
+#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) /* {{{ */
{
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
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 */
#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),
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 */
}
} /* }}} */
-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
#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);
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 */