From c00abb0e75628d2284f76098e43626266a440d3e Mon Sep 17 00:00:00 2001 From: krakjoe Date: Tue, 12 Nov 2013 08:26:11 +0000 Subject: [PATCH] printer commands --- config.m4 | 2 +- phpdbg_print.c | 29 +++++++++++++++++++++++++++++ phpdbg_print.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ phpdbg_prompt.c | 17 ++++++++++++----- 4 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 phpdbg_print.c create mode 100644 phpdbg_print.h diff --git a/config.m4 b/config.m4 index df127084ae8..92f626e8655 100644 --- a/config.m4 +++ b/config.m4 @@ -9,7 +9,7 @@ if test "$PHP_PHPDBG" != "no"; then AC_DEFINE(HAVE_PHPDBG, 1, [ ]) PHP_PHPDBG_CFLAGS="-I$abc_srcdir" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c" + PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c" PHP_SUBST(PHP_PHPDBG_CFLAGS) PHP_SUBST(PHP_PHPDBG_FILES) diff --git a/phpdbg_print.c b/phpdbg_print.c new file mode 100644 index 00000000000..c167482b6f6 --- /dev/null +++ b/phpdbg_print.c @@ -0,0 +1,29 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + +----------------------------------------------------------------------+ +*/ + +#include +#include "zend.h" +#include "phpdbg.h" +#include "phpdbg_print.h" + +PHPDBG_PRINT(default) /* {{{ */ +{ + printf("in default printer\n"); + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_print.h b/phpdbg_print.h new file mode 100644 index 00000000000..825316a965d --- /dev/null +++ b/phpdbg_print.h @@ -0,0 +1,47 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Felipe Pena | + | Authors: Joe Watkins | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHPDBG_PRINT_H +#define PHPDBG_PRINT_H + +#include "TSRM.h" +#include "phpdbg_prompt.h" + +/** + * Command Declarators + */ +#define PHPDBG_PRINT_D(name, tip) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, phpdbg_do_print_##name} +#define PHPDBG_PRINT(name) \ + int phpdbg_do_print_##name(const char *expr, size_t expr_len TSRMLS_DC) + +/** + * Printer Forward Declarations + */ +PHPDBG_PRINT(default); + +/** + * Commands + */ +static const phpdbg_command_t phpdbg_print_commands[] = { + PHPDBG_PRINT_D(default, "the default print command"), + {NULL, 0, 0} +}; + +#endif /* PHPDBG_PRINT_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index d42e638b519..dd225d6dbc4 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -23,6 +23,7 @@ #include "zend_compile.h" #include "phpdbg.h" #include "phpdbg_help.h" +#include "phpdbg_print.h" #include "phpdbg_bp.h" #include "phpdbg_opcode.h" #include "phpdbg_list.h" @@ -228,16 +229,22 @@ static PHPDBG_COMMAND(back) /* {{{ */ static PHPDBG_COMMAND(print) /* {{{ */ { - if (expr_len) { - printf("%s\n", expr); + if (expr_len > 0L) { + if (phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) { + printf( + "%sFailed to find print command: %s/%lu%s\n", + PHPDBG_RED_LINE(TSRMLS_C), expr, expr_len, PHPDBG_END_LINE(TSRMLS_C)); + } return SUCCESS; } -#ifdef HAVE_READLINE_H - printf("HAVE READLINE\n"); -#endif printf("--------------------------------------\n"); printf("Execution Context Information:\n"); +#ifdef HAVE_LIBREADLINE + printf("Readline\tyes\n"); +#else + printf("Readline\tno\n"); +#endif printf("Exec\t\t%s\n", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); printf("Compiled\t%s\n", PHPDBG_G(ops) ? "yes" : "no"); printf("Stepping\t%s\n", (PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ? "on" : "off");