Merge branch 'master' into watchpoints_recursive

Conflicts:
	phpdbg.c
	phpdbg_utils.c
	phpdbg_utils.h
This commit is contained in:
Bob Weinand 2014-03-23 23:32:13 +01:00
commit c86ba551ac
22 changed files with 1058 additions and 787 deletions

View File

@ -3,10 +3,10 @@ dnl $Id$
dnl
PHP_ARG_ENABLE(phpdbg, for phpdbg support,
[ --enable-phpdbg Build phpdbg], yes, yes)
[ --enable-phpdbg Build phpdbg], no, no)
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
if test "$PHP_PHPDBG" != "no"; then
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@ -20,9 +20,14 @@ if test "$PHP_PHPDBG" != "no"; then
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
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 phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c"
if test "$PHP_READLINE" != "no"; then
PHPDBG_EXTRA_LIBS="-lreadline"
fi
PHP_SUBST(PHP_PHPDBG_CFLAGS)
PHP_SUBST(PHP_PHPDBG_FILES)
PHP_SUBST(PHPDBG_EXTRA_LIBS)
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag])
PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)])

View File

@ -1,4 +1,4 @@
ARG_ENABLE('phpdbg', 'Build phpdbg', 'yes');
ARG_ENABLE('phpdbg', 'Build phpdbg', 'no');
ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no');
PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_win.c phpdbg_btree.c';
@ -15,4 +15,4 @@ if (PHP_PHPDBGS == "yes") {
SAPI('phpdbgs', PHPDBG_SOURCES, PHPDBG_DLL, '/D PHP_PHPDBG_EXPORTS /I win32');
ADD_FLAG("LIBS_PHPDBGS", "ws2_32.lib user32.lib");
DEFINE("CFLAGS", configure_subst.item("CFLAGS") + " /EHa");
}
}

View File

