move oplog command to set commands

add help for set commands
move set down in the list of prompt commands
This commit is contained in:
krakjoe 2013-11-24 15:24:12 +00:00
parent c7ef093095
commit e99fd22866
5 changed files with 76 additions and 47 deletions

View File

@ -24,6 +24,7 @@
#include "phpdbg_break.h"
#include "phpdbg_list.h"
#include "phpdbg_info.h"
#include "phpdbg_set.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@ -430,7 +431,28 @@ PHPDBG_HELP(oplog) /* {{{ */
phpdbg_writeln("Note: upon failure to open a new oplog, the last oplog is held open");
phpdbg_help_footer();
return SUCCESS;
}
} /* }}} */
PHPDBG_HELP(set) /* {{{ */
{
phpdbg_help_header();
phpdbg_writeln("Configure how phpdbg looks and behaves with the set command");
phpdbg_writeln("Specific set commands are show below:");
phpdbg_notice("Commands");
{
const phpdbg_command_t *set_command = phpdbg_set_commands;
phpdbg_writeln("\tAlias\tCommand\t\tPurpose");
while (set_command && set_command->name) {
if (set_command->alias) {
phpdbg_writeln("\t[%c]\t%s\t\t%s", set_command->alias, set_command->name, set_command->tip);
} else phpdbg_writeln("\t[ ]\t%s\t\t%s", set_command->name, set_command->tip);
++set_command;
}
}
phpdbg_help_footer();
return SUCCESS;
} /* }}} */
PHPDBG_HELP(register) /* {{{ */
{

View File

@ -47,7 +47,7 @@ PHPDBG_HELP(back);
PHPDBG_HELP(frame);
PHPDBG_HELP(quiet);
PHPDBG_HELP(list);
PHPDBG_HELP(oplog);
PHPDBG_HELP(set);
PHPDBG_HELP(register);
PHPDBG_HELP(options);
PHPDBG_HELP(shell);
@ -74,7 +74,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = {
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(oplog, "keep clutter off the screen by logging oplines", 'O', help_oplog, 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(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0),

View File

@ -46,7 +46,6 @@ const phpdbg_command_t phpdbg_prompt_commands[] = {
PHPDBG_COMMAND_D(until, "continue past the current line", 'u', NULL, 0),
PHPDBG_COMMAND_D(finish, "continue past the end of the stack", 'F', NULL, 0),
PHPDBG_COMMAND_D(leave, "continue until the end of the stack", 'L', NULL, 0),
PHPDBG_COMMAND_D(set, "set debug properties", 'S', phpdbg_set_commands, 1),
PHPDBG_COMMAND_D(print, "print something", 'p', phpdbg_print_commands, 2),
PHPDBG_COMMAND_D(break, "set breakpoint", 'b', phpdbg_break_commands, 1),
PHPDBG_COMMAND_D(back, "show trace", 't', NULL, 0),
@ -58,7 +57,7 @@ const phpdbg_command_t phpdbg_prompt_commands[] = {
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(oplog, "sets oplog output", 'O', NULL, 1),
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(shell, "shell a command", '-', NULL, 1),
PHPDBG_COMMAND_D(quit, "exit phpdbg", 'q', NULL, 0),
@ -931,48 +930,6 @@ PHPDBG_COMMAND(aliases) /* {{{ */
return SUCCESS;
} /* }}} */
PHPDBG_COMMAND(oplog) /* {{{ */
{
switch (param->type) {
case EMPTY_PARAM:
case NUMERIC_PARAM:
if ((param->type != NUMERIC_PARAM) || !param->num) {
if (PHPDBG_G(oplog)) {
phpdbg_notice("Disabling oplog");
fclose(
PHPDBG_G(oplog));
} else {
phpdbg_error("No oplog currently open !");
}
} else {
phpdbg_error(
"No action taken !");
}
break;
case STR_PARAM: {
/* open oplog */
FILE *old = PHPDBG_G(oplog);
PHPDBG_G(oplog) = fopen(param->str, "w+");
if (!PHPDBG_G(oplog)) {
phpdbg_error("Failed to open %s for oplog", param->str);
PHPDBG_G(oplog) = old;
} else {
if (old) {
phpdbg_notice("Closing previously open oplog");
fclose(old);
}
phpdbg_notice("Successfully opened oplog %s", param->str);
}
} break;
phpdbg_default_switch_case();
}
return SUCCESS;
} /* }}} */
PHPDBG_COMMAND(help) /* {{{ */
{
switch (param->type) {

View File

@ -55,3 +55,51 @@ PHPDBG_SET(prompt) /* {{{ */
return SUCCESS;
} /* }}} */
PHPDBG_SET(oplog) /* {{{ */
{
switch (param->type) {
case EMPTY_PARAM:
phpdbg_notice(
"Oplog %s", PHPDBG_G(oplog) ? "enabled" : "disabled");
break;
case NUMERIC_PARAM: switch (param->num) {
case 1:
phpdbg_error(
"An output file must be provided to enable oplog");
break;
case 0: {
if (PHPDBG_G(oplog)) {
phpdbg_notice("Disabling oplog");
fclose(
PHPDBG_G(oplog));
} else {
phpdbg_error("Oplog is not enabled !");
}
} break;
} break;
case STR_PARAM: {
/* open oplog */
FILE *old = PHPDBG_G(oplog);
PHPDBG_G(oplog) = fopen(param->str, "w+");
if (!PHPDBG_G(oplog)) {
phpdbg_error("Failed to open %s for oplog", param->str);
PHPDBG_G(oplog) = old;
} else {
if (old) {
phpdbg_notice("Closing previously open oplog");
fclose(old);
}
phpdbg_notice("Successfully opened oplog %s", param->str);
}
} break;
phpdbg_default_switch_case();
}
return SUCCESS;
} /* }}} */

View File

@ -28,9 +28,11 @@ void phpdbg_set_prompt(const char* TSRMLS_DC);
const char* phpdbg_get_prompt(TSRMLS_D);
PHPDBG_SET(prompt);
PHPDBG_SET(oplog);
static const phpdbg_command_t phpdbg_set_commands[] = {
PHPDBG_COMMAND_D_EX(prompt, "set prompt", 'p', set_prompt, NULL, 0),
PHPDBG_COMMAND_D_EX(oplog, "set oplog output", 'O', set_oplog, NULL, 0),
PHPDBG_END_COMMAND
};