com php-src: Merge phpdbg into PHP-5.6: phpdbg.c phpdbg_frame .c phpdbg_list.c phpdbg_prompt.c phpdbg_utils .h
| From: | Bob Weinand | Date: | Sat, 25 Oct 2014 16:59:48 +0000 |
| Subject: | com php-src: Merge phpdbg into PHP-5.6: phpdbg.c phpdbg_frame .c phpdbg_list.c phpdbg_prompt.c phpdbg_utils .h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82789@lists.php.net to get a copy of this message | ||
Commit: e4e39d852a9dac3e2ee8dc46656ffefa41b6ce25
Author: Bob Weinand <bobwei9@hotmail.com> Sat, 25 Oct 2014 18:59:48 +0200
Parents: 062284e4fbe8a66251eef01beb9242edd21d23a1
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e4e39d852a9dac3e2ee8dc46656ffefa41b6ce25
Log:
Merge phpdbg into PHP-5.6
Changed paths:
M phpdbg.c
M phpdbg_frame.c
M phpdbg_list.c
M phpdbg_prompt.c
M phpdbg_utils.h
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index f09dc4e..aaf1e5f 100644
--- a/phpdbg.c
+++ b/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/phpdbg_frame.c b/phpdbg_frame.c
index df304e3..437e6d4 100644
--- a/phpdbg_frame.c
+++ b/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/phpdbg_list.c b/phpdbg_list.c
index 80b5d2b..7aa8c4f 100644
--- a/phpdbg_list.c
+++ b/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/phpdbg_prompt.c b/phpdbg_prompt.c
index 82444fb..2e0c698 100644
--- a/phpdbg_prompt.c
+++ b/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/phpdbg_utils.h b/phpdbg_utils.h
index d657dc7..9038aa7 100644
--- a/phpdbg_utils.h
+++ b/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 */