printer commands

This commit is contained in:
krakjoe 2013-11-12 08:26:11 +00:00
parent ff4c0c9397
commit c00abb0e75
4 changed files with 89 additions and 6 deletions

View File

@ -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)

29
phpdbg_print.c Normal file
View File

@ -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;
} /* }}} */

47
phpdbg_print.h Normal file
View File

@ -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 */

View 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");