summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2014-10-25 18:59:48 +0200
committerBob Weinand <bobwei9@hotmail.com>2014-10-25 18:59:48 +0200
commit24babb01946ccb63b993b98b161455475a697d42 (patch)
tree4d8f727a26125ebbaf4eb0e74513c66c085301a2
parent3794431b7818cb1a8ed1464dd89428ea8011cee2 (diff)
parentbbcee18b4b6d9220d4fdcb0d69a33979a5fa84a4 (diff)
downloadphp-git-24babb01946ccb63b993b98b161455475a697d42.tar.gz
Merge phpdbg into PHP-5.6
-rw-r--r--sapi/phpdbg/phpdbg.c15
-rw-r--r--sapi/phpdbg/phpdbg_frame.c7
-rw-r--r--sapi/phpdbg/phpdbg_list.c9
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c27
-rw-r--r--sapi/phpdbg/phpdbg_utils.h25
5 files changed, 74 insertions, 9 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index f09dc4ee13..aaf1e5f406 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -477,15 +477,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
case E_USER_ERROR:
case E_PARSE:
case E_RECOVERABLE_ERROR:
- if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
- phpdbg_list_file(
- zend_get_executed_filename(TSRMLS_C),
- 3,
- zend_get_executed_lineno(TSRMLS_C)-1,
- zend_get_executed_lineno(TSRMLS_C)
- TSRMLS_CC
- );
- }
+ phpdbg_list_file(zend_get_executed_filename(TSRMLS_C), 3, zend_get_executed_lineno(TSRMLS_C)-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
do {
switch (phpdbg_interactive(1 TSRMLS_CC)) {
@@ -1532,6 +1524,11 @@ phpdbg_out:
efree(SG(request_info).argv);
}
+#ifndef _WIN32
+ /* reset it... else we risk a stack overflow upon next run (when clean'ing) */
+ php_stream_stdio_ops.write = PHPDBG_G(php_stdiop_write);
+#endif
+
#ifndef ZTS
/* force cleanup of auto and core globals */
zend_hash_clean(CG(auto_globals));
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index df304e3541..437e6d474a 100644
--- a/sapi/phpdbg/phpdbg_frame.c
+++ b/sapi/phpdbg/phpdbg_frame.c
@@ -25,6 +25,7 @@
#include "phpdbg_list.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+ZEND_EXTERN_MODULE_GLOBALS(output);
void phpdbg_restore_frame(TSRMLS_D) /* {{{ */
{
@@ -198,8 +199,12 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
int i = 0, limit = num;
int user_defined;
+ PHPDBG_OUTPUT_BACKUP();
+
if (limit < 0) {
phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit);
+
+ PHPDBG_OUTPUT_BACKUP_RESTORE();
return;
}
@@ -242,4 +247,6 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
phpdbg_xml("</backtrace>");
zval_dtor(&zbacktrace);
+
+ PHPDBG_OUTPUT_BACKUP_RESTORE();
} /* }}} */
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 80b5d2b189..7aa8c4f9e0 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -128,6 +128,11 @@ void phpdbg_list_file(const char *filename, uint count, int offset, uint highlig
{
uint line, lastline;
phpdbg_file_source **data;
+ char resolved_path_buf[MAXPATHLEN];
+
+ if (VCWD_REALPATH(filename, resolved_path_buf)) {
+ filename = resolved_path_buf;
+ }
if (zend_hash_find(&PHPDBG_G(file_sources), filename, strlen(filename), (void **) &data) == FAILURE) {
phpdbg_error("list", "type=\"unknownfile\"", "Could not find information about included file...");
@@ -232,6 +237,7 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
char *filename = (char *)(file->opened_path ? file->opened_path : file->filename);
uint line;
char *bufptr, *endptr;
+ char resolved_path_buf[MAXPATHLEN];
zend_stream_fixup(file, &data.buf, &data.len TSRMLS_CC);
@@ -258,6 +264,9 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
fake.opened_path = file->opened_path;
*(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint) * data.len)) = data;
+ if (VCWD_REALPATH(filename, resolved_path_buf)) {
+ filename = resolved_path_buf;
+ }
zend_hash_add(&PHPDBG_G(file_sources), filename, strlen(filename), &dataptr, sizeof(phpdbg_file_source *), NULL);
for (line = 0, bufptr = data.buf - 1, endptr = data.buf + data.len; ++bufptr < endptr;) {
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index 82444fbf1d..2e0c698f05 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -42,6 +42,7 @@
#include "phpdbg_eol.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+ZEND_EXTERN_MODULE_GLOBALS(output);
#ifdef HAVE_LIBDL
#ifdef PHP_WIN32
@@ -689,12 +690,26 @@ PHPDBG_COMMAND(ev) /* {{{ */
zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING) == PHPDBG_IS_STEPPING);
zval retval;
+ zend_op **orig_opline = EG(opline_ptr);
+ zend_op_array *orig_op_array = EG(active_op_array);
+ zval **orig_retval_ptr = EG(return_value_ptr_ptr);
+ zend_execute_data *ex = EG(current_execute_data);
+ HashTable *original_active_symbol_table = EG(active_symbol_table);
+ zval *original_This = EG(This);
+ zend_class_entry *original_scope = EG(scope);
+ zend_class_entry *original_called_scope = EG(called_scope);
+ zend_vm_stack original_stack = EG(argument_stack);
+
+ PHPDBG_OUTPUT_BACKUP();
+
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
phpdbg_try_access {
phpdbg_parse_variable(param->str, param->len, &EG(symbol_table), 0, phpdbg_output_ev_variable, 0 TSRMLS_CC);
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch data, invalid data source");
} phpdbg_end_try_access();
+
+ PHPDBG_OUTPUT_BACKUP_RESTORE();
return SUCCESS;
}
@@ -716,6 +731,16 @@ PHPDBG_COMMAND(ev) /* {{{ */
phpdbg_out("\n");
zval_dtor(&retval);
}
+ } zend_catch {
+ EG(active_op_array) = orig_op_array;
+ EG(opline_ptr) = orig_opline;
+ EG(return_value_ptr_ptr) = orig_retval_ptr;
+ EG(current_execute_data) = ex;
+ EG(active_symbol_table) = original_active_symbol_table;
+ EG(This) = original_This;
+ EG(scope) = original_scope;
+ EG(called_scope) = original_called_scope;
+ EG(argument_stack) = original_stack;
} zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
@@ -726,6 +751,8 @@ PHPDBG_COMMAND(ev) /* {{{ */
CG(unclean_shutdown) = 0;
+ PHPDBG_OUTPUT_BACKUP_RESTORE();
+
return SUCCESS;
} /* }}} */
diff --git a/sapi/phpdbg/phpdbg_utils.h b/sapi/phpdbg/phpdbg_utils.h
index d657dc79fd..9038aa7457 100644
--- a/sapi/phpdbg/phpdbg_utils.h
+++ b/sapi/phpdbg/phpdbg_utils.h
@@ -112,4 +112,29 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC);
+#ifdef ZTS
+#define PHPDBG_OUTPUT_BACKUP_DEFINES() \
+ zend_output_globals *output_globals_ptr; \
+ zend_output_globals original_output_globals; \
+ output_globals_ptr = (zend_output_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)];
+#else
+#define PHPDBG_OUTPUT_BACKUP_DEFINES() \
+ zend_output_globals *output_globals_ptr; \
+ zend_output_globals original_output_globals; \
+ output_globals_ptr = &output_globals;
+#endif
+
+#define PHPDBG_OUTPUT_BACKUP_SWAP() \
+ original_output_globals = *output_globals_ptr; \
+ memset(output_globals_ptr, 0, sizeof(zend_output_globals)); \
+ php_output_activate(TSRMLS_C);
+
+#define PHPDBG_OUTPUT_BACKUP() \
+ PHPDBG_OUTPUT_BACKUP_DEFINES() \
+ PHPDBG_OUTPUT_BACKUP_SWAP()
+
+#define PHPDBG_OUTPUT_BACKUP_RESTORE() \
+ php_output_deactivate(TSRMLS_C); \
+ *output_globals_ptr = original_output_globals;
+
#endif /* PHPDBG_UTILS_H */