]> granicus.if.org Git - php/commitdiff
- Initial code for info command
authorFelipe Pena <felipensp@gmail.com>
Sun, 17 Nov 2013 15:42:34 +0000 (13:42 -0200)
committerFelipe Pena <felipensp@gmail.com>
Sun, 17 Nov 2013 15:42:34 +0000 (13:42 -0200)
config.m4
phpdbg_info.c [new file with mode: 0644]
phpdbg_info.h [new file with mode: 0644]
phpdbg_prompt.c

index 3ee8ec8d99974f7db6d16e951825f5de58b0109b..248647a186406f91277ccc7784f2375c6ee21197 100644 (file)
--- 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 (file)
index 0000000..c396f15
--- /dev/null
@@ -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 <felipe@php.net>                                |
+   | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
+   +----------------------------------------------------------------------+
+*/
+
+#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 (file)
index 0000000..44a5868
--- /dev/null
@@ -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 <felipe@php.net>                                |
+   | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
+   +----------------------------------------------------------------------+
+*/
+
+#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 */
index ef041321f5ac1b55de43ba36d07b0df196589a46..c110657d3519d3cc9885db389fad033d370575df 100644 (file)
@@ -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) {