static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */
{
- if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) {
+ if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) == PHPDBG_IS_CLEANING) {
zend_phpdbg_globals *pg = PHPDBG_G(backup) = calloc(1, sizeof(zend_phpdbg_globals));
php_phpdbg_globals_ctor(pg);
pg->oplog = PHPDBG_G(oplog);
pg->prompt[0] = PHPDBG_G(prompt)[0];
pg->prompt[1] = PHPDBG_G(prompt)[1];
- memset(pg->colors, PHPDBG_G(colors), sizeof(pg->colors));
+ memcpy(pg->colors, PHPDBG_G(colors), sizeof(pg->colors));
pg->eol = PHPDBG_G(eol);
pg->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK;
}
zend_ulong flags;
char *php_optarg;
int php_optind, opt, show_banner = 1;
- long cleaning = 0;
+ long cleaning = -1;
zend_bool remote = 0;
int step = 0;
zend_phpdbg_globals *settings = NULL;
/* Make stdin, stdout and stderr accessible from PHP scripts */
phpdbg_register_file_handles(TSRMLS_C);
- if (show_banner) {
+ if (show_banner && cleaning < 2) {
/* print blurb */
- phpdbg_welcome((cleaning > 0) TSRMLS_CC);
+ phpdbg_welcome(cleaning == 1 TSRMLS_CC);
}
- /* auto compile */
- if (PHPDBG_G(exec)) {
- phpdbg_compile(TSRMLS_C);
- }
+ cleaning = -1;
/* initialize from file */
PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
zend_try {
phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC);
+ PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC);
+ PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
} zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
goto phpdbg_out;
}
+ /* auto compile */
+ if (PHPDBG_G(exec)) {
+ if (settings) {
+ PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
+ }
+ phpdbg_compile(TSRMLS_C);
+ PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
+ }
+
/* step from here, not through init */
if (step) {
PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
}
if (phpdbg_startup_run) {
- /* no need to try{}, run does it ... */
- PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC);
+ zend_try {
+ PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC);
+ } zend_end_try();
if (phpdbg_startup_run > 1) {
/* if -r is on the command line more than once just quit */
goto phpdbg_out;
} zend_catch {
if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) {
FILE *bp_tmp_fp = fopen(bp_tmp_file, "w");
+ PHPDBG_G(flags) |= PHPDBG_DISCARD_OUTPUT;
phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC);
+ PHPDBG_G(flags) &= ~PHPDBG_DISCARD_OUTPUT;
fclose(bp_tmp_fp);
cleaning = 1;
} else {
} __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) {
phpdbg_error("segfault", "", "Access violation (Segementation fault) encountered\ntrying to abort cleanly...");
}
-/* phpdbg_out: */
#endif
+ if (cleaning <= 0) {
+ PHPDBG_G(flags) &= ~PHPDBG_IS_CLEANING;
+ cleaning = -1;
+ }
+
{
int i;
/* free argv */
if ((PHPDBG_G(flags) & (PHPDBG_IS_QUITTING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_RUNNING) {
phpdbg_notice("stop", "type=\"normal\"", "Script ended normally");
+ cleaning++;
}
- if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) {
+ if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) == PHPDBG_IS_CLEANING) {
settings = PHPDBG_G(backup);
}
}
- if (cleaning || remote) {
+ if (cleaning > 0 || remote) {
goto phpdbg_main;
}
#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33)
+#define PHPDBG_DISCARD_OUTPUT (1ULL<<34)
+
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE)
#define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_BP_MASK (PHPDBG_HAS_FILE_BP | PHPDBG_HAS_SYM_BP | PHPDBG_HAS_METHOD_BP | PHPDBG_HAS_OPLINE_BP | PHPDBG_HAS_COND_BP | PHPDBG_HAS_OPCODE_BP | PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP)
#define PHPDBG_IS_STOPPING (PHPDBG_IS_QUITTING | PHPDBG_IS_CLEANING)
-#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE)
+#define PHPDBG_PRESERVE_FLAGS_MASK (PHPDBG_SHOW_REFCOUNTS | PHPDBG_IS_STEPONEVAL | PHPDBG_IS_BP_ENABLED | PHPDBG_STEP_OPCODE | PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED)
#ifndef _WIN32
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET | PHPDBG_IS_COLOURED | PHPDBG_IS_BP_ENABLED)
goto next_line;
}
- {
+ zend_try {
char *input = phpdbg_read_input(cmd TSRMLS_CC);
phpdbg_param_t stack;
phpdbg_stack_free(&stack);
phpdbg_destroy_input(&input TSRMLS_CC);
- }
+ } zend_catch {
+ PHPDBG_G(flags) &= ~(PHPDBG_IS_RUNNING | PHPDBG_IS_CLEANING);
+ if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) {
+ zend_bailout();
+ }
+ } zend_end_try();
}
next_line:
line++;
phpdbg_writeln("clean", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants)));
phpdbg_writeln("clean", "includes=\"%d\"", "Includes %d", zend_hash_num_elements(&EG(included_files)));
+ PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING;
+
phpdbg_clean(1 TSRMLS_CC);
phpdbg_xml("</cleaninfo>");