- Initial code for info command

This commit is contained in:
Felipe Pena 2013-11-17 13:42:34 -02:00
parent f2b8cdc5be
commit ca32181b1c
4 changed files with 97 additions and 3 deletions

View File

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

40
phpdbg_info.c Normal file
View File

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

46
phpdbg_info.h Normal file
View File

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

View 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) {