Merge remote-tracking branch 'origin/PHP-5.6'

Conflicts:
	sapi/phpdbg/phpdbg.c
	sapi/phpdbg/phpdbg_list.c
This commit is contained in:
Bob Weinand 2014-10-25 19:09:19 +02:00
commit 044f37a832
5 changed files with 74 additions and 8 deletions

View file

@ -469,13 +469,11 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
case E_COMPILE_ERROR: case E_COMPILE_ERROR:
case E_USER_ERROR: case E_USER_ERROR:
case E_PARSE: case E_PARSE:
case E_RECOVERABLE_ERROR: case E_RECOVERABLE_ERROR: {
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { const char *file_char = zend_get_executed_filename(TSRMLS_C);
const char *file_char = zend_get_executed_filename(TSRMLS_C); zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
zend_string *file = zend_string_init(file_char, strlen(file_char), 0); phpdbg_list_file(file, 3, zend_get_executed_lineno(TSRMLS_C) - 1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
phpdbg_list_file(file, 3, zend_get_executed_lineno(TSRMLS_C) - 1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); efree(file);
efree(file);
}
do { do {
switch (phpdbg_interactive(1 TSRMLS_CC)) { switch (phpdbg_interactive(1 TSRMLS_CC)) {
@ -486,6 +484,7 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
return; return;
} }
} while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)); } while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING));
}
} }
} else fprintf(stdout, "%s\n", message); } else fprintf(stdout, "%s\n", message);
@ -1521,6 +1520,11 @@ phpdbg_out:
efree(SG(request_info).argv); 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 #ifndef ZTS
/* force cleanup of auto and core globals */ /* force cleanup of auto and core globals */
zend_hash_clean(CG(auto_globals)); zend_hash_clean(CG(auto_globals));

View file

@ -25,6 +25,7 @@
#include "phpdbg_list.h" #include "phpdbg_list.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
ZEND_EXTERN_MODULE_GLOBALS(output);
void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ void phpdbg_restore_frame(TSRMLS_D) /* {{{ */
{ {
@ -174,8 +175,12 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
zval *file, *line; zval *file, *line;
int i = 0, limit = num; int i = 0, limit = num;
PHPDBG_OUTPUT_BACKUP();
if (limit < 0) { if (limit < 0) {
phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit); phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit);
PHPDBG_OUTPUT_BACKUP_RESTORE();
return; return;
} }
@ -218,4 +223,6 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
phpdbg_xml("</backtrace>"); phpdbg_xml("</backtrace>");
zval_dtor(&zbacktrace); zval_dtor(&zbacktrace);
PHPDBG_OUTPUT_BACKUP_RESTORE();
} /* }}} */ } /* }}} */

View file

@ -126,8 +126,16 @@ void phpdbg_list_file(zend_string *filename, uint count, int offset, uint highli
{ {
uint line, lastline; uint line, lastline;
phpdbg_file_source *data; phpdbg_file_source *data;
char resolved_path_buf[MAXPATHLEN];
const char *abspath;
if (!(data = zend_hash_find_ptr(&PHPDBG_G(file_sources), filename))) { if (VCWD_REALPATH(filename->val, resolved_path_buf)) {
abspath = resolved_path_buf;
} else {
abspath = filename->val;
}
if (!(data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), abspath, strlen(abspath)))) {
phpdbg_error("list", "type=\"unknownfile\"", "Could not find information about included file..."); phpdbg_error("list", "type=\"unknownfile\"", "Could not find information about included file...");
return; return;
} }
@ -230,6 +238,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); char *filename = (char *)(file->opened_path ? file->opened_path : file->filename);
uint line; uint line;
char *bufptr, *endptr; char *bufptr, *endptr;
char resolved_path_buf[MAXPATHLEN];
zend_stream_fixup(file, &data.buf, &data.len TSRMLS_CC); zend_stream_fixup(file, &data.buf, &data.len TSRMLS_CC);
@ -256,6 +265,9 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
fake.opened_path = file->opened_path; fake.opened_path = file->opened_path;
*(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint) * data.len)) = data; *(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint) * data.len)) = data;
if (VCWD_REALPATH(filename, resolved_path_buf)) {
filename = resolved_path_buf;
}
for (line = 0, bufptr = data.buf - 1, endptr = data.buf + data.len; ++bufptr < endptr;) { for (line = 0, bufptr = data.buf - 1, endptr = data.buf + data.len; ++bufptr < endptr;) {
if (*bufptr == '\n') { if (*bufptr == '\n') {

View file

@ -43,6 +43,7 @@
#include "phpdbg_eol.h" #include "phpdbg_eol.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg); ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
ZEND_EXTERN_MODULE_GLOBALS(output);
#ifdef HAVE_LIBDL #ifdef HAVE_LIBDL
#ifdef PHP_WIN32 #ifdef PHP_WIN32
@ -645,12 +646,21 @@ PHPDBG_COMMAND(ev) /* {{{ */
zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING) == PHPDBG_IS_STEPPING); zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING) == PHPDBG_IS_STEPPING);
zval retval; zval retval;
zend_execute_data *original_execute_data = EG(current_execute_data);
zend_class_entry *original_scope = EG(scope);
zend_vm_stack original_stack = EG(vm_stack);
original_stack->top = EG(vm_stack_top);
PHPDBG_OUTPUT_BACKUP();
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
phpdbg_try_access { phpdbg_try_access {
phpdbg_parse_variable(param->str, param->len, &EG(symbol_table).ht, 0, phpdbg_output_ev_variable, 0 TSRMLS_CC); phpdbg_parse_variable(param->str, param->len, &EG(symbol_table).ht, 0, phpdbg_output_ev_variable, 0 TSRMLS_CC);
} phpdbg_catch_access { } phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch data, invalid data source"); phpdbg_error("signalsegv", "", "Could not fetch data, invalid data source");
} phpdbg_end_try_access(); } phpdbg_end_try_access();
PHPDBG_OUTPUT_BACKUP_RESTORE();
return SUCCESS; return SUCCESS;
} }
@ -672,6 +682,12 @@ PHPDBG_COMMAND(ev) /* {{{ */
phpdbg_out("\n"); phpdbg_out("\n");
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
} }
} zend_catch {
EG(current_execute_data) = original_execute_data;
EG(scope) = original_scope;
EG(vm_stack_top) = original_stack->top;
EG(vm_stack_end) = original_stack->end;
EG(vm_stack) = original_stack;
} zend_end_try(); } zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
@ -682,6 +698,8 @@ PHPDBG_COMMAND(ev) /* {{{ */
CG(unclean_shutdown) = 0; CG(unclean_shutdown) = 0;
PHPDBG_OUTPUT_BACKUP_RESTORE();
return SUCCESS; return SUCCESS;
} /* }}} */ } /* }}} */

View file

@ -94,4 +94,29 @@ int phpdbg_is_auto_global(char *name, int len TSRMLS_DC);
PHPDBG_API void phpdbg_xml_var_dump(zval *zv TSRMLS_DC); 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 */ #endif /* PHPDBG_UTILS_H */