@ -221,8 +221,8 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
static PHP_FUNCTION(phpdbg_exec)
{
char *exec = NULL;
zend_ulong exec_len = 0L;
int exec_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) {
return;
}
@ -263,9 +263,9 @@ static PHP_FUNCTION(phpdbg_exec)
static PHP_FUNCTION(phpdbg_break)
{
if (ZEND_NUM_ARGS() > 0) {
long type;
long type = 0;
char *expr = NULL;
zend_uint expr_len = 0;
int expr_len = 0;
phpdbg_param_t param;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type, &expr, &expr_len) == FAILURE) {
@ -323,9 +323,9 @@ static PHP_FUNCTION(phpdbg_clear)
/* {{{ proto void phpdbg_color(integer element, string color) */
static PHP_FUNCTION(phpdbg_color)
{
long element;
char *color;
zend_uint color_len;
long element = 0L;
char *color = NULL;
int color_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) {
return;
@ -345,8 +345,8 @@ static PHP_FUNCTION(phpdbg_color)
/* {{{ proto void phpdbg_prompt(string prompt) */
static PHP_FUNCTION(phpdbg_prompt)
{
char *prompt;
zend_uint prompt_len;
char *prompt = NULL;
int prompt_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) {
return;
@ -619,10 +619,10 @@ const char phpdbg_ini_hardcoded[] =
/* overwriteable ini defaults must be set in phpdbg_ini_defaults() */
#define INI_DEFAULT(name, value) \
Z_SET_REFCOUNT(tmp, 0); \
Z_UNSET_ISREF(tmp); \
ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \
zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);
Z_SET_REFCOUNT(tmp, 0); \
Z_UNSET_ISREF(tmp); \
ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \
zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);
void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */
{
@ -856,7 +856,13 @@ int main(int argc, char **argv) /* {{{ */
zend_bool remote = 0;
int run = 0;
int step = 0;
char *bp_tmp_file;
#ifdef _WIN32
char *bp_tmp_file = NULL;
#else
char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX";
#endif
#ifndef _WIN32
char *address;
int listen[2];
@ -900,11 +906,27 @@ int main(int argc, char **argv) /* {{{ */
phpdbg_main:
if (!cleaning) {
#ifdef _WIN32
bp_tmp_file = malloc(L_tmpnam);
tmpnam(bp_tmp_file);
if (bp_tmp_file == NULL) {
phpdbg_error("Unable to create temporary file");
if (bp_tmp_file) {
if (!tmpnam(bp_tmp_file)) {
free(bp_tmp_file);
bp_tmp_file = NULL;
}
}
if (!bp_tmp_file) {
phpdbg_error("Unable to create temporary file");
return 1;
}
#else
if (!mkstemp(bp_tmp_file)) {
memset(bp_tmp_file, 0, sizeof(bp_tmp_file));
}
#endif
}
ini_entries = NULL;
ini_entries_len = 0;
@ -1181,6 +1203,8 @@ phpdbg_main:
sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
#endif
php_request_startup(TSRMLS_C);
/* do not install sigint handlers for remote consoles */
/* sending SIGINT then provides a decent way of shutting down the server */
#if defined(ZEND_SIGNALS) && !defined(_WIN32)
@ -1238,20 +1262,11 @@ phpdbg_main:
/* set default prompt */
phpdbg_set_prompt(PROMPT TSRMLS_CC);
zend_try {
zend_activate_modules(TSRMLS_C);
} zend_end_try();
if (show_banner) {
/* print blurb */
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
}
zend_try {
/* activate globals, they can be overwritten */
zend_activate_auto_globals(TSRMLS_C);
} zend_end_try();
/* initialize from file */
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
zend_try {
@ -1357,24 +1372,14 @@ phpdbg_out:
if (ini_override) {
free(ini_override);
}
/* this must be forced */
CG(unclean_shutdown) = 0;
/* this is just helpful */
PG(report_memleaks) = 0;
if (PG(modules_activated)) {
zend_try {
zend_deactivate_modules(TSRMLS_C);
} zend_end_try();
}
zend_deactivate(TSRMLS_C);
zend_try {
zend_post_deactivate_modules(TSRMLS_C);
} zend_end_try();
#ifdef ZEND_SIGNALS
zend_try {
zend_signal_deactivate(TSRMLS_C);
} zend_end_try();
#endif
php_request_shutdown((void*)0);
zend_try {
php_module_shutdown(TSRMLS_C);
@ -1402,8 +1407,12 @@ phpdbg_out:
if (sapi_name) {
free(sapi_name);
}
#ifdef _WIN32
free(bp_tmp_file);
#else
unlink(bp_tmp_file);
#endif
return 0;
} /* }}} */

View File

@ -154,7 +154,7 @@
#define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */
#define PHPDBG_URL "http://phpdbg.com"
#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues"
#define PHPDBG_VERSION "0.3.1"
#define PHPDBG_VERSION "0.3.2"
#define PHPDBG_INIT_FILENAME ".phpdbginit"
/* }}} */

View File

@ -324,9 +324,9 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
PHPDBG_BREAK_MAPPING(new_break.id, class_table);
} else {
phpdbg_notice("Breakpoint exists at %s::%s", class_name, func_name);
}
}
efree(lcname);
efree(lcname);
} /* }}} */
PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ */
@ -355,7 +355,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{
PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
phpdbg_breakline_t opline_break;
if (op_array->last < brake->opline_num) {
if (op_array->last <= brake->opline_num) {
if (brake->class_name == NULL) {
phpdbg_error("There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num);
} else if (brake->func_name == NULL) {
@ -992,7 +992,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position);
zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS;
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) {
zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) {
zval *retval = NULL;
int orig_interactive = CG(interactive);
zval **orig_retval = EG(return_value_ptr_ptr);

View File

@ -27,6 +27,22 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
/**
* Commands
*/
const phpdbg_command_t phpdbg_break_commands[] = {
PHPDBG_COMMAND_D_EX(file, "specify breakpoint by file:line", 'F', break_file, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "specify breakpoint by global function name", 'f', break_func, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "specify breakpoint by class::method", 'm', break_method, NULL, 1),
PHPDBG_COMMAND_D_EX(address, "specify breakpoint by address", 'a', break_address, NULL, 1),
PHPDBG_COMMAND_D_EX(op, "specify breakpoint by opcode", 'O', break_op, NULL, 1),
PHPDBG_COMMAND_D_EX(on, "specify breakpoint by condition", 'o', break_on, NULL, 1),
PHPDBG_COMMAND_D_EX(at, "specify breakpoint by location and condition", 'A', break_at, NULL, 1),
PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, 1),
PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, 1),
PHPDBG_END_COMMAND
};
PHPDBG_BREAK(file) /* {{{ */
{
switch (param->type) {

View File

@ -39,20 +39,6 @@ PHPDBG_BREAK(on);
PHPDBG_BREAK(lineno);
PHPDBG_BREAK(del);
/**
* Commands
*/
static const phpdbg_command_t phpdbg_break_commands[] = {
PHPDBG_COMMAND_D_EX(file, "specify breakpoint by file:line", 'F', break_file, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "specify breakpoint by global function name", 'f', break_func, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "specify breakpoint by class::method", 'm', break_method, NULL, 1),
PHPDBG_COMMAND_D_EX(address, "specify breakpoint by address", 'a', break_address, NULL, 1),
PHPDBG_COMMAND_D_EX(op, "specify breakpoint by opcode", 'O', break_op, NULL, 1),
PHPDBG_COMMAND_D_EX(on, "specify breakpoint by condition", 'o', break_on, NULL, 1),
PHPDBG_COMMAND_D_EX(at, "specify breakpoint by location and condition", 'A', break_at, NULL, 1),
PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, 1),
PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, 1),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_break_commands[];
#endif /* PHPDBG_BREAK_H */

View File

@ -459,6 +459,9 @@ PHPDBG_API phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
phpdbg_input_t *buffer = NULL;
char *cmd = NULL;
#ifndef HAVE_LIBREADLINE
char buf[PHPDBG_MAX_CMD];
#endif
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) &&
@ -475,9 +478,8 @@ disconnect:
}
#ifndef HAVE_LIBREADLINE
char buf[PHPDBG_MAX_CMD];
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) {
if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) {
goto disconnect;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -30,63 +30,19 @@
/**
* Helper Forward Declarations
*/
PHPDBG_HELP(exec);
PHPDBG_HELP(compile);
PHPDBG_HELP(step);
PHPDBG_HELP(next);
PHPDBG_HELP(run);
PHPDBG_HELP(eval);
PHPDBG_HELP(until);
PHPDBG_HELP(finish);
PHPDBG_HELP(leave);
PHPDBG_HELP(print);
PHPDBG_HELP(break);
PHPDBG_HELP(clean);
PHPDBG_HELP(clear);
PHPDBG_HELP(info);
PHPDBG_HELP(back);
PHPDBG_HELP(frame);
PHPDBG_HELP(quiet);
PHPDBG_HELP(list);
PHPDBG_HELP(set);
PHPDBG_HELP(register);
PHPDBG_HELP(options);
PHPDBG_HELP(source);
PHPDBG_HELP(shell);
PHPDBG_HELP(aliases);
/**
* Commands
*/
static const phpdbg_command_t phpdbg_help_commands[] = {
PHPDBG_COMMAND_D_EX(exec, "the execution context should be a valid path", 'e', help_exec, NULL, 0),
PHPDBG_COMMAND_D_EX(compile, "allow inspection of code before execution", 'c', help_compile, NULL, 0),
PHPDBG_COMMAND_D_EX(step, "step through execution to break at every opcode", 's', help_step, NULL, 0),
PHPDBG_COMMAND_D_EX(next, "continue executing while stepping or after breaking", 'n', help_next, NULL, 0),
PHPDBG_COMMAND_D_EX(run, "execute inside the phpdbg vm", 'r', help_run, NULL, 0),
PHPDBG_COMMAND_D_EX(eval, "access to eval() allows affecting the environment", 'E', help_eval, NULL, 0),
PHPDBG_COMMAND_D_EX(until, "continue until the current line is executed", 'u', help_until, NULL, 0),
PHPDBG_COMMAND_D_EX(finish, "continue until the current function has returned", 'F', help_finish, NULL, 0),
PHPDBG_COMMAND_D_EX(leave, "continue until the current function is returning", 'L', help_leave, NULL, 0),
PHPDBG_COMMAND_D_EX(print, "print context information or instructions", 'p', help_print, NULL, 0),
PHPDBG_COMMAND_D_EX(break, "breakpoints allow execution interruption", 'b', help_break, NULL, 0),
PHPDBG_COMMAND_D_EX(clean, "resetting the environment is useful while debugging", 'X', help_clean, NULL, 0),
PHPDBG_COMMAND_D_EX(clear, "reset breakpoints to execute without interruption", 'c', help_clear, NULL, 0),
PHPDBG_COMMAND_D_EX(info, "quick access to useful information on the console", 'i', help_info, NULL, 0),
PHPDBG_COMMAND_D_EX(back, "show debug backtrace information during execution", 't', help_back, NULL, 0),
PHPDBG_COMMAND_D_EX(frame, "switch to a frame in the current stack for inspection", 'f', help_frame, NULL, 0),
PHPDBG_COMMAND_D_EX(quiet, "be quiet during execution", 'Q', help_quiet, NULL, 0),
PHPDBG_COMMAND_D_EX(list, "list code gives you quick access to code", 'l', help_list, NULL, 0),
PHPDBG_COMMAND_D_EX(set, "configure how phpdbg looks and behaves", 'S', help_set, NULL, 0),
PHPDBG_COMMAND_D_EX(register, "register a function for use as a command", 'R', help_register,NULL, 0),
PHPDBG_COMMAND_D_EX(options, "show information about command line options", 'o', help_options, NULL, 0),
PHPDBG_COMMAND_D_EX(source, "load a phpdbginit file at the console", '.', help_source, NULL, 0),
PHPDBG_COMMAND_D_EX(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_help_commands[];
#define phpdbg_help_header() \
phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s", PHPDBG_VERSION);
#define phpdbg_help_footer() \
phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES);
typedef struct _phpdbg_help_text_t {
char *key;
char *text;
} phpdbg_help_text_t;
extern phpdbg_help_text_t phpdbg_help_text[];
#endif /* PHPDBG_HELP_H */

View File

@ -26,6 +26,18 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
const phpdbg_command_t phpdbg_info_commands[] = {
PHPDBG_COMMAND_D_EX(break, "show breakpoints", 'b', info_break, NULL, 0),
PHPDBG_COMMAND_D_EX(files, "show included files", 'F', info_files, NULL, 0),
PHPDBG_COMMAND_D_EX(classes, "show loaded classes", 'c', info_classes, NULL, 0),
PHPDBG_COMMAND_D_EX(funcs, "show loaded classes", 'f', info_funcs, NULL, 0),
PHPDBG_COMMAND_D_EX(error, "show last error", 'e', info_error, NULL, 0),
PHPDBG_COMMAND_D_EX(vars, "show active variables", 'v', info_vars, NULL, 0),
PHPDBG_COMMAND_D_EX(literal, "show active literal constants", 'l', info_literal, NULL, 0),
PHPDBG_COMMAND_D_EX(memory, "show memory manager stats", 'm', info_memory, NULL, 0),
PHPDBG_END_COMMAND
};
PHPDBG_INFO(break) /* {{{ */
{
phpdbg_print_breakpoints(PHPDBG_BREAK_FILE TSRMLS_CC);

View File

@ -34,16 +34,6 @@ PHPDBG_INFO(vars);
PHPDBG_INFO(literal);
PHPDBG_INFO(memory);
static const phpdbg_command_t phpdbg_info_commands[] = {
PHPDBG_COMMAND_D_EX(break, "show breakpoints", 'b', info_break, NULL, 0),
PHPDBG_COMMAND_D_EX(files, "show included files", 'F', info_files, NULL, 0),
PHPDBG_COMMAND_D_EX(classes, "show loaded classes", 'c', info_classes, NULL, 0),
PHPDBG_COMMAND_D_EX(funcs, "show loaded classes", 'f', info_funcs, NULL, 0),
PHPDBG_COMMAND_D_EX(error, "show last error", 'e', info_error, NULL, 0),
PHPDBG_COMMAND_D_EX(vars, "show active variables", 'v', info_vars, NULL, 0),
PHPDBG_COMMAND_D_EX(literal, "show active literal constants", 'l', info_literal, NULL, 0),
PHPDBG_COMMAND_D_EX(memory, "show memory manager stats", 'm', info_memory, NULL, 0),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_info_commands[];
#endif /* PHPDBG_INFO_H */

View File

@ -32,6 +32,14 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
const phpdbg_command_t phpdbg_list_commands[] = {
PHPDBG_COMMAND_D_EX(lines, "lists the specified lines", 'l', list_lines, NULL, 1),
PHPDBG_COMMAND_D_EX(class, "lists the specified class", 'c', list_class, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "lists the specified method", 'm', list_method, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "lists the specified function", 'f', list_func, NULL, 1),
PHPDBG_END_COMMAND
};
PHPDBG_LIST(lines) /* {{{ */
{
if (!PHPDBG_G(exec) && !zend_is_executing(TSRMLS_C)) {

View File

@ -36,12 +36,6 @@ void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC);
void phpdbg_list_function(const zend_function* TSRMLS_DC);
void phpdbg_list_file(const char*, long, long, int TSRMLS_DC);
static const phpdbg_command_t phpdbg_list_commands[] = {
PHPDBG_COMMAND_D_EX(lines, "lists the specified lines", 'l', list_lines, NULL, 1),
PHPDBG_COMMAND_D_EX(class, "lists the specified class", 'c', list_class, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "lists the specified method", 'm', list_method, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "lists the specified function", 'f', list_func, NULL, 1),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_list_commands[];
#endif /* PHPDBG_LIST_H */

View File

@ -26,6 +26,16 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
const phpdbg_command_t phpdbg_print_commands[] = {
PHPDBG_COMMAND_D_EX(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0),
PHPDBG_COMMAND_D_EX(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0),
PHPDBG_COMMAND_D_EX(class, "print out the instructions in the specified class", 'c', print_class, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "print out the instructions in the specified method", 'm', print_method, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "print out the instructions in the specified function", 'f', print_func, NULL, 1),
PHPDBG_COMMAND_D_EX(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0),
PHPDBG_END_COMMAND
};
PHPDBG_PRINT(opline) /* {{{ */
{
if (EG(in_execution) && EG(current_execute_data)) {
@ -77,7 +87,7 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
phpdbg_error("\tFailed to decode opline %16p", opline);
}
opline++;
} while (++opcode < end);
} while (opcode++ < end);
zend_hash_destroy(&vars);
}
} break;

View File

@ -35,17 +35,6 @@ PHPDBG_PRINT(method);
PHPDBG_PRINT(func);
PHPDBG_PRINT(stack);
/**
* Commands
*/
static const phpdbg_command_t phpdbg_print_commands[] = {
PHPDBG_COMMAND_D_EX(exec, "print out the instructions in the execution context", 'e', print_exec, NULL, 0),
PHPDBG_COMMAND_D_EX(opline, "print out the instruction in the current opline", 'o', print_opline, NULL, 0),
PHPDBG_COMMAND_D_EX(class, "print out the instructions in the specified class", 'c', print_class, NULL, 1),
PHPDBG_COMMAND_D_EX(method, "print out the instructions in the specified method", 'm', print_method, NULL, 1),
PHPDBG_COMMAND_D_EX(func, "print out the instructions in the specified function", 'f', print_func, NULL, 1),
PHPDBG_COMMAND_D_EX(stack, "print out the instructions in the current stack", 's', print_stack, NULL, 0),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_print_commands[];
#endif /* PHPDBG_PRINT_H */

View File

@ -57,7 +57,6 @@ const phpdbg_command_t phpdbg_prompt_commands[] = {
PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0),
PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, 2),
PHPDBG_COMMAND_D(quiet, "silence some output", 'Q', NULL, 1),
PHPDBG_COMMAND_D(aliases, "show alias list", 'a', NULL, 0),
PHPDBG_COMMAND_D(set, "set phpdbg configuration", 'S', phpdbg_set_commands, 1),
PHPDBG_COMMAND_D(register,"register a function", 'R', NULL, 1),
PHPDBG_COMMAND_D(source, "execute a phpdbginit", '.', NULL, 1),
@ -553,6 +552,7 @@ PHPDBG_COMMAND(run) /* {{{ */
zend_op_array *orig_op_array = EG(active_op_array);
zval **orig_retval_ptr = EG(return_value_ptr_ptr);
zend_bool restore = 1;
zend_execute_data *ex = EG(current_execute_data);
if (!PHPDBG_G(ops)) {
if (phpdbg_compile(TSRMLS_C) == FAILURE) {
@ -568,7 +568,6 @@ PHPDBG_COMMAND(run) /* {{{ */
}
/* clean up from last execution */
zend_execute_data *ex = EG(current_execute_data);
if (ex && ex->symbol_table) {
zend_hash_clean(ex->symbol_table);
}
@ -909,76 +908,6 @@ PHPDBG_COMMAND(clear) /* {{{ */
return SUCCESS;
} /* }}} */
PHPDBG_COMMAND(aliases) /* {{{ */
{
const phpdbg_command_t *prompt_command = phpdbg_prompt_commands;
phpdbg_help_header();
phpdbg_writeln("Below are the aliased, short versions of all supported commands");
while (prompt_command && prompt_command->name) {
if (prompt_command->alias) {
if (prompt_command->subs) {
const phpdbg_command_t *sub_command = prompt_command->subs;
phpdbg_writeln(EMPTY);
phpdbg_writeln(" %c -> %9s", prompt_command->alias, prompt_command->name);
while (sub_command && sub_command->name) {
if (sub_command->alias) {
phpdbg_writeln(" |-------- %c -> %15s\t%s", sub_command->alias,
sub_command->name, sub_command->tip);
}
++sub_command;
}
phpdbg_writeln(EMPTY);
} else {
phpdbg_writeln(" %c -> %9s\t\t\t%s", prompt_command->alias,
prompt_command->name, prompt_command->tip);
}
}
++prompt_command;
}
phpdbg_help_footer();
return SUCCESS;
} /* }}} */
PHPDBG_COMMAND(help) /* {{{ */
{
switch (param->type) {
case EMPTY_PARAM: {
const phpdbg_command_t *prompt_command = phpdbg_prompt_commands;
const phpdbg_command_t *help_command = phpdbg_help_commands;
phpdbg_help_header();
phpdbg_writeln("To get help regarding a specific command type \"help command\"");
phpdbg_notice("Commands");
while (prompt_command && prompt_command->name) {
phpdbg_writeln(
" %10s\t%s", prompt_command->name, prompt_command->tip);
++prompt_command;
}
phpdbg_notice("Help Commands");
while (help_command && help_command->name) {
phpdbg_writeln(" %10s\t%s", help_command->name, help_command->tip);
++help_command;
}
phpdbg_help_footer();
} break;
default: {
phpdbg_error(
"No help can be found for the subject \"%s\"", param->str);
}
}
return SUCCESS;
} /* }}} */
PHPDBG_COMMAND(quiet) /* {{{ */
{
switch (param->type) {

View File

@ -48,7 +48,6 @@ PHPDBG_COMMAND(clean);
PHPDBG_COMMAND(clear);
PHPDBG_COMMAND(help);
PHPDBG_COMMAND(quiet);
PHPDBG_COMMAND(aliases);
PHPDBG_COMMAND(shell);
PHPDBG_COMMAND(set);
PHPDBG_COMMAND(source);

View File

@ -26,6 +26,17 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
const phpdbg_command_t phpdbg_set_commands[] = {
PHPDBG_COMMAND_D_EX(prompt, "usage: set prompt <string>", 'p', set_prompt, NULL, 0),
#ifndef _WIN32
PHPDBG_COMMAND_D_EX(color, "usage: set color <element> <color>", 'c', set_color, NULL, 1),
PHPDBG_COMMAND_D_EX(colors, "usage: set colors <on|off>", 'C', set_colors, NULL, 1),
#endif
PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog <output>", 'O', set_oplog, NULL, 0),
PHPDBG_COMMAND_D_EX(break, "usage: set break [id] <on|off>", 'b', set_break, NULL, 0),
PHPDBG_END_COMMAND
};
PHPDBG_SET(prompt) /* {{{ */
{
switch (param->type) {

View File

@ -33,15 +33,6 @@ PHPDBG_SET(colors);
PHPDBG_SET(oplog);
PHPDBG_SET(break);
static const phpdbg_command_t phpdbg_set_commands[] = {
PHPDBG_COMMAND_D_EX(prompt, "usage: set prompt <string>", 'p', set_prompt, NULL, 0),
#ifndef _WIN32
PHPDBG_COMMAND_D_EX(color, "usage: set color <element> <color>", 'c', set_color, NULL, 1),
PHPDBG_COMMAND_D_EX(colors, "usage: set colors <on|off>", 'C', set_colors, NULL, 1),
#endif
PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog <output>", 'O', set_oplog, NULL, 0),
PHPDBG_COMMAND_D_EX(break, "usage: set break [id] <on|off>", 'b', set_break, NULL, 0),
PHPDBG_END_COMMAND
};
extern const phpdbg_command_t phpdbg_set_commands[];
#endif /* PHPDBG_SET_H */

View File

@ -30,6 +30,8 @@
#ifdef _WIN32
# include "win32/time.h"
#elif defined(HAVE_SYS_IOCTL_H)
# include "sys/ioctl.h"
#endif
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@ -403,3 +405,21 @@ int phpdbg_rebuild_symtable(TSRMLS_D) {
return SUCCESS;
}
PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */
{
int columns;
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
#elif defined(HAVE_SYS_IOCTL_H)
struct winsize w;
columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100;
#else
columns = 100;
#endif
return columns;
} /* }}} */

View File

@ -107,6 +107,9 @@ PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); /* }}} */
PHPDBG_API void phpdbg_set_prompt(const char* TSRMLS_DC);
PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */
/* {{{ Console Width */
PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */
int phpdbg_rebuild_symtable(TSRMLS_D);
#endif /* PHPDBG_UTILS_H */