]> granicus.if.org Git - php/commitdiff
printer commands
authorkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 08:26:11 +0000 (08:26 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 08:26:11 +0000 (08:26 +0000)
config.m4
phpdbg_print.c [new file with mode: 0644]
phpdbg_print.h [new file with mode: 0644]
phpdbg_prompt.c

index df127084ae843c62429dc4ee8054b76375cd8700..92f626e86557d0639e2c4a863953d2f89ec13646 100644 (file)
--- 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 (file)
index 0000000..c167482
--- /dev/null
@@ -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 <felipe@php.net>                                |
+   | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
+   +----------------------------------------------------------------------+
+*/
+
+#include <stdio.h>
+#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 (file)
index 0000000..825316a
--- /dev/null
@@ -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 <felipe@php.net>                                |
+   | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
+   +----------------------------------------------------------------------+
+*/
+
+#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 */
index d42e638b51997e41186a557c953fb822f79a76e8..dd225d6dbc43f4ff33a15b00ab5964b677cb1ba8 100644 (file)
@@ -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");