This commit is contained in:
Bob Weinand 2013-11-25 23:45:55 +01:00
parent 4e6a8eeffa
commit 02ae3f8de1
6 changed files with 80 additions and 49 deletions

View file

@ -162,6 +162,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
if (PHPDBG_G(prompt)[0]) {
free(PHPDBG_G(prompt)[0]);
}
if (PHPDBG_G(prompt)[1]) {
free(PHPDBG_G(prompt)[1]);
}
@ -565,19 +566,21 @@ int main(int argc, char **argv) /* {{{ */
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
phpdbg_main:
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
tsrm_ls = ts_resource(0);
#endif
if (!cleaning) {
bp_tmp_file = malloc(L_tmpnam);
tmpnam(bp_tmp_file);
if (bp_tmp_file == NULL) {
phpdbg_error("Unable to create temporary file");
}
}
phpdbg_main:
ini_entries = NULL;
ini_entries_len = 0;
ini_ignore = 0;
@ -858,16 +861,15 @@ phpdbg_out:
sapi_shutdown();
}
#ifdef ZTS
tsrm_shutdown();
#endif
if (cleaning) {
goto phpdbg_main;
}
free(bp_tmp_file);
#ifdef ZTS
/* bugggy */
/* tsrm_shutdown(); */
#endif
return 0;
} /* }}} */

View file

@ -112,11 +112,12 @@
#define PHPDBG_IS_INITIALIZING (1<<19)
#define PHPDBG_IS_SIGNALED (1<<20)
#define PHPDBG_IS_INTERACTIVE (1<<21)
#define PHPDBG_IS_BP_ENABLED (1<<22)
#ifndef _WIN32
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED|PHPDBG_IS_BP_ENABLED)
#else
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET)
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_BP_ENABLED)
#endif /* }}} */
/* {{{ strings */

View file

@ -545,6 +545,10 @@ int phpdbg_find_conditional_breakpoint(TSRMLS_D) /* {{{ */
int phpdbg_find_breakpoint(zend_execute_data* execute_data TSRMLS_DC) /* {{{ */
{
if (!(PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED)) {
return FAILURE;
}
/* conditions cannot be executed by eval()'d code */
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)
&& (PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)

View file

@ -234,7 +234,7 @@ PHPDBG_HELP(break) /* {{{ */
phpdbg_writeln(EMPTY);
phpdbg_writeln("\t%sbreak [address] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C));
phpdbg_writeln("\t%sb [a] 0x7ff68f570e08", phpdbg_get_prompt(TSRMLS_C));
phpdbg_writeln("\tWill break at the opline with the address provided (addresses are shown during execution)");
phpdbg_writeln("\tWill break at the opline with the address provided");
phpdbg_writeln(EMPTY);
phpdbg_writeln("\t%sbreak [lineno] 200", phpdbg_get_prompt(TSRMLS_C));
phpdbg_writeln("\t%sb [l] 200", phpdbg_get_prompt(TSRMLS_C));

View file

@ -41,6 +41,28 @@ PHPDBG_SET(prompt) /* {{{ */
return SUCCESS;
} /* }}} */
PHPDBG_SET(break) /* {{{ */
{
switch (param->type) {
case EMPTY_PARAM:
phpdbg_writeln("%s",
PHPDBG_G(flags) & PHPDBG_IS_BP_ENABLED ? "on" : "off");
break;
case STR_PARAM:
if (strncasecmp(param->str, PHPDBG_STRL("on")) == 0) {
PHPDBG_G(flags) |= PHPDBG_IS_BP_ENABLED;
} else if (strncasecmp(param->str, PHPDBG_STRL("off")) == 0) {
PHPDBG_G(flags) ^= PHPDBG_IS_BP_ENABLED;
}
break;
phpdbg_default_switch_case();
}
return SUCCESS;
} /* }}} */
PHPDBG_SET(color) /* {{{ */
{
if ((param->type == STR_PARAM) && (input->argc == 3)) {

View file

@ -27,11 +27,13 @@
PHPDBG_SET(prompt);
PHPDBG_SET(color);
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),
PHPDBG_COMMAND_D_EX(color, "usage: set color <element> <color>", 'c', set_color, NULL, 1),
PHPDBG_COMMAND_D_EX(oplog, "usage: set oplog <output>", 'O', set_oplog, NULL, 0),
PHPDBG_COMMAND_D_EX(break, "usage: set break <on|off>", 'b', set_break, NULL, 0),
PHPDBG_END_COMMAND
};