From ca32181b1c1a16cd6887c0a32c02991663b3ddac Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 17 Nov 2013 13:42:34 -0200 Subject: [PATCH] - Initial code for info command --- config.m4 | 6 +++--- phpdbg_info.c | 40 ++++++++++++++++++++++++++++++++++++++++ phpdbg_info.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ phpdbg_prompt.c | 8 ++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 phpdbg_info.c create mode 100644 phpdbg_info.h diff --git a/config.m4 b/config.m4 index 3ee8ec8d999..248647a1864 100644 --- a/config.m4 +++ b/config.m4 @@ -10,15 +10,15 @@ PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, if test "$PHP_PHPDBG" != "no"; then AC_DEFINE(HAVE_PHPDBG, 1, [ ]) - + if test "$PHP_PHPDBG_DEBUG" != "no"; then AC_DEFINE(PHPDBG_DEBUG, 1, [ ]) else AC_DEFINE(PHPDBG_DEBUG, 0, [ ]) fi - + PHP_PHPDBG_CFLAGS="-I$abc_srcdir" - PHP_PHPDBG_FILES="phpdbg.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.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_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c" PHP_SUBST(PHP_PHPDBG_CFLAGS) PHP_SUBST(PHP_PHPDBG_FILES) diff --git a/phpdbg_info.c b/phpdbg_info.c new file mode 100644 index 00000000000..c396f15bfad --- /dev/null +++ b/phpdbg_info.c @@ -0,0 +1,40 @@ +/* + +----------------------------------------------------------------------+ + | 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 "php.h" +#include "phpdbg_utils.h" +#include "phpdbg_info.h" + +PHPDBG_INFO(files) /* {{{ */ +{ + HashPosition pos; + char *fname; + + phpdbg_notice("Included files: %d", + zend_hash_num_elements(&EG(included_files))); + + zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos); + while (zend_hash_get_current_key_ex(&EG(included_files), &fname, + NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) { + phpdbg_writeln("File: %s", fname); + zend_hash_move_forward_ex(&EG(included_files), &pos); + } + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_info.h b/phpdbg_info.h new file mode 100644 index 00000000000..44a58682231 --- /dev/null +++ b/phpdbg_info.h @@ -0,0 +1,46 @@ +/* + +----------------------------------------------------------------------+ + | 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_INFO_H +#define PHPDBG_INFO_H + +#include "TSRM.h" +#include "phpdbg.h" +#include "phpdbg_prompt.h" +#include "phpdbg_utils.h" + +/** + * Command Declarators + */ +#define PHPDBG_INFO_HANDLER(name) phpdbg_do_info_##name +#define PHPDBG_INFO_D(name, tip) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, 0, phpdbg_do_info_##name, NULL} +#define PHPDBG_INFO_EX_D(name, tip, alias) \ + {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_info_##name, NULL} +#define PHPDBG_INFO(name) \ + int PHPDBG_INFO_HANDLER(name)(phpdbg_param_t *param TSRMLS_DC) + +PHPDBG_INFO(files); + +static const phpdbg_command_t phpdbg_info_commands[] = { + PHPDBG_INFO_EX_D(files, "lists included files", 'f'), + {NULL, 0, 0} +}; + +#endif /* PHPDBG_INFO_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index ef041321f5a..c110657d351 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -24,6 +24,7 @@ #include "phpdbg.h" #include "phpdbg_help.h" #include "phpdbg_print.h" +#include "phpdbg_info.h" #include "phpdbg_break.h" #include "phpdbg_bp.h" #include "phpdbg_opcode.h" @@ -43,6 +44,7 @@ static PHPDBG_COMMAND(print); static PHPDBG_COMMAND(break); static PHPDBG_COMMAND(back); static PHPDBG_COMMAND(list); +static PHPDBG_COMMAND(info); static PHPDBG_COMMAND(clean); static PHPDBG_COMMAND(clear); static PHPDBG_COMMAND(help); @@ -65,6 +67,7 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMANDS_D(break, "set breakpoint", 'b', phpdbg_break_commands), PHPDBG_COMMAND_EX_D(back, "show trace", 't'), PHPDBG_COMMANDS_D(list, "lists some code", 'l', phpdbg_list_commands), + PHPDBG_COMMANDS_D(info, "displays some informations", 'i', phpdbg_info_commands), PHPDBG_COMMAND_EX_D(clean, "clean the execution environment", 'X'), PHPDBG_COMMAND_EX_D(clear, "clear breakpoints", 'C'), PHPDBG_COMMANDS_D(help, "show help menu", 'h', phpdbg_help_commands), @@ -489,6 +492,11 @@ static PHPDBG_COMMAND(print) /* {{{ */ return SUCCESS; } /* }}} */ +static PHPDBG_COMMAND(info) /* {{{ */ +{ + return SUCCESS; +} /* }}} */ + static PHPDBG_COMMAND(break) /* {{{ */ { switch (param->type) {