summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'sapi')
-rw-r--r--sapi/phpdbg/phpdbg.c76
-rw-r--r--sapi/phpdbg/phpdbg.h2
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c21
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c6
4 files changed, 59 insertions, 46 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index e7f841c0bc..6cb1645e65 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -831,7 +831,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];
@@ -871,10 +877,26 @@ 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;
+ }
+ }
+#else
+ if (!mkstemp(bp_tmp_file)) {
+ memset(bp_tmp_file, 0, sizeof(bp_tmp_file));
+ }
+#endif
+
+ if (!bp_tmp_file) {
+ phpdbg_error(
+ "Unable to create temporary file");
+ return 1;
}
}
ini_entries = NULL;
@@ -1117,8 +1139,7 @@ phpdbg_main:
phpdbg->ini_entries = ini_entries;
if (phpdbg->startup(phpdbg) == SUCCESS) {
-
- zend_activate(TSRMLS_C);
+ 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 */
@@ -1186,20 +1207,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 {
@@ -1269,12 +1281,6 @@ phpdbg_interact:
} zend_end_try();
} while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING));
- /* this must be forced */
- CG(unclean_shutdown) = 0;
-
- /* this is just helpful */
- PG(report_memleaks) = 0;
-
phpdbg_out:
#ifndef _WIN32
if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) {
@@ -1297,24 +1303,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);
@@ -1342,7 +1338,11 @@ phpdbg_out:
free(sapi_name);
}
+#ifdef _WIN32
free(bp_tmp_file);
+#else
+ unlink(bp_tmp_file);
+#endif
return 0;
} /* }}} */
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index 6b7afb2370..68c505ca63 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -149,7 +149,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"
/* }}} */
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index c700851243..1d78c53321 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -479,7 +479,7 @@ disconnect:
#ifndef HAVE_LIBREADLINE
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;
}
}
@@ -595,6 +595,8 @@ PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *in
(command->alias == *input->argv[0]->string))) {
phpdbg_param_t param;
+ phpdbg_command_t *initial_last_cmd;
+ phpdbg_param_t initial_last_param;
param.type = EMPTY_PARAM;
@@ -657,15 +659,20 @@ PHPDBG_API int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *in
}
}
+ initial_last_param = PHPDBG_G(lparam);
+ initial_last_cmd = (phpdbg_command_t *)PHPDBG_G(lcmd);
+ PHPDBG_G(lparam) = param;
+ PHPDBG_G(lcmd) = (phpdbg_command_t *)command;
+
rc = command->handler(&param, input TSRMLS_CC);
/* only set last command when it is worth it! */
- if ((rc != FAILURE) &&
- !(PHPDBG_G(flags) & PHPDBG_IS_INITIALIZING)) {
- PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
- phpdbg_clear_param(
- &PHPDBG_G(lparam) TSRMLS_CC);
- PHPDBG_G(lparam) = param;
+ if (rc != FAILURE && !(PHPDBG_G(flags) & PHPDBG_IS_INITIALIZING)) {
+ phpdbg_clear_param(&initial_last_param TSRMLS_CC);
+ } else if (PHPDBG_G(lcmd) == command && !memcmp(&PHPDBG_G(lparam),& initial_last_param, sizeof(phpdbg_param_t))) {
+ PHPDBG_G(lparam) = initial_last_param;
+ PHPDBG_G(lcmd) = initial_last_cmd;
+ phpdbg_clear_param(&param TSRMLS_CC);
}
break;
}
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index cb46407957..f586bb5a84 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -552,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) {
@@ -566,6 +567,11 @@ PHPDBG_COMMAND(run) /* {{{ */
zend_rebuild_symbol_table(TSRMLS_C);
}
+ /* clean up from last execution */
+ if (ex && ex->symbol_table) {
+ zend_hash_clean(ex->symbol_table);
+ }
+
/* clean seek state */
PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK;
zend_hash_clean